From ec0a1b710edcfabbc982c65982106881b779b96c Mon Sep 17 00:00:00 2001 From: seerge Date: Wed, 29 Mar 2023 12:19:00 +0200 Subject: [PATCH] New slider --- app/ControlHelper.cs | 14 +++++++++++--- app/CustomControls.cs | 3 ++- app/GHelper.csproj | 2 +- app/NativeMethods.cs | 2 ++ app/Program.cs | 6 +++--- app/Settings.cs | 2 +- app/Slider.cs | 14 +++++++------- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/ControlHelper.cs b/app/ControlHelper.cs index 7af6bfec..aab1cd96 100644 --- a/app/ControlHelper.cs +++ b/app/ControlHelper.cs @@ -1,4 +1,5 @@ using CustomControls; +using WinFormsSliderBar; using System.Drawing.Drawing2D; using System.Windows.Forms.DataVisualization.Charting; @@ -38,7 +39,7 @@ public static class ControlHelper foreMain = SystemColors.ControlText; foreAccent = Color.LightGray; borderMain = Color.LightGray; - buttonMain = Color.FromArgb(255, 230, 230, 230); + buttonMain = Color.FromArgb(255, 250, 250, 250); } container.BackColor = formBack; @@ -53,7 +54,7 @@ public static class ControlHelper public static void Resize(RForm container, float baseScale = 2) { _scale = GetDpiScale(container).Value / baseScale; - ResizeControls(container.Controls); + if (Math.Abs(_scale - 1) > 0.2) ResizeControls(container.Controls); } @@ -65,9 +66,11 @@ public static class ControlHelper if (button != null && button.Image is not null) button.Image = ResizeImage(button.Image); + /* var pictureBox = control as PictureBox; if (pictureBox != null && pictureBox.BackgroundImage is not null) pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage); + */ ResizeControls(control.Controls); } @@ -95,7 +98,7 @@ public static class ControlHelper if (pictureBox != null && pictureBox.BackgroundImage is not null) pictureBox.BackgroundImage = AdjustImage(pictureBox.BackgroundImage); - + var combo = control as RComboBox; if (combo != null) { @@ -111,6 +114,11 @@ public static class ControlHelper gb.ForeColor = foreMain; } + var sl = control as Slider; + if (sl != null) + { + sl.borderColor = buttonMain; + } var chart = control as Chart; if (chart != null) diff --git a/app/CustomControls.cs b/app/CustomControls.cs index f02f4d5d..8d6fa718 100644 --- a/app/CustomControls.cs +++ b/app/CustomControls.cs @@ -1,5 +1,6 @@ using Microsoft.Win32; using System.ComponentModel; +using System.Diagnostics; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; @@ -30,7 +31,7 @@ namespace CustomControls return (int)registryValueObject <= 0; } - public bool InitTheme(bool setDPI = true) + public bool InitTheme(bool setDPI = false) { bool newDarkTheme = CheckSystemDarkModeStatus(); bool changed = (darkTheme != newDarkTheme); diff --git a/app/GHelper.csproj b/app/GHelper.csproj index 695220a8..a4a29d1a 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ x64 False True - 0.41 + 0.42 diff --git a/app/NativeMethods.cs b/app/NativeMethods.cs index 0c4e7636..13c14858 100644 --- a/app/NativeMethods.cs +++ b/app/NativeMethods.cs @@ -674,6 +674,7 @@ public class NativeMethods PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + /* var hrDC = PowerWriteDCValueIndex( IntPtr.Zero, activeSchemeGuid, @@ -682,6 +683,7 @@ public class NativeMethods boost); PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + */ Logger.WriteLine("Boost " + boost); } diff --git a/app/Program.cs b/app/Program.cs index 310cfe01..11a1f362 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -103,13 +103,13 @@ namespace GHelper case UserPreferenceCategory.General: Debug.WriteLine("Theme Changed"); Thread.Sleep(1000); - settingsForm.InitTheme(false); + settingsForm.InitTheme(); if (settingsForm.fans is not null && settingsForm.fans.Text != "") - settingsForm.fans.InitTheme(false); + settingsForm.fans.InitTheme(); if (settingsForm.keyb is not null && settingsForm.keyb.Text != "") - settingsForm.keyb.InitTheme(false); + settingsForm.keyb.InitTheme(); break; } diff --git a/app/Settings.cs b/app/Settings.cs index d9d1aaef..891ef536 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -32,7 +32,7 @@ namespace GHelper public SettingsForm() { InitializeComponent(); - InitTheme(); + InitTheme(true); FormClosing += SettingsForm_FormClosing; diff --git a/app/Slider.cs b/app/Slider.cs index 532d8657..062e1e28 100644 --- a/app/Slider.cs +++ b/app/Slider.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using System.Drawing.Drawing2D; +using System.Drawing.Drawing2D; namespace WinFormsSliderBar { @@ -30,6 +29,7 @@ namespace WinFormsSliderBar private int _step = 5; public Color accentColor = Color.FromArgb(255, 58, 174, 239); + public Color borderColor = Color.White; public event EventHandler ValueChanged; @@ -85,7 +85,7 @@ namespace WinFormsSliderBar Brush brushAccent = new SolidBrush(accentColor); Brush brushEmpty = new SolidBrush(Color.Gray); - Brush brushBorder = new SolidBrush(Color.White); + Brush brushBorder = new SolidBrush(borderColor); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.FillRectangle(brushEmpty, @@ -105,11 +105,11 @@ namespace WinFormsSliderBar private void RecalculateParameters() { - _radius = 0.45F * ClientSize.Height; - _barSize = new SizeF(ClientSize.Width - 4 * _radius, ClientSize.Height*0.15F); + _radius = 0.4F * ClientSize.Height; + _barSize = new SizeF(ClientSize.Width - 4 * _radius, ClientSize.Height * 0.15F); _barPos = new PointF(_radius, (ClientSize.Height - _barSize.Height) / 2); _thumbPos = new PointF( - _barSize.Width / (Max - Min) * (Value-Min) + _barPos.X, + _barSize.Width / (Max - Min) * (Value - Min) + _barPos.X, _barPos.Y + 0.5f * _barSize.Height); Invalidate(); } @@ -145,7 +145,7 @@ namespace WinFormsSliderBar thumbX = _barPos.X + _barSize.Width; } Value = (int)Math.Round(Min + (thumbX - _barPos.X) * (Max - Min) / _barSize.Width); - + } protected override void OnMouseMove(MouseEventArgs e)