aboutsummaryrefslogtreecommitdiff
path: root/Histacom2.Engine/UI
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-10-24 11:27:51 +0100
committerAlex-TIMEHACK <[email protected]>2017-10-24 11:27:51 +0100
commit3d2e297b43cbd7f99269c9a58b25651a83ccef3c (patch)
treeef636bc39af2b880af61acde98a2c5fb9e92cbaa /Histacom2.Engine/UI
parente5f29e7b53322e11578acd0deb3b1d454998bb77 (diff)
parentaff052b475abc5d4035369a85fa471f62cad021b (diff)
downloadhistacom2-3d2e297b43cbd7f99269c9a58b25651a83ccef3c.tar.gz
histacom2-3d2e297b43cbd7f99269c9a58b25651a83ccef3c.tar.bz2
histacom2-3d2e297b43cbd7f99269c9a58b25651a83ccef3c.zip
Updated my fork!
Diffstat (limited to 'Histacom2.Engine/UI')
-rw-r--r--Histacom2.Engine/UI/ClassicLabel.cs18
-rw-r--r--Histacom2.Engine/UI/ClassicStartMenuItem.cs104
2 files changed, 109 insertions, 13 deletions
diff --git a/Histacom2.Engine/UI/ClassicLabel.cs b/Histacom2.Engine/UI/ClassicLabel.cs
index f207eb1..eba8dc6 100644
--- a/Histacom2.Engine/UI/ClassicLabel.cs
+++ b/Histacom2.Engine/UI/ClassicLabel.cs
@@ -12,20 +12,34 @@ namespace Histacom2.Engine.UI
{
public class ClassicLabel : Control
{
+ public bool DropShadow { get; set; }
+
public ClassicLabel()
{
-
+ SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+ TextChanged += (s, e) => Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var gfx = e.Graphics;
- gfx.Clear(BackColor);
+ if (BackColor != Color.Transparent) gfx.Clear(BackColor);
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
gfx.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle);
Height = (int)gfx.MeasureString(Text, Font, ClientRectangle.Width).Height;
}
+
+ private const int CS_DROPSHADOW = 0x00020000;
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ if (DropShadow) cp.ClassStyle |= CS_DROPSHADOW;
+ return cp;
+ }
+ }
}
}
diff --git a/Histacom2.Engine/UI/ClassicStartMenuItem.cs b/Histacom2.Engine/UI/ClassicStartMenuItem.cs
index 49aecd9..dcb8361 100644
--- a/Histacom2.Engine/UI/ClassicStartMenuItem.cs
+++ b/Histacom2.Engine/UI/ClassicStartMenuItem.cs
@@ -10,41 +10,106 @@ 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 bool DoBackColorAdapt { get; set; }
+
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 (SaveSystem.currentTheme != null && DoBackColorAdapt) e.Graphics.Clear(SaveSystem.currentTheme.threeDObjectsColor);
+ else if (BackColor != Color.Transparent) e.Graphics.FillRectangle(new SolidBrush(BackColor), new Rectangle(0, 0, Width, Height));
+
+ e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
+ if (BackgroundImage != null)
+ {
+ if (BackgroundImageLayout == ImageLayout.Stretch) e.Graphics.DrawImage(BackgroundImage, new Rectangle(0, 0, Width, Height + 9));
+ }
+
if (Selected)
{
- if (SaveSystem.currentTheme != null) e.Graphics.Clear(SaveSystem.currentTheme.selectedBackColor);
- else e.Graphics.Clear(Color.Navy);
+ if (SaveSystem.currentTheme != null && DoBackColorAdapt) 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;
-
- e.Graphics.DrawImage(Image, 0 + Padding.Left - Padding.Right, 0);
+
+ 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) {
- e.Graphics.DrawString(Text, new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular), Brushes.Black, 38, 11, sf);
+ switch (layout) {
+ case ClassicStartMenuItemLayout.DistancedTitle:
+ e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), imgWidth + 6, getYForString(), sf);
+ break;
+ case ClassicStartMenuItemLayout.CloseTitle:
+ e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), imgWidth + 2, getYForString(), 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(Pens.Black, new Point[] { new Point(121, 11), new Point(124, 14), new Point(121, 17) });
- e.Graphics.FillPolygon(Brushes.Black, new Point[] { new Point(121, 11), new Point(124, 14), new Point(121, 17) });
+ 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)
{
- e.Graphics.DrawString(Text, new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular), new SolidBrush(SaveSystem.currentTheme.selectedTextColor), 38, 11, sf);
+ switch (layout)
+ {
+ case ClassicStartMenuItemLayout.DistancedTitle:
+ e.Graphics.DrawString(Text, Font, new SolidBrush(SaveSystem.currentTheme.selectedTextColor), imgWidth + 6, getYForString(), sf);
+ break;
+ case ClassicStartMenuItemLayout.CloseTitle:
+ e.Graphics.DrawString(Text, Font, new SolidBrush(SaveSystem.currentTheme.selectedTextColor), imgWidth + 2, getYForString(), 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) });
@@ -53,5 +118,22 @@ namespace Histacom2.Engine.UI
}
}
}
+
+ private int getYForString()
+ {
+ if (Image != null)
+ {
+ if (Image.Height == 32) return 9;
+ if (Image.Height == 24) return 6;
+ }
+ return 0;
+ }
+ }
+ public enum ClassicStartMenuItemLayout
+ {
+ DistancedTitle,
+ CloseTitle,
+ CloseTitleWithTwoLines,
+ CloseTitleWithLightSubtitle
}
}