From 2adefe86f4c10c670f8f1ab75c5de77ea766430e Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 16 May 2021 14:15:35 +0800 Subject: [PATCH] write shit --- BallanceTASEditor.csproj | 2 + Core/ClipboardUtil.cs | 63 +++++++++++ Core/KeyboardState.cs | 223 +++++++++++++++++++++++++++++++++++++++ Core/TASFile.cs | 44 ++++++-- Core/TASStruct.cs | 4 + Core/Util.cs | 63 +++++++++++ MainWindow.xaml.cs | 47 --------- UI/SelectionHelp.cs | 9 +- UI/TASFlow.xaml.cs | 33 ++++-- UI/TASViewer.cs | 68 ++++++++++++ 10 files changed, 489 insertions(+), 67 deletions(-) create mode 100644 Core/ClipboardUtil.cs create mode 100644 Core/KeyboardState.cs diff --git a/BallanceTASEditor.csproj b/BallanceTASEditor.csproj index 71587e1..50f1c88 100644 --- a/BallanceTASEditor.csproj +++ b/BallanceTASEditor.csproj @@ -57,6 +57,8 @@ MSBuild:Compile Designer + + diff --git a/Core/ClipboardUtil.cs b/Core/ClipboardUtil.cs new file mode 100644 index 0000000..7169aa0 --- /dev/null +++ b/Core/ClipboardUtil.cs @@ -0,0 +1,63 @@ +using BallanceTASEditor.Core.TASStruct; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; + +namespace BallanceTASEditor.Core { + public class ClipboardUtil { + + // comes from https://stackoverflow.com/questions/22272822/copy-binary-data-to-clipboard + + private static readonly string CLIPBOARD_DATA_FORMAT = "BallanceTASFrameData"; + public static bool SetFrameData(LinkedList ls) { + try { + DataObject data = new DataObject(); + using (var mem = new MemoryStream()) { + mem.Write(BitConverter.GetBytes(ls.Count), 0, 4); + + var node = ls.First; + while (node != null) { + mem.Write(BitConverter.GetBytes(node.Value.deltaTime), 0, 4); + mem.Write(BitConverter.GetBytes(node.Value.keystates), 0, 4); + node = node.Next; + } + + data.SetData(CLIPBOARD_DATA_FORMAT, mem, false); + Clipboard.SetDataObject(data, true); + } + return true; + } catch { + return false; + } + } + + public static bool GetFrameData(LinkedList ls) { + try { + // detect + DataObject retrievedData = Clipboard.GetDataObject() as DataObject; + if (retrievedData == null || !retrievedData.GetDataPresent(CLIPBOARD_DATA_FORMAT)) + return false; + MemoryStream byteStream = retrievedData.GetData(CLIPBOARD_DATA_FORMAT) as MemoryStream; + if (byteStream == null) + return false; + + // read + byteStream.Seek(0, SeekOrigin.Begin); + byte[] temp = new byte[8]; + byteStream.Read(temp, 0, 4); + int count = BitConverter.ToInt32(temp, 0); + + for (int i = 0; i < count; i++) { + ls.AddLast(new FrameData(byteStream)); + } + + return true; + } catch { + return false; + } + } + } +} diff --git a/Core/KeyboardState.cs b/Core/KeyboardState.cs new file mode 100644 index 0000000..6e08e65 --- /dev/null +++ b/Core/KeyboardState.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace BallanceTASEditor.Core { + public class KeyboardState { + + [DllImport("user32.dll")] + static extern short GetKeyState(VirtualKeyStates nVirtKey); + + public static bool IsKeyPressed(VirtualKeyStates testKey) { + bool keyPressed = false; + short result = GetKeyState(testKey); + switch (result) { + case 0: + // Not pressed and not toggled on. + keyPressed = false; + break; + + case 1: + // Not pressed, but toggled on + keyPressed = false; + break; + + default: + // Pressed (and may be toggled on) + keyPressed = true; + break; + } + return keyPressed; + } + + public enum VirtualKeyStates : int { + VK_LBUTTON = 0x01, + VK_RBUTTON = 0x02, + VK_CANCEL = 0x03, + VK_MBUTTON = 0x04, + // + VK_XBUTTON1 = 0x05, + VK_XBUTTON2 = 0x06, + // + VK_BACK = 0x08, + VK_TAB = 0x09, + // + VK_CLEAR = 0x0C, + VK_RETURN = 0x0D, + // + VK_SHIFT = 0x10, + VK_CONTROL = 0x11, + VK_MENU = 0x12, + VK_PAUSE = 0x13, + VK_CAPITAL = 0x14, + // + VK_KANA = 0x15, + VK_HANGEUL = 0x15, /* old name - should be here for compatibility */ + VK_HANGUL = 0x15, + VK_JUNJA = 0x17, + VK_FINAL = 0x18, + VK_HANJA = 0x19, + VK_KANJI = 0x19, + // + VK_ESCAPE = 0x1B, + // + VK_CONVERT = 0x1C, + VK_NONCONVERT = 0x1D, + VK_ACCEPT = 0x1E, + VK_MODECHANGE = 0x1F, + // + VK_SPACE = 0x20, + VK_PRIOR = 0x21, + VK_NEXT = 0x22, + VK_END = 0x23, + VK_HOME = 0x24, + VK_LEFT = 0x25, + VK_UP = 0x26, + VK_RIGHT = 0x27, + VK_DOWN = 0x28, + VK_SELECT = 0x29, + VK_PRINT = 0x2A, + VK_EXECUTE = 0x2B, + VK_SNAPSHOT = 0x2C, + VK_INSERT = 0x2D, + VK_DELETE = 0x2E, + VK_HELP = 0x2F, + // + VK_LWIN = 0x5B, + VK_RWIN = 0x5C, + VK_APPS = 0x5D, + // + VK_SLEEP = 0x5F, + // + VK_NUMPAD0 = 0x60, + VK_NUMPAD1 = 0x61, + VK_NUMPAD2 = 0x62, + VK_NUMPAD3 = 0x63, + VK_NUMPAD4 = 0x64, + VK_NUMPAD5 = 0x65, + VK_NUMPAD6 = 0x66, + VK_NUMPAD7 = 0x67, + VK_NUMPAD8 = 0x68, + VK_NUMPAD9 = 0x69, + VK_MULTIPLY = 0x6A, + VK_ADD = 0x6B, + VK_SEPARATOR = 0x6C, + VK_SUBTRACT = 0x6D, + VK_DECIMAL = 0x6E, + VK_DIVIDE = 0x6F, + VK_F1 = 0x70, + VK_F2 = 0x71, + VK_F3 = 0x72, + VK_F4 = 0x73, + VK_F5 = 0x74, + VK_F6 = 0x75, + VK_F7 = 0x76, + VK_F8 = 0x77, + VK_F9 = 0x78, + VK_F10 = 0x79, + VK_F11 = 0x7A, + VK_F12 = 0x7B, + VK_F13 = 0x7C, + VK_F14 = 0x7D, + VK_F15 = 0x7E, + VK_F16 = 0x7F, + VK_F17 = 0x80, + VK_F18 = 0x81, + VK_F19 = 0x82, + VK_F20 = 0x83, + VK_F21 = 0x84, + VK_F22 = 0x85, + VK_F23 = 0x86, + VK_F24 = 0x87, + // + VK_NUMLOCK = 0x90, + VK_SCROLL = 0x91, + // + VK_OEM_NEC_EQUAL = 0x92, // '=' key on numpad + // + VK_OEM_FJ_JISHO = 0x92, // 'Dictionary' key + VK_OEM_FJ_MASSHOU = 0x93, // 'Unregister word' key + VK_OEM_FJ_TOUROKU = 0x94, // 'Register word' key + VK_OEM_FJ_LOYA = 0x95, // 'Left OYAYUBI' key + VK_OEM_FJ_ROYA = 0x96, // 'Right OYAYUBI' key + // + VK_LSHIFT = 0xA0, + VK_RSHIFT = 0xA1, + VK_LCONTROL = 0xA2, + VK_RCONTROL = 0xA3, + VK_LMENU = 0xA4, + VK_RMENU = 0xA5, + // + VK_BROWSER_BACK = 0xA6, + VK_BROWSER_FORWARD = 0xA7, + VK_BROWSER_REFRESH = 0xA8, + VK_BROWSER_STOP = 0xA9, + VK_BROWSER_SEARCH = 0xAA, + VK_BROWSER_FAVORITES = 0xAB, + VK_BROWSER_HOME = 0xAC, + // + VK_VOLUME_MUTE = 0xAD, + VK_VOLUME_DOWN = 0xAE, + VK_VOLUME_UP = 0xAF, + VK_MEDIA_NEXT_TRACK = 0xB0, + VK_MEDIA_PREV_TRACK = 0xB1, + VK_MEDIA_STOP = 0xB2, + VK_MEDIA_PLAY_PAUSE = 0xB3, + VK_LAUNCH_MAIL = 0xB4, + VK_LAUNCH_MEDIA_SELECT = 0xB5, + VK_LAUNCH_APP1 = 0xB6, + VK_LAUNCH_APP2 = 0xB7, + // + VK_OEM_1 = 0xBA, // ';:' for US + VK_OEM_PLUS = 0xBB, // '+' any country + VK_OEM_COMMA = 0xBC, // ',' any country + VK_OEM_MINUS = 0xBD, // '-' any country + VK_OEM_PERIOD = 0xBE, // '.' any country + VK_OEM_2 = 0xBF, // '/?' for US + VK_OEM_3 = 0xC0, // '`~' for US + // + VK_OEM_4 = 0xDB, // '[{' for US + VK_OEM_5 = 0xDC, // '\|' for US + VK_OEM_6 = 0xDD, // ']}' for US + VK_OEM_7 = 0xDE, // ''"' for US + VK_OEM_8 = 0xDF, + // + VK_OEM_AX = 0xE1, // 'AX' key on Japanese AX kbd + VK_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key kbd. + VK_ICO_HELP = 0xE3, // Help key on ICO + VK_ICO_00 = 0xE4, // 00 key on ICO + // + VK_PROCESSKEY = 0xE5, + // + VK_ICO_CLEAR = 0xE6, + // + VK_PACKET = 0xE7, + // + VK_OEM_RESET = 0xE9, + VK_OEM_JUMP = 0xEA, + VK_OEM_PA1 = 0xEB, + VK_OEM_PA2 = 0xEC, + VK_OEM_PA3 = 0xED, + VK_OEM_WSCTRL = 0xEE, + VK_OEM_CUSEL = 0xEF, + VK_OEM_ATTN = 0xF0, + VK_OEM_FINISH = 0xF1, + VK_OEM_COPY = 0xF2, + VK_OEM_AUTO = 0xF3, + VK_OEM_ENLW = 0xF4, + VK_OEM_BACKTAB = 0xF5, + // + VK_ATTN = 0xF6, + VK_CRSEL = 0xF7, + VK_EXSEL = 0xF8, + VK_EREOF = 0xF9, + VK_PLAY = 0xFA, + VK_ZOOM = 0xFB, + VK_NONAME = 0xFC, + VK_PA1 = 0xFD, + VK_OEM_CLEAR = 0xFE + } + } +} diff --git a/Core/TASFile.cs b/Core/TASFile.cs index 3138d51..fd44d83 100644 --- a/Core/TASFile.cs +++ b/Core/TASFile.cs @@ -1,4 +1,5 @@ using BallanceTASEditor.Core.TASStruct; +using BallanceTASEditor.UI; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -60,20 +61,43 @@ namespace BallanceTASEditor.Core { } } - public void Set(FrameDataField field, long prevRange, long nextRange, bool isSet) { + // if isSet is null, mean flip state + public void Set(SelectionRange field, SelectionRange relativeRange, bool? isSet) { if (mPointer == null) return; var cachePointer = mPointer; - var offset = ConstValue.Mapping[field]; - for (long i = 0; i < nextRange && cachePointer != null; i++) { - if (isSet) cachePointer.Value.SetKeyStates(offset); - else cachePointer.Value.UnsetKeyStates(offset); - cachePointer = cachePointer.Next; + uint offset = 0; + for(int i = (int)field.start; i <= (int)field.end; i++) { + offset |= ConstValue.Mapping[(FrameDataField)i]; } - for (long i = 0; i < prevRange && cachePointer != null; i++) { - if (isSet) cachePointer.Value.SetKeyStates(offset); - else cachePointer.Value.UnsetKeyStates(offset); - cachePointer = cachePointer.Previous; + foreach(var item in mMem.IterateWithSelectionRange(relativeRange, mPointer)) { + if (isSet == null) item.Value.ReverseKeyStates(offset); + else if (isSet == true) item.Value.SetKeyStates(offset); + else if (isSet == false) item.Value.UnsetKeyStates(offset); + } + } + + public void Remove(SelectionRange relativeRange) { + if (mPointer == null) return; + + mMem.RemoveWithSelectionRange(relativeRange, mPointer); + // todo: fix pointer point to invalid item + } + + public void Add(long relativePos, bool isAddBefore) { + + } + + public void Insert(long relativePos, LinkedList data, bool isInsertBefore) { + if (mPointer == null) return; + + } + + public void Copy(SelectionRange relativeRange, LinkedList data) { + if (mPointer == null) return; + + foreach (var item in mMem.IterateWithSelectionRange(relativeRange, mPointer)) { + data.AddLast(item.Value); } } diff --git a/Core/TASStruct.cs b/Core/TASStruct.cs index 92d93ab..3df9ec7 100644 --- a/Core/TASStruct.cs +++ b/Core/TASStruct.cs @@ -110,6 +110,10 @@ namespace BallanceTASEditor.Core.TASStruct { keystates &= ~offset; } + public void ReverseKeyStates(UInt32 offset) { + keystates ^= offset; + } + public float deltaTime; public UInt32 keystates; } diff --git a/Core/Util.cs b/Core/Util.cs index 3097d57..cfcae7b 100644 --- a/Core/Util.cs +++ b/Core/Util.cs @@ -1,4 +1,5 @@ using BallanceTASEditor.Core.TASStruct; +using BallanceTASEditor.UI; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -18,5 +19,67 @@ namespace BallanceTASEditor.Core { // if (index + count > list.Count) count = list.Count - index; // for (int i = 0; i < count; i++) list.RemoveAt(index); //} + public static IEnumerable> IterateFull(this LinkedList ls) { + var pos = ls.First; + + while(pos != null) { + yield return pos; + pos = pos.Next; + } + } + + + public static IEnumerable> IterateWithSelectionRange(this LinkedList ls, SelectionRange relativeRange, LinkedListNode current) { + if (current == null) goto end; + + // goto header first + long counter; + var cache = current.TryShiftTo(relativeRange.start, out counter); + + while (counter <= relativeRange.end && cache != null) { + yield return cache; + cache = cache.Next; + counter++; + } + + end:; + } + + public static void RemoveWithSelectionRange(this LinkedList ls, SelectionRange relativeRange, LinkedListNode current) { + if (current == null) goto end; + + // goto header first + long counter; + var cache = current.TryShiftTo(relativeRange.start, out counter); + + LinkedListNode cacheNextNode; + while (counter <= relativeRange.end && cache != null) { + cacheNextNode = cache.Next; + ls.Remove(cache); + cache = cacheNextNode; + counter++; + } + + end:; + } + + public static LinkedListNode TryShiftTo(this LinkedListNode node, long offset, out long realShifted) { + var cache = node; + + realShifted = 0; + if (offset < 0) { + while (realShifted != offset && cache.Previous != null) { + cache = cache.Previous; + realShifted--; + } + } else if (offset > 0) { + while (realShifted != offset && cache.Next != null) { + cache = cache.Next; + realShifted++; + } + } + + return cache; + } } } diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 88e18be..41fe8f2 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -22,21 +22,9 @@ namespace BallanceTASEditor { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); - - // bind event without xaml due to xaml shit design - uiTASData.uiDataMenu_Set.Click += funcDataMenu_Set; - uiTASData.uiDataMenu_Unset.Click += funcDataMenu_Unset; - uiTASData.uiDataMenu_Copy.Click += funcDataMenu_Copy; - uiTASData.uiDataMenu_Delete.Click += funcDataMenu_Delete; - uiTASData.uiDataMenu_PasteAfter.Click += funcDataMenu_PasteAfter; - uiTASData.uiDataMenu_PasteBefore.Click += funcDataMenu_PasteBefore; - uiTASData.uiDataMenu_AddAfter.Click += funcDataMenu_AddAfter; - uiTASData.uiDataMenu_AddBefore.Click += funcDataMenu_AddBefore; - RefreshUI(false); } - TASFile mFile; TASViewer mViewer; @@ -100,41 +88,6 @@ namespace BallanceTASEditor { #endregion - #region data menu - - private void funcDataMenu_AddBefore(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_AddAfter(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_PasteBefore(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_PasteAfter(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_Delete(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_Copy(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_Unset(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - private void funcDataMenu_Set(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - } - - #endregion private void ChangeToolMode(ToolMode mode) { switch (mode) { diff --git a/UI/SelectionHelp.cs b/UI/SelectionHelp.cs index d1049cb..6173941 100644 --- a/UI/SelectionHelp.cs +++ b/UI/SelectionHelp.cs @@ -87,7 +87,7 @@ namespace BallanceTASEditor.UI { if (mMode == ToolMode.Fill) throw new Exception("Read with wrong mode."); if (!mIsStartConfirmed) throw new Exception("Data is not ready to read"); - if (mMode == ToolMode.Cursor) return mStart; + if (mMode == ToolMode.Overwrite) return mStart; else { // cursor mode if (mIsStartConfirmed) return mStart; @@ -95,6 +95,13 @@ namespace BallanceTASEditor.UI { } } + public FrameDataField GetPointField() { + if (mMode != ToolMode.Overwrite) throw new Exception("Read with wrong mode."); + if (!mIsStartConfirmed) throw new Exception("Data is not ready to read"); + + return mStartField; + } + public bool IsDataReady() { switch (mMode) { case ToolMode.Cursor: diff --git a/UI/TASFlow.xaml.cs b/UI/TASFlow.xaml.cs index dac2f19..8248a05 100644 --- a/UI/TASFlow.xaml.cs +++ b/UI/TASFlow.xaml.cs @@ -1,4 +1,5 @@ -using BallanceTASEditor.Core.TASStruct; +using BallanceTASEditor.Core; +using BallanceTASEditor.Core.TASStruct; using System; using System.Collections.Generic; using System.Linq; @@ -26,6 +27,8 @@ namespace BallanceTASEditor.UI { SetItemCount(1); } + public event Action Click; + private int mItemCount; private List mItemList; private Dictionary mRectMap; @@ -147,10 +150,21 @@ namespace BallanceTASEditor.UI { var pos = mRectMap[rect]; if (!mItemList[pos.column - 1].rawIsEnable) return; if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) { - SelectionHelp.FirstClick(mItemList[pos.column - 1].rawFrame, pos.field); - } else if (e.MouseDevice.RightButton == MouseButtonState.Pressed) { - SelectionHelp.LastClick(mItemList[pos.column - 1].rawFrame, pos.field); + if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) { + SelectionHelp.LastClick(mItemList[pos.column - 1].rawFrame, pos.field); + } else { + SelectionHelp.FirstClick(mItemList[pos.column - 1].rawFrame, pos.field); + } } + + // note main window to process it. + OnClick(); + } + + // only raised in overwrite mode + private void OnClick() { + if (SelectionHelp.GetToolMode() == ToolMode.Overwrite) + Click?.Invoke(); } } @@ -159,12 +173,12 @@ namespace BallanceTASEditor.UI { private static readonly Thickness DEFAULT_MARGIN = new Thickness(2); private static readonly Thickness RECT_MARGIN = new Thickness(1); private static readonly SolidColorBrush SEL_RECT_NORMAL_BRUSH = new SolidColorBrush(Colors.White); - private static readonly SolidColorBrush SEL_RECT_SELECTED_BRUSH = new SolidColorBrush(Colors.Orange); - private static readonly SolidColorBrush SEL_RECT_STROKE = new SolidColorBrush(Colors.Gray); + private static readonly SolidColorBrush SEL_RECT_SELECTED_BRUSH = new SolidColorBrush(Colors.OrangeRed); + private static readonly SolidColorBrush SEL_RECT_STROKE = new SolidColorBrush(Colors.LightGray); private static readonly Color COLOR_SET = Color.FromRgb(30, 144, 255); private static readonly Color COLOR_UNSET = Color.FromArgb(0, 255, 255, 255); - private static readonly Color COLOR_SELECTED = Colors.Orange; - private static readonly Color COLOR_UNSELECTED = Colors.Gray; + private static readonly Color COLOR_SELECTED = Colors.OrangeRed; + private static readonly Color COLOR_UNSELECTED = Colors.LightGray; private const int KEY_COUNT = 9; private const double SELECTION_HEADER_HEIGHT = 10.0f; @@ -185,7 +199,7 @@ namespace BallanceTASEditor.UI { frame.Margin = DEFAULT_MARGIN; deltaTime.Margin = DEFAULT_MARGIN; - sel_rect.StrokeThickness = 3; + sel_rect.StrokeThickness = 2; sel_rect.Stroke = SEL_RECT_STROKE; sel_rect.Height = SELECTION_HEADER_HEIGHT; @@ -246,6 +260,7 @@ namespace BallanceTASEditor.UI { keystatesFill[7].Color = isEnable && fdd.key_esc ? COLOR_SET : COLOR_UNSET; keystatesFill[8].Color = isEnable && fdd.key_enter ? COLOR_SET : COLOR_UNSET; + sel_rect.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed; frame.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed; deltaTime.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed; for (int i = 0; i < KEY_COUNT; i++) { diff --git a/UI/TASViewer.cs b/UI/TASViewer.cs index 96c4994..f974e36 100644 --- a/UI/TASViewer.cs +++ b/UI/TASViewer.cs @@ -33,6 +33,17 @@ namespace BallanceTASEditor.UI { // bind event and source mDataGrid.DataSources = mDataSource; mDataGrid.SelectionHelp = mSelectionHelp; + + mDataGrid.uiDataMenu_Set.Click += funcDataMenu_Set; + mDataGrid.uiDataMenu_Unset.Click += funcDataMenu_Unset; + mDataGrid.uiDataMenu_Copy.Click += funcDataMenu_Copy; + mDataGrid.uiDataMenu_Delete.Click += funcDataMenu_Delete; + mDataGrid.uiDataMenu_PasteAfter.Click += funcDataMenu_PasteAfter; + mDataGrid.uiDataMenu_PasteBefore.Click += funcDataMenu_PasteBefore; + mDataGrid.uiDataMenu_AddAfter.Click += funcDataMenu_AddAfter; + mDataGrid.uiDataMenu_AddBefore.Click += funcDataMenu_AddBefore; + mDataGrid.Click += funcDataMenu_Click; + mSlider.ValueChanged += sliderValueChanged; // display data @@ -41,6 +52,17 @@ namespace BallanceTASEditor.UI { public void Dispose() { mDataGrid.DataSources = null; + + mDataGrid.uiDataMenu_Set.Click -= funcDataMenu_Set; + mDataGrid.uiDataMenu_Unset.Click -= funcDataMenu_Unset; + mDataGrid.uiDataMenu_Copy.Click -= funcDataMenu_Copy; + mDataGrid.uiDataMenu_Delete.Click -= funcDataMenu_Delete; + mDataGrid.uiDataMenu_PasteAfter.Click -= funcDataMenu_PasteAfter; + mDataGrid.uiDataMenu_PasteBefore.Click -= funcDataMenu_PasteBefore; + mDataGrid.uiDataMenu_AddAfter.Click -= funcDataMenu_AddAfter; + mDataGrid.uiDataMenu_AddBefore.Click -= funcDataMenu_AddBefore; + mDataGrid.Click -= funcDataMenu_Click; + mSlider.ValueChanged -= sliderValueChanged; } @@ -141,5 +163,51 @@ namespace BallanceTASEditor.UI { mSelectionHelp.SetMode(mode); } + + + #region data menu + + private void funcDataMenu_AddBefore(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_AddAfter(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_PasteBefore(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_PasteAfter(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_Delete(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_Copy(object sender, RoutedEventArgs e) { + throw new NotImplementedException(); + } + + private void funcDataMenu_Unset(object sender, RoutedEventArgs e) { + mFile.Set(mSelectionHelp.GetFieldRange(), mSelectionHelp.GetRange().GetRelative(mPosition), false); + RefreshDisplay(mPosition); + } + + private void funcDataMenu_Set(object sender, RoutedEventArgs e) { + mFile.Set(mSelectionHelp.GetFieldRange(), mSelectionHelp.GetRange().GetRelative(mPosition), true); + RefreshDisplay(mPosition); + } + + private void funcDataMenu_Click() { + var data = mSelectionHelp.GetPoint() - mPosition; + var field = (int)mSelectionHelp.GetPointField(); + mFile.Set(new SelectionRange(field, field), new SelectionRange(data, data), null); + RefreshDisplay(mPosition); + } + + #endregion } }