mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-18 23:07:15 -05:00
fix issues
This commit is contained in:
1 parent
8c186679cf
commit
fa013b056f
4 files changed
+45
-85
No files matched your search
@@ -36,6 +36,10 @@ namespace ColorControl.Forms
|
||||
|
||||
public class DarkModeProfessionalColors : ProfessionalColorTable
|
||||
{
|
||||
public override Color CheckBackground
|
||||
{ get { return FormUtils.DarkModeBackColor; } }
|
||||
public override Color CheckSelectedBackground
|
||||
{ get { return Color.FromArgb(16, 32, 49); } }
|
||||
public override Color MenuItemSelectedGradientBegin
|
||||
{ get { return Color.FromArgb(16, 32, 49); } }
|
||||
public override Color MenuItemSelectedGradientEnd
|
||||
@@ -67,45 +71,50 @@ namespace ColorControl.Forms
|
||||
|
||||
form.SuspendLayout();
|
||||
|
||||
//var settings = new UISettings();
|
||||
|
||||
//var foregroundColorValue = settings.GetColorValue(UIColorType.Foreground);
|
||||
//var backroundColorValue = settings.GetColorValue(UIColorType.Background);
|
||||
//var isDarkMode = FormUtils.IsColorLight(foregroundColorValue);
|
||||
|
||||
// Takes care of system context menu
|
||||
WinApi.SetPreferredAppMode(toDark ? 1 : 0);
|
||||
|
||||
var backColor = toDark ? FormUtils.DarkModeBackColor : SystemColors.Control;
|
||||
var foreColor = toDark ? FormUtils.DarkModeForeColor : SystemColors.ControlText;
|
||||
|
||||
FormUtils.CurrentBackColor = backColor;
|
||||
FormUtils.CurrentForeColor = foreColor;
|
||||
|
||||
SetControlTheme(form, backColor, foreColor);
|
||||
|
||||
var value = toDark ? 1 : 0;
|
||||
|
||||
// Takes care of title bar
|
||||
WinApi.DwmSetWindowAttribute(form.Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, 4);
|
||||
|
||||
if (toDark)
|
||||
try
|
||||
{
|
||||
_defaultRenderer ??= ToolStripManager.Renderer;
|
||||
//var settings = new UISettings();
|
||||
|
||||
ToolStripManager.Renderer = new DarkModeToolStripRenderer();
|
||||
//var foregroundColorValue = settings.GetColorValue(UIColorType.Foreground);
|
||||
//var backroundColorValue = settings.GetColorValue(UIColorType.Background);
|
||||
//var isDarkMode = FormUtils.IsColorLight(foregroundColorValue);
|
||||
|
||||
// Takes care of system context menu
|
||||
WinApi.SetPreferredAppMode(toDark ? 1 : 0);
|
||||
|
||||
var backColor = toDark ? FormUtils.DarkModeBackColor : SystemColors.Control;
|
||||
var foreColor = toDark ? FormUtils.DarkModeForeColor : SystemColors.ControlText;
|
||||
|
||||
FormUtils.CurrentBackColor = backColor;
|
||||
FormUtils.CurrentForeColor = foreColor;
|
||||
|
||||
SetControlTheme(form, backColor, foreColor);
|
||||
|
||||
var value = toDark ? 1 : 0;
|
||||
|
||||
// Takes care of title bar
|
||||
WinApi.DwmSetWindowAttribute(form.Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, 4);
|
||||
|
||||
if (toDark)
|
||||
{
|
||||
_defaultRenderer ??= ToolStripManager.Renderer;
|
||||
|
||||
ToolStripManager.Renderer = new DarkModeToolStripRenderer();
|
||||
}
|
||||
else if (_defaultRenderer != null)
|
||||
{
|
||||
ToolStripManager.Renderer = _defaultRenderer;
|
||||
}
|
||||
|
||||
FormUtils.MenuItemForeColor = foreColor;
|
||||
|
||||
WinApi.FlushMenuThemes();
|
||||
}
|
||||
else if (_defaultRenderer != null)
|
||||
finally
|
||||
{
|
||||
ToolStripManager.Renderer = _defaultRenderer;
|
||||
form.ResumeLayout();
|
||||
form.Refresh();
|
||||
}
|
||||
|
||||
FormUtils.MenuItemForeColor = foreColor;
|
||||
|
||||
WinApi.FlushMenuThemes();
|
||||
|
||||
form.ResumeLayout();
|
||||
form.Refresh();
|
||||
}
|
||||
|
||||
public static void SetControlTheme(Control control)
|
||||
|
||||
@@ -366,55 +366,6 @@ namespace ColorControl.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public static void ListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
|
||||
{
|
||||
//Fills one solid background for each cell.
|
||||
using (SolidBrush backBrush = new SolidBrush(CurrentBackColor))
|
||||
{
|
||||
e.Graphics.FillRectangle(backBrush, e.Bounds);
|
||||
}
|
||||
//Draw the borders for the header around each cell.
|
||||
using (Pen backBrush = new Pen(Color.DimGray))
|
||||
{
|
||||
e.Graphics.DrawRectangle(backBrush, e.Bounds);
|
||||
}
|
||||
using (SolidBrush foreBrush = new SolidBrush(CurrentForeColor))
|
||||
{
|
||||
//Since e.Header.TextAlign returns 'HorizontalAlignment' with values of (Right, Center, Left).
|
||||
//DrawString uses 'StringAlignment' with values of (Near, Center, Far).
|
||||
//We must translate these and setup a vertical alignment that doesn't exist in DrawListViewColumnHeaderEventArgs.
|
||||
StringFormat stringFormat = GetStringFormat(e.Header.TextAlign);
|
||||
|
||||
//Do some padding, since these draws right up next to the border for Left/Near. Will need to change this if you use Right/Far
|
||||
Rectangle rect = e.Bounds; rect.X += 2;
|
||||
e.Graphics.DrawString(e.Header.Text, e.Font, foreBrush, rect, stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private static StringFormat GetStringFormat(HorizontalAlignment ha)
|
||||
{
|
||||
StringAlignment align;
|
||||
|
||||
switch (ha)
|
||||
{
|
||||
case HorizontalAlignment.Right:
|
||||
align = StringAlignment.Far;
|
||||
break;
|
||||
case HorizontalAlignment.Center:
|
||||
align = StringAlignment.Center;
|
||||
break;
|
||||
default:
|
||||
align = StringAlignment.Near;
|
||||
break;
|
||||
}
|
||||
|
||||
return new StringFormat()
|
||||
{
|
||||
Alignment = align,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsForegroundFullScreenAndDisabledNotifications(Screen screen = null)
|
||||
{
|
||||
return IsNotificationDisabled() && IsForegroundFullScreen(screen);
|
||||
|
||||
@@ -689,7 +689,7 @@ NOTE: installing the service may cause a User Account Control popup.");
|
||||
|
||||
protected override void SetVisibleCore(bool value)
|
||||
{
|
||||
if (!_setVisibleCalled && _config.StartMinimized/* && !Debugger.IsAttached*/)
|
||||
if (!_setVisibleCalled && _config.StartMinimized && !Debugger.IsAttached)
|
||||
{
|
||||
_setVisibleCalled = true;
|
||||
if (_config.MinimizeToTray)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
|
||||
<Version>0.8.1.104</Version>
|
||||
<Version>0.8.1.105</Version>
|
||||
<Company>falahati.net</Company>
|
||||
<Description>NvAPIWrapper is a .Net wrapper for NVIDIA public API</Description>
|
||||
<Authors>Soroush Falahati</Authors>
|
||||
|
||||
Reference in new issue
Block a user