From ab9f118edb06826ed49c0b46bb1bce38d407e4f6 Mon Sep 17 00:00:00 2001 From: lempamo Date: Tue, 12 Sep 2017 09:51:26 -0400 Subject: various classic control things --- Histacom2.Engine/Histacom2.Engine.csproj | 3 +++ Histacom2.Engine/Paintbrush.cs | 1 + Histacom2.Engine/UI/ClassicButton.cs | 35 +++++++++++++++++++++++++------- Histacom2.Engine/UI/ClassicLabel.cs | 29 ++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 Histacom2.Engine/UI/ClassicLabel.cs (limited to 'Histacom2.Engine') diff --git a/Histacom2.Engine/Histacom2.Engine.csproj b/Histacom2.Engine/Histacom2.Engine.csproj index e8b62bc..69a1b02 100644 --- a/Histacom2.Engine/Histacom2.Engine.csproj +++ b/Histacom2.Engine/Histacom2.Engine.csproj @@ -94,6 +94,9 @@ Component + + Component + Component diff --git a/Histacom2.Engine/Paintbrush.cs b/Histacom2.Engine/Paintbrush.cs index 4424371..02cb49b 100644 --- a/Histacom2.Engine/Paintbrush.cs +++ b/Histacom2.Engine/Paintbrush.cs @@ -56,6 +56,7 @@ namespace Histacom2.Engine public static Color GetDarkFromColor(Color basecolor) { + if (basecolor == Color.Silver) return Color.Gray; if (basecolor == Color.FromArgb(112, 112, 112)) return Color.FromArgb(72, 72, 72); if (basecolor == Color.FromArgb(169, 200, 169)) return Color.FromArgb(95, 153, 95); return ControlPaint.Dark(basecolor, 70); diff --git a/Histacom2.Engine/UI/ClassicButton.cs b/Histacom2.Engine/UI/ClassicButton.cs index b761504..1a77964 100644 --- a/Histacom2.Engine/UI/ClassicButton.cs +++ b/Histacom2.Engine/UI/ClassicButton.cs @@ -8,14 +8,26 @@ using System.Windows.Forms; namespace Histacom2.Engine.UI { - public class ClassicButton : Control + public class ClassicButton : Control, IButtonControl { private Color _lightBack; private Color _darkBack; - private Font _font; private bool _pressing = false; + public DialogResult DialogResult + { + get + { + throw new NotImplementedException(); + } + + set + { + throw new NotImplementedException(); + } + } + public ClassicButton() : base() { if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; @@ -26,8 +38,8 @@ namespace Histacom2.Engine.UI if (SaveSystem.currentTheme != null) ForeColor = SaveSystem.currentTheme.threeDObjectsTextColor; else ForeColor = Color.Black; - if (SaveSystem.currentTheme != null) _font = SaveSystem.currentTheme.buttonFont; - else _font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); + if (SaveSystem.currentTheme != null) Font = SaveSystem.currentTheme.buttonFont; + else Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); MouseDown += (s, e) => { _pressing = true; Invalidate(); }; MouseUp += (s, e) => { _pressing = false; Invalidate(); }; @@ -59,7 +71,7 @@ namespace Histacom2.Engine.UI g.FillRectangle(new SolidBrush(_darkBack), new Rectangle(1, 1, Width - 2, Height - 2)); g.FillRectangle(new SolidBrush(BackColor), new Rectangle(2, 2, Width - 3, Height - 3)); - g.DrawString(Text, _font, new SolidBrush(ForeColor), ((Width / 2) + 1) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 2, sf); + g.DrawString(Text, Font, new SolidBrush(ForeColor), ((Width / 2) + 1) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 2, sf); } else { @@ -68,9 +80,18 @@ namespace Histacom2.Engine.UI g.FillRectangle(new SolidBrush(_darkBack), new Rectangle(1, 1, Width - 2, Height - 2)); g.FillRectangle(new SolidBrush(BackColor), new Rectangle(1, 1, Width - 3, Height - 3)); - g.DrawString(Text, _font, new SolidBrush(ForeColor), (Width / 2) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 1, sf); + g.DrawString(Text, Font, new SolidBrush(ForeColor), (Width / 2) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 1, sf); } } - + + public void NotifyDefault(bool value) + { + + } + + public void PerformClick() + { + this.OnClick(new EventArgs()); + } } } diff --git a/Histacom2.Engine/UI/ClassicLabel.cs b/Histacom2.Engine/UI/ClassicLabel.cs new file mode 100644 index 0000000..0b9d9c2 --- /dev/null +++ b/Histacom2.Engine/UI/ClassicLabel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Histacom2.Engine.UI +{ + public class ClassicLabel : Control + { + public ClassicLabel() + { + + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + var gfx = e.Graphics; + gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + + gfx.DrawString(Text, Font, new SolidBrush(ForeColor), 0, 0); + } + } +} -- cgit v1.2.3