From 1a970e69dada088c5f5ea82dd5683da9ae306ebe Mon Sep 17 00:00:00 2001 From: lempamo Date: Mon, 4 Sep 2017 20:14:19 -0400 Subject: new classic buttons! --- Histacom2.Engine/UI/ClassicButton.Designer.cs | 91 ------------------- Histacom2.Engine/UI/ClassicButton.cs | 77 ++++++++-------- Histacom2.Engine/UI/ClassicButton.resx | 123 -------------------------- 3 files changed, 40 insertions(+), 251 deletions(-) delete mode 100644 Histacom2.Engine/UI/ClassicButton.Designer.cs delete mode 100644 Histacom2.Engine/UI/ClassicButton.resx (limited to 'Histacom2.Engine/UI') diff --git a/Histacom2.Engine/UI/ClassicButton.Designer.cs b/Histacom2.Engine/UI/ClassicButton.Designer.cs deleted file mode 100644 index c76bba0..0000000 --- a/Histacom2.Engine/UI/ClassicButton.Designer.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace Histacom2.Engine.UI -{ - partial class ClassicButton - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.borderpart = new System.Windows.Forms.Panel(); - this.graystuff = new System.Windows.Forms.Panel(); - this.lessgraystuff = new System.Windows.Forms.Label(); - this.borderpart.SuspendLayout(); - this.graystuff.SuspendLayout(); - this.SuspendLayout(); - // - // borderpart - // - this.borderpart.BackColor = System.Drawing.Color.White; - this.borderpart.Controls.Add(this.graystuff); - this.borderpart.Location = new System.Drawing.Point(0, 0); - this.borderpart.Name = "borderpart"; - this.borderpart.Size = new System.Drawing.Size(99, 24); - this.borderpart.TabIndex = 0; - // - // graystuff - // - this.graystuff.BackColor = System.Drawing.Color.Gray; - this.graystuff.Controls.Add(this.lessgraystuff); - this.graystuff.Location = new System.Drawing.Point(1, 1); - this.graystuff.Name = "graystuff"; - this.graystuff.Size = new System.Drawing.Size(98, 23); - this.graystuff.TabIndex = 0; - // - // lessgraystuff - // - this.lessgraystuff.BackColor = System.Drawing.Color.Silver; - this.lessgraystuff.Location = new System.Drawing.Point(0, 0); - this.lessgraystuff.Margin = new System.Windows.Forms.Padding(0); - this.lessgraystuff.Name = "lessgraystuff"; - this.lessgraystuff.Size = new System.Drawing.Size(97, 22); - this.lessgraystuff.TabIndex = 0; - this.lessgraystuff.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lessgraystuff.Paint += new System.Windows.Forms.PaintEventHandler(this.lessgraystuff_Paint); - // - // ClassicButton - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.borderpart); - this.Name = "ClassicButton"; - this.Size = new System.Drawing.Size(100, 25); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.ClassicButton_Paint); - this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ClassicButton_MouseDown); - this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ClassicButton_MouseUp); - this.Resize += new System.EventHandler(this.ClassicButton_Resize); - this.borderpart.ResumeLayout(false); - this.graystuff.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel borderpart; - private System.Windows.Forms.Panel graystuff; - private System.Windows.Forms.Label lessgraystuff; - } -} diff --git a/Histacom2.Engine/UI/ClassicButton.cs b/Histacom2.Engine/UI/ClassicButton.cs index 26629a8..e82a742 100644 --- a/Histacom2.Engine/UI/ClassicButton.cs +++ b/Histacom2.Engine/UI/ClassicButton.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,49 +8,54 @@ using System.Windows.Forms; namespace Histacom2.Engine.UI { - public partial class ClassicButton : UserControl + public class ClassicButton : Control { - public ClassicButton() - { - InitializeComponent(); - } - - private void ClassicButton_SizeChanged(object sender, EventArgs e) - { + private Color _lightBack = Color.White; + private Color _darkBack = Color.Gray; - } + private bool _pressing = false; - private void ClassicButton_MouseDown(object sender, MouseEventArgs e) + public ClassicButton() : base() { - this.BackColor = Color.White; - borderpart.BackColor = Color.Black; - lessgraystuff.Location = new Point(1, 1); - } + if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; + else BackColor = Color.Silver; + _lightBack = ControlPaint.Light(BackColor, 50); + _darkBack = ControlPaint.Dark(BackColor, 50); - private void ClassicButton_Paint(object sender, PaintEventArgs e) - { - e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - base.OnPaint(e); - } + if (SaveSystem.currentTheme != null) ForeColor = SaveSystem.currentTheme.threeDObjectsTextColor; + else ForeColor = Color.Black; - private void lessgraystuff_Paint(object sender, PaintEventArgs e) - { - e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - base.OnPaint(e); + MouseDown += (s, e) => { _pressing = true; Invalidate(); }; + MouseUp += (s, e) => { _pressing = false; Invalidate(); }; } - private void ClassicButton_MouseUp(object sender, MouseEventArgs e) + protected override void OnPaint(PaintEventArgs e) { - this.BackColor = Color.Black; - borderpart.BackColor = Color.White; - lessgraystuff.Location = new Point(0, 0); - } - - private void ClassicButton_Resize(object sender, EventArgs e) - { - borderpart.Size = new Size(this.Width - 1, this.Height - 1); - graystuff.Size = new Size(this.Width - 2, this.Height - 2); - lessgraystuff.Size = new Size(this.Width - 3, this.Height - 3); + base.OnPaint(e); + var g = e.Graphics; + g.Clear(BackColor); + + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + + if (_pressing) + { + g.FillRectangle(new SolidBrush(_lightBack), new Rectangle(0, 0, Width, Height)); + g.FillRectangle(Brushes.Black, new Rectangle(0, 0, Width - 1, Height - 1)); + 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) - (g.MeasureString(Text, Font).Width / 2) + 1, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 1); + } + else + { + g.FillRectangle(Brushes.Black, new Rectangle(0, 0, Width, Height)); + g.FillRectangle(new SolidBrush(_lightBack), new Rectangle(0, 0, Width - 1, Height - 1)); + 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) - (g.MeasureString(Text, Font).Width / 2), (Height / 2) - (g.MeasureString(Text, Font).Height / 2)); + } } + } -} \ No newline at end of file +} diff --git a/Histacom2.Engine/UI/ClassicButton.resx b/Histacom2.Engine/UI/ClassicButton.resx deleted file mode 100644 index d5494e3..0000000 --- a/Histacom2.Engine/UI/ClassicButton.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file -- cgit v1.2.3