New slider

This commit is contained in:
seerge
2023-03-29 12:19:00 +02:00
parent 14dc1741f7
commit ec0a1b710e
7 changed files with 27 additions and 16 deletions

View File

@@ -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);
}
@@ -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)

View File

@@ -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);

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.41</AssemblyVersion>
<AssemblyVersion>0.42</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -32,7 +32,7 @@ namespace GHelper
public SettingsForm()
{
InitializeComponent();
InitTheme();
InitTheme(true);
FormClosing += SettingsForm_FormClosing;

View File

@@ -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();
}