Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Disable WMR device on app's startup was implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtYurchenko committed Dec 6, 2020
1 parent af59c25 commit 8871d2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Background="Gray"
Icon="Main.ico">
<Grid>
<ToggleButton Content="Disable WMR device" FontSize="24" Width="256" Height="124" Checked="DisableWmrDeviceAction" Unchecked="EnableWmrDeviceAction" HorizontalAlignment="Center"/>
<ToggleButton Name="WmrStatusToggle" Content="Disable WMR device" FontSize="24" Width="256" Height="124" Checked="DisableWmrDeviceAction" Unchecked="EnableWmrDeviceAction" HorizontalAlignment="Center"/>
<CheckBox Name="AutostartCheckbox" Click="SwitchAutostartStatus" Content="Add to autostart" FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="50">
<CheckBox.LayoutTransform>
<ScaleTransform ScaleX="2" ScaleY="2" />
Expand Down
8 changes: 8 additions & 0 deletions WMR-USB-Controller/WMR-USB-Controller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public MainWindow()
SetupAutostartManager();

_usbDevicesManager.Initialize();

DisableWmrDeviceOnStartup();
}

private void SetupTrayIconManager()
Expand All @@ -38,6 +40,11 @@ private void SetupAutostartManager()
_autostartManager.Initialize();
}

private void DisableWmrDeviceOnStartup()
{
ChangeWmrDeviceState(false);
}

protected override void OnStateChanged(EventArgs e)
{
if (WindowState == WindowState.Minimized)
Expand Down Expand Up @@ -67,6 +74,7 @@ private void EnableWmrDeviceAction(object sender, RoutedEventArgs e)
public void ChangeWmrDeviceState(bool newState)
{
_usbDevicesManager.ActivateWmrDevice(newState);
WmrStatusToggle.IsChecked = !newState;
}

private void SwitchAutostartStatus(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Initialize()
{
InitializeTrayOptions();

_trayIcon.ContextMenu = _disableWmrMenu;
_trayIcon.ContextMenu = _enableWmrMenu;

_trayIcon.DoubleClick += ShowMainWindow;
}
Expand Down

0 comments on commit 8871d2b

Please sign in to comment.