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

Commit

Permalink
Last commit changes adjustment; dynamic window size was implelmented
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtYurchenko committed Feb 24, 2021
1 parent face892 commit c4a17e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 4 additions & 2 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
<TabItem Header="WMR status" FontSize="24">
<TabItem.Content>
<StackPanel Background="#FF5B5B5B">
<ToggleButton Name="WmrStatusToggle" Content="Disable WMR device" FontSize="24" Width="256" Height="124" Margin="50" Checked="DisableWmrDeviceAction"
<ToggleButton Name="WmrStatusToggle" Content="Disable WMR device" FontSize="24" Width="256" Height="124" Margin="25" Checked="DisableWmrDeviceAction"
Unchecked="EnableWmrDeviceAction" HorizontalAlignment="Center" />
<Button Name="WMRStartButton" Content="Start WMR" FontSize="24" Width="256" Height="124" Margin="50" Click="StartWMR" ClickMode="Press" HorizontalAlignment="Center" />
<Button FontSize="24" Width="256" Height="124" Margin="0, 0, 0, 25" Click="StartWMR" ClickMode="Press" HorizontalAlignment="Center">
<TextBlock TextWrapping="Wrap" TextAlignment="Center">Start WMR with specified screen resolution</TextBlock>
</Button>
<CheckBox Name="VirtualScreensCheckbox" Content="Disable virtual screens" FontSize="14" Margin="10" HorizontalAlignment="Center" Checked="DisableVirtualScreens" Unchecked="EnableVirtualScreens">
<CheckBox.LayoutTransform>
<ScaleTransform ScaleX="2" ScaleY="2" />
Expand Down
22 changes: 20 additions & 2 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
using System.Text.RegularExpressions;
using System.Management.Automation;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using WMR_USB_Controller.YUART.Autostart;
using WMR_USB_Controller.YUART.Holographic.Sleep_Mode;
using WMR_USB_Controller.YUART.Holographic.VirtualScreens;
using WMR_USB_Controller.YUART.Tray_Icon;
using WMR_USB_Controller.YUART.USB;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;

namespace WMR_USB_Controller
{
Expand All @@ -19,9 +21,11 @@ public partial class MainWindow
{
private const string DisableWMRToggleText = "Disable WMR device";
private const string EnableWMRToggleText = "Enable WMR device";
PowerShell ps = PowerShell.Create();
private const double WindowToScreenSizeRatio = 4;

private readonly UsbDevicesManager _usbDevicesManager = new UsbDevicesManager();

private readonly PowerShell ps = PowerShell.Create();

private AutostartManager _autostartManager;
private TrayIconManager _trayIconManager;
private SleepModeManager _sleepModeManager;
Expand All @@ -31,6 +35,8 @@ public MainWindow()
{
InitializeComponent();

SetProgramWindowSizeWithRatio();

SetupTrayIconManager();
SetupAutostartManager();
SetupSleepModeManager();
Expand All @@ -40,6 +46,17 @@ public MainWindow()

DisableWmrDeviceOnStartup();
}

private void SetProgramWindowSizeWithRatio()
{
var primaryScreenBounds = Screen.PrimaryScreen.Bounds;

var heightScreenSizeWithRatio = primaryScreenBounds.Height / WindowToScreenSizeRatio;

Width = heightScreenSizeWithRatio;

Height = heightScreenSizeWithRatio;
}

private void SetupTrayIconManager()
{
Expand Down Expand Up @@ -105,6 +122,7 @@ public void ChangeWmrDeviceState(bool newState)

private void StartWMR(object sender, RoutedEventArgs e) {
ps.Commands.Clear();
EnableWmrDeviceAction(null, null);
ps.AddScript(File.ReadAllText(@"resolution_script.ps1")).Invoke();
}

Expand Down

0 comments on commit c4a17e1

Please sign in to comment.