remove TASFlow and re-define it as a assist class
This commit is contained in:
@ -29,13 +29,13 @@ namespace BallanceTASEditor {
|
|||||||
|
|
||||||
// init configure manager
|
// init configure manager
|
||||||
GlobalVariable.configManager = new Core.ConfigManager("ballance-tas-editor.cfg", new Dictionary<string, string>() {
|
GlobalVariable.configManager = new Core.ConfigManager("ballance-tas-editor.cfg", new Dictionary<string, string>() {
|
||||||
{"Language", CultureInfo.CurrentCulture.ThreeLetterWindowsLanguageName},
|
{Core.ConfigManager.CfgNode_Language, CultureInfo.CurrentCulture.ThreeLetterWindowsLanguageName},
|
||||||
{"ItemCount", "15"},
|
{Core.ConfigManager.CfgNode_ItemCount, "15"},
|
||||||
{"IsHorizonLayout", "True"}
|
{Core.ConfigManager.CfgNode_IsHorizonLayout, "True"}
|
||||||
});
|
});
|
||||||
|
|
||||||
// init i18n
|
// init i18n
|
||||||
Core.I18NProcessor.ChangeLanguage(GlobalVariable.configManager.Configuration["Language"]);
|
Core.I18NProcessor.ChangeLanguage(GlobalVariable.configManager.Configuration[Core.ConfigManager.CfgNode_Language]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,9 +76,8 @@
|
|||||||
<Compile Include="UI\OperationEnum.cs" />
|
<Compile Include="UI\OperationEnum.cs" />
|
||||||
<Compile Include="UI\SelectionHelp.cs" />
|
<Compile Include="UI\SelectionHelp.cs" />
|
||||||
<Compile Include="UI\StyleConverter.cs" />
|
<Compile Include="UI\StyleConverter.cs" />
|
||||||
<Compile Include="UI\TASFlow.xaml.cs">
|
<Compile Include="UI\TASFlow.cs" />
|
||||||
<DependentUpon>TASFlow.xaml</DependentUpon>
|
<Compile Include="UI\TASSlider.cs" />
|
||||||
</Compile>
|
|
||||||
<Compile Include="UI\TASViewer.cs" />
|
<Compile Include="UI\TASViewer.cs" />
|
||||||
<Compile Include="UI\Util.cs" />
|
<Compile Include="UI\Util.cs" />
|
||||||
<Page Include="Language\CHS.xaml">
|
<Page Include="Language\CHS.xaml">
|
||||||
@ -110,10 +109,6 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="UI\TASFlow.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
|||||||
@ -20,6 +20,10 @@ namespace BallanceTASEditor.Core {
|
|||||||
string _defaultValue;
|
string _defaultValue;
|
||||||
public Dictionary<string, string> Configuration;
|
public Dictionary<string, string> Configuration;
|
||||||
|
|
||||||
|
public static readonly string CfgNode_Language = "Language";
|
||||||
|
public static readonly string CfgNode_ItemCount = "ItemCount";
|
||||||
|
public static readonly string CfgNode_IsHorizonLayout = "IsHorizonLayout";
|
||||||
|
|
||||||
Dictionary<string, string> Read() {
|
Dictionary<string, string> Read() {
|
||||||
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, _fileName)))
|
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, _fileName)))
|
||||||
Init();
|
Init();
|
||||||
|
|||||||
@ -8,8 +8,31 @@
|
|||||||
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
|
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="{DynamicResource ui_MainWindow_Title}" Height="500" Width="800" KeyUp="funcWindow_KeyUp"
|
Title="{DynamicResource ui_MainWindow_Title}" Height="500" Width="800" KeyUp="funcWindow_KeyUp"
|
||||||
input:InputMethod.IsInputMethodEnabled="False">
|
input:InputMethod.IsInputMethodEnabled="False" MouseWheel="funcWindow_MouseWheel">
|
||||||
|
|
||||||
|
<!-- shortcut defination-->
|
||||||
|
<Window.Resources>
|
||||||
|
<RoutedUICommand x:Key="commandMenu_File_Open"/>
|
||||||
|
<RoutedUICommand x:Key="commandMenu_File_Save"/>
|
||||||
|
<RoutedUICommand x:Key="commandMenu_Display_Undo"/>
|
||||||
|
<RoutedUICommand x:Key="commandMenu_Display_Redo"/>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Window.InputBindings>
|
||||||
|
<KeyBinding Gesture="Ctrl+O" Command="{StaticResource commandMenu_File_Open}"/>
|
||||||
|
<KeyBinding Gesture="Ctrl+S" Command="{StaticResource commandMenu_File_Save}"/>
|
||||||
|
<KeyBinding Gesture="Ctrl+Z" Command="{StaticResource commandMenu_Display_Undo}"/>
|
||||||
|
<KeyBinding Gesture="Ctrl+Y" Command="{StaticResource commandMenu_Display_Redo}"/>
|
||||||
|
</Window.InputBindings>
|
||||||
|
|
||||||
|
<Window.CommandBindings>
|
||||||
|
<CommandBinding Command="{StaticResource commandMenu_File_Open}" Executed="funcCommand_Menu_File_Open" CanExecute="funcCanExeCmd_Menu_File_Open"/>
|
||||||
|
<CommandBinding Command="{StaticResource commandMenu_File_Save}" Executed="funcCommand_Menu_File_Save" CanExecute="funcCanExeCmd_Menu_File_Save"/>
|
||||||
|
<CommandBinding Command="{StaticResource commandMenu_Display_Undo}" Executed="funcCommand_Menu_Display_Undo" CanExecute="funcCanExeCmd_Menu_Display_Undo"/>
|
||||||
|
<CommandBinding Command="{StaticResource commandMenu_Display_Redo}" Executed="funcCommand_Menu_Display_Redo" CanExecute="funcCanExeCmd_Menu_Display_Redo"/>
|
||||||
|
</Window.CommandBindings>
|
||||||
|
|
||||||
|
<!-- real ui elements-->
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
@ -78,8 +101,59 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<controls:TASFlow x:Name="uiTASData" Grid.Row="1" Margin="5" BorderThickness="1" BorderBrush="Gray">
|
<Border BorderThickness="1" BorderBrush="Gray" Grid.Row="1" Margin="5" Background="#ffffff">
|
||||||
</controls:TASFlow>
|
<Grid x:Name="uiTASData">
|
||||||
|
<Grid.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem x:Name="uiDataMenu_Set" Header="{DynamicResource ui_TASFlow_Menu_Set}" Click="uiDataMenu_Set_Click"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_Unset" Header="{DynamicResource ui_TASFlow_Menu_Unset}" Click="uiDataMenu_Unset_Click"/>
|
||||||
|
<Separator/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_Cut" Header="{DynamicResource ui_TASFlow_Menu_Cut}" Click="uiDataMenu_Cut_Click" InputGestureText="Ctrl + X"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_Copy" Header="{DynamicResource ui_TASFlow_Menu_Copy}" Click="uiDataMenu_Copy_Click" InputGestureText="Ctrl + C"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_PasteAfter" Header="{DynamicResource ui_TASFlow_Menu_PasteAfter}" Click="uiDataMenu_PasteAfter_Click"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_PasteBefore" Header="{DynamicResource ui_TASFlow_Menu_PasterBefore}" Click="uiDataMenu_PasteBefore_Click"/>
|
||||||
|
<Separator/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_Delete" Header="{DynamicResource ui_TASFlow_Menu_Delete}" Click="uiDataMenu_Delete_Click"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_DeleteAfter" Header="{DynamicResource ui_TASFlow_Menu_DeleteAfter}" Click="uiDataMenu_DeleteAfter_Click" InputGestureText="Del"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_DeleteBefore" Header="{DynamicResource ui_TASFlow_Menu_PasterBefore}" Click="uiDataMenu_DeleteBefore_Click" InputGestureText="Backspace"/>
|
||||||
|
<Separator/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_AddAfter" Header="{DynamicResource ui_TASFlow_Menu_AddAfter}" Click="uiDataMenu_AddAfter_Click"/>
|
||||||
|
<MenuItem x:Name="uiDataMenu_AddBefore" Header="{DynamicResource ui_TASFlow_Menu_AddBefore}" Click="uiDataMenu_AddBefore_Click"/>
|
||||||
|
</ContextMenu>
|
||||||
|
</Grid.ContextMenu>
|
||||||
|
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="1" Text="{DynamicResource ui_TASFlow_Sheet_Frame}"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="2" Text="{DynamicResource ui_TASFlow_Sheet_DeltaTime}"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="3" Text="^"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="4" Text="v"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="5" Text="<"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="6" Text=">"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="7" Text="shift"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="8" Text="space"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="9" Text="q"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="10" Text="esc"/>
|
||||||
|
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="11" Text="enter"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<Grid Grid.Row="2" Margin="5">
|
<Grid Grid.Row="2" Margin="5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -128,8 +202,6 @@
|
|||||||
</Slider>
|
</Slider>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<StatusBar x:Name="uiStatusbar" Grid.Row="2">
|
<StatusBar x:Name="uiStatusbar" Grid.Row="2">
|
||||||
|
|||||||
@ -23,14 +23,31 @@ namespace BallanceTASEditor {
|
|||||||
public MainWindow() {
|
public MainWindow() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
RefreshUI(false);
|
RefreshUI(false);
|
||||||
|
mFlow = new TASFlow(uiTASData);
|
||||||
|
mSlider = new TASSlider(uiTASSlider);
|
||||||
}
|
}
|
||||||
|
|
||||||
TASFile mFile;
|
TASFile mFile;
|
||||||
TASViewer mViewer;
|
TASViewer mViewer;
|
||||||
|
TASFlow mFlow;
|
||||||
|
TASSlider mSlider;
|
||||||
|
|
||||||
#region ui func
|
#region ui func
|
||||||
|
|
||||||
|
// shortcut
|
||||||
|
|
||||||
|
private void funcCommand_Menu_File_Open(object sender, ExecutedRoutedEventArgs e) => funcMenu_File_Open(sender, e);
|
||||||
|
private void funcCommand_Menu_File_Save(object sender, ExecutedRoutedEventArgs e) => funcMenu_File_Save(sender, e);
|
||||||
|
private void funcCommand_Menu_Display_Undo(object sender, ExecutedRoutedEventArgs e) => funcMenu_Display_Undo(sender, e);
|
||||||
|
private void funcCommand_Menu_Display_Redo(object sender, ExecutedRoutedEventArgs e) => funcMenu_Display_Redo(sender, e);
|
||||||
|
private void funcCanExeCmd_Menu_File_Open(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = uiMenu_File_Open.IsEnabled;
|
||||||
|
private void funcCanExeCmd_Menu_File_Save(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = uiMenu_File_Save.IsEnabled;
|
||||||
|
private void funcCanExeCmd_Menu_Display_Undo(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = uiMenu_Display_Undo.IsEnabled;
|
||||||
|
private void funcCanExeCmd_Menu_Display_Redo(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = uiMenu_Display_Redo.IsEnabled;
|
||||||
|
|
||||||
// =========================== menu
|
// =========================== menu
|
||||||
|
#region window menu
|
||||||
|
|
||||||
private void funcMenu_Help_ReportBugs(object sender, RoutedEventArgs e) {
|
private void funcMenu_Help_ReportBugs(object sender, RoutedEventArgs e) {
|
||||||
System.Diagnostics.Process.Start("https://github.com/yyc12345/BallanceTASEditor/issues");
|
System.Diagnostics.Process.Start("https://github.com/yyc12345/BallanceTASEditor/issues");
|
||||||
}
|
}
|
||||||
@ -43,9 +60,15 @@ namespace BallanceTASEditor {
|
|||||||
var file = DialogUtil.OpenFileDialog();
|
var file = DialogUtil.OpenFileDialog();
|
||||||
if (file == "") return;
|
if (file == "") return;
|
||||||
mFile = new TASFile(file);
|
mFile = new TASFile(file);
|
||||||
mViewer = new TASViewer(mFile, uiTASSlider, uiTASData, uiStatusbar_Selected);
|
mViewer = new TASViewer(mFile, mSlider, mFlow);
|
||||||
|
|
||||||
|
mViewer.UpdateDataUI += RefreshDataUI;
|
||||||
|
mViewer.UpdateSelection += RefreshSelection;
|
||||||
|
mViewer.UpdateToolMode += RefreshToolMode;
|
||||||
|
|
||||||
RefreshUI(true);
|
RefreshUI(true);
|
||||||
ChangeToolMode(ToolMode.Cursor);
|
|
||||||
|
mViewer.ChangeToolMode(ToolMode.Cursor);
|
||||||
mViewer.ChangeOverwrittenMode(uiMenu_Display_OverwrittenPaste.IsChecked);
|
mViewer.ChangeOverwrittenMode(uiMenu_Display_OverwrittenPaste.IsChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +84,11 @@ namespace BallanceTASEditor {
|
|||||||
|
|
||||||
private void funcMenu_File_Close(object sender, RoutedEventArgs e) {
|
private void funcMenu_File_Close(object sender, RoutedEventArgs e) {
|
||||||
if (!DialogUtil.ConfirmDialog("Do you want to close this TAS file?")) return;
|
if (!DialogUtil.ConfirmDialog("Do you want to close this TAS file?")) return;
|
||||||
|
|
||||||
|
mViewer.UpdateDataUI -= RefreshDataUI;
|
||||||
|
mViewer.UpdateSelection -= RefreshSelection;
|
||||||
|
mViewer.UpdateToolMode -= RefreshToolMode;
|
||||||
|
|
||||||
mViewer.Dispose();
|
mViewer.Dispose();
|
||||||
mFile = null;
|
mFile = null;
|
||||||
mViewer = null;
|
mViewer = null;
|
||||||
@ -88,35 +116,85 @@ namespace BallanceTASEditor {
|
|||||||
mViewer.ProcessOperation(OperationEnum.Undo);
|
mViewer.ProcessOperation(OperationEnum.Undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region menu operation
|
||||||
|
|
||||||
|
private void uiDataMenu_Set_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.Set);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_Unset_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.Unset);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_Cut_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.Cut);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_Copy_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_PasteAfter_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.PasteAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_PasteBefore_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.PasteBefore);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_Delete_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.Delete);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_DeleteAfter_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.DeleteAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_DeleteBefore_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.DeleteBefore);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_AddAfter_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.AddAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uiDataMenu_AddBefore_Click(object sender, RoutedEventArgs e) {
|
||||||
|
mViewer.ProcessOperation(OperationEnum.AddBefore);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
// =========================== btn
|
// =========================== btn
|
||||||
private void funcBtn_Cursor(object sender, RoutedEventArgs e) {
|
private void funcBtn_Cursor(object sender, RoutedEventArgs e) {
|
||||||
ChangeToolMode(ToolMode.Cursor);
|
mViewer.ChangeToolMode(ToolMode.Cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcBtn_Fill(object sender, RoutedEventArgs e) {
|
private void funcBtn_Fill(object sender, RoutedEventArgs e) {
|
||||||
ChangeToolMode(ToolMode.Fill);
|
mViewer.ChangeToolMode(ToolMode.Fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcBtn_Overwrite(object sender, RoutedEventArgs e) {
|
private void funcBtn_Overwrite(object sender, RoutedEventArgs e) {
|
||||||
ChangeToolMode(ToolMode.Overwrite);
|
mViewer.ChangeToolMode(ToolMode.Overwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move btn
|
// move btn
|
||||||
|
|
||||||
private void funcBtn_FastMovePrev(object sender, RoutedEventArgs e) {
|
private void funcBtn_FastMovePrev(object sender, RoutedEventArgs e) {
|
||||||
MoveSliderManually(true, true);
|
mSlider.MoveSliderManually(true, true, mViewer.GetItemCountInPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcBtn_MovePrev(object sender, RoutedEventArgs e) {
|
private void funcBtn_MovePrev(object sender, RoutedEventArgs e) {
|
||||||
MoveSliderManually(true, false);
|
mSlider.MoveSliderManually(true, false, mViewer.GetItemCountInPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcBtn_MoveNext(object sender, RoutedEventArgs e) {
|
private void funcBtn_MoveNext(object sender, RoutedEventArgs e) {
|
||||||
MoveSliderManually(false, false);
|
mSlider.MoveSliderManually(false, false, mViewer.GetItemCountInPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcBtn_FastMoveNext(object sender, RoutedEventArgs e) {
|
private void funcBtn_FastMoveNext(object sender, RoutedEventArgs e) {
|
||||||
MoveSliderManually(false, true);
|
mSlider.MoveSliderManually(false, true, mViewer.GetItemCountInPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// move keyboard
|
// move keyboard
|
||||||
@ -126,24 +204,56 @@ namespace BallanceTASEditor {
|
|||||||
|
|
||||||
switch(e.Key) {
|
switch(e.Key) {
|
||||||
case Key.A:
|
case Key.A:
|
||||||
MoveSliderManually(true, true);
|
mSlider.MoveSliderManually(true, true, mViewer.GetItemCountInPage());
|
||||||
break;
|
break;
|
||||||
case Key.S:
|
case Key.S:
|
||||||
MoveSliderManually(true, false);
|
mSlider.MoveSliderManually(true, false, mViewer.GetItemCountInPage());
|
||||||
break;
|
break;
|
||||||
case Key.D:
|
case Key.D:
|
||||||
MoveSliderManually(false, false);
|
mSlider.MoveSliderManually(false, false, mViewer.GetItemCountInPage());
|
||||||
break;
|
break;
|
||||||
case Key.F:
|
case Key.F:
|
||||||
MoveSliderManually(false, true);
|
mSlider.MoveSliderManually(false, true, mViewer.GetItemCountInPage());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move mouse
|
||||||
|
|
||||||
|
private void funcWindow_MouseWheel(object sender, MouseWheelEventArgs e) {
|
||||||
|
if (e.Delta > 0) {
|
||||||
|
// wheel up
|
||||||
|
if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) {
|
||||||
|
// move quickly
|
||||||
|
mSlider.MoveSliderManually(true, true, mViewer.GetItemCountInPage());
|
||||||
|
} else if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_CONTROL)) {
|
||||||
|
// decrease item count
|
||||||
|
var newvalue = mViewer.GetItemCountInPage();
|
||||||
|
mViewer.ChangeListLength(newvalue - 1);
|
||||||
|
} else {
|
||||||
|
// normally move
|
||||||
|
mSlider.MoveSliderManually(true, false, mViewer.GetItemCountInPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (e.Delta < 0) {
|
||||||
|
// wheel down
|
||||||
|
if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) {
|
||||||
|
// move quickly
|
||||||
|
mSlider.MoveSliderManually(false, true, mViewer.GetItemCountInPage());
|
||||||
|
} else if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_CONTROL)) {
|
||||||
|
// increase item count
|
||||||
|
var newvalue = mViewer.GetItemCountInPage();
|
||||||
|
mViewer.ChangeListLength(newvalue + 1);
|
||||||
|
} else {
|
||||||
|
// normally move
|
||||||
|
mSlider.MoveSliderManually(false, false, mViewer.GetItemCountInPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void RefreshToolMode(ToolMode mode) {
|
||||||
private void ChangeToolMode(ToolMode mode) {
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case ToolMode.Cursor:
|
case ToolMode.Cursor:
|
||||||
uiBtn_Cursor.IsEnabled = false;
|
uiBtn_Cursor.IsEnabled = false;
|
||||||
@ -173,8 +283,6 @@ namespace BallanceTASEditor {
|
|||||||
uiStatusbar_Mode_Overwrite.Visibility = Visibility.Visible;
|
uiStatusbar_Mode_Overwrite.Visibility = Visibility.Visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mViewer.ChangeToolMode(mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshUI(bool isFileOpened) {
|
private void RefreshUI(bool isFileOpened) {
|
||||||
@ -211,9 +319,46 @@ namespace BallanceTASEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveSliderManually(bool isPrev, bool isFast) {
|
private void RefreshDataUI(bool showCursorPasteAddDeleteOne, bool showFill, bool showCursorCopyDelete) {
|
||||||
var step = isFast ? mViewer.GetItemCountInPage() : 1;
|
uiDataMenu_Set.IsEnabled = showFill;
|
||||||
uiTASSlider.Value = Util.Clamp(uiTASSlider.Value.ToInt32() + (isPrev ? -1 : 1) * step, uiTASSlider.Minimum.ToInt32(), uiTASSlider.Maximum.ToInt32());
|
uiDataMenu_Unset.IsEnabled = showFill;
|
||||||
|
uiDataMenu_Cut.IsEnabled = showCursorCopyDelete;
|
||||||
|
uiDataMenu_Copy.IsEnabled = showCursorCopyDelete;
|
||||||
|
uiDataMenu_Delete.IsEnabled = showCursorCopyDelete;
|
||||||
|
uiDataMenu_DeleteAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
uiDataMenu_DeleteBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
uiDataMenu_PasteAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
uiDataMenu_PasteBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
uiDataMenu_AddAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
uiDataMenu_AddBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshSelection(SelectionHelp mSelectionHelp) {
|
||||||
|
var mode = mSelectionHelp.GetToolMode();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case ToolMode.Cursor:
|
||||||
|
if (mSelectionHelp.IsDataReady()) {
|
||||||
|
var data = mSelectionHelp.GetRange();
|
||||||
|
uiStatusbar_Selected.Text = $"{data.start} - {data.end}";
|
||||||
|
} else if (mSelectionHelp.IsDataPartialReady()) {
|
||||||
|
var data2 = mSelectionHelp.GetPoint();
|
||||||
|
uiStatusbar_Selected.Text = data2.ToString();
|
||||||
|
} else uiStatusbar_Selected.Text = "-";
|
||||||
|
break;
|
||||||
|
case ToolMode.Fill:
|
||||||
|
if (mSelectionHelp.IsDataReady()) {
|
||||||
|
var data3 = mSelectionHelp.GetRange();
|
||||||
|
uiStatusbar_Selected.Text = $"{data3.start} - {data3.end}";
|
||||||
|
} else uiStatusbar_Selected.Text = "-";
|
||||||
|
break;
|
||||||
|
case ToolMode.Overwrite:
|
||||||
|
if (mSelectionHelp.IsDataReady()) {
|
||||||
|
var data4 = mSelectionHelp.GetPoint();
|
||||||
|
uiStatusbar_Selected.Text = data4.ToString();
|
||||||
|
} else uiStatusbar_Selected.Text = "-";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,12 +15,9 @@ using System.Windows.Navigation;
|
|||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
namespace BallanceTASEditor.UI {
|
namespace BallanceTASEditor.UI {
|
||||||
/// <summary>
|
public partial class TASFlow {
|
||||||
/// TASFlow.xaml 的交互逻辑
|
public TASFlow(Grid coreWindow) {
|
||||||
/// </summary>
|
uiCoreWindow = coreWindow;
|
||||||
public partial class TASFlow : UserControl {
|
|
||||||
public TASFlow() {
|
|
||||||
InitializeComponent();
|
|
||||||
mItemList = new List<TASFlowUIItem>();
|
mItemList = new List<TASFlowUIItem>();
|
||||||
mRectMap = new Dictionary<Rectangle, CellPosition>();
|
mRectMap = new Dictionary<Rectangle, CellPosition>();
|
||||||
mItemCount = 0;
|
mItemCount = 0;
|
||||||
@ -28,8 +25,8 @@ namespace BallanceTASEditor.UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public event Action Click;
|
public event Action Click;
|
||||||
public event Action<OperationEnum> NewOperation;
|
|
||||||
|
|
||||||
|
private Grid uiCoreWindow;
|
||||||
private int mItemCount;
|
private int mItemCount;
|
||||||
private List<TASFlowUIItem> mItemList;
|
private List<TASFlowUIItem> mItemList;
|
||||||
private Dictionary<Rectangle, CellPosition> mRectMap;
|
private Dictionary<Rectangle, CellPosition> mRectMap;
|
||||||
@ -53,7 +50,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
for (int i = 0; i < abs; i++) {
|
for (int i = 0; i < abs; i++) {
|
||||||
var item = new ColumnDefinition();
|
var item = new ColumnDefinition();
|
||||||
item.Width = GridLength.Auto;
|
item.Width = new GridLength(1, GridUnitType.Star);
|
||||||
uiCoreWindow.ColumnDefinitions.Add(item);
|
uiCoreWindow.ColumnDefinitions.Add(item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -78,27 +75,6 @@ namespace BallanceTASEditor.UI {
|
|||||||
mItemCount = newCount;
|
mItemCount = newCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshDataMenu() {
|
|
||||||
if (SelectionHelp == null) return;
|
|
||||||
|
|
||||||
ToolMode mode = SelectionHelp.GetToolMode();
|
|
||||||
bool showCursorPasteAddDeleteOne = mode == ToolMode.Cursor && SelectionHelp.IsDataPartialReady();
|
|
||||||
bool showFill = mode == ToolMode.Fill && SelectionHelp.IsDataReady();
|
|
||||||
bool showCursorCopyDelete = mode == ToolMode.Cursor && SelectionHelp.IsDataReady();
|
|
||||||
|
|
||||||
uiDataMenu_Set.IsEnabled = showFill;
|
|
||||||
uiDataMenu_Unset.IsEnabled = showFill;
|
|
||||||
uiDataMenu_Cut.IsEnabled = showCursorCopyDelete;
|
|
||||||
uiDataMenu_Copy.IsEnabled = showCursorCopyDelete;
|
|
||||||
uiDataMenu_Delete.IsEnabled = showCursorCopyDelete;
|
|
||||||
uiDataMenu_DeleteAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
uiDataMenu_DeleteBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
uiDataMenu_PasteAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
uiDataMenu_PasteBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
uiDataMenu_AddAfter.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
uiDataMenu_AddBefore.IsEnabled = showCursorPasteAddDeleteOne;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshSelectionHighlight() {
|
public void RefreshSelectionHighlight() {
|
||||||
ToolMode mode = SelectionHelp.GetToolMode();
|
ToolMode mode = SelectionHelp.GetToolMode();
|
||||||
|
|
||||||
@ -171,54 +147,6 @@ namespace BallanceTASEditor.UI {
|
|||||||
Click?.Invoke();
|
Click?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region menu operation
|
|
||||||
|
|
||||||
private void uiDataMenu_Set_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.Set);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_Unset_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.Unset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_Cut_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.Cut);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_Copy_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_PasteAfter_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.PasteAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_PasteBefore_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.PasteBefore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_Delete_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.Delete);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_DeleteAfter_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.DeleteAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_DeleteBefore_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.DeleteBefore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_AddAfter_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.AddAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uiDataMenu_AddBefore_Click(object sender, RoutedEventArgs e) {
|
|
||||||
NewOperation?.Invoke(OperationEnum.AddBefore);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TASFlowUIItem {
|
public class TASFlowUIItem {
|
||||||
@ -1,60 +0,0 @@
|
|||||||
<UserControl x:Class="BallanceTASEditor.UI.TASFlow"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:local="clr-namespace:BallanceTASEditor.UI"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignHeight="400" d:DesignWidth="800">
|
|
||||||
<Grid x:Name="uiCoreWindow" Background="#ffffff">
|
|
||||||
<Grid.ContextMenu>
|
|
||||||
<ContextMenu>
|
|
||||||
<MenuItem x:Name="uiDataMenu_Set" Header="{DynamicResource ui_TASFlow_Menu_Set}" Click="uiDataMenu_Set_Click"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_Unset" Header="{DynamicResource ui_TASFlow_Menu_Unset}" Click="uiDataMenu_Unset_Click"/>
|
|
||||||
<Separator/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_Cut" Header="{DynamicResource ui_TASFlow_Menu_Cut}" Click="uiDataMenu_Cut_Click" InputGestureText="Ctrl + X"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_Copy" Header="{DynamicResource ui_TASFlow_Menu_Copy}" Click="uiDataMenu_Copy_Click" InputGestureText="Ctrl + C"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_PasteAfter" Header="{DynamicResource ui_TASFlow_Menu_PasteAfter}" Click="uiDataMenu_PasteAfter_Click"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_PasteBefore" Header="{DynamicResource ui_TASFlow_Menu_PasterBefore}" Click="uiDataMenu_PasteBefore_Click"/>
|
|
||||||
<Separator/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_Delete" Header="{DynamicResource ui_TASFlow_Menu_Delete}" Click="uiDataMenu_Delete_Click"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_DeleteAfter" Header="{DynamicResource ui_TASFlow_Menu_DeleteAfter}" Click="uiDataMenu_DeleteAfter_Click" InputGestureText="Del"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_DeleteBefore" Header="{DynamicResource ui_TASFlow_Menu_PasterBefore}" Click="uiDataMenu_DeleteBefore_Click" InputGestureText="Backspace"/>
|
|
||||||
<Separator/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_AddAfter" Header="{DynamicResource ui_TASFlow_Menu_AddAfter}" Click="uiDataMenu_AddAfter_Click"/>
|
|
||||||
<MenuItem x:Name="uiDataMenu_AddBefore" Header="{DynamicResource ui_TASFlow_Menu_AddBefore}" Click="uiDataMenu_AddBefore_Click"/>
|
|
||||||
</ContextMenu>
|
|
||||||
</Grid.ContextMenu>
|
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="auto"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="auto"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="1" Text="{DynamicResource ui_TASFlow_Sheet_Frame}"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="2" Text="{DynamicResource ui_TASFlow_Sheet_DeltaTime}"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="3" Text="^"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="4" Text="v"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="5" Text="<"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="6" Text=">"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="7" Text="shift"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="8" Text="space"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="9" Text="q"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="10" Text="esc"/>
|
|
||||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="11" Text="enter"/>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
||||||
44
BallanceTASEditor/UI/TASSlider.cs
Normal file
44
BallanceTASEditor/UI/TASSlider.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using BallanceTASEditor.Core;
|
||||||
|
using BallanceTASEditor.Core.TASStruct;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace BallanceTASEditor.UI {
|
||||||
|
public class TASSlider {
|
||||||
|
public TASSlider(Slider slider) {
|
||||||
|
mSlider = slider;
|
||||||
|
mSlider.Minimum = 0;
|
||||||
|
|
||||||
|
mSlider.ValueChanged += func_SliderValueChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<long> ValueChanged;
|
||||||
|
Slider mSlider;
|
||||||
|
|
||||||
|
public void MoveSliderManually(bool isPrev, bool isFast, int fastCount) {
|
||||||
|
var step = isFast ? fastCount : 1;
|
||||||
|
mSlider.Value = Util.Clamp(mSlider.Value.ToInt32() + (isPrev ? -1 : 1) * step, mSlider.Minimum.ToInt32(), mSlider.Maximum.ToInt32());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateRange(TASFile mFile) {
|
||||||
|
mSlider.Maximum = mFile.mFrameCount - 1;
|
||||||
|
mSlider.Value = mFile.GetPointerIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void func_SliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||||
|
ValueChanged?.Invoke(e.NewValue.ToInt64());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,15 +10,13 @@ using System.Windows;
|
|||||||
|
|
||||||
namespace BallanceTASEditor.UI {
|
namespace BallanceTASEditor.UI {
|
||||||
public class TASViewer : IDisposable {
|
public class TASViewer : IDisposable {
|
||||||
public TASViewer(TASFile file, Slider slider, TASFlow datagrid, TextBlock statusbar) {
|
public TASViewer(TASFile file, TASSlider slider, TASFlow datagrid) {
|
||||||
mFile = file;
|
mFile = file;
|
||||||
mSlider = slider;
|
mSlider = slider;
|
||||||
mDataGrid = datagrid;
|
mDataGrid = datagrid;
|
||||||
mStatusbar = statusbar;
|
|
||||||
|
|
||||||
// restore slider
|
// restore slider
|
||||||
mSlider.Minimum = 0;
|
mSlider.UpdateRange(mFile);
|
||||||
updateSliderRange();
|
|
||||||
|
|
||||||
// init selection
|
// init selection
|
||||||
mSelectionHelp = new SelectionHelp();
|
mSelectionHelp = new SelectionHelp();
|
||||||
@ -35,86 +33,81 @@ namespace BallanceTASEditor.UI {
|
|||||||
mDataGrid.SelectionHelp = mSelectionHelp;
|
mDataGrid.SelectionHelp = mSelectionHelp;
|
||||||
|
|
||||||
mDataGrid.Click += funcDataMenu_Click;
|
mDataGrid.Click += funcDataMenu_Click;
|
||||||
mDataGrid.NewOperation += funcDataMenu_NewOperation;
|
mSlider.ValueChanged += funcSlider_ValueChanged;
|
||||||
|
|
||||||
mSlider.ValueChanged += sliderValueChanged;
|
|
||||||
|
|
||||||
// display data
|
// display data
|
||||||
ChangeListLength(DATA_LIST_LENGTH);
|
ChangeListLength(int.Parse(GlobalVariable.configManager.Configuration[ConfigManager.CfgNode_ItemCount]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
mDataGrid.DataSources = null;
|
mDataGrid.DataSources = null;
|
||||||
|
|
||||||
mDataGrid.Click -= funcDataMenu_Click;
|
mDataGrid.Click -= funcDataMenu_Click;
|
||||||
mDataGrid.NewOperation -= funcDataMenu_NewOperation;
|
mSlider.ValueChanged -= funcSlider_ValueChanged;
|
||||||
|
|
||||||
mSlider.ValueChanged -= sliderValueChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int DATA_LIST_LENGTH = 15;
|
//const int DATA_LIST_LENGTH = 15;
|
||||||
FrameData INVALID_FRAME_DATA;
|
FrameData INVALID_FRAME_DATA;
|
||||||
TASFile mFile;
|
TASFile mFile;
|
||||||
Slider mSlider;
|
TASSlider mSlider;
|
||||||
TextBlock mStatusbar;
|
|
||||||
TASFlow mDataGrid;
|
TASFlow mDataGrid;
|
||||||
SelectionHelp mSelectionHelp;
|
SelectionHelp mSelectionHelp;
|
||||||
int mListLength;
|
int mListLength;
|
||||||
List<FrameDataDisplay> mDataSource;
|
List<FrameDataDisplay> mDataSource;
|
||||||
bool mOverwrittenPaste;
|
bool mOverwrittenPaste;
|
||||||
|
|
||||||
private void sliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
#region self event
|
||||||
long pos = e.NewValue.ToInt64();
|
public event Action<bool, bool, bool> UpdateDataUI;
|
||||||
mFile.Shift(pos);
|
public event Action<ToolMode> UpdateToolMode;
|
||||||
|
public event Action<SelectionHelp> UpdateSelection;
|
||||||
|
|
||||||
|
private void OnUpdateDataUI() {
|
||||||
|
ToolMode mode = mSelectionHelp.GetToolMode();
|
||||||
|
bool showCursorPasteAddDeleteOne = mode == ToolMode.Cursor && mSelectionHelp.IsDataPartialReady();
|
||||||
|
bool showFill = mode == ToolMode.Fill && mSelectionHelp.IsDataReady();
|
||||||
|
bool showCursorCopyDelete = mode == ToolMode.Cursor && mSelectionHelp.IsDataReady();
|
||||||
|
|
||||||
|
UpdateDataUI?.Invoke(showCursorPasteAddDeleteOne, showFill, showCursorCopyDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUpdateToolMode() {
|
||||||
|
UpdateToolMode?.Invoke(mSelectionHelp.GetToolMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUpdateSelection() {
|
||||||
|
UpdateSelection?.Invoke(mSelectionHelp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region process event
|
||||||
|
|
||||||
|
private void funcSlider_ValueChanged(long pos) {
|
||||||
|
mFile.Shift(pos);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSliderRange() {
|
|
||||||
mSlider.Maximum = mFile.mFrameCount - 1;
|
|
||||||
mSlider.Value = mFile.GetPointerIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void funcSelectionHelp_SelectionChanged() {
|
private void funcSelectionHelp_SelectionChanged() {
|
||||||
mDataGrid.RefreshDataMenu();
|
|
||||||
mDataGrid.RefreshSelectionHighlight();
|
mDataGrid.RefreshSelectionHighlight();
|
||||||
OnStatusbarSelectionChanged();
|
OnUpdateDataUI();
|
||||||
|
OnUpdateSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStatusbarSelectionChanged() {
|
private void funcDataMenu_Click() {
|
||||||
var mode = mSelectionHelp.GetToolMode();
|
var data = mSelectionHelp.GetPoint();
|
||||||
|
var field = (int)mSelectionHelp.GetPointField();
|
||||||
|
mFile.Set(new SelectionRange(field, field), new SelectionRange(data, data), null);
|
||||||
|
RefreshDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
switch (mode) {
|
#endregion
|
||||||
case ToolMode.Cursor:
|
|
||||||
if (mSelectionHelp.IsDataReady()) {
|
|
||||||
var data = mSelectionHelp.GetRange();
|
|
||||||
mStatusbar.Text = $"{data.start} - {data.end}";
|
|
||||||
} else if (mSelectionHelp.IsDataPartialReady()) {
|
|
||||||
var data2 = mSelectionHelp.GetPoint();
|
|
||||||
mStatusbar.Text = data2.ToString();
|
|
||||||
} else mStatusbar.Text = "-";
|
|
||||||
break;
|
|
||||||
case ToolMode.Fill:
|
|
||||||
if (mSelectionHelp.IsDataReady()) {
|
|
||||||
var data3 = mSelectionHelp.GetRange();
|
|
||||||
mStatusbar.Text = $"{data3.start} - {data3.end}";
|
|
||||||
} else mStatusbar.Text = "-";
|
|
||||||
break;
|
|
||||||
case ToolMode.Overwrite:
|
|
||||||
if (mSelectionHelp.IsDataReady()) {
|
|
||||||
var data4 = mSelectionHelp.GetPoint();
|
|
||||||
mStatusbar.Text = data4.ToString();
|
|
||||||
} else mStatusbar.Text = "-";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeOverwrittenMode(bool isOverwritten) {
|
public void ChangeOverwrittenMode(bool isOverwritten) {
|
||||||
mOverwrittenPaste = isOverwritten;
|
mOverwrittenPaste = isOverwritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeListLength(int newLen) {
|
public void ChangeListLength(int newLen) {
|
||||||
if (newLen < 5 || newLen > 30) return;
|
if (newLen < 5 || newLen > 200) return;
|
||||||
int offset = newLen - mListLength;
|
int offset = newLen - mListLength;
|
||||||
int abs = Math.Abs(offset);
|
int abs = Math.Abs(offset);
|
||||||
if (offset == 0) return;
|
if (offset == 0) return;
|
||||||
@ -147,6 +140,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
|
|
||||||
public void ChangeToolMode(ToolMode mode) {
|
public void ChangeToolMode(ToolMode mode) {
|
||||||
mSelectionHelp.SetMode(mode);
|
mSelectionHelp.SetMode(mode);
|
||||||
|
OnUpdateToolMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetItemCountInPage() {
|
public int GetItemCountInPage() {
|
||||||
@ -176,7 +170,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
// do delete
|
// do delete
|
||||||
mFile.Remove(mSelectionHelp.GetRange());
|
mFile.Remove(mSelectionHelp.GetRange());
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -193,7 +187,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
if (ClipboardUtil.GetFrameData(data)) {
|
if (ClipboardUtil.GetFrameData(data)) {
|
||||||
mFile.Insert(mSelectionHelp.GetPoint(), data, oper == OperationEnum.PasteBefore, mOverwrittenPaste);
|
mFile.Insert(mSelectionHelp.GetPoint(), data, oper == OperationEnum.PasteBefore, mOverwrittenPaste);
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
} else MessageBox.Show("Fail to paste due to unknow reason or blank clipboard!");
|
} else MessageBox.Show("Fail to paste due to unknow reason or blank clipboard!");
|
||||||
}
|
}
|
||||||
@ -201,7 +195,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
case OperationEnum.Delete: {
|
case OperationEnum.Delete: {
|
||||||
mFile.Remove(mSelectionHelp.GetRange());
|
mFile.Remove(mSelectionHelp.GetRange());
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -226,7 +220,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
// do real operation
|
// do real operation
|
||||||
mFile.Remove(new SelectionRange(pos, pos));
|
mFile.Remove(new SelectionRange(pos, pos));
|
||||||
|
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -237,40 +231,26 @@ namespace BallanceTASEditor.UI {
|
|||||||
var pos = mSelectionHelp.GetPoint();
|
var pos = mSelectionHelp.GetPoint();
|
||||||
mFile.Add(pos, count, deltaTime, oper == OperationEnum.AddBefore);
|
mFile.Add(pos, count, deltaTime, oper == OperationEnum.AddBefore);
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OperationEnum.Undo: {
|
case OperationEnum.Undo: {
|
||||||
mFile.Undo();
|
mFile.Undo();
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OperationEnum.Redo: {
|
case OperationEnum.Redo: {
|
||||||
mFile.Redo();
|
mFile.Redo();
|
||||||
mSelectionHelp.Reset();
|
mSelectionHelp.Reset();
|
||||||
updateSliderRange();
|
mSlider.UpdateRange(mFile);
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region data menu
|
|
||||||
|
|
||||||
private void funcDataMenu_Click() {
|
|
||||||
var data = mSelectionHelp.GetPoint();
|
|
||||||
var field = (int)mSelectionHelp.GetPointField();
|
|
||||||
mFile.Set(new SelectionRange(field, field), new SelectionRange(data, data), null);
|
|
||||||
RefreshDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void funcDataMenu_NewOperation(OperationEnum obj) {
|
|
||||||
ProcessOperation(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user