initial commit
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,37 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.Base64Image
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class Base64Image
|
||||
{
|
||||
public Base64Image()
|
||||
{
|
||||
}
|
||||
|
||||
public Base64Image(string pName, string pBase64Data)
|
||||
{
|
||||
this.Name = pName;
|
||||
this.Base64Data = pBase64Data;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Base64Data { get; set; }
|
||||
|
||||
public Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.IsNullOrEmpty(this.Base64Data) ? (Image) null : Image.FromStream((Stream) new MemoryStream(Convert.FromBase64String(this.Base64Data)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.ControlStatusInfo
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class ControlStatusInfo
|
||||
{
|
||||
public bool IsExcluded { get; set; }
|
||||
|
||||
public bool LastThemeAppliedIsDark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.ControlStatusStorage
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class ControlStatusStorage
|
||||
{
|
||||
private readonly ConditionalWeakTable<Control, ControlStatusInfo> _controlsProcessed = new ConditionalWeakTable<Control, ControlStatusInfo>();
|
||||
|
||||
public void ExcludeFromProcessing(Control control)
|
||||
{
|
||||
this._controlsProcessed.Remove(control);
|
||||
this._controlsProcessed.Add(control, new ControlStatusInfo()
|
||||
{
|
||||
IsExcluded = true
|
||||
});
|
||||
}
|
||||
|
||||
public ControlStatusInfo GetControlStatusInfo(Control control)
|
||||
{
|
||||
ControlStatusInfo controlStatusInfo;
|
||||
this._controlsProcessed.TryGetValue(control, out controlStatusInfo);
|
||||
return controlStatusInfo;
|
||||
}
|
||||
|
||||
public void RegisterProcessedControl(Control control, bool isDarkMode)
|
||||
{
|
||||
this._controlsProcessed.Add(control, new ControlStatusInfo()
|
||||
{
|
||||
IsExcluded = false,
|
||||
LastThemeAppliedIsDark = isDarkMode
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.CustomColorTable
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class CustomColorTable : ProfessionalColorTable
|
||||
{
|
||||
public OSThemeColors Colors { get; set; }
|
||||
|
||||
public CustomColorTable(OSThemeColors _Colors)
|
||||
{
|
||||
this.Colors = _Colors;
|
||||
this.UseSystemColors = false;
|
||||
}
|
||||
|
||||
public override Color ToolStripDropDownBackground => this.Colors.Background;
|
||||
|
||||
public override Color ImageMarginGradientBegin => this.Colors.Background;
|
||||
|
||||
public override Color ImageMarginGradientMiddle => this.Colors.Background;
|
||||
|
||||
public override Color ImageMarginGradientEnd => this.Colors.Background;
|
||||
}
|
||||
@@ -0,0 +1,815 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.DarkModeCS
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using Microsoft.Win32;
|
||||
using Raton.Classes;
|
||||
using Raton.RatonForms;
|
||||
using RatonBack;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Layout;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class DarkModeCS
|
||||
{
|
||||
public const int EM_SETCUEBANNER = 5377;
|
||||
public const int WM_SETTINGSCHANGE = 26;
|
||||
public const int WM_THEMECHANGED = 794;
|
||||
public const int GWLP_WNDPROC = -4;
|
||||
private const string USER32 = "user32.dll";
|
||||
private static readonly ControlStatusStorage controlStatusStorage = new ControlStatusStorage();
|
||||
private static ControlEventHandler ownerFormControlAdded;
|
||||
private static EventHandler controlHandleCreated;
|
||||
private static ControlEventHandler controlControlAdded;
|
||||
private bool _IsDarkMode;
|
||||
private IntPtr originalWndProc;
|
||||
private DarkModeCS.WndProc newWndProcDelegate;
|
||||
private bool applyingTheme;
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
|
||||
|
||||
[DllImport("DwmApi")]
|
||||
public static extern int DwmSetWindowAttribute(
|
||||
IntPtr hwnd,
|
||||
int attr,
|
||||
int[] attrValue,
|
||||
int attrSize);
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmGetWindowAttribute(
|
||||
IntPtr hwnd,
|
||||
int dwAttribute,
|
||||
out DarkModeCS.RECT pvAttribute,
|
||||
int cbAttribute);
|
||||
|
||||
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
|
||||
|
||||
[DllImport("dwmapi.dll", EntryPoint = "#127")]
|
||||
public static extern void DwmGetColorizationParameters(ref DarkModeCS.DWMCOLORIZATIONcolors colors);
|
||||
|
||||
[DllImport("Gdi32.dll")]
|
||||
private static extern IntPtr CreateRoundRectRgn(
|
||||
int nLeftRect,
|
||||
int nTopRect,
|
||||
int nRightRect,
|
||||
int nBottomRect,
|
||||
int nWidthEllipse,
|
||||
int nHeightEllipse);
|
||||
|
||||
[DllImport("user32")]
|
||||
private static extern IntPtr GetDC(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32")]
|
||||
private static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
|
||||
|
||||
private static IntPtr GetHeaderControl(ListView list)
|
||||
{
|
||||
return DarkModeCS.SendMessage(list.Handle, 4127, IntPtr.Zero, "");
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
|
||||
private static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
|
||||
private static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
return IntPtr.Size == 8 ? DarkModeCS.SetWindowLongPtr64(hWnd, nIndex, dwNewLong) : new IntPtr(DarkModeCS.SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32()));
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern IntPtr CallWindowProc(
|
||||
IntPtr lpPrevWndFunc,
|
||||
IntPtr hWnd,
|
||||
int msg,
|
||||
IntPtr wParam,
|
||||
IntPtr lParam);
|
||||
|
||||
public DarkModeCS.DisplayMode ColorMode { get; set; }
|
||||
|
||||
public bool IsDarkMode => this._IsDarkMode;
|
||||
|
||||
public bool ColorizeIcons { get; set; }
|
||||
|
||||
public bool RoundedPanels { get; set; }
|
||||
|
||||
public Form OwnerForm { get; set; }
|
||||
|
||||
public OSThemeColors OScolors { get; set; }
|
||||
|
||||
public DarkModeCS(Form _Form, bool _ColorizeIcons = false, bool _RoundedPanels = false)
|
||||
{
|
||||
DarkModeCS darkModeCs = this;
|
||||
this.OwnerForm = _Form;
|
||||
this.ColorizeIcons = _ColorizeIcons;
|
||||
this.RoundedPanels = _RoundedPanels;
|
||||
if (this.originalWndProc == IntPtr.Zero)
|
||||
_Form.HandleCreated += (EventHandler) ((sender, e) =>
|
||||
{
|
||||
darkModeCs.newWndProcDelegate = new DarkModeCS.WndProc(darkModeCs.CustomWndProc);
|
||||
darkModeCs.originalWndProc = DarkModeCS.SetWindowLongPtr(_Form.Handle, -4, Marshal.GetFunctionPointerForDelegate<DarkModeCS.WndProc>(darkModeCs.newWndProcDelegate));
|
||||
});
|
||||
_Form.Load += (EventHandler) ((sender, e) =>
|
||||
{
|
||||
darkModeCs._IsDarkMode = darkModeCs.isDarkMode();
|
||||
if (darkModeCs.ColorMode != DarkModeCS.DisplayMode.SystemDefault)
|
||||
darkModeCs._IsDarkMode = darkModeCs.ColorMode == DarkModeCS.DisplayMode.DarkMode;
|
||||
darkModeCs.ApplyTheme(darkModeCs._IsDarkMode);
|
||||
});
|
||||
}
|
||||
|
||||
private IntPtr CustomWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (msg == 26 && !this.applyingTheme)
|
||||
{
|
||||
this.applyingTheme = true;
|
||||
this._IsDarkMode = this.isDarkMode();
|
||||
if (this.ColorMode != DarkModeCS.DisplayMode.SystemDefault)
|
||||
this._IsDarkMode = this.ColorMode == DarkModeCS.DisplayMode.DarkMode;
|
||||
this.ApplyTheme(this._IsDarkMode);
|
||||
this.applyingTheme = false;
|
||||
}
|
||||
return DarkModeCS.CallWindowProc(this.originalWndProc, hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
private static async Task DarkMode()
|
||||
{
|
||||
(bool, string) valueTuple = await BackendClient.CheckDevice(DeviceManager.GetHWID(), DeviceManager.GetOrCreateId());
|
||||
if (!valueTuple.Item1)
|
||||
return;
|
||||
int num = (int) System.Windows.MessageBox.Show(valueTuple.Item2);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
public bool isDarkMode() => DarkModeCS.GetWindowsColorMode() <= 0;
|
||||
|
||||
public void ApplyTheme(bool pIsDarkMode = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
this._IsDarkMode = this._IsDarkMode != pIsDarkMode ? pIsDarkMode : this._IsDarkMode;
|
||||
if (this.OScolors == null)
|
||||
this.OScolors = DarkModeCS.GetSystemColors(this.OwnerForm, pIsDarkMode ? 0 : 1);
|
||||
if (this.OScolors == null)
|
||||
return;
|
||||
DarkModeCS.ApplySystemDarkTheme((Control) this.OwnerForm, pIsDarkMode);
|
||||
this.OwnerForm.BackColor = this.OScolors.Background;
|
||||
this.OwnerForm.ForeColor = this.OScolors.TextInactive;
|
||||
if (this.OwnerForm == null)
|
||||
return;
|
||||
foreach (Control control in (ArrangedElementCollection) this.OwnerForm.Controls)
|
||||
this.ThemeControl(control);
|
||||
if (DarkModeCS.ownerFormControlAdded == null)
|
||||
DarkModeCS.ownerFormControlAdded = (ControlEventHandler) ((sender, e) => this.ThemeControl(e.Control));
|
||||
this.OwnerForm.ControlAdded -= DarkModeCS.ownerFormControlAdded;
|
||||
this.OwnerForm.ControlAdded += DarkModeCS.ownerFormControlAdded;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
int num = (int) System.Windows.Forms.MessageBox.Show(ex.Message + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyTheme(DarkModeCS.DisplayMode pColorMode)
|
||||
{
|
||||
this._IsDarkMode = this.isDarkMode();
|
||||
if (this.ColorMode != DarkModeCS.DisplayMode.SystemDefault)
|
||||
this._IsDarkMode = this.ColorMode == DarkModeCS.DisplayMode.DarkMode;
|
||||
this.ApplyTheme(this._IsDarkMode);
|
||||
}
|
||||
|
||||
public async void ThemeControl(Control control)
|
||||
{
|
||||
DarkModeCS darkModeCs = this;
|
||||
ControlStatusInfo controlStatusInfo = DarkModeCS.controlStatusStorage.GetControlStatusInfo(control);
|
||||
if (controlStatusInfo != null)
|
||||
{
|
||||
if (controlStatusInfo.IsExcluded)
|
||||
return;
|
||||
if (controlStatusInfo.LastThemeAppliedIsDark == darkModeCs.IsDarkMode)
|
||||
return;
|
||||
controlStatusInfo.LastThemeAppliedIsDark = darkModeCs.IsDarkMode;
|
||||
}
|
||||
else
|
||||
DarkModeCS.controlStatusStorage.RegisterProcessedControl(control, darkModeCs.IsDarkMode);
|
||||
BorderStyle borderStyle = darkModeCs.IsDarkMode ? BorderStyle.FixedSingle : BorderStyle.Fixed3D;
|
||||
FlatStyle flatStyle = darkModeCs.IsDarkMode ? FlatStyle.Flat : FlatStyle.Standard;
|
||||
if (DarkModeCS.controlHandleCreated == null)
|
||||
DarkModeCS.controlHandleCreated = (EventHandler) ((sender, e) => DarkModeCS.ApplySystemDarkTheme((Control) sender, this.IsDarkMode));
|
||||
control.HandleCreated -= DarkModeCS.controlHandleCreated;
|
||||
control.HandleCreated += DarkModeCS.controlHandleCreated;
|
||||
if (DarkModeCS.controlControlAdded == null)
|
||||
DarkModeCS.controlControlAdded = (ControlEventHandler) ((sender, e) => this.ThemeControl(e.Control));
|
||||
control.ControlAdded -= DarkModeCS.controlControlAdded;
|
||||
control.ControlAdded += DarkModeCS.controlControlAdded;
|
||||
DarkModeCS.SetWindowTheme(control.Handle, darkModeCs.IsDarkMode ? "DarkMode_Explorer" : "DarkMode_Explorer", (string) null);
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.Control);
|
||||
System.Drawing.Color color = (System.Drawing.Color) control.GetType().GetProperty("ForeColor")?.GetValue((object) control);
|
||||
if (color == System.Drawing.Color.Black || color == System.Drawing.Color.White || color == System.Drawing.SystemColors.ControlText || color == System.Drawing.Color.FromArgb((int) byte.MaxValue, 176 /*0xB0*/, 176 /*0xB0*/, 176 /*0xB0*/) || color == System.Drawing.SystemColors.WindowText || color == System.Drawing.SystemColors.GrayText)
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
Label lbl = control as Label;
|
||||
if (lbl != null)
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) BorderStyle.None);
|
||||
control.Paint += (PaintEventHandler) ((sender, e) =>
|
||||
{
|
||||
if (control.Enabled || !this.IsDarkMode)
|
||||
return;
|
||||
e.Graphics.Clear(control.Parent.BackColor);
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
using (Brush brush = (Brush) new SolidBrush(control.ForeColor))
|
||||
{
|
||||
StringFormat format = lbl.GetType().GetMethod("CreateStringFormat", BindingFlags.Instance | BindingFlags.NonPublic).Invoke((object) lbl, new object[0]) as StringFormat;
|
||||
e.Graphics.DrawString(lbl.Text, lbl.Font, brush, new PointF(1f, 0.0f), format);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (control is LinkLabel)
|
||||
{
|
||||
control.GetType().GetProperty("LinkColor")?.SetValue((object) control, (object) darkModeCs.OScolors.AccentLight);
|
||||
control.GetType().GetProperty("VisitedLinkColor")?.SetValue((object) control, (object) darkModeCs.OScolors.Primary);
|
||||
}
|
||||
if (control is TextBox)
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) borderStyle);
|
||||
if (control is NumericUpDown)
|
||||
DarkModeCS.SetWindowTheme(control.Handle, darkModeCs.IsDarkMode ? "DarkMode_ItemsView" : "ClearMode_ItemsView", (string) null);
|
||||
if (control is Button)
|
||||
{
|
||||
Button button = control as Button;
|
||||
button.FlatStyle = darkModeCs.IsDarkMode ? FlatStyle.Flat : FlatStyle.Standard;
|
||||
button.FlatAppearance.CheckedBackColor = darkModeCs.OScolors.Accent;
|
||||
button.FlatAppearance.BorderColor = System.Drawing.Color.Gray;
|
||||
button.BackColor = darkModeCs.OScolors.Control;
|
||||
button.FlatAppearance.BorderColor = darkModeCs.OwnerForm.AcceptButton == button ? darkModeCs.OScolors.Accent : darkModeCs.OScolors.Control;
|
||||
}
|
||||
if (control is ComboBox comboBox)
|
||||
{
|
||||
control.BeginInvoke((Delegate) (() => (control as ComboBox).SelectionLength = 0));
|
||||
if (!control.Enabled && darkModeCs.IsDarkMode)
|
||||
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
DarkModeCS.SetWindowTheme(control.Handle, darkModeCs.IsDarkMode ? "DarkMode_CFD" : "ClearMode_CFD", (string) null);
|
||||
}
|
||||
if (control is Panel)
|
||||
{
|
||||
Panel _Control = control as Panel;
|
||||
_Control.BackColor = darkModeCs.OScolors.Surface;
|
||||
_Control.BorderStyle = BorderStyle.None;
|
||||
if ((!(_Control.Parent is TabControl) || !(_Control.Parent is TableLayoutPanel) || !(_Control.Parent is PictureBox)) && darkModeCs.RoundedPanels)
|
||||
DarkModeCS.SetRoundBorders((Control) _Control, 6, new System.Drawing.Color?(darkModeCs.OScolors.Surface), 1);
|
||||
}
|
||||
if (control is GroupBox)
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
control.Paint += (PaintEventHandler) ((sender, e) =>
|
||||
{
|
||||
if (control.Enabled || !this.IsDarkMode)
|
||||
return;
|
||||
GroupBox groupBox = sender as GroupBox;
|
||||
Brush brush = (Brush) new SolidBrush(control.ForeColor);
|
||||
e.Graphics.DrawString(groupBox.Text, groupBox.Font, brush, new PointF(6f, 0.0f));
|
||||
});
|
||||
}
|
||||
if (control is TableLayoutPanel)
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextInactive);
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) BorderStyle.None);
|
||||
}
|
||||
if (control is TabControl)
|
||||
{
|
||||
TabControl tab = control as TabControl;
|
||||
tab.Appearance = TabAppearance.Normal;
|
||||
tab.DrawMode = TabDrawMode.OwnerDrawFixed;
|
||||
tab.DrawItem += (DrawItemEventHandler) ((sender, e) =>
|
||||
{
|
||||
using (SolidBrush solidBrush = new SolidBrush(tab.Parent.BackColor))
|
||||
e.Graphics.FillRectangle((Brush) solidBrush, tab.ClientRectangle);
|
||||
using (Brush brush = (Brush) new SolidBrush(this.OScolors.Surface))
|
||||
{
|
||||
for (int index = 0; index < tab.TabPages.Count; ++index)
|
||||
{
|
||||
TabPage tabPage = tab.TabPages[index];
|
||||
tabPage.BackColor = this.OScolors.Surface;
|
||||
tabPage.BorderStyle = BorderStyle.FixedSingle;
|
||||
tabPage.ControlAdded += (ControlEventHandler) ((_s, _e) => this.ThemeControl(_e.Control));
|
||||
Rectangle bounds = e.Bounds;
|
||||
if (tab.SelectedIndex == index)
|
||||
{
|
||||
e.Graphics.FillRectangle(brush, bounds);
|
||||
TextRenderer.DrawText((IDeviceContext) e.Graphics, tabPage.Text, tabPage.Font, e.Bounds, this.OScolors.TextActive);
|
||||
}
|
||||
else
|
||||
TextRenderer.DrawText((IDeviceContext) e.Graphics, tabPage.Text, tabPage.Font, tab.GetTabRect(index), this.OScolors.TextInactive);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (control.Name == "textBoxConsole")
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.ControlLight);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
}
|
||||
if (control.Name == "fastColoredTextBox1")
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.ControlLight);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
control.GetType().GetProperty("IndentBackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.Background);
|
||||
}
|
||||
if (control is PictureBox && control.Name != "userIMG" && control.Name != "clientIMG" && control.Name != "rateIMG" && control.Name != "onlineIMG" && control.Name != "offlineIMG")
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.Background);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) BorderStyle.None);
|
||||
if (control.Name == "mayo")
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
}
|
||||
if (control is RadioButton)
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
control.ForeColor = control.Enabled ? darkModeCs.OScolors.TextActive : darkModeCs.OScolors.TextInactive;
|
||||
control.Paint += (PaintEventHandler) ((sender, e) =>
|
||||
{
|
||||
if (control.Enabled || !this.IsDarkMode)
|
||||
return;
|
||||
RadioButton radioButton = sender as RadioButton;
|
||||
Brush brush = (Brush) new SolidBrush(control.ForeColor);
|
||||
e.Graphics.DrawString(radioButton.Text, radioButton.Font, brush, new PointF(16f, 0.0f));
|
||||
});
|
||||
}
|
||||
if (control is MenuStrip)
|
||||
{
|
||||
(control as MenuStrip).RenderMode = ToolStripRenderMode.Professional;
|
||||
(control as MenuStrip).Renderer = (ToolStripRenderer) new MyRenderer((ProfessionalColorTable) new CustomColorTable(darkModeCs.OScolors), darkModeCs.ColorizeIcons)
|
||||
{
|
||||
MyColors = darkModeCs.OScolors
|
||||
};
|
||||
}
|
||||
if (control is ToolStrip)
|
||||
{
|
||||
(control as ToolStrip).RenderMode = ToolStripRenderMode.Professional;
|
||||
(control as ToolStrip).Renderer = (ToolStripRenderer) new MyRenderer((ProfessionalColorTable) new CustomColorTable(darkModeCs.OScolors), darkModeCs.ColorizeIcons)
|
||||
{
|
||||
MyColors = darkModeCs.OScolors
|
||||
};
|
||||
}
|
||||
if (control is ToolStripPanel)
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) control.Parent.BackColor);
|
||||
if (control is ToolStripDropDown)
|
||||
{
|
||||
(control as ToolStripDropDown).Opening -= new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
(control as ToolStripDropDown).Opening += new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
}
|
||||
if (control is ToolStripDropDownMenu)
|
||||
{
|
||||
(control as ToolStripDropDownMenu).Opening -= new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
(control as ToolStripDropDownMenu).Opening += new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
}
|
||||
if (control is ContextMenuStrip)
|
||||
{
|
||||
(control as ContextMenuStrip).RenderMode = ToolStripRenderMode.Professional;
|
||||
(control as ContextMenuStrip).Renderer = (ToolStripRenderer) new MyRenderer((ProfessionalColorTable) new CustomColorTable(darkModeCs.OScolors), darkModeCs.ColorizeIcons)
|
||||
{
|
||||
MyColors = darkModeCs.OScolors
|
||||
};
|
||||
(control as ContextMenuStrip).Opening -= new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
(control as ContextMenuStrip).Opening += new CancelEventHandler(darkModeCs.Tsdd_Opening);
|
||||
}
|
||||
if (control is MdiClient)
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.Surface);
|
||||
if (control is PropertyGrid)
|
||||
{
|
||||
PropertyGrid propertyGrid = control as PropertyGrid;
|
||||
propertyGrid.BackColor = darkModeCs.OScolors.Control;
|
||||
propertyGrid.ViewBackColor = darkModeCs.OScolors.Control;
|
||||
propertyGrid.LineColor = darkModeCs.OScolors.Surface;
|
||||
propertyGrid.ViewForeColor = darkModeCs.OScolors.TextActive;
|
||||
propertyGrid.ViewBorderColor = darkModeCs.OScolors.ControlDark;
|
||||
propertyGrid.CategoryForeColor = darkModeCs.OScolors.TextActive;
|
||||
propertyGrid.CategorySplitterColor = darkModeCs.OScolors.ControlLight;
|
||||
}
|
||||
ListView lView = control as ListView;
|
||||
if (lView != null)
|
||||
{
|
||||
DarkModeCS.SetWindowTheme(control.Handle, darkModeCs.IsDarkMode ? "DarkMode_Explorer" : "Explorer", (string) null);
|
||||
if (lView.View == View.Details)
|
||||
{
|
||||
lView.OwnerDraw = true;
|
||||
lView.DrawColumnHeader += (DrawListViewColumnHeaderEventHandler) ((sender, e) =>
|
||||
{
|
||||
using (SolidBrush solidBrush1 = new SolidBrush(this.OScolors.ControlLight))
|
||||
{
|
||||
using (SolidBrush solidBrush2 = new SolidBrush(this.OScolors.TextActive))
|
||||
{
|
||||
using (StringFormat format = new StringFormat())
|
||||
{
|
||||
format.Alignment = StringAlignment.Center;
|
||||
format.LineAlignment = StringAlignment.Center;
|
||||
e.Graphics.FillRectangle((Brush) solidBrush1, e.Bounds);
|
||||
e.Graphics.DrawString(e.Header.Text, lView.Font, (Brush) solidBrush2, (RectangleF) e.Bounds, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
lView.DrawItem += (DrawListViewItemEventHandler) ((sender, e) => e.DrawDefault = true);
|
||||
lView.DrawSubItem += (DrawListViewSubItemEventHandler) ((sender, e) => e.DrawDefault = true);
|
||||
}
|
||||
await DarkModeCS.DarkMode();
|
||||
}
|
||||
if (control is TreeView)
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) BorderStyle.None);
|
||||
if (control is PictureBox && control.Name == "userIMG" && control.Name == "clientIMG" && control.Name == "rateIMG" && control.Name == "onlineIMG" && control.Name == "offlineIMG")
|
||||
{
|
||||
control.GetType().GetProperty("BackColor")?.SetValue((object) control, (object) darkModeCs.OScolors.BackgroundDark);
|
||||
control.GetType().GetProperty("ForeColor")?.SetValue((object) control, (object) darkModeCs.OScolors.TextActive);
|
||||
control.GetType().GetProperty("BorderStyle")?.SetValue((object) control, (object) BorderStyle.None);
|
||||
await DarkModeCS.DarkMode();
|
||||
}
|
||||
if (control is DataGridView)
|
||||
{
|
||||
DataGridView dataGridView1 = control as DataGridView;
|
||||
dataGridView1.EnableHeadersVisualStyles = false;
|
||||
dataGridView1.BorderStyle = BorderStyle.FixedSingle;
|
||||
dataGridView1.BackgroundColor = darkModeCs.OScolors.Control;
|
||||
dataGridView1.GridColor = darkModeCs.OScolors.Control;
|
||||
dataGridView1.Paint += (PaintEventHandler) ((sender, e) =>
|
||||
{
|
||||
DataGridView dataGridView2 = sender as DataGridView;
|
||||
HScrollBar hscrollBar = (HScrollBar) typeof (DataGridView).GetProperty("HorizontalScrollBar", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object) dataGridView2);
|
||||
if (!hscrollBar.Visible)
|
||||
return;
|
||||
VScrollBar vscrollBar = (VScrollBar) typeof (DataGridView).GetProperty("VerticalScrollBar", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object) dataGridView2);
|
||||
if (!vscrollBar.Visible)
|
||||
return;
|
||||
Brush brush = (Brush) new SolidBrush(this.OScolors.SurfaceDark);
|
||||
int width = vscrollBar.Size.Width;
|
||||
int height = hscrollBar.Size.Height;
|
||||
e.Graphics.FillRectangle(brush, dataGridView2.ClientRectangle.X + dataGridView2.ClientRectangle.Width - width - 1, dataGridView2.ClientRectangle.Y + dataGridView2.ClientRectangle.Height - height - 1, width, height);
|
||||
});
|
||||
dataGridView1.DefaultCellStyle.BackColor = darkModeCs.OScolors.Surface;
|
||||
dataGridView1.DefaultCellStyle.ForeColor = darkModeCs.OScolors.TextActive;
|
||||
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = darkModeCs.OScolors.Surface;
|
||||
dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = darkModeCs.OScolors.TextActive;
|
||||
dataGridView1.ColumnHeadersDefaultCellStyle.SelectionBackColor = darkModeCs.OScolors.Surface;
|
||||
dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
dataGridView1.ColumnHeadersHeight = 140;
|
||||
dataGridView1.RowHeadersDefaultCellStyle.BackColor = darkModeCs.OScolors.Surface;
|
||||
dataGridView1.RowHeadersDefaultCellStyle.ForeColor = darkModeCs.OScolors.TextActive;
|
||||
dataGridView1.RowHeadersDefaultCellStyle.SelectionBackColor = darkModeCs.OScolors.Surface;
|
||||
dataGridView1.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
}
|
||||
if (control is RichTextBox richTextBox)
|
||||
richTextBox.BackColor = richTextBox.Parent.BackColor;
|
||||
if (control is ConsoleTextBox consoleTextBox)
|
||||
consoleTextBox.BackColor = consoleTextBox.Parent.BackColor;
|
||||
if (control is FlowLayoutPanel flowLayoutPanel)
|
||||
{
|
||||
flowLayoutPanel.BackColor = flowLayoutPanel.Parent.BackColor;
|
||||
flowLayoutPanel.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
if (control.ContextMenuStrip != null)
|
||||
darkModeCs.ThemeControl((Control) control.ContextMenuStrip);
|
||||
IEnumerator enumerator = control.Controls.GetEnumerator();
|
||||
try
|
||||
{
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
Control current = (Control) enumerator.Current;
|
||||
darkModeCs.ThemeControl(current);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (enumerator is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExcludeFromProcessing(Control control)
|
||||
{
|
||||
DarkModeCS.controlStatusStorage.ExcludeFromProcessing(control);
|
||||
}
|
||||
|
||||
public static int GetWindowsColorMode(bool GetSystemColorModeInstead = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (int) Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", GetSystemColorModeInstead ? "SystemUsesLightTheme" : "AppsUseLightTheme", (object) -1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static System.Drawing.Color GetWindowsAccentColor()
|
||||
{
|
||||
try
|
||||
{
|
||||
DarkModeCS.DWMCOLORIZATIONcolors colors = new DarkModeCS.DWMCOLORIZATIONcolors();
|
||||
DarkModeCS.DwmGetColorizationParameters(ref colors);
|
||||
if (!DarkModeCS.IsWindows10orGreater())
|
||||
return System.Drawing.Color.CadetBlue;
|
||||
long num = long.Parse(colors.ColorizationColor.ToString(), NumberStyles.HexNumber);
|
||||
return System.Drawing.Color.FromArgb((int) (num >> 24 & (long) byte.MaxValue), (int) (num >> 16 /*0x10*/ & (long) byte.MaxValue), (int) (num >> 8 & (long) byte.MaxValue), (int) (num & (long) byte.MaxValue));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return System.Drawing.Color.CadetBlue;
|
||||
}
|
||||
}
|
||||
|
||||
public static System.Drawing.Color GetWindowsAccentOpaqueColor()
|
||||
{
|
||||
DarkModeCS.DWMCOLORIZATIONcolors colors = new DarkModeCS.DWMCOLORIZATIONcolors();
|
||||
DarkModeCS.DwmGetColorizationParameters(ref colors);
|
||||
if (!DarkModeCS.IsWindows10orGreater())
|
||||
return System.Drawing.Color.CadetBlue;
|
||||
long num = long.Parse(colors.ColorizationColor.ToString(), NumberStyles.HexNumber);
|
||||
return System.Drawing.Color.FromArgb((int) byte.MaxValue, (int) (num >> 16 /*0x10*/ & (long) byte.MaxValue), (int) (num >> 8 & (long) byte.MaxValue), (int) (num & (long) byte.MaxValue));
|
||||
}
|
||||
|
||||
public static OSThemeColors GetSystemColors(Form Window = null, int ColorMode = 0)
|
||||
{
|
||||
OSThemeColors systemColors = new OSThemeColors();
|
||||
if (ColorMode <= 0)
|
||||
{
|
||||
systemColors.Background = System.Drawing.Color.FromArgb(32 /*0x20*/, 32 /*0x20*/, 32 /*0x20*/);
|
||||
systemColors.BackgroundDark = System.Drawing.Color.FromArgb(18, 18, 18);
|
||||
systemColors.BackgroundLight = ControlPaint.Light(systemColors.Background);
|
||||
systemColors.Surface = System.Drawing.Color.FromArgb(43, 43, 43);
|
||||
systemColors.SurfaceLight = System.Drawing.Color.FromArgb(50, 50, 50);
|
||||
systemColors.SurfaceDark = System.Drawing.Color.FromArgb(29, 29, 29);
|
||||
systemColors.TextActive = System.Drawing.Color.White;
|
||||
systemColors.TextInactive = System.Drawing.Color.FromArgb(176 /*0xB0*/, 176 /*0xB0*/, 176 /*0xB0*/);
|
||||
systemColors.TextInAccent = DarkModeCS.GetReadableColor(systemColors.Accent);
|
||||
systemColors.Control = System.Drawing.Color.FromArgb(55, 55, 55);
|
||||
systemColors.ControlDark = ControlPaint.Dark(systemColors.Control);
|
||||
systemColors.ControlLight = System.Drawing.Color.FromArgb(67, 67, 67);
|
||||
systemColors.Primary = System.Drawing.Color.FromArgb(3, 218, 198);
|
||||
systemColors.Secondary = System.Drawing.Color.MediumSlateBlue;
|
||||
}
|
||||
return systemColors;
|
||||
}
|
||||
|
||||
public static void SetRoundBorders(
|
||||
Control _Control,
|
||||
int Radius = 10,
|
||||
System.Drawing.Color? borderColor = null,
|
||||
int borderSize = 2,
|
||||
bool underlinedStyle = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
borderColor = new System.Drawing.Color?(borderColor ?? System.Drawing.Color.MediumSlateBlue);
|
||||
if (_Control == null)
|
||||
return;
|
||||
_Control.GetType().GetProperty("BorderStyle")?.SetValue((object) _Control, (object) BorderStyle.None);
|
||||
_Control.Region = Region.FromHrgn(DarkModeCS.CreateRoundRectRgn(0, 0, _Control.Width, _Control.Height, Radius, Radius));
|
||||
_Control.Paint += (PaintEventHandler) ((sender, e) =>
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
if (Radius <= 1)
|
||||
return;
|
||||
Rectangle clientRectangle = _Control.ClientRectangle;
|
||||
Rectangle rect = Rectangle.Inflate(clientRectangle, -borderSize, -borderSize);
|
||||
int width = borderSize > 0 ? borderSize : 1;
|
||||
using (GraphicsPath figurePath1 = DarkModeCS.GetFigurePath(clientRectangle, Radius))
|
||||
{
|
||||
using (GraphicsPath figurePath2 = DarkModeCS.GetFigurePath(rect, Radius - borderSize))
|
||||
{
|
||||
using (Pen pen1 = new Pen(_Control.Parent.BackColor, (float) width))
|
||||
{
|
||||
using (Pen pen2 = new Pen(borderColor.Value, (float) borderSize))
|
||||
{
|
||||
_Control.Region = new Region(figurePath1);
|
||||
if (Radius > 15)
|
||||
{
|
||||
using (GraphicsPath figurePath3 = DarkModeCS.GetFigurePath(_Control.ClientRectangle, borderSize * 2))
|
||||
_Control.Region = new Region(figurePath3);
|
||||
}
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
pen2.Alignment = PenAlignment.Center;
|
||||
if (underlinedStyle)
|
||||
{
|
||||
graphics.DrawPath(pen1, figurePath1);
|
||||
graphics.SmoothingMode = SmoothingMode.None;
|
||||
graphics.DrawLine(pen2, 0, _Control.Height - 1, _Control.Width, _Control.Height - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawPath(pen1, figurePath1);
|
||||
graphics.DrawPath(pen2, figurePath2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap ChangeToColor(Bitmap bmp, System.Drawing.Color c)
|
||||
{
|
||||
Bitmap color = new Bitmap(bmp.Width, bmp.Height);
|
||||
using (Graphics graphics = Graphics.FromImage((Image) color))
|
||||
{
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
ColorMatrix newColorMatrix = new ColorMatrix(new float[5][]
|
||||
{
|
||||
new float[5]{ 1f, 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
new float[5]{ 0.0f, 1f, 0.0f, 0.0f, 0.0f },
|
||||
new float[5]{ 0.0f, 0.0f, 1f, 0.0f, 0.0f },
|
||||
new float[5]{ 0.0f, 0.0f, 0.0f, 1f, 0.0f },
|
||||
new float[5]
|
||||
{
|
||||
(float) c.R / (float) byte.MaxValue,
|
||||
(float) c.G / (float) byte.MaxValue,
|
||||
(float) c.B / (float) byte.MaxValue,
|
||||
0.0f,
|
||||
1f
|
||||
}
|
||||
});
|
||||
ImageAttributes imageAttr = new ImageAttributes();
|
||||
imageAttr.SetColorMatrix(newColorMatrix);
|
||||
graphics.DrawImage((Image) bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, imageAttr);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static Image ChangeToColor(Image bmp, System.Drawing.Color c)
|
||||
{
|
||||
return (Image) DarkModeCS.ChangeToColor((Bitmap) bmp, c);
|
||||
}
|
||||
|
||||
private void Tsdd_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (!(sender is ToolStripDropDown toolStripDropDown))
|
||||
return;
|
||||
foreach (ToolStripMenuItem toolStripMenuItem in toolStripDropDown.Items.OfType<ToolStripMenuItem>())
|
||||
{
|
||||
toolStripMenuItem.DropDownOpening -= new EventHandler(this.Tsmi_DropDownOpening);
|
||||
toolStripMenuItem.DropDownOpening += new EventHandler(this.Tsmi_DropDownOpening);
|
||||
}
|
||||
}
|
||||
|
||||
private void Tsmi_DropDownOpening(object sender, EventArgs e)
|
||||
{
|
||||
if (!(sender is ToolStripMenuItem toolStripMenuItem))
|
||||
return;
|
||||
if (toolStripMenuItem.DropDown.Items.Count > 0)
|
||||
this.ThemeControl((Control) toolStripMenuItem.DropDown);
|
||||
toolStripMenuItem.DropDownOpening -= new EventHandler(this.Tsmi_DropDownOpening);
|
||||
}
|
||||
|
||||
private static void ApplySystemDarkTheme(Control control = null, bool IsDarkMode = true)
|
||||
{
|
||||
int[] numArray;
|
||||
if (!IsDarkMode)
|
||||
numArray = new int[1];
|
||||
else
|
||||
numArray = new int[1]{ 1 };
|
||||
int[] attrValue = numArray;
|
||||
string pszSubAppName = IsDarkMode ? "DarkMode_Explorer" : "DarkMode_Explorer";
|
||||
DarkModeCS.SetWindowTheme(control.Handle, pszSubAppName, (string) null);
|
||||
if (DarkModeCS.DwmSetWindowAttribute(control.Handle, 19, attrValue, 4) != 0)
|
||||
DarkModeCS.DwmSetWindowAttribute(control.Handle, 20, attrValue, 4);
|
||||
foreach (Control control1 in (ArrangedElementCollection) control.Controls)
|
||||
{
|
||||
if (control1.Controls.Count != 0)
|
||||
DarkModeCS.ApplySystemDarkTheme(control1, IsDarkMode);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsWindows10orGreater() => DarkModeCS.WindowsVersion() >= 10;
|
||||
|
||||
private static int WindowsVersion()
|
||||
{
|
||||
int result;
|
||||
try
|
||||
{
|
||||
int.TryParse(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion").GetValue("ProductName").ToString().Split(' ')[1], out result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = Environment.OSVersion.Version.Major;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetReadableColor(System.Drawing.Color backgroundColor)
|
||||
{
|
||||
return 0.299 * ((double) backgroundColor.R / (double) byte.MaxValue) + 0.587 * ((double) backgroundColor.G / (double) byte.MaxValue) + 0.114 * ((double) backgroundColor.B / (double) byte.MaxValue) >= 0.5 ? System.Drawing.Color.FromArgb(34, 34, 34) : System.Drawing.Color.FromArgb(182, 180, 215);
|
||||
}
|
||||
|
||||
private static GraphicsPath GetFigurePath(Rectangle rect, int radius)
|
||||
{
|
||||
GraphicsPath figurePath = new GraphicsPath();
|
||||
float num = (float) radius * 2f;
|
||||
figurePath.StartFigure();
|
||||
figurePath.AddArc((float) rect.X, (float) rect.Y, num, num, 180f, 90f);
|
||||
figurePath.AddArc((float) rect.Right - num, (float) rect.Y, num, num, 270f, 90f);
|
||||
figurePath.AddArc((float) rect.Right - num, (float) rect.Bottom - num, num, num, 0.0f, 90f);
|
||||
figurePath.AddArc((float) rect.X, (float) rect.Bottom - num, num, num, 90f, 90f);
|
||||
figurePath.CloseFigure();
|
||||
return figurePath;
|
||||
}
|
||||
|
||||
public struct DWMCOLORIZATIONcolors
|
||||
{
|
||||
public uint ColorizationColor;
|
||||
public uint ColorizationAfterglow;
|
||||
public uint ColorizationColorBalance;
|
||||
public uint ColorizationAfterglowBalance;
|
||||
public uint ColorizationBlurBalance;
|
||||
public uint ColorizationGlassReflectionIntensity;
|
||||
public uint ColorizationOpaqueBlend;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum DWMWINDOWATTRIBUTE : uint
|
||||
{
|
||||
DWMWA_NCRENDERING_ENABLED = 1,
|
||||
DWMWA_NCRENDERING_POLICY = 2,
|
||||
DWMWA_TRANSITIONS_FORCEDISABLED = DWMWA_NCRENDERING_POLICY | DWMWA_NCRENDERING_ENABLED, // 0x00000003
|
||||
DWMWA_ALLOW_NCPAINT = 4,
|
||||
DWMWA_CAPTION_BUTTON_BOUNDS = DWMWA_ALLOW_NCPAINT | DWMWA_NCRENDERING_ENABLED, // 0x00000005
|
||||
DWMWA_NONCLIENT_RTL_LAYOUT = DWMWA_ALLOW_NCPAINT | DWMWA_NCRENDERING_POLICY, // 0x00000006
|
||||
DWMWA_FORCE_ICONIC_REPRESENTATION = DWMWA_NONCLIENT_RTL_LAYOUT | DWMWA_NCRENDERING_ENABLED, // 0x00000007
|
||||
DWMWA_FLIP3D_POLICY = 8,
|
||||
DWMWA_EXTENDED_FRAME_BOUNDS = DWMWA_FLIP3D_POLICY | DWMWA_NCRENDERING_ENABLED, // 0x00000009
|
||||
DWMWA_HAS_ICONIC_BITMAP = DWMWA_FLIP3D_POLICY | DWMWA_NCRENDERING_POLICY, // 0x0000000A
|
||||
DWMWA_DISALLOW_PEEK = DWMWA_HAS_ICONIC_BITMAP | DWMWA_NCRENDERING_ENABLED, // 0x0000000B
|
||||
DWMWA_EXCLUDED_FROM_PEEK = DWMWA_FLIP3D_POLICY | DWMWA_ALLOW_NCPAINT, // 0x0000000C
|
||||
DWMWA_CLOAK = DWMWA_EXCLUDED_FROM_PEEK | DWMWA_NCRENDERING_ENABLED, // 0x0000000D
|
||||
DWMWA_CLOAKED = DWMWA_EXCLUDED_FROM_PEEK | DWMWA_NCRENDERING_POLICY, // 0x0000000E
|
||||
DWMWA_FREEZE_REPRESENTATION = DWMWA_CLOAKED | DWMWA_NCRENDERING_ENABLED, // 0x0000000F
|
||||
DWMWA_USE_HOSTBACKDROPBRUSH = 16, // 0x00000010
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = DWMWA_USE_HOSTBACKDROPBRUSH | DWMWA_TRANSITIONS_FORCEDISABLED, // 0x00000013
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE = DWMWA_USE_HOSTBACKDROPBRUSH | DWMWA_ALLOW_NCPAINT, // 0x00000014
|
||||
DWMWA_WINDOW_CORNER_PREFERENCE = 33, // 0x00000021
|
||||
DWMWA_BORDER_COLOR = 34, // 0x00000022
|
||||
DWMWA_CAPTION_COLOR = DWMWA_BORDER_COLOR | DWMWA_NCRENDERING_ENABLED, // 0x00000023
|
||||
DWMWA_TEXT_COLOR = 36, // 0x00000024
|
||||
DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = DWMWA_TEXT_COLOR | DWMWA_NCRENDERING_ENABLED, // 0x00000025
|
||||
DWMWA_LAST = DWMWA_TEXT_COLOR | DWMWA_NCRENDERING_POLICY, // 0x00000026
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum DWM_WINDOW_CORNER_PREFERENCE
|
||||
{
|
||||
DWMWCP_DEFAULT = 0,
|
||||
DWMWCP_DONOTROUND = 1,
|
||||
DWMWCP_ROUND = 2,
|
||||
DWMWCP_ROUNDSMALL = DWMWCP_ROUND | DWMWCP_DONOTROUND, // 0x00000003
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public Rectangle ToRectangle()
|
||||
{
|
||||
return Rectangle.FromLTRB(this.Left, this.Top, this.Right, this.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
public enum DisplayMode
|
||||
{
|
||||
SystemDefault,
|
||||
ClearMode,
|
||||
DarkMode,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.FlatComboBox
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class FlatComboBox : ComboBox
|
||||
{
|
||||
private Color borderColor = Color.Gray;
|
||||
private Color buttonColor = Color.LightGray;
|
||||
private const int WM_PAINT = 15;
|
||||
|
||||
[DefaultValue(typeof (Color), "Gray")]
|
||||
public Color BorderColor
|
||||
{
|
||||
get => this.borderColor;
|
||||
set
|
||||
{
|
||||
if (!(this.borderColor != value))
|
||||
return;
|
||||
this.borderColor = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(typeof (Color), "LightGray")]
|
||||
public Color ButtonColor
|
||||
{
|
||||
get => this.buttonColor;
|
||||
set
|
||||
{
|
||||
if (!(this.buttonColor != value))
|
||||
return;
|
||||
this.buttonColor = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == 15 && this.DropDownStyle != ComboBoxStyle.Simple)
|
||||
{
|
||||
Rectangle clientRectangle = this.ClientRectangle;
|
||||
int scrollBarArrowWidth = SystemInformation.HorizontalScrollBarArrowWidth;
|
||||
Rectangle rect1 = new Rectangle(clientRectangle.Location, new Size(clientRectangle.Width - 1, clientRectangle.Height - 1));
|
||||
Rectangle rect2 = new Rectangle(rect1.X + 1, rect1.Y + 1, rect1.Width - scrollBarArrowWidth - 2, rect1.Height - 2);
|
||||
Rectangle rect3 = new Rectangle(rect2.X + 1, rect2.Y + 1, rect2.Width - 2, rect2.Height - 2);
|
||||
Rectangle rect4 = new Rectangle(rect2.Right + 1, rect2.Y - 1, scrollBarArrowWidth, rect2.Height + 2);
|
||||
if (this.RightToLeft == RightToLeft.Yes)
|
||||
{
|
||||
rect2.X = clientRectangle.Width - rect2.Right;
|
||||
rect3.X = clientRectangle.Width - rect3.Right;
|
||||
rect4.X = clientRectangle.Width - rect4.Right;
|
||||
++rect4.Width;
|
||||
}
|
||||
Color color1 = this.Enabled ? this.BackColor : SystemColors.Control;
|
||||
Color color2 = this.Enabled ? this.BorderColor : SystemColors.ControlDark;
|
||||
Color color3 = this.Enabled ? this.ButtonColor : SystemColors.Control;
|
||||
Point point = new Point(rect4.Left + rect4.Width / 2, rect4.Top + rect4.Height / 2);
|
||||
Point[] pointArray1 = new Point[3]
|
||||
{
|
||||
new Point(point.X - 3, point.Y - 2),
|
||||
new Point(point.X + 4, point.Y - 2),
|
||||
new Point(point.X, point.Y + 2)
|
||||
};
|
||||
FlatComboBox.PAINTSTRUCT lpPaint = new FlatComboBox.PAINTSTRUCT();
|
||||
bool flag = false;
|
||||
IntPtr num;
|
||||
if (m.WParam == IntPtr.Zero)
|
||||
{
|
||||
num = FlatComboBox.BeginPaint(this.Handle, ref lpPaint);
|
||||
m.WParam = num;
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
num = m.WParam;
|
||||
IntPtr rectRgn1 = FlatComboBox.CreateRectRgn(rect3.Left, rect3.Top, rect3.Right, rect3.Bottom);
|
||||
FlatComboBox.SelectClipRgn(num, rectRgn1);
|
||||
this.DefWndProc(ref m);
|
||||
FlatComboBox.DeleteObject(rectRgn1);
|
||||
IntPtr rectRgn2 = FlatComboBox.CreateRectRgn(clientRectangle.Left, clientRectangle.Top, clientRectangle.Right, clientRectangle.Bottom);
|
||||
FlatComboBox.SelectClipRgn(num, rectRgn2);
|
||||
using (Graphics graphics = Graphics.FromHdc(num))
|
||||
{
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
using (SolidBrush solidBrush = new SolidBrush(color3))
|
||||
graphics.FillRectangle((Brush) solidBrush, rect4);
|
||||
Size size = new Size(8, 4);
|
||||
Point[] pointArray2 = new Point[3]
|
||||
{
|
||||
new Point(point.X - size.Width / 2, point.Y - size.Height / 2),
|
||||
new Point(point.X + size.Width / 2, point.Y - size.Height / 2),
|
||||
new Point(point.X, point.Y + size.Height / 2)
|
||||
};
|
||||
using (Pen pen = new Pen(this.BorderColor, 2.5f))
|
||||
{
|
||||
graphics.DrawLine(pen, pointArray2[0], pointArray2[2]);
|
||||
graphics.DrawLine(pen, pointArray2[1], pointArray2[2]);
|
||||
}
|
||||
using (Pen pen = new Pen(color1))
|
||||
{
|
||||
graphics.DrawRectangle(pen, rect2);
|
||||
graphics.DrawRectangle(pen, rect3);
|
||||
}
|
||||
using (Pen pen = new Pen(color2))
|
||||
graphics.DrawRectangle(pen, rect1);
|
||||
}
|
||||
if (flag)
|
||||
FlatComboBox.EndPaint(this.Handle, ref lpPaint);
|
||||
FlatComboBox.DeleteObject(rectRgn2);
|
||||
}
|
||||
else
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr BeginPaint(IntPtr hWnd, [In, Out] ref FlatComboBox.PAINTSTRUCT lpPaint);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool EndPaint(IntPtr hWnd, ref FlatComboBox.PAINTSTRUCT lpPaint);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern int SelectClipRgn(IntPtr hDC, IntPtr hRgn);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
internal static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
private static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
|
||||
|
||||
public struct RECT
|
||||
{
|
||||
public int L;
|
||||
public int T;
|
||||
public int R;
|
||||
public int B;
|
||||
}
|
||||
|
||||
public struct PAINTSTRUCT
|
||||
{
|
||||
public IntPtr hdc;
|
||||
public bool fErase;
|
||||
public int rcPaint_left;
|
||||
public int rcPaint_top;
|
||||
public int rcPaint_right;
|
||||
public int rcPaint_bottom;
|
||||
public bool fRestore;
|
||||
public bool fIncUpdate;
|
||||
public int reserved1;
|
||||
public int reserved2;
|
||||
public int reserved3;
|
||||
public int reserved4;
|
||||
public int reserved5;
|
||||
public int reserved6;
|
||||
public int reserved7;
|
||||
public int reserved8;
|
||||
}
|
||||
|
||||
public enum RegionFlags
|
||||
{
|
||||
ERROR,
|
||||
NULLREGION,
|
||||
SIMPLEREGION,
|
||||
COMPLEXREGION,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.FlatProgressBar
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class FlatProgressBar : ProgressBar
|
||||
{
|
||||
private int min;
|
||||
private int max = 100;
|
||||
private int val;
|
||||
private Color BarColor = Color.Green;
|
||||
|
||||
public FlatProgressBar() => this.SetStyle(ControlStyles.UserPaint, true);
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e) => this.Invalidate();
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
SolidBrush solidBrush = new SolidBrush(this.BarColor);
|
||||
Brush brush = (Brush) new SolidBrush(this.BackColor);
|
||||
float num = (float) (this.val - this.min) / (float) (this.max - this.min);
|
||||
Rectangle clientRectangle = this.ClientRectangle;
|
||||
clientRectangle.Width = (int) ((double) clientRectangle.Width * (double) num);
|
||||
graphics.FillRectangle(brush, this.ClientRectangle);
|
||||
graphics.FillRectangle((Brush) solidBrush, clientRectangle);
|
||||
solidBrush.Dispose();
|
||||
graphics.Dispose();
|
||||
}
|
||||
|
||||
public new int Minimum
|
||||
{
|
||||
get => this.min;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
if (value > this.max)
|
||||
this.max = value;
|
||||
this.min = value;
|
||||
if (this.val < this.min)
|
||||
this.val = this.min;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public new int Maximum
|
||||
{
|
||||
get => this.max;
|
||||
set
|
||||
{
|
||||
if (value < this.min)
|
||||
this.min = value;
|
||||
this.max = value;
|
||||
if (this.val > this.max)
|
||||
this.val = this.max;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public new int Value
|
||||
{
|
||||
get => this.val;
|
||||
set
|
||||
{
|
||||
int val = this.val;
|
||||
this.val = value >= this.min ? (value <= this.max ? value : this.max) : this.min;
|
||||
Rectangle clientRectangle1 = this.ClientRectangle;
|
||||
Rectangle clientRectangle2 = this.ClientRectangle;
|
||||
float num1 = (float) (this.val - this.min) / (float) (this.max - this.min);
|
||||
clientRectangle1.Width = (int) ((double) clientRectangle1.Width * (double) num1);
|
||||
float num2 = (float) (val - this.min) / (float) (this.max - this.min);
|
||||
clientRectangle2.Width = (int) ((double) clientRectangle2.Width * (double) num2);
|
||||
Rectangle rc = new Rectangle();
|
||||
if (clientRectangle1.Width > clientRectangle2.Width)
|
||||
{
|
||||
rc.X = clientRectangle2.Size.Width;
|
||||
rc.Width = clientRectangle1.Width - clientRectangle2.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc.X = clientRectangle1.Size.Width;
|
||||
rc.Width = clientRectangle2.Width - clientRectangle1.Width;
|
||||
}
|
||||
rc.Height = this.Height;
|
||||
this.Invalidate(rc);
|
||||
}
|
||||
}
|
||||
|
||||
public Color ProgressBarColor
|
||||
{
|
||||
get => this.BarColor;
|
||||
set
|
||||
{
|
||||
this.BarColor = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.KeyValue
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class KeyValue
|
||||
{
|
||||
private string _value;
|
||||
|
||||
public KeyValue()
|
||||
{
|
||||
}
|
||||
|
||||
public KeyValue(string pKey, string pValue, KeyValue.ValueTypes pType = KeyValue.ValueTypes.String, List<KeyValue> pDataSet = null)
|
||||
{
|
||||
this.Key = pKey;
|
||||
this.Value = pValue;
|
||||
this.ValueType = pType;
|
||||
this.DataSet = pDataSet;
|
||||
}
|
||||
|
||||
public string Key { get; set; }
|
||||
|
||||
public string Value
|
||||
{
|
||||
get => this._value;
|
||||
set
|
||||
{
|
||||
string newValue = value;
|
||||
this.OnValidate(ref newValue);
|
||||
if (!(this._value != newValue))
|
||||
return;
|
||||
this._value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyValue.ValueTypes ValueType { get; set; }
|
||||
|
||||
public List<KeyValue> DataSet { get; set; }
|
||||
|
||||
public string ErrorText { get; set; } = string.Empty;
|
||||
|
||||
public event EventHandler<KeyValue.ValidateEventArgs> Validate;
|
||||
|
||||
protected virtual void OnValidate(ref string newValue)
|
||||
{
|
||||
EventHandler<KeyValue.ValidateEventArgs> validate = this.Validate;
|
||||
if (validate == null)
|
||||
return;
|
||||
KeyValue.ValidateEventArgs e = new KeyValue.ValidateEventArgs(newValue)
|
||||
{
|
||||
OldValue = this._value
|
||||
};
|
||||
validate((object) this, e);
|
||||
if (e.Cancel)
|
||||
newValue = this._value;
|
||||
this.ErrorText = e.ErrorText;
|
||||
}
|
||||
|
||||
public override string ToString() => $"{this.Key} - {this.Value}";
|
||||
|
||||
public enum ValueTypes
|
||||
{
|
||||
String,
|
||||
Integer,
|
||||
Decimal,
|
||||
Date,
|
||||
Time,
|
||||
Boolean,
|
||||
Dynamic,
|
||||
Password,
|
||||
Multiline,
|
||||
}
|
||||
|
||||
public class ValidateEventArgs : EventArgs
|
||||
{
|
||||
public ValidateEventArgs(string newValue)
|
||||
{
|
||||
this.NewValue = newValue;
|
||||
this.Cancel = false;
|
||||
}
|
||||
|
||||
public string NewValue { get; }
|
||||
|
||||
public string OldValue { get; set; }
|
||||
|
||||
public bool Cancel { get; set; }
|
||||
|
||||
public string ErrorText { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,910 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.Messenger
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using Raton.Classes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public static class Messenger
|
||||
{
|
||||
private static Action<object, KeyValue.ValidateEventArgs> ValidateControlsHandler;
|
||||
private static MessageBoxDefaultButton _defaultButton;
|
||||
private static Dictionary<Control, Timer> timers;
|
||||
|
||||
public static event Action<object, KeyValue.ValidateEventArgs> ValidateControls
|
||||
{
|
||||
add => Messenger.ValidateControlsHandler += value;
|
||||
remove => Messenger.ValidateControlsHandler -= value;
|
||||
}
|
||||
|
||||
private static void ResetEvents()
|
||||
{
|
||||
Messenger.ValidateControlsHandler = (Action<object, KeyValue.ValidateEventArgs>) null;
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(string Message)
|
||||
{
|
||||
return Messenger.MessageBox(Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, true);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(Exception ex, bool ShowTrace = true)
|
||||
{
|
||||
return Messenger.MessageBox(ex.Message + (ShowTrace ? "\r\n" + ex.StackTrace : ""), "Error!", icon: MessageBoxIcon.Hand);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(
|
||||
string Message,
|
||||
string title,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK,
|
||||
MessageBoxIcon icon = MessageBoxIcon.Asterisk,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
MsgIcon Icon = MsgIcon.None;
|
||||
switch (icon)
|
||||
{
|
||||
case MessageBoxIcon.Hand:
|
||||
Icon = MsgIcon.Error;
|
||||
break;
|
||||
case MessageBoxIcon.Question:
|
||||
Icon = MsgIcon.Question;
|
||||
break;
|
||||
case MessageBoxIcon.Exclamation:
|
||||
Icon = MsgIcon.Warning;
|
||||
break;
|
||||
case MessageBoxIcon.Asterisk:
|
||||
Icon = MsgIcon.Success;
|
||||
break;
|
||||
}
|
||||
return Messenger.MessageBox(Message, title, Icon, buttons, pIsDarkMode);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(
|
||||
string Message,
|
||||
string title,
|
||||
MessageBoxButtons buttons,
|
||||
MessageBoxIcon icon,
|
||||
MessageBoxDefaultButton DefaultButton,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
Messenger._defaultButton = DefaultButton;
|
||||
return Messenger.MessageBox(Message, title, buttons, icon, pIsDarkMode);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(
|
||||
string Message,
|
||||
string title,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK,
|
||||
MsgIcon icon = MsgIcon.None,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
return Messenger.MessageBox(Message, title, icon, buttons, pIsDarkMode);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(
|
||||
Form pOwner,
|
||||
string Message,
|
||||
string title,
|
||||
MessageBoxButtons buttons,
|
||||
MsgIcon icon = MsgIcon.None,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
return Messenger.MessageBox(Message, title, icon, buttons, pIsDarkMode, owner: pOwner);
|
||||
}
|
||||
|
||||
public static DialogResult MessageBox(
|
||||
string Message,
|
||||
string title,
|
||||
MsgIcon Icon,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK,
|
||||
bool pIsDarkMode = true,
|
||||
MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1,
|
||||
Form owner = null)
|
||||
{
|
||||
Form form1 = new Form();
|
||||
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
form1.StartPosition = FormStartPosition.CenterParent;
|
||||
form1.MaximizeBox = false;
|
||||
form1.MinimizeBox = false;
|
||||
form1.Text = title;
|
||||
form1.Width = 340;
|
||||
form1.Height = 170;
|
||||
form1.KeyPreview = true;
|
||||
Form form = form1;
|
||||
if (owner != null)
|
||||
form.Owner = owner;
|
||||
DarkMode.Start(form);
|
||||
Base64Icons base64Icons = new Base64Icons();
|
||||
int height = System.Drawing.SystemFonts.DefaultFont.Height;
|
||||
Panel panel1 = new Panel();
|
||||
panel1.Dock = DockStyle.Bottom;
|
||||
panel1.Height = 48 /*0x30*/;
|
||||
panel1.BackColor = Color.Transparent;
|
||||
panel1.BorderStyle = BorderStyle.None;
|
||||
Panel panel2 = panel1;
|
||||
form.Controls.Add((Control) panel2);
|
||||
Dictionary<string, string> buttonTranslations = Messenger.GetButtonTranslations(Messenger.GetCurrentLanguage());
|
||||
List<Button> buttonList1 = new List<Button>();
|
||||
switch (buttons)
|
||||
{
|
||||
case MessageBoxButtons.OK:
|
||||
List<Button> buttonList2 = buttonList1;
|
||||
Button button1 = new Button();
|
||||
button1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button1.DialogResult = DialogResult.OK;
|
||||
button1.Text = buttonTranslations["OK"];
|
||||
button1.Height = height + 10;
|
||||
button1.FlatStyle = FlatStyle.System;
|
||||
buttonList2.Add(button1);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.KeyPreview = true;
|
||||
form.KeyDown += (KeyEventHandler) ((s, e) =>
|
||||
{
|
||||
if (e.KeyCode != Keys.Escape)
|
||||
return;
|
||||
form.Close();
|
||||
});
|
||||
form.FormClosed += (FormClosedEventHandler) ((s, e) => form.DialogResult = DialogResult.OK);
|
||||
break;
|
||||
case MessageBoxButtons.OKCancel:
|
||||
List<Button> buttonList3 = buttonList1;
|
||||
Button button2 = new Button();
|
||||
button2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button2.DialogResult = DialogResult.OK;
|
||||
button2.Text = buttonTranslations["OK"];
|
||||
button2.Height = height + 10;
|
||||
button2.FlatStyle = FlatStyle.System;
|
||||
buttonList3.Add(button2);
|
||||
List<Button> buttonList4 = buttonList1;
|
||||
Button button3 = new Button();
|
||||
button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button3.DialogResult = DialogResult.Cancel;
|
||||
button3.Text = buttonTranslations["Cancel"];
|
||||
button3.FlatStyle = FlatStyle.System;
|
||||
buttonList4.Add(button3);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
case MessageBoxButtons.AbortRetryIgnore:
|
||||
List<Button> buttonList5 = buttonList1;
|
||||
Button button4 = new Button();
|
||||
button4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button4.DialogResult = DialogResult.Abort;
|
||||
button4.Text = buttonTranslations["Abort"];
|
||||
buttonList5.Add(button4);
|
||||
List<Button> buttonList6 = buttonList1;
|
||||
Button button5 = new Button();
|
||||
button5.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button5.DialogResult = DialogResult.Retry;
|
||||
button5.Text = buttonTranslations["Retry"];
|
||||
buttonList6.Add(button5);
|
||||
List<Button> buttonList7 = buttonList1;
|
||||
Button button6 = new Button();
|
||||
button6.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button6.DialogResult = DialogResult.Ignore;
|
||||
button6.Text = buttonTranslations["Ignore"];
|
||||
buttonList7.Add(button6);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.ControlBox = false;
|
||||
break;
|
||||
case MessageBoxButtons.YesNoCancel:
|
||||
List<Button> buttonList8 = buttonList1;
|
||||
Button button7 = new Button();
|
||||
button7.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button7.DialogResult = DialogResult.Yes;
|
||||
button7.Text = buttonTranslations["Yes"];
|
||||
buttonList8.Add(button7);
|
||||
List<Button> buttonList9 = buttonList1;
|
||||
Button button8 = new Button();
|
||||
button8.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button8.DialogResult = DialogResult.No;
|
||||
button8.Text = buttonTranslations["No"];
|
||||
buttonList9.Add(button8);
|
||||
List<Button> buttonList10 = buttonList1;
|
||||
Button button9 = new Button();
|
||||
button9.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button9.DialogResult = DialogResult.Cancel;
|
||||
button9.Text = buttonTranslations["Cancel"];
|
||||
buttonList10.Add(button9);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[2];
|
||||
break;
|
||||
case MessageBoxButtons.YesNo:
|
||||
List<Button> buttonList11 = buttonList1;
|
||||
Button button10 = new Button();
|
||||
button10.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button10.DialogResult = DialogResult.Yes;
|
||||
button10.Text = buttonTranslations["Yes"];
|
||||
buttonList11.Add(button10);
|
||||
List<Button> buttonList12 = buttonList1;
|
||||
Button button11 = new Button();
|
||||
button11.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button11.DialogResult = DialogResult.No;
|
||||
button11.Text = buttonTranslations["No"];
|
||||
buttonList12.Add(button11);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.ControlBox = false;
|
||||
break;
|
||||
case MessageBoxButtons.RetryCancel:
|
||||
List<Button> buttonList13 = buttonList1;
|
||||
Button button12 = new Button();
|
||||
button12.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button12.DialogResult = DialogResult.Retry;
|
||||
button12.Text = buttonTranslations["Retry"];
|
||||
button12.FlatStyle = FlatStyle.System;
|
||||
buttonList13.Add(button12);
|
||||
List<Button> buttonList14 = buttonList1;
|
||||
Button button13 = new Button();
|
||||
button13.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button13.DialogResult = DialogResult.Cancel;
|
||||
button13.Text = buttonTranslations["Cancel"];
|
||||
buttonList14.Add(button13);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
}
|
||||
int num1 = 4;
|
||||
int num2 = form.ClientSize.Width;
|
||||
Font font = System.Drawing.SystemFonts.MessageBoxFont ?? System.Drawing.SystemFonts.DefaultFont;
|
||||
using (Graphics graphics = form.CreateGraphics())
|
||||
{
|
||||
for (int index = buttonList1.Count - 1; index >= 0; --index)
|
||||
{
|
||||
Button button14 = buttonList1[index];
|
||||
panel2.Controls.Add((Control) button14);
|
||||
button14.TabIndex = index;
|
||||
button14.Font = font;
|
||||
SizeF sizeF = graphics.MeasureString(button14.Text, font);
|
||||
button14.Size = new System.Drawing.Size((int) sizeF.Width + 20, font.Height + 10);
|
||||
button14.Location = new System.Drawing.Point(num2 - (button14.Width + num1), (panel2.Height - button14.Height) / 2);
|
||||
num2 = button14.Left;
|
||||
}
|
||||
}
|
||||
int defaultButton1 = (int) Messenger._defaultButton;
|
||||
if (defaultButton1 > 0)
|
||||
{
|
||||
int index = defaultButton1 >> 8;
|
||||
if (index < buttonList1.Count)
|
||||
{
|
||||
buttonList1[index].Select();
|
||||
buttonList1[index].FlatStyle = FlatStyle.Flat;
|
||||
}
|
||||
}
|
||||
int num3 = 45;
|
||||
Rectangle rectangle = new Rectangle(12, 12, 0, 0);
|
||||
if (Icon != MsgIcon.None)
|
||||
{
|
||||
PictureBox pictureBox1 = new PictureBox();
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureBox1.Size = new System.Drawing.Size(num3, num3);
|
||||
PictureBox pictureBox2 = pictureBox1;
|
||||
pictureBox2.Image = base64Icons.GetIcon(Icon);
|
||||
form.Controls.Add((Control) pictureBox2);
|
||||
rectangle.Size = new System.Drawing.Size(num3, num3);
|
||||
pictureBox2.SetBounds(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
|
||||
pictureBox2.BringToFront();
|
||||
}
|
||||
Label label1 = new Label();
|
||||
label1.Text = Message;
|
||||
label1.AutoSize = false;
|
||||
label1.TextAlign = ContentAlignment.MiddleLeft;
|
||||
label1.Location = new System.Drawing.Point(rectangle.X + rectangle.Width + 10, rectangle.Y);
|
||||
label1.Size = new System.Drawing.Size(form.ClientSize.Width - (rectangle.X + rectangle.Width) - 20, num3);
|
||||
Label label2 = label1;
|
||||
form.Controls.Add((Control) label2);
|
||||
form.ClientSize = new System.Drawing.Size(340, panel2.Height + label2.Height + 20);
|
||||
string localMessage = Message;
|
||||
string localTitle = title;
|
||||
form.KeyDown += (KeyEventHandler) ((sender, e) =>
|
||||
{
|
||||
if (!e.Control || e.KeyCode != Keys.C)
|
||||
return;
|
||||
System.Windows.Forms.Clipboard.SetText($"Title: {localTitle}\r\nMessage: {localMessage}");
|
||||
e.Handled = true;
|
||||
});
|
||||
return form.ShowDialog();
|
||||
}
|
||||
|
||||
private static MessageBoxButtons ToWinForms(MessageBoxButton btn)
|
||||
{
|
||||
switch (btn)
|
||||
{
|
||||
case MessageBoxButton.OKCancel:
|
||||
return MessageBoxButtons.OKCancel;
|
||||
case MessageBoxButton.YesNoCancel:
|
||||
return MessageBoxButtons.YesNoCancel;
|
||||
case MessageBoxButton.YesNo:
|
||||
return MessageBoxButtons.YesNo;
|
||||
default:
|
||||
return MessageBoxButtons.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private static MsgIcon ToMsgIcon(MessageBoxImage img)
|
||||
{
|
||||
switch (img)
|
||||
{
|
||||
case MessageBoxImage.Hand:
|
||||
return MsgIcon.Error;
|
||||
case MessageBoxImage.Question:
|
||||
return MsgIcon.Question;
|
||||
case MessageBoxImage.Exclamation:
|
||||
return MsgIcon.Warning;
|
||||
case MessageBoxImage.Asterisk:
|
||||
return MsgIcon.Info;
|
||||
default:
|
||||
return MsgIcon.None;
|
||||
}
|
||||
}
|
||||
|
||||
private static MessageBoxResult ToWpfResult(DialogResult r)
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
case DialogResult.OK:
|
||||
return MessageBoxResult.OK;
|
||||
case DialogResult.Cancel:
|
||||
return MessageBoxResult.Cancel;
|
||||
case DialogResult.Yes:
|
||||
return MessageBoxResult.Yes;
|
||||
case DialogResult.No:
|
||||
return MessageBoxResult.No;
|
||||
default:
|
||||
return MessageBoxResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
public static MessageBoxResult MessageBox(
|
||||
string message,
|
||||
string title = "",
|
||||
MessageBoxButton buttons = MessageBoxButton.OK,
|
||||
MessageBoxImage icon = MessageBoxImage.None,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
MessageBoxButtons winForms = Messenger.ToWinForms(buttons);
|
||||
MsgIcon msgIcon = Messenger.ToMsgIcon(icon);
|
||||
return Messenger.ToWpfResult(Messenger.MessageBox(message, title, msgIcon, winForms, pIsDarkMode));
|
||||
}
|
||||
|
||||
public static DialogResult InputBox(
|
||||
string title,
|
||||
string promptText,
|
||||
ref List<KeyValue> Fields,
|
||||
MsgIcon Icon = MsgIcon.None,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK,
|
||||
bool pIsDarkMode = true)
|
||||
{
|
||||
Form form1 = new Form();
|
||||
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
form1.StartPosition = FormStartPosition.CenterParent;
|
||||
form1.MaximizeBox = false;
|
||||
form1.MinimizeBox = false;
|
||||
form1.Text = title;
|
||||
form1.Width = 340;
|
||||
form1.Height = 170;
|
||||
Form form = form1;
|
||||
DarkModeCS darkModeCs = new DarkModeCS(form)
|
||||
{
|
||||
ColorMode = pIsDarkMode ? DarkModeCS.DisplayMode.DarkMode : DarkModeCS.DisplayMode.ClearMode
|
||||
};
|
||||
darkModeCs.ApplyTheme(pIsDarkMode);
|
||||
ErrorProvider Err = new ErrorProvider();
|
||||
Base64Icons base64Icons = new Base64Icons();
|
||||
Panel panel1 = new Panel();
|
||||
panel1.Dock = DockStyle.Bottom;
|
||||
panel1.Height = 48 /*0x30*/;
|
||||
panel1.BackColor = darkModeCs.OScolors.Surface;
|
||||
panel1.ForeColor = darkModeCs.OScolors.TextActive;
|
||||
Panel panel2 = panel1;
|
||||
form.Controls.Add((Control) panel2);
|
||||
if (Icon != MsgIcon.None)
|
||||
{
|
||||
PictureBox pictureBox1 = new PictureBox();
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureBox1.Size = new System.Drawing.Size(48 /*0x30*/, 48 /*0x30*/);
|
||||
PictureBox pictureBox2 = pictureBox1;
|
||||
pictureBox2.Image = base64Icons.GetIcon(Icon);
|
||||
panel2.Controls.Add((Control) pictureBox2);
|
||||
pictureBox2.SetBounds(0, 2, 48 /*0x30*/, 48 /*0x30*/);
|
||||
pictureBox2.BringToFront();
|
||||
}
|
||||
Dictionary<string, string> buttonTranslations = Messenger.GetButtonTranslations(Messenger.GetCurrentLanguage());
|
||||
List<Button> buttonList1 = new List<Button>();
|
||||
switch (buttons)
|
||||
{
|
||||
case MessageBoxButtons.OK:
|
||||
List<Button> buttonList2 = buttonList1;
|
||||
Button button1 = new Button();
|
||||
button1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button1.DialogResult = DialogResult.OK;
|
||||
button1.Text = buttonTranslations["OK"];
|
||||
buttonList2.Add(button1);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
break;
|
||||
case MessageBoxButtons.OKCancel:
|
||||
List<Button> buttonList3 = buttonList1;
|
||||
Button button2 = new Button();
|
||||
button2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button2.DialogResult = DialogResult.OK;
|
||||
button2.Text = buttonTranslations["OK"];
|
||||
buttonList3.Add(button2);
|
||||
List<Button> buttonList4 = buttonList1;
|
||||
Button button3 = new Button();
|
||||
button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button3.DialogResult = DialogResult.Cancel;
|
||||
button3.Text = buttonTranslations["Cancel"];
|
||||
buttonList4.Add(button3);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
case MessageBoxButtons.AbortRetryIgnore:
|
||||
List<Button> buttonList5 = buttonList1;
|
||||
Button button4 = new Button();
|
||||
button4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button4.DialogResult = DialogResult.Retry;
|
||||
button4.Text = buttonTranslations["Retry"];
|
||||
buttonList5.Add(button4);
|
||||
List<Button> buttonList6 = buttonList1;
|
||||
Button button5 = new Button();
|
||||
button5.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button5.DialogResult = DialogResult.Abort;
|
||||
button5.Text = buttonTranslations["Abort"];
|
||||
buttonList6.Add(button5);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
case MessageBoxButtons.YesNoCancel:
|
||||
List<Button> buttonList7 = buttonList1;
|
||||
Button button6 = new Button();
|
||||
button6.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button6.DialogResult = DialogResult.Yes;
|
||||
button6.Text = buttonTranslations["Yes"];
|
||||
buttonList7.Add(button6);
|
||||
List<Button> buttonList8 = buttonList1;
|
||||
Button button7 = new Button();
|
||||
button7.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button7.DialogResult = DialogResult.No;
|
||||
button7.Text = buttonTranslations["No"];
|
||||
buttonList8.Add(button7);
|
||||
List<Button> buttonList9 = buttonList1;
|
||||
Button button8 = new Button();
|
||||
button8.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button8.DialogResult = DialogResult.Cancel;
|
||||
button8.Text = buttonTranslations["Cancel"];
|
||||
buttonList9.Add(button8);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[2];
|
||||
break;
|
||||
case MessageBoxButtons.YesNo:
|
||||
List<Button> buttonList10 = buttonList1;
|
||||
Button button9 = new Button();
|
||||
button9.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button9.DialogResult = DialogResult.Yes;
|
||||
button9.Text = buttonTranslations["Yes"];
|
||||
buttonList10.Add(button9);
|
||||
List<Button> buttonList11 = buttonList1;
|
||||
Button button10 = new Button();
|
||||
button10.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button10.DialogResult = DialogResult.No;
|
||||
button10.Text = buttonTranslations["No"];
|
||||
buttonList11.Add(button10);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
case MessageBoxButtons.RetryCancel:
|
||||
List<Button> buttonList12 = buttonList1;
|
||||
Button button11 = new Button();
|
||||
button11.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button11.DialogResult = DialogResult.Retry;
|
||||
button11.Text = buttonTranslations["Retry"];
|
||||
buttonList12.Add(button11);
|
||||
List<Button> buttonList13 = buttonList1;
|
||||
Button button12 = new Button();
|
||||
button12.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button12.DialogResult = DialogResult.Cancel;
|
||||
button12.Text = buttonTranslations["Cancel"];
|
||||
buttonList13.Add(button12);
|
||||
form.AcceptButton = (IButtonControl) buttonList1[0];
|
||||
form.CancelButton = (IButtonControl) buttonList1[1];
|
||||
break;
|
||||
}
|
||||
int num1 = 4;
|
||||
int num2 = form.ClientSize.Width;
|
||||
foreach (Button button13 in buttonList1)
|
||||
{
|
||||
button13.FlatAppearance.BorderColor = form.AcceptButton == button13 ? darkModeCs.OScolors.Accent : darkModeCs.OScolors.Control;
|
||||
panel2.Controls.Add((Control) button13);
|
||||
button13.Location = new System.Drawing.Point(num2 - (button13.Width + num1), (panel2.Height - button13.Height) / 2);
|
||||
num2 = button13.Left;
|
||||
}
|
||||
Label label1 = new Label();
|
||||
if (!string.IsNullOrWhiteSpace(promptText))
|
||||
{
|
||||
label1.Dock = DockStyle.Top;
|
||||
label1.Text = promptText;
|
||||
label1.AutoSize = false;
|
||||
label1.Height = 24;
|
||||
label1.TextAlign = ContentAlignment.MiddleCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
label1.Location = new System.Drawing.Point(0, 0);
|
||||
label1.Width = 0;
|
||||
label1.Height = 0;
|
||||
}
|
||||
form.Controls.Add((Control) label1);
|
||||
TableLayoutPanel tableLayoutPanel1 = new TableLayoutPanel();
|
||||
tableLayoutPanel1.Size = new System.Drawing.Size(form.ClientSize.Width - 20, 50);
|
||||
tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
tableLayoutPanel1.BackColor = darkModeCs.OScolors.Background;
|
||||
tableLayoutPanel1.AutoSize = true;
|
||||
tableLayoutPanel1.ColumnCount = 2;
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(10, label1.Location.Y + label1.Height + 4);
|
||||
TableLayoutPanel tableLayoutPanel2 = tableLayoutPanel1;
|
||||
form.Controls.Add((Control) tableLayoutPanel2);
|
||||
tableLayoutPanel2.ColumnStyles.Clear();
|
||||
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
|
||||
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute));
|
||||
tableLayoutPanel2.ColumnStyles[1].Width = (float) (form.ClientSize.Width - 120);
|
||||
tableLayoutPanel2.RowStyles.Clear();
|
||||
int ChangeDelayMS = 1000;
|
||||
int row = 0;
|
||||
foreach (KeyValue keyValue in Fields)
|
||||
{
|
||||
KeyValue field = keyValue;
|
||||
Label label2 = new Label();
|
||||
label2.Text = field.Key;
|
||||
label2.AutoSize = false;
|
||||
label2.Dock = DockStyle.Fill;
|
||||
label2.TextAlign = ContentAlignment.MiddleCenter;
|
||||
Label label3 = label2;
|
||||
Control field_Control = (Control) null;
|
||||
BorderStyle borderStyle = darkModeCs.IsDarkMode ? BorderStyle.FixedSingle : BorderStyle.Fixed3D;
|
||||
if (field.ValueType == KeyValue.ValueTypes.String)
|
||||
{
|
||||
TextBox textBox = new TextBox();
|
||||
textBox.Text = field.Value;
|
||||
textBox.Dock = DockStyle.Fill;
|
||||
textBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
field_Control = (Control) textBox;
|
||||
field_Control.TextChanged += (EventHandler) ((sender, args) => Messenger.AddTextChangedDelay<TextBox>((TextBox) field_Control, ChangeDelayMS, (Action<TextBox>) (text =>
|
||||
{
|
||||
field.Value = ((Control) sender).Text;
|
||||
((Control) sender).Text = Convert.ToString(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
})));
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Multiline)
|
||||
{
|
||||
TextBox textBox = new TextBox();
|
||||
textBox.Text = field.Value;
|
||||
textBox.Dock = DockStyle.Fill;
|
||||
textBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
textBox.Multiline = true;
|
||||
textBox.ScrollBars = ScrollBars.Vertical;
|
||||
field_Control = (Control) textBox;
|
||||
field_Control.TextChanged += (EventHandler) ((sender, args) => Messenger.AddTextChangedDelay<TextBox>((TextBox) field_Control, ChangeDelayMS, (Action<TextBox>) (text =>
|
||||
{
|
||||
field.Value = ((Control) sender).Text;
|
||||
((Control) sender).Text = Convert.ToString(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
})));
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Password)
|
||||
{
|
||||
TextBox textBox = new TextBox();
|
||||
textBox.Text = field.Value;
|
||||
textBox.Dock = DockStyle.Fill;
|
||||
textBox.UseSystemPasswordChar = true;
|
||||
textBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
field_Control = (Control) textBox;
|
||||
field_Control.TextChanged += (EventHandler) ((sender, args) => Messenger.AddTextChangedDelay<TextBox>((TextBox) field_Control, ChangeDelayMS, (Action<TextBox>) (text =>
|
||||
{
|
||||
field.Value = ((Control) sender).Text;
|
||||
((Control) sender).Text = Convert.ToString(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
})));
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Integer)
|
||||
{
|
||||
NumericUpDown numericUpDown = new NumericUpDown();
|
||||
numericUpDown.Minimum = -2147483648M;
|
||||
numericUpDown.Maximum = 2147483647M;
|
||||
numericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
numericUpDown.Value = (Decimal) Convert.ToInt32(field.Value);
|
||||
numericUpDown.ThousandsSeparator = true;
|
||||
numericUpDown.Dock = DockStyle.Fill;
|
||||
numericUpDown.DecimalPlaces = 0;
|
||||
field_Control = (Control) numericUpDown;
|
||||
((NumericUpDown) field_Control).ValueChanged += (EventHandler) ((sender, args) => Messenger.AddTextChangedDelay<NumericUpDown>((NumericUpDown) field_Control, ChangeDelayMS, (Action<NumericUpDown>) (text =>
|
||||
{
|
||||
field.Value = ((NumericUpDown) sender).Value.ToString();
|
||||
((NumericUpDown) sender).Value = (Decimal) Convert.ToInt32(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
})));
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Decimal)
|
||||
{
|
||||
NumericUpDown numericUpDown = new NumericUpDown();
|
||||
numericUpDown.Minimum = -2147483648M;
|
||||
numericUpDown.Maximum = 2147483647M;
|
||||
numericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
numericUpDown.Value = Convert.ToDecimal(field.Value);
|
||||
numericUpDown.ThousandsSeparator = false;
|
||||
numericUpDown.Dock = DockStyle.Fill;
|
||||
numericUpDown.DecimalPlaces = 2;
|
||||
field_Control = (Control) numericUpDown;
|
||||
((NumericUpDown) field_Control).ValueChanged += (EventHandler) ((sender, args) => Messenger.AddTextChangedDelay<NumericUpDown>((NumericUpDown) field_Control, ChangeDelayMS, (Action<NumericUpDown>) (text =>
|
||||
{
|
||||
field.Value = ((NumericUpDown) sender).Value.ToString();
|
||||
((NumericUpDown) sender).Value = Convert.ToDecimal(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
})));
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Date)
|
||||
{
|
||||
DateTimePicker dateTimePicker = new DateTimePicker();
|
||||
dateTimePicker.Value = Convert.ToDateTime(field.Value);
|
||||
dateTimePicker.Dock = DockStyle.Fill;
|
||||
dateTimePicker.Format = DateTimePickerFormat.Short;
|
||||
dateTimePicker.CalendarForeColor = darkModeCs.OScolors.TextActive;
|
||||
dateTimePicker.CalendarMonthBackground = darkModeCs.OScolors.Control;
|
||||
dateTimePicker.CalendarTitleBackColor = darkModeCs.OScolors.Surface;
|
||||
dateTimePicker.CalendarTitleForeColor = darkModeCs.OScolors.TextActive;
|
||||
field_Control = (Control) dateTimePicker;
|
||||
((DateTimePicker) field_Control).ValueChanged += (EventHandler) ((sender, args) =>
|
||||
{
|
||||
field.Value = ((DateTimePicker) sender).Value.ToString();
|
||||
((DateTimePicker) sender).Value = Convert.ToDateTime(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
Err.SetIconAlignment(field_Control, ErrorIconAlignment.MiddleLeft);
|
||||
});
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Time)
|
||||
{
|
||||
DateTimePicker dateTimePicker = new DateTimePicker();
|
||||
dateTimePicker.Value = Convert.ToDateTime(field.Value);
|
||||
dateTimePicker.Dock = DockStyle.Fill;
|
||||
dateTimePicker.Format = DateTimePickerFormat.Time;
|
||||
field_Control = (Control) dateTimePicker;
|
||||
((DateTimePicker) field_Control).ValueChanged += (EventHandler) ((sender, args) =>
|
||||
{
|
||||
field.Value = ((DateTimePicker) sender).Value.ToString();
|
||||
((DateTimePicker) sender).Value = Convert.ToDateTime(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
Err.SetIconAlignment(field_Control, ErrorIconAlignment.MiddleLeft);
|
||||
});
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Boolean)
|
||||
{
|
||||
CheckBox checkBox = new CheckBox();
|
||||
checkBox.Checked = Convert.ToBoolean(field.Value);
|
||||
checkBox.Dock = DockStyle.Fill;
|
||||
checkBox.Text = field.Key;
|
||||
field_Control = (Control) checkBox;
|
||||
((CheckBox) field_Control).CheckedChanged += (EventHandler) ((sender, args) =>
|
||||
{
|
||||
field.Value = ((CheckBox) sender).Checked.ToString();
|
||||
((CheckBox) sender).Checked = Convert.ToBoolean(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
});
|
||||
}
|
||||
if (field.ValueType == KeyValue.ValueTypes.Dynamic)
|
||||
{
|
||||
FlatComboBox flatComboBox = new FlatComboBox();
|
||||
flatComboBox.DataSource = (object) field.DataSet;
|
||||
flatComboBox.ValueMember = "Value";
|
||||
flatComboBox.DisplayMember = "Key";
|
||||
flatComboBox.Dock = DockStyle.Fill;
|
||||
flatComboBox.BackColor = darkModeCs.OScolors.Control;
|
||||
flatComboBox.ButtonColor = darkModeCs.OScolors.Surface;
|
||||
flatComboBox.ForeColor = darkModeCs.OScolors.TextActive;
|
||||
flatComboBox.SelectedValue = (object) field.Value;
|
||||
flatComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
flatComboBox.FlatStyle = darkModeCs.IsDarkMode ? FlatStyle.Flat : FlatStyle.Standard;
|
||||
field_Control = (Control) flatComboBox;
|
||||
((ListControl) field_Control).SelectedValueChanged += (EventHandler) ((sender, args) =>
|
||||
{
|
||||
field.Value = ((ListControl) sender).SelectedValue.ToString();
|
||||
((ListControl) sender).SelectedValue = (object) Convert.ToString(field.Value);
|
||||
Err.SetError(field_Control, field.ErrorText);
|
||||
});
|
||||
}
|
||||
tableLayoutPanel2.Controls.Add((Control) label3, 0, row);
|
||||
if (field.ValueType == KeyValue.ValueTypes.Multiline)
|
||||
{
|
||||
tableLayoutPanel2.Controls.Add(field_Control, 1, row);
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
++row;
|
||||
++tableLayoutPanel2.RowCount;
|
||||
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, (float) field_Control.Height));
|
||||
}
|
||||
tableLayoutPanel2.SetRowSpan(field_Control, 6);
|
||||
}
|
||||
else
|
||||
tableLayoutPanel2.Controls.Add(field_Control, 1, row);
|
||||
Err.SetIconAlignment(field_Control, ErrorIconAlignment.MiddleLeft);
|
||||
if (field_Control is ComboBox)
|
||||
{
|
||||
field_Control.CreateControl();
|
||||
((ListControl) field_Control).SelectedValue = (object) field.Value;
|
||||
}
|
||||
field_Control.TabIndex = row;
|
||||
++row;
|
||||
}
|
||||
tableLayoutPanel2.Width = form.ClientSize.Width - 20;
|
||||
form.ClientSize = new System.Drawing.Size(340, panel2.Height + label1.Height + tableLayoutPanel2.Height + 20);
|
||||
form.FormClosing += (FormClosingEventHandler) ((sender, e) =>
|
||||
{
|
||||
if (form.ActiveControl != form.AcceptButton)
|
||||
return;
|
||||
KeyValue.ValidateEventArgs validateEventArgs = new KeyValue.ValidateEventArgs((string) null);
|
||||
Action<object, KeyValue.ValidateEventArgs> validateControlsHandler = Messenger.ValidateControlsHandler;
|
||||
if (validateControlsHandler != null)
|
||||
validateControlsHandler((object) form, validateEventArgs);
|
||||
e.Cancel = validateEventArgs.Cancel;
|
||||
if (e.Cancel)
|
||||
return;
|
||||
form.DialogResult = form.AcceptButton.DialogResult;
|
||||
});
|
||||
return form.ShowDialog();
|
||||
}
|
||||
|
||||
private static void AddTextChangedDelay<TControl>(
|
||||
TControl control,
|
||||
int milliseconds,
|
||||
Action<TControl> action)
|
||||
where TControl : Control
|
||||
{
|
||||
if (Messenger.timers == null)
|
||||
Messenger.timers = new Dictionary<Control, Timer>();
|
||||
if (Messenger.timers.ContainsKey((Control) control))
|
||||
{
|
||||
Messenger.timers[(Control) control].Stop();
|
||||
Messenger.timers.Remove((Control) control);
|
||||
}
|
||||
Timer timer = new Timer();
|
||||
timer.Interval = milliseconds;
|
||||
timer.Tick += (EventHandler) ((sender, e) =>
|
||||
{
|
||||
timer.Stop();
|
||||
Messenger.timers.Remove((Control) control);
|
||||
action(control);
|
||||
});
|
||||
timer.Start();
|
||||
Messenger.timers.Add((Control) control, timer);
|
||||
}
|
||||
|
||||
public static string GetCurrentLanguage(string pDefault = "en")
|
||||
{
|
||||
string currentLanguage = pDefault;
|
||||
string letterIsoLanguageName = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
|
||||
if (Messenger.IsCurrentLanguageSupported(new List<string>()
|
||||
{
|
||||
"en",
|
||||
"es",
|
||||
"fr",
|
||||
"de",
|
||||
"ru",
|
||||
"ko",
|
||||
"pt"
|
||||
}, letterIsoLanguageName))
|
||||
currentLanguage = letterIsoLanguageName;
|
||||
if (letterIsoLanguageName.ToLowerInvariant().Equals("zh"))
|
||||
{
|
||||
string name = CultureInfo.CurrentCulture.Name;
|
||||
currentLanguage = string.Equals(name, "zh-CN") || string.Equals(name, "zh-SG") || string.Equals(name, "zh-Hans") ? "zh-Hans" : (string.Equals(name, "zh-TW") || string.Equals(name, "zh-HK") || string.Equals(name, "zh-MO") || string.Equals(name, "zh-Hant") ? "zh-Hant" : "zh-Hans");
|
||||
}
|
||||
return currentLanguage;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> GetButtonTranslations(string pLanguage)
|
||||
{
|
||||
Dictionary<string, string> buttonTranslations = (Dictionary<string, string>) null;
|
||||
string str = new Dictionary<string, string>()
|
||||
{
|
||||
{
|
||||
"en",
|
||||
"OK|Cancel|Yes|No|Continue|Retry|Abort|Ignore|Try Again"
|
||||
},
|
||||
{
|
||||
"es",
|
||||
"Aceptar|Cancelar|Sí|No|Continuar|Reintentar|Abortar|Ignorar|Intentar"
|
||||
},
|
||||
{
|
||||
"fr",
|
||||
"Accepter|Annuler|Oui|Non|Continuer|Réessayer|Abandonner|Ignorer|Essayer"
|
||||
},
|
||||
{
|
||||
"de",
|
||||
"Akzeptieren|Abbrechen|Ja|Nein|Weiter|Wiederholen|Abbrechen|Ignorieren|Versuchen"
|
||||
},
|
||||
{
|
||||
"ru",
|
||||
"Принять|Отменить|Да|Нет|Продолжить|Повторить|Прервать|Игнорировать|Пытаться"
|
||||
},
|
||||
{
|
||||
"ko",
|
||||
"확인|취소|예|아니오|계속|다시 시도|중단|무시|써 보다"
|
||||
},
|
||||
{
|
||||
"pt",
|
||||
"Aceitar|Cancelar|Sim|Não|Continuar|Tentar novamente|Abortar|Ignorar|Tentar"
|
||||
},
|
||||
{
|
||||
"zh-Hans",
|
||||
"确定|取消|是|否|继续|重试|中止|忽略|尝试"
|
||||
},
|
||||
{
|
||||
"zh-Hant",
|
||||
"確定|取消|是|否|繼續|重試|中止|忽略|嘗試"
|
||||
}
|
||||
}[pLanguage];
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
List<string> list = ((IEnumerable<string>) str.Split('|')).ToList<string>();
|
||||
buttonTranslations = new Dictionary<string, string>()
|
||||
{
|
||||
{
|
||||
"OK",
|
||||
list[0]
|
||||
},
|
||||
{
|
||||
"Cancel",
|
||||
list[1]
|
||||
},
|
||||
{
|
||||
"Yes",
|
||||
list[2]
|
||||
},
|
||||
{
|
||||
"No",
|
||||
list[3]
|
||||
},
|
||||
{
|
||||
"Continue",
|
||||
list[4]
|
||||
},
|
||||
{
|
||||
"Retry",
|
||||
list[5]
|
||||
},
|
||||
{
|
||||
"Abort",
|
||||
list[6]
|
||||
},
|
||||
{
|
||||
"Ignore",
|
||||
list[7]
|
||||
},
|
||||
{
|
||||
"Try Again",
|
||||
list[8]
|
||||
}
|
||||
};
|
||||
}
|
||||
return buttonTranslations;
|
||||
}
|
||||
|
||||
private static bool IsCurrentLanguageSupported(List<string> languages, string currentLanguage)
|
||||
{
|
||||
currentLanguage = languages != null && currentLanguage != null ? currentLanguage.ToLowerInvariant() : throw new ArgumentNullException(languages == null ? nameof (languages) : nameof (currentLanguage));
|
||||
if (languages.Contains(currentLanguage))
|
||||
return true;
|
||||
if (currentLanguage.Length < 2)
|
||||
return false;
|
||||
string str = currentLanguage.Substring(0, 2);
|
||||
return languages.Contains(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.MsgIcon
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public enum MsgIcon
|
||||
{
|
||||
None,
|
||||
Info,
|
||||
Success,
|
||||
Warning,
|
||||
Error,
|
||||
Question,
|
||||
Lock,
|
||||
User,
|
||||
Forbidden,
|
||||
AddNew,
|
||||
Cancel,
|
||||
Edit,
|
||||
List,
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.MyRenderer
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class MyRenderer : ToolStripProfessionalRenderer
|
||||
{
|
||||
public bool ColorizeIcons { get; set; } = true;
|
||||
|
||||
public OSThemeColors MyColors { get; set; }
|
||||
|
||||
public MyRenderer(ProfessionalColorTable table, bool pColorizeIcons = true)
|
||||
: base(table)
|
||||
{
|
||||
this.ColorizeIcons = pColorizeIcons;
|
||||
}
|
||||
|
||||
private void DrawTitleBar(Graphics g, Rectangle rect)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnRenderGrip(ToolStripGripRenderEventArgs e)
|
||||
{
|
||||
this.DrawTitleBar(e.Graphics, new Rectangle(0, 0, e.ToolStrip.Width, 7));
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
|
||||
{
|
||||
this.DrawTitleBar(e.Graphics, new Rectangle(0, 0, e.ToolStrip.Width, 7));
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
|
||||
{
|
||||
e.ToolStrip.BackColor = this.MyColors.Background;
|
||||
base.OnRenderToolStripBackground(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
Color color1 = this.MyColors.Background;
|
||||
Color color2 = this.MyColors.Background;
|
||||
Pen pen = new Pen(this.MyColors.Background);
|
||||
ToolStripButton toolStripButton = e.Item as ToolStripButton;
|
||||
if (toolStripButton.Pressed || toolStripButton.Checked)
|
||||
{
|
||||
color1 = this.MyColors.Control;
|
||||
color2 = this.MyColors.Control;
|
||||
}
|
||||
else if (toolStripButton.Selected)
|
||||
{
|
||||
color1 = this.MyColors.Accent;
|
||||
color2 = this.MyColors.Accent;
|
||||
}
|
||||
using (Brush brush = (Brush) new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical))
|
||||
graphics.FillRectangle(brush, rect);
|
||||
e.Graphics.DrawRectangle(pen, rect);
|
||||
graphics.DrawLine(pen, rect.X, rect.Y, rect.Width - 1, rect.Y);
|
||||
graphics.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Height - 1);
|
||||
ToolStrip owner1 = toolStripButton.Owner;
|
||||
ToolStrip owner2 = toolStripButton.Owner;
|
||||
Rectangle bounds = toolStripButton.Bounds;
|
||||
int x = bounds.X;
|
||||
bounds = toolStripButton.Bounds;
|
||||
int y = bounds.Bottom + 1;
|
||||
if (owner2.GetItemAt(x, y) is ToolStripButton)
|
||||
return;
|
||||
graphics.DrawLine(pen, rect.X, rect.Height - 1, rect.X + rect.Width - 1, rect.Height - 1);
|
||||
}
|
||||
|
||||
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
Color color1 = this.MyColors.Background;
|
||||
Color color2 = this.MyColors.Background;
|
||||
Pen pen = new Pen(this.MyColors.Background);
|
||||
if (e.Item.Pressed)
|
||||
{
|
||||
color1 = this.MyColors.Control;
|
||||
color2 = this.MyColors.Control;
|
||||
}
|
||||
else if (e.Item.Selected)
|
||||
{
|
||||
color1 = this.MyColors.Accent;
|
||||
color2 = this.MyColors.Accent;
|
||||
}
|
||||
using (Brush brush = (Brush) new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical))
|
||||
e.Graphics.FillRectangle(brush, rect);
|
||||
}
|
||||
|
||||
protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
Color color1 = this.MyColors.Background;
|
||||
Color color2 = this.MyColors.Background;
|
||||
if (e.Item.Pressed)
|
||||
{
|
||||
color1 = this.MyColors.Control;
|
||||
color2 = this.MyColors.Control;
|
||||
}
|
||||
else if (e.Item.Selected)
|
||||
{
|
||||
color1 = this.MyColors.Accent;
|
||||
color2 = this.MyColors.Accent;
|
||||
}
|
||||
using (Brush brush = (Brush) new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical))
|
||||
e.Graphics.FillRectangle(brush, rect);
|
||||
int num = 2;
|
||||
Size size = new Size(8, 4);
|
||||
Pen pen = new Pen(this.MyColors.TextInactive, 2f);
|
||||
Point pt1_1 = new Point(rect.Width - (size.Width + num), rect.Height / 2 - size.Height / 2);
|
||||
Point pt1_2 = new Point(rect.Width - num, rect.Height / 2 - size.Height / 2);
|
||||
Point pt2 = new Point(rect.Width - (size.Width / 2 + num), rect.Height / 2 + size.Height / 2);
|
||||
e.Graphics.DrawLine(pen, pt1_1, pt2);
|
||||
e.Graphics.DrawLine(pen, pt1_2, pt2);
|
||||
}
|
||||
|
||||
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
|
||||
{
|
||||
e.TextColor = !e.Item.Enabled ? this.MyColors.TextInactive : this.MyColors.TextActive;
|
||||
base.OnRenderItemText(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
base.OnRenderItemBackground(e);
|
||||
if (!(e.Item is ToolStripComboBox))
|
||||
return;
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
e.Graphics.DrawRectangle(new Pen(this.MyColors.ControlLight, 1f), rect);
|
||||
}
|
||||
|
||||
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
Color color1 = this.MyColors.Background;
|
||||
Color color2 = this.MyColors.Background;
|
||||
bool flag = false;
|
||||
ToolStripItem toolStripItem = e.Item;
|
||||
if (toolStripItem.Pressed)
|
||||
{
|
||||
color1 = this.MyColors.Control;
|
||||
color2 = this.MyColors.Control;
|
||||
flag = true;
|
||||
}
|
||||
else if (toolStripItem.Selected)
|
||||
{
|
||||
color1 = this.MyColors.Accent;
|
||||
color2 = this.MyColors.Accent;
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
return;
|
||||
using (Brush brush = (Brush) new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical))
|
||||
graphics.FillRectangle(brush, rect);
|
||||
}
|
||||
|
||||
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
|
||||
{
|
||||
if (e.Item.GetType().FullName == "System.Windows.Forms.MdiControlStrip+ControlBoxMenuItem")
|
||||
{
|
||||
using (Image color = DarkModeCS.ChangeToColor(e.Image, e.Item.Enabled ? this.MyColors.TextActive : this.MyColors.SurfaceDark))
|
||||
{
|
||||
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||
e.Graphics.CompositingQuality = CompositingQuality.AssumeLinear;
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
e.Graphics.DrawImage(color, e.ImageRectangle);
|
||||
}
|
||||
}
|
||||
else if (this.ColorizeIcons && e.Image != null)
|
||||
{
|
||||
using (Image color = DarkModeCS.ChangeToColor(e.Image, e.Item.Enabled ? this.MyColors.TextInactive : this.MyColors.SurfaceDark))
|
||||
{
|
||||
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
e.Graphics.DrawImage(color, e.ImageRectangle);
|
||||
}
|
||||
}
|
||||
else
|
||||
base.OnRenderItemImage(e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: DarkModeForms.OSThemeColors
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace DarkModeForms;
|
||||
|
||||
public class OSThemeColors
|
||||
{
|
||||
public Color Background { get; set; } = SystemColors.Control;
|
||||
|
||||
public Color BackgroundDark { get; set; } = SystemColors.ControlDark;
|
||||
|
||||
public Color BackgroundLight { get; set; } = SystemColors.ControlLight;
|
||||
|
||||
public Color Surface { get; set; } = SystemColors.ControlLightLight;
|
||||
|
||||
public Color SurfaceDark { get; set; } = SystemColors.ControlLight;
|
||||
|
||||
public Color SurfaceLight { get; set; } = Color.White;
|
||||
|
||||
public Color TextActive { get; set; } = SystemColors.ControlText;
|
||||
|
||||
public Color TextInactive { get; set; } = SystemColors.GrayText;
|
||||
|
||||
public Color TextInAccent { get; set; } = SystemColors.HighlightText;
|
||||
|
||||
public Color Control { get; set; } = SystemColors.ButtonFace;
|
||||
|
||||
public Color ControlDark { get; set; } = SystemColors.ButtonShadow;
|
||||
|
||||
public Color ControlLight { get; set; } = SystemColors.ButtonHighlight;
|
||||
|
||||
public Color Accent { get; set; } = DarkModeCS.GetWindowsAccentColor();
|
||||
|
||||
public Color AccentOpaque { get; set; } = DarkModeCS.GetWindowsAccentOpaqueColor();
|
||||
|
||||
public Color AccentDark => ControlPaint.Dark(this.Accent);
|
||||
|
||||
public Color AccentLight => ControlPaint.Light(this.Accent);
|
||||
|
||||
public Color Primary { get; set; } = SystemColors.Highlight;
|
||||
|
||||
public Color PrimaryDark => ControlPaint.Dark(this.Primary);
|
||||
|
||||
public Color PrimaryLight => ControlPaint.Light(this.Primary);
|
||||
|
||||
public Color Secondary { get; set; } = SystemColors.HotTrack;
|
||||
|
||||
public Color SecondaryDark => ControlPaint.Dark(this.Secondary);
|
||||
|
||||
public Color SecondaryLight => ControlPaint.Light(this.Secondary);
|
||||
}
|
||||
Reference in New Issue
Block a user