diff --git a/DS4Windows/DS4Forms/RecordBox.xaml b/DS4Windows/DS4Forms/RecordBox.xaml index 903ed7c..6fcc38e 100644 --- a/DS4Windows/DS4Forms/RecordBox.xaml +++ b/DS4Windows/DS4Forms/RecordBox.xaml @@ -10,7 +10,7 @@ lex:ResxLocalizationProvider.DefaultDictionary="Strings" xmlns:local="clr-namespace:DS4WinWPF.DS4Forms" mc:Ignorable="d" - d:DesignHeight="350" d:DesignWidth="800" KeyDown="UserControl_KeyDown" KeyUp="UserControl_KeyUp" MouseDown="UserControl_MouseDown" MouseUp="UserControl_MouseUp" > + d:DesignHeight="350" d:DesignWidth="800" KeyDown="UserControl_KeyDown" KeyUp="UserControl_KeyUp" MouseDown="UserControl_MouseDown" MouseUp="UserControl_MouseUp" Focusable="True" > diff --git a/DS4Windows/DS4Forms/RecordBox.xaml.cs b/DS4Windows/DS4Forms/RecordBox.xaml.cs index cfa4f32..ac2c07e 100644 --- a/DS4Windows/DS4Forms/RecordBox.xaml.cs +++ b/DS4Windows/DS4Forms/RecordBox.xaml.cs @@ -62,6 +62,23 @@ namespace DS4WinWPF.DS4Forms private void SetupLateEvents() { macroListBox.SelectionChanged += MacroListBox_SelectionChanged; + recordBoxVM.MacroSteps.CollectionChanged += MacroSteps_CollectionChanged; + } + + private void MacroSteps_CollectionChanged(object sender, + System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) + { + Dispatcher.BeginInvoke((Action)(() => + { + int count = recordBoxVM.MacroSteps.Count; + if (count > 0) + { + macroListBox.ScrollIntoView(recordBoxVM.MacroSteps[count - 1]); + } + })); + } } private void MacroListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -271,12 +288,14 @@ namespace DS4WinWPF.DS4Forms recordBoxVM.KeysdownMap.Add(value, true); } + e.Handled = true; //Console.WriteLine(e.Key); //Console.WriteLine(e.SystemKey); } else if (e.Key == Key.Delete && recordBoxVM.MacroStepIndex >= 0) { recordBoxVM.MacroSteps.RemoveAt(recordBoxVM.MacroStepIndex); + e.Handled = true; } } @@ -294,6 +313,7 @@ namespace DS4WinWPF.DS4Forms recordBoxVM.KeysdownMap.Remove(value); } + e.Handled = true; //Console.WriteLine(e.Key); //Console.WriteLine(e.SystemKey); } @@ -499,6 +519,7 @@ namespace DS4WinWPF.DS4Forms DS4Windows.MacroStep.StepType.ActDown, DS4Windows.MacroStep.StepOutput.Button); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Add(value, true); + e.Handled = true; } } @@ -521,6 +542,7 @@ namespace DS4WinWPF.DS4Forms DS4Windows.MacroStep.StepType.ActUp, DS4Windows.MacroStep.StepOutput.Button); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Remove(value); + e.Handled = true; } } }