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
110
111
112
113
114
115
116
117
118
119
120
121
|
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Histacom2.Engine.UI
{
public class ClassicStartMenuItem : ToolStripMenuItem
{
private ClassicStartMenuItemLayout layout;
public ClassicStartMenuItemLayout LayoutStyle {
get
{
return layout;
}
set
{
layout = value;
Invalidate();
}
}
private string subtext = "Subtitle";
public string SubTitle
{
get
{
return subtext;
}
set
{
subtext = value;
Invalidate();
}
}
public ClassicStartMenuItem()
{
AutoSize = false;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (SaveSystem.currentTheme != null) e.Graphics.Clear(SaveSystem.currentTheme.threeDObjectsColor);
else e.Graphics.Clear(BackColor);
if (Selected)
{
if (SaveSystem.currentTheme != null) e.Graphics.FillRectangle(new SolidBrush(SaveSystem.currentTheme.selectedBackColor), new Rectangle(0, 0, Width, Image.Height));
else e.Graphics.FillRectangle(Brushes.Navy, new Rectangle(0, 0, Width, Image.Height));
}
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
StringFormat sf = new StringFormat();
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
int imgWidth = 0;
if (Image != null) { e.Graphics.DrawImage(Image, 0 + Padding.Left - Padding.Right, 0); imgWidth = Image.Width; }
if (Image != null) if (Height != Image.Height) if (layout == ClassicStartMenuItemLayout.CloseTitleWithLightSubtitle && Height != Image.Height + 8) { Height = Image.Height; }
if (!Selected) {
switch (layout) {
case ClassicStartMenuItemLayout.DistancedTitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), imgWidth + 6, 11, sf);
break;
case ClassicStartMenuItemLayout.CloseTitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), imgWidth + 2, 9, sf);
break;
case ClassicStartMenuItemLayout.CloseTitleWithLightSubtitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), imgWidth + 2, 3, sf);
e.Graphics.DrawString(subtext, new Font(Font, FontStyle.Regular), Brushes.Gray, imgWidth + 2, 16, sf);
if (Image != null) if (Height != Image.Height + 8) Height = Image.Height + 8;
break;
}
if (DropDownItems.Count > 0)
{
e.Graphics.DrawPolygon(new Pen(ForeColor), new Point[] { new Point(Width - 16, 11), new Point(Width - 13, 14), new Point(Width - 16, 17) });
e.Graphics.FillPolygon(new SolidBrush(ForeColor), new Point[] { new Point(Width - 16, 11), new Point(Width - 13, 14), new Point(Width - 16, 17) });
}
} else
{
if (SaveSystem.currentTheme != null)
{
switch (layout)
{
case ClassicStartMenuItemLayout.DistancedTitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(SaveSystem.currentTheme.selectedTextColor), imgWidth + 6, 11, sf);
break;
case ClassicStartMenuItemLayout.CloseTitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(SaveSystem.currentTheme.selectedTextColor), imgWidth + 2, 11, sf);
break;
case ClassicStartMenuItemLayout.CloseTitleWithLightSubtitle:
e.Graphics.DrawString(Text, Font, new SolidBrush(SaveSystem.currentTheme.selectedTextColor), imgWidth + 2, 3, sf);
if (Image != null) if (Height != Image.Height + 8) Height = Image.Height + 8;
break;
}
if (DropDownItems.Count > 0)
{
e.Graphics.DrawPolygon(new Pen(SaveSystem.currentTheme.selectedTextColor), new Point[] { new Point(121, 11), new Point(124, 14), new Point(121, 17) });
e.Graphics.FillPolygon(new SolidBrush(SaveSystem.currentTheme.selectedTextColor), new Point[] { new Point(121, 11), new Point(124, 14), new Point(121, 17) });
}
}
}
}
}
public enum ClassicStartMenuItemLayout
{
DistancedTitle,
CloseTitle,
CloseTitleWithTwoLines,
CloseTitleWithLightSubtitle
}
}
|