Files

182 lines
6.0 KiB
C#
Raw Permalink Normal View History

2026-08-27 11:23:13 -06:00
// 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,
}
}