From 07a75244fe05eb4b2b0b628ec8f038cced238579 Mon Sep 17 00:00:00 2001 From: Roy Date: Wed, 26 Apr 2023 16:23:07 +0300 Subject: Eureka UI Screen. --- .../PPC/Tango.PPC.UI/Helpers/DpiHelper.cs | 36 ++++++++++++++++++++ .../PPC/Tango.PPC.UI/MainWindow.xaml.cs | 38 +++++++++++++++------- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 3 +- .../PPC/Tango.PPC.UI/Views/LayoutEurekaView.xaml | 6 ++-- .../PPC/Tango.PPC.UI/Views/MachineStatusView.xaml | 2 +- 5 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Helpers/DpiHelper.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Helpers/DpiHelper.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Helpers/DpiHelper.cs new file mode 100644 index 000000000..0d0ac9f1e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Helpers/DpiHelper.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.UI.Helpers +{ + public static class DpiHelper + { + private enum ProcessDPIAwareness + { + ProcessDPIUnaware = 0, + ProcessSystemDPIAware = 1, + ProcessPerMonitorDPIAware = 2 + } + + [DllImport("shcore.dll")] + private static extern int SetProcessDpiAwareness(ProcessDPIAwareness value); + + public static void SetDpiAwareness() + { + try + { + if (Environment.OSVersion.Version.Major >= 6) + { + SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware); + } + } + catch (EntryPointNotFoundException)//this exception occures if OS does not implement this API, just ignore it. + { + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index b7f6c40ae..1cfa60f92 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -21,6 +21,7 @@ using Tango.Core.DI; using Tango.PPC.Common.Application; using Tango.PPC.Common.Build; using Tango.PPC.UI.Build; +using Tango.PPC.UI.Helpers; using Tango.Touch.Helpers; namespace Tango.PPC.UI @@ -68,17 +69,32 @@ namespace Tango.PPC.UI var screens = System.Windows.Forms.Screen.AllScreens; var touch_screen = screens.Last(); - WindowStyle = WindowStyle.SingleBorderWindow; - ResizeMode = ResizeMode.CanResize; - Width = 1280; - Height = 720; - WindowStartupLocation = WindowStartupLocation.CenterScreen; - WindowState = WindowState.Normal; - Topmost = false; // sure? - //Left = touch_screen.Bounds.Left; - //Top = touch_screen.Bounds.Top; - //Width = touch_screen.Bounds.Width; - //Height = touch_screen.Bounds.Height; + + bool hasTouch = TouchHelper.IsTouchEnabled(); + + if (!hasTouch) + { + WindowStyle = WindowStyle.SingleBorderWindow; + ResizeMode = ResizeMode.CanResize; + Width = 1280; + Height = 720; + WindowStartupLocation = WindowStartupLocation.CenterScreen; + WindowState = WindowState.Normal; + Topmost = false; // sure? + } + else + { + WindowState = WindowState.Normal; + WindowStyle = WindowStyle.None; + ResizeMode = ResizeMode.NoResize; + Left = screens.Length == 2 ? screens[0].Bounds.Width : 0; + Top = 0; + Width = 1920; + Height = 1080; + WindowStartupLocation = WindowStartupLocation.Manual; + Topmost = false; // sure? + } + //App.Current.Resources["TangoPanelMaskColor"] = App.Current.Resources["TangoPanelMaskColorLight"]; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index bb67015e9..af76c09ce 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -203,6 +203,7 @@ + @@ -892,7 +893,7 @@ if $(ConfigurationName) == Debug "rc.exe" "$(TargetPath)" --set-version-string " - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutEurekaView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutEurekaView.xaml index d827205f8..a2d0d5930 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutEurekaView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutEurekaView.xaml @@ -204,8 +204,8 @@ - - + + @@ -213,7 +213,7 @@ - - + -- cgit v1.3.1