Make sure RecordBox can have focus. Allow extra keys to be usable while recording a macro.

This commit is contained in:
ryochan7@protonmail.com 2019-12-30 01:18:19 -06:00
parent 1ce2f50cba
commit e39cccf279
2 changed files with 23 additions and 1 deletions

View File

@ -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" >
<UserControl.Resources>
<DataTemplate x:Key="DisplayTemplate">
<StackPanel Orientation="Horizontal">

View File

@ -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;
}
}
}