aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Engine
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-08-22 20:44:03 -0400
committerlempamo <[email protected]>2017-08-22 20:44:03 -0400
commit99fef5c57360f07259fc86f433bed8a9ab59c48e (patch)
tree7b6bd1bc591dd2fdbcb11313901aca898f552a2c /TimeHACK.Engine
parent085ae85fd59c87df05e8f58009f04cdfc2bd7d8d (diff)
downloadhistacom2-99fef5c57360f07259fc86f433bed8a9ab59c48e.tar.gz
histacom2-99fef5c57360f07259fc86f433bed8a9ab59c48e.tar.bz2
histacom2-99fef5c57360f07259fc86f433bed8a9ab59c48e.zip
gtn things
Diffstat (limited to 'TimeHACK.Engine')
-rw-r--r--TimeHACK.Engine/TimeHACK.Engine.csproj12
-rw-r--r--TimeHACK.Engine/UI/ClassicButton.Designer.cs91
-rw-r--r--TimeHACK.Engine/UI/ClassicButton.cs58
-rw-r--r--TimeHACK.Engine/UI/ClassicButton.resx120
-rw-r--r--TimeHACK.Engine/UI/IProgressBar.cs234
5 files changed, 515 insertions, 0 deletions
diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj
index f326107..056d4dc 100644
--- a/TimeHACK.Engine/TimeHACK.Engine.csproj
+++ b/TimeHACK.Engine/TimeHACK.Engine.csproj
@@ -78,6 +78,15 @@
<DependentUpon>WinClassic.cs</DependentUpon>
</Compile>
<Compile Include="Theme.cs" />
+ <Compile Include="UI\ClassicButton.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="UI\ClassicButton.Designer.cs">
+ <DependentUpon>ClassicButton.cs</DependentUpon>
+ </Compile>
+ <Compile Include="UI\IProgressBar.cs">
+ <SubType>Component</SubType>
+ </Compile>
<Compile Include="WindowManager.cs" />
<Compile Include="MessageParser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -104,6 +113,9 @@
<EmbeddedResource Include="Template\WinClassic.resx">
<DependentUpon>WinClassic.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\ClassicButton.resx">
+ <DependentUpon>ClassicButton.cs</DependentUpon>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\chord.wav" />
diff --git a/TimeHACK.Engine/UI/ClassicButton.Designer.cs b/TimeHACK.Engine/UI/ClassicButton.Designer.cs
new file mode 100644
index 0000000..b6033b2
--- /dev/null
+++ b/TimeHACK.Engine/UI/ClassicButton.Designer.cs
@@ -0,0 +1,91 @@
+namespace TimeHACK.Engine.UI
+{
+ partial class ClassicButton
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ 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/TimeHACK.Engine/UI/ClassicButton.cs b/TimeHACK.Engine/UI/ClassicButton.cs
new file mode 100644
index 0000000..e61b564
--- /dev/null
+++ b/TimeHACK.Engine/UI/ClassicButton.cs
@@ -0,0 +1,58 @@
+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;
+using System.Windows.Forms;
+
+namespace TimeHACK.Engine.UI
+{
+ public partial class ClassicButton : UserControl
+ {
+ public ClassicButton()
+ {
+ InitializeComponent();
+ }
+
+ private void ClassicButton_SizeChanged(object sender, EventArgs e)
+ {
+
+ }
+
+ private void ClassicButton_MouseDown(object sender, MouseEventArgs e)
+ {
+ this.BackColor = Color.White;
+ borderpart.BackColor = Color.Black;
+ lessgraystuff.Location = new Point(1, 1);
+ }
+
+ private void ClassicButton_Paint(object sender, PaintEventArgs e)
+ {
+ e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ base.OnPaint(e);
+ }
+
+ private void lessgraystuff_Paint(object sender, PaintEventArgs e)
+ {
+ e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ base.OnPaint(e);
+ }
+
+ private void ClassicButton_MouseUp(object sender, MouseEventArgs 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);
+ }
+ }
+} \ No newline at end of file
diff --git a/TimeHACK.Engine/UI/ClassicButton.resx b/TimeHACK.Engine/UI/ClassicButton.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/TimeHACK.Engine/UI/ClassicButton.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/TimeHACK.Engine/UI/IProgressBar.cs b/TimeHACK.Engine/UI/IProgressBar.cs
new file mode 100644
index 0000000..d16debf
--- /dev/null
+++ b/TimeHACK.Engine/UI/IProgressBar.cs
@@ -0,0 +1,234 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace TimeHACK.UI
+{
+ public class ProgressBar : Control
+ {
+ private Color _pColor = Color.DarkBlue;
+ private ProgressBarStyle _style = ProgressBarStyle.Continuous;
+
+ private Timer RedrawTimer = null;
+
+ public Color ProgressColor
+ {
+ get
+ {
+ return _pColor;
+ }
+ set
+ {
+ _pColor = value; Refresh();
+ }
+ }
+
+
+ public ProgressBarStyle Style
+ {
+ get
+ {
+ return _style;
+ }
+ set
+ {
+ _style = value; Refresh();
+ }
+ }
+
+
+ private double _max = 100.0;
+ private double _min = 0.0;
+
+ public double Maximum
+ {
+ get
+ {
+ return _max;
+ }
+ set
+ {
+ _max = value; Refresh();
+ }
+ }
+ public double Minimum
+ {
+ get
+ {
+ return _min;
+ }
+ set
+ {
+ _min = value; Refresh();
+ }
+ }
+
+
+ private int _blockWidth = 14;
+
+ public int BlockWidth
+ {
+ get
+ {
+ return _blockWidth;
+ }
+ set
+ {
+ _blockWidth = value;
+ Refresh();
+ }
+ }
+
+ private int _blockSpacing = 2;
+
+ public int BlockSpacing
+ {
+ get
+ {
+ return _blockSpacing;
+ }
+ set
+ {
+ _blockSpacing = value;
+ Refresh();
+ }
+ }
+
+ public ProgressBar() : base()
+ {
+ MarqueeWidth = 125;
+ BlockWidth = 20;
+ BlockSpacing = 5;
+ Minimum = 0.00;
+ Maximum = 100.0;
+ Style = ProgressBarStyle.Continuous;
+ ProgressColor = Color.DarkBlue;
+ RedrawTimer = new Timer();
+ RedrawTimer.Tick += (o, a) =>
+ {
+ if (this.Style == ProgressBarStyle.Marquee)
+ {
+ if (_marqueePos >= this.Width)
+ _marqueePos = 0;
+ else
+ _marqueePos++;
+ this.Refresh();
+ }
+ };
+ RedrawTimer.Interval = 50;
+ }
+
+ private double _value = 0.00;
+
+ public double Value
+ {
+ get
+ {
+ return _value;
+ }
+ set
+ {
+ if (value < Minimum || value > Maximum)
+ throw new ArgumentOutOfRangeException("The value is outside the minimum and maximum range.");
+ this.Refresh();
+ _value = value;
+ }
+ }
+
+ private int _marqueeWidth = 14;
+
+ public int MarqueeWidth
+ {
+ get
+ {
+ return _marqueeWidth;
+ }
+ set
+ {
+ _marqueeWidth = value;
+ Refresh();
+ }
+ }
+
+ private bool _showText = false;
+
+ public bool ShowText
+ {
+ get
+ {
+ return _showText;
+ }
+ set
+ {
+ _showText = value;
+ Refresh();
+ }
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ if (Visible)
+ RedrawTimer.Start();
+ else
+ RedrawTimer.Stop();
+ }
+
+ private int _marqueePos = 0;
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+ var g = e.Graphics;
+ g.Clear(BackColor);
+ //Stolen from the ShiftOS code :3
+ switch (Style)
+ {
+ case ProgressBarStyle.Continuous:
+ double width = linear(this.Value, this.Minimum, this.Maximum, 0, this.Width);
+ g.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height));
+ break;
+ case ProgressBarStyle.Blocks:
+ int block_count = this.Width / (this.BlockWidth + this.BlockSpacing);
+ int blocks = (int)linear(this.Value, this.Minimum, this.Maximum, 0, block_count);
+ for (int i = 0; i < blocks - 1; i++)
+ {
+ int position = i * (BlockWidth + BlockSpacing);
+ g.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockWidth, this.Height));
+ }
+ break;
+ case ProgressBarStyle.Marquee:
+ g.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, MarqueeWidth, this.Height));
+ break;
+ }
+ if (ShowText)
+ {
+ var f = this.Font;
+ var t = this.Text;
+ var size = g.MeasureString(t, f);
+ var loc = new PointF(
+ (this.Width - size.Width) / 2,
+ (this.Height - size.Height) / 2
+ );
+ var color = this.ForeColor;
+ g.DrawString(t, f, new SolidBrush(color), loc);
+ }
+
+ }
+
+ ///<summary>
+ /// Simple linear interpolation algorithm. (http://stackoverflow.com/questions/12838007/c-sharp-linear-interpolation)
+ /// </summary>
+ private double linear(double x, double x0, double x1, double y0, double y1)
+ {
+ if ((x1 - x0) == 0)
+ {
+ return (y0 + y1) / 2;
+ }
+ return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
+ }
+ }
+}