Skip to content

Commit 21b7582

Browse files
committed
controller: alt-l alt-o for lock and full opacity.
1 parent a8fe350 commit 21b7582

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

ChuniVController/ChuniVController/ChuniVController.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38+
<Reference Include="NHotkey, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>..\packages\NHotkey.1.2.1\lib\net20\NHotkey.dll</HintPath>
40+
</Reference>
41+
<Reference Include="NHotkey.Wpf, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
42+
<HintPath>..\packages\NHotkey.Wpf.1.2.1\lib\net35\NHotkey.Wpf.dll</HintPath>
43+
</Reference>
3844
<Reference Include="System" />
3945
<Reference Include="System.Data" />
4046
<Reference Include="System.Xml" />
@@ -90,6 +96,7 @@
9096
<Generator>ResXFileCodeGenerator</Generator>
9197
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
9298
</EmbeddedResource>
99+
<None Include="packages.config" />
93100
<None Include="Properties\Settings.settings">
94101
<Generator>SettingsSingleFileGenerator</Generator>
95102
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

ChuniVController/ChuniVController/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
5151
<Label Content="Opacity" />
5252
<Slider Margin="3" x:Name="OpacitySlider" Width="100" Maximum="1" Minimum="0.1" Value="1" TickFrequency="0.01" SmallChange="0.01" LargeChange="0.1"/>
53-
<CheckBox Margin="3" Content="Allow Mouse" Checked="SetAllowMouse" Unchecked="UnsetAllowMouse" Height="17" />
54-
<CheckBox Margin="3" Content="Lock Window" Checked="SetLockWindow" Unchecked="UnsetLockWindow" Height="17" />
53+
<CheckBox x:Name="AllowMouse" Margin="3" Content="Allow Mouse" Checked="SetAllowMouse" Unchecked="UnsetAllowMouse" Height="17" />
54+
<CheckBox x:Name="LockWindow" Margin="3" Content="Lock Window" Checked="SetLockWindow" Unchecked="UnsetLockWindow" Height="17" />
5555
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
5656
<Button Margin="3" Content="Coin" HorizontalAlignment="Left" Width="50" Click="DoCoin" />
5757
<Button Margin="3" Content="Service" HorizontalAlignment="Left" Width="50" Click="DoService" />

ChuniVController/ChuniVController/MainWindow.xaml.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
using System.Windows.Media.Imaging;
1515
using System.Windows.Navigation;
1616
using System.Windows.Shapes;
17+
using NHotkey;
18+
using NHotkey.Wpf;
1719

1820
namespace ChuniVController
1921
{
2022
public partial class MainWindow : Window
2123
{
22-
private ChuniIO cio;
24+
private readonly ChuniIO cio;
2325

2426
private void handleRecv(ChuniIoMessage message)
2527
{
@@ -35,6 +37,20 @@ public MainWindow()
3537
InitializeComponent();
3638
cio = new ChuniIO("127.0.0.1", 24864, handleRecv);
3739
cio.Start();
40+
41+
HotkeyManager.Current.AddOrReplace("Lock", Key.L, ModifierKeys.Alt, ToggleLockWindow);
42+
HotkeyManager.Current.AddOrReplace("Opacity", Key.O, ModifierKeys.Alt, ToggleFullOpacity);
43+
}
44+
45+
private void ToggleLockWindow(object sender, HotkeyEventArgs e)
46+
{
47+
LockWindow.IsChecked = !drag_locked;
48+
}
49+
50+
private void ToggleFullOpacity(object sender, HotkeyEventArgs e)
51+
{
52+
if (Opacity > 0) Opacity = 0;
53+
else Opacity = 1;
3854
}
3955

4056
private bool drag_locked = false;
@@ -109,7 +125,7 @@ private void Render()
109125

110126
protected override void OnPreviewKeyDown(KeyEventArgs e)
111127
{
112-
if (e.Key == Key.Space) e.Handled = true; // so that checkboxes won't be trigger by the IR sensor simulation
128+
if (e.Key == Key.Enter) e.Handled = true; // so if user do aime simulation it won't triggers button
113129
base.OnPreviewKeyDown(e);
114130
}
115131

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NHotkey" version="1.2.1" targetFramework="net472" />
4+
<package id="NHotkey.Wpf" version="1.2.1" targetFramework="net472" />
5+
</packages>

0 commit comments

Comments
 (0)