yangyin
2025-03-27 b0de14c2670b9ff0079dacfb4b7457b438368f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Util;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region ForeverPalette
 
    public class ForeverPalette : Control
    {
        private int W;
        private int H;
 
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            Width = 180;
            Height = 80;
        }
 
        [Category("Colors")]
        public Color Red { get; set; } = Color.FromArgb(220, 85, 96);
 
        [Category("Colors")]
        public Color Cyan { get; set; } = Color.FromArgb(10, 154, 157);
 
        [Category("Colors")]
        public Color Blue { get; set; } = Color.FromArgb(0, 128, 255);
 
        [Category("Colors")]
        public Color LimeGreen { get; set; } = Color.FromArgb(35, 168, 109);
 
        [Category("Colors")]
        public Color Orange { get; set; } = Color.FromArgb(253, 181, 63);
 
        [Category("Colors")]
        public Color Purple { get; set; } = Color.FromArgb(155, 88, 181);
 
        [Category("Colors")]
        public Color Black { get; set; } = Color.FromArgb(45, 47, 49);
 
        [Category("Colors")]
        public Color Gray { get; set; } = Color.FromArgb(63, 70, 73);
 
        [Category("Colors")]
        public Color White { get; set; } = Color.FromArgb(243, 243, 243);
 
        [Category("Options")]
        public string String { get; set; } = "Color Palette";
 
        [Category("Colors")]
        public Color StringColor { get; set; } = Color.White;
 
        public ForeverPalette()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
            DoubleBuffered = true;
            BackColor = Color.FromArgb(60, 70, 73);
            Size = new(160, 80);
            Font = new("Segoe UI", 12);
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            Bitmap B = new(Width, Height);
            Graphics G = Graphics.FromImage(B);
 
            W = Width - 1;
            H = Height - 1;
 
            Graphics _with6 = G;
            _with6.SmoothingMode = SmoothingMode.HighQuality;
            _with6.PixelOffsetMode = PixelOffsetMode.HighQuality;
            _with6.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            _with6.Clear(BackColor);
 
            //-- Colors 
            _with6.FillRectangle(new SolidBrush(Red), new Rectangle(0, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Cyan), new Rectangle(20, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Blue), new Rectangle(40, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(LimeGreen), new Rectangle(60, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Orange), new Rectangle(80, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Purple), new Rectangle(100, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Black), new Rectangle(120, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(Gray), new Rectangle(140, 0, 20, 40));
            _with6.FillRectangle(new SolidBrush(White), new Rectangle(160, 0, 20, 40));
 
            //-- Text
            _with6.DrawString(String, Font, new SolidBrush(StringColor), new Rectangle(0, 22, W, H), ForeverLibrary.CenterSF);
 
            base.OnPaint(e);
 
            G.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            B.Dispose();
        }
    }
 
    #endregion
}