From c23e42cc396d4fc55799d659bae2149cc183dbf6 Mon Sep 17 00:00:00 2001 From: FloppyDiskDrive Date: Sun, 1 Oct 2017 09:49:14 -0500 Subject: Added a fuckton of changes New infobox icons, new WIP port of Snakey, we are getting closer to a pre-alpha! --- .../ShiftOS/Apps/ShifterStuff/SelectColor.cs | 10 +- ShiftOS.Main/ShiftOS/Apps/Snakey.Designer.cs | 93 ++++++++++++ ShiftOS.Main/ShiftOS/Apps/Snakey.cs | 123 +++++++++++++++ ShiftOS.Main/ShiftOS/Apps/Snakey.resx | 120 +++++++++++++++ ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs | 168 +++++++++++---------- ShiftOS.Main/ShiftOS/Apps/TestForm.cs | 24 ++- 6 files changed, 446 insertions(+), 92 deletions(-) create mode 100644 ShiftOS.Main/ShiftOS/Apps/Snakey.Designer.cs create mode 100644 ShiftOS.Main/ShiftOS/Apps/Snakey.cs create mode 100644 ShiftOS.Main/ShiftOS/Apps/Snakey.resx (limited to 'ShiftOS.Main/ShiftOS/Apps') diff --git a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs index 697e22e..5eb5faa 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs @@ -27,12 +27,12 @@ namespace ShiftOS.Main.ShiftOS.Apps } catch(FormatException ex) { - ShiftWM.StartInfoboxSession("Error!", "Failed to parse integer. Error:\n" + ex, InfoboxTemplate.ButtonType.Ok); + ShiftWM.StartInfoboxSession("Error!", "Failed to parse integer. Error:\n" + ex, InfoboxTemplate.ButtonType.Ok, InfoboxTemplate.ErrorIcon.Critical); } if (_colorType1 > 255 || _colorType2 > 255 || _colorType3 > 255) { - ShiftWM.StartInfoboxSession("Error!", "A value cannot be greater than 255!", InfoboxTemplate.ButtonType.Ok); + ShiftWM.StartInfoboxSession("Error!", "A value cannot be greater than 255!", InfoboxTemplate.ButtonType.Ok, InfoboxTemplate.ErrorIcon.Critical); } else { @@ -40,12 +40,12 @@ namespace ShiftOS.Main.ShiftOS.Apps { ShiftWindow sw = new ShiftWindow(); _finalColor = Color.FromArgb(_colorType1, _colorType2, _colorType3); - BackColor = _finalColor; - ShiftWM.StartInfoboxSession("Success!", "Changed color to:\n" + _colorType1.ToString() + ", " + _colorType2.ToString() + ", " + _colorType3.ToString() + ".", InfoboxTemplate.ButtonType.Ok); + ShiftWM.SetTitleBarColor(_finalColor); + ShiftWM.StartInfoboxSession("Success!", "Changed color to:\n" + _colorType1.ToString() + ", " + _colorType2.ToString() + ", " + _colorType3.ToString() + ".", InfoboxTemplate.ButtonType.Ok, InfoboxTemplate.ErrorIcon.Info); } catch (Exception) { - ShiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok); + ShiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok, InfoboxTemplate.ErrorIcon.Critical); } } } diff --git a/ShiftOS.Main/ShiftOS/Apps/Snakey.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/Snakey.Designer.cs new file mode 100644 index 0000000..bef7a6b --- /dev/null +++ b/ShiftOS.Main/ShiftOS/Apps/Snakey.Designer.cs @@ -0,0 +1,93 @@ +namespace ShiftOS.Main.ShiftOS.Apps +{ + partial class Snakey + { + /// + /// 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.length = new System.Windows.Forms.Label(); + this.speed = new System.Windows.Forms.Label(); + this.score = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // length + // + this.length.AutoSize = true; + this.length.BackColor = System.Drawing.Color.Transparent; + this.length.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.length.ForeColor = System.Drawing.Color.White; + this.length.Location = new System.Drawing.Point(573, 18); + this.length.Name = "length"; + this.length.Size = new System.Drawing.Size(76, 20); + this.length.TabIndex = 16; + this.length.Text = "Length: 5"; + // + // speed + // + this.speed.AutoSize = true; + this.speed.BackColor = System.Drawing.Color.Transparent; + this.speed.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.speed.ForeColor = System.Drawing.Color.White; + this.speed.Location = new System.Drawing.Point(287, 18); + this.speed.Name = "speed"; + this.speed.Size = new System.Drawing.Size(73, 20); + this.speed.TabIndex = 15; + this.speed.Text = "Speed: 1"; + // + // score + // + this.score.AutoSize = true; + this.score.BackColor = System.Drawing.Color.Transparent; + this.score.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.score.ForeColor = System.Drawing.Color.White; + this.score.Location = new System.Drawing.Point(24, 18); + this.score.Name = "score"; + this.score.Size = new System.Drawing.Size(100, 20); + this.score.TabIndex = 14; + this.score.Text = "Total Points: "; + // + // Snakey + // + 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.length); + this.Controls.Add(this.speed); + this.Controls.Add(this.score); + this.Name = "Snakey"; + this.Size = new System.Drawing.Size(673, 447); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label length; + internal System.Windows.Forms.Label speed; + internal System.Windows.Forms.Label score; + } +} diff --git a/ShiftOS.Main/ShiftOS/Apps/Snakey.cs b/ShiftOS.Main/ShiftOS/Apps/Snakey.cs new file mode 100644 index 0000000..d8d4a98 --- /dev/null +++ b/ShiftOS.Main/ShiftOS/Apps/Snakey.cs @@ -0,0 +1,123 @@ +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; +using System.Drawing.Drawing2D; +using ShiftOS.Engine; +using ShiftOS.Main.Properties; + +namespace ShiftOS.Main.ShiftOS.Apps +{ + public partial class Snakey : UserControl + { + public Snakey() + { + InitializeComponent(); + } + private struct structSnake + { + public Rectangle rect; + public int x; + public int y; + } + private enum directions + { + Rightward, + Downward, + Leftward, + Upward + } + #region Various-Objects + private const int INTIAL_SNAKE_RECT_COUNT = 5; + private const int COLUMN_COUNT = 65; + private const int ROW_COUNT = 47; + private int curRecCount; + private Rectangle[,] Rects; + + + private bool [,] isSnakePart; + private List snake; + private Brush snakeBrush = new SolidBrush(Color.FromArgb(255, 255, 255)); + private Brush backBrush = new SolidBrush(Color.FromArgb(1, 1, 1)); + private Brush tokenBrush = new SolidBrush(Color.FromArgb(255, 255, 255)); + private directions curDirection; + private Bitmap buffer; + private int columnCount; + private int rowCount; + private int snakePoints; + private double snakeSpeed; + private int snakeLength; + private Rectangle token; + #endregion + private int xyIndexToRect(int X, int Y) + { + return (Y * (columnCount)) + X; + } + private void rectToIndexXY(double index, double X, double Y) + { + X = index % (columnCount); + Y = Math.Round(index / columnCount); + } + private void initSnake() + { + int x; + int y; + int index; + snake = new List(); + structSnake sSnake = new structSnake(); + x = ((columnCount) - 10 / 2); + y = ((rowCount) - 6) / 2; + Point snakePosition = new Point(x, y); + index = xyIndexToRect(x, y); + for (int i = 0; i < INTIAL_SNAKE_RECT_COUNT; i++) + { + rectToIndexXY(index + (i - 1), x, y); + sSnake.rect = Rects[x, y]; + sSnake.x = x; + sSnake.y = y; + snake.Add(sSnake); + } + snakeLength = INTIAL_SNAKE_RECT_COUNT; + snakeSpeed = 1; + length.Text = "Length: " + snakeLength.ToString(); + speed.Text = "Speed: " + snakeSpeed.ToString(); + } + private void selectRectangles() + { + Graphics g = Graphics.FromImage(Resources.snakeyback); + int i; + structSnake sSnake = new structSnake(); + for (i = 0; i < INTIAL_SNAKE_RECT_COUNT; i++) + { + sSnake = snake[i]; + g.FillRectangle(snakeBrush, sSnake.rect); + isSnakePart[sSnake.x, sSnake.y] = true; + } + buffer = new Bitmap(Resources.snakeyback); + g.Dispose(); + Refresh(); + } + private void initRectangles() + { + int i; + int j; + columnCount = COLUMN_COUNT; + rowCount = ROW_COUNT; + Rects = new Rectangle[columnCount, rowCount]; + isSnakePart = new bool[columnCount, rowCount]; + for (j = 0; j < rowCount; j++) + { + for (i = 0; i < columnCount; i++) + { + //TO-DO: I can't really port this over right now. Commiting soon. -FDD + } + } + } + } +} + diff --git a/ShiftOS.Main/ShiftOS/Apps/Snakey.resx b/ShiftOS.Main/ShiftOS/Apps/Snakey.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.Main/ShiftOS/Apps/Snakey.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs index 50bcb58..53765bd 100644 --- a/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs +++ b/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs @@ -28,60 +28,57 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.systemIconsBindingSource = new System.Windows.Forms.BindingSource(this.components); - ((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).BeginInit(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(18, 20); - this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(388, 26); - this.textBox1.TabIndex = 0; - this.textBox1.Text = "Title"; - // - // textBox2 - // - this.textBox2.Location = new System.Drawing.Point(18, 60); - this.textBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(388, 26); - this.textBox2.TabIndex = 1; - this.textBox2.Text = "Contents"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(13, 149); - this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(192, 35); - this.button1.TabIndex = 2; - this.button1.Text = "Create Window"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.Button1_Click); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(217, 149); - this.button2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(189, 35); - this.button2.TabIndex = 4; - this.button2.Text = "Test Shifter"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // comboBox1 - // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { + this.components = new System.ComponentModel.Container(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.systemIconsBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.panel1 = new System.Windows.Forms.Panel(); + ((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).BeginInit(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(12, 13); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(260, 20); + this.textBox1.TabIndex = 0; + this.textBox1.Text = "Title"; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(12, 39); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(260, 20); + this.textBox2.TabIndex = 1; + this.textBox2.Text = "Contents"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(9, 97); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(128, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Create Window"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.Button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(145, 97); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(126, 23); + this.button2.TabIndex = 4; + this.button2.Text = "Test Shifter"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { "Application", "Asterisk", "Error", @@ -92,31 +89,41 @@ "Shield", "Warning", "WinLogo"}); - this.comboBox1.Location = new System.Drawing.Point(18, 104); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(388, 28); - this.comboBox1.TabIndex = 5; - // - // systemIconsBindingSource - // - this.systemIconsBindingSource.DataSource = typeof(System.Drawing.SystemIcons); - // - // TestForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(426, 198); - this.Controls.Add(this.comboBox1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.Controls.Add(this.textBox2); - this.Controls.Add(this.textBox1); - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.Name = "TestForm"; - this.Text = "TestForm"; - ((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.comboBox1.Location = new System.Drawing.Point(12, 68); + this.comboBox1.Margin = new System.Windows.Forms.Padding(2); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(260, 21); + this.comboBox1.TabIndex = 5; + // + // systemIconsBindingSource + // + this.systemIconsBindingSource.DataSource = typeof(System.Drawing.SystemIcons); + // + // panel1 + // + this.panel1.BackColor = System.Drawing.SystemColors.ControlDarkDark; + this.panel1.Location = new System.Drawing.Point(71, 138); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 37); + this.panel1.TabIndex = 6; + this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseMove); + // + // TestForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 175); + this.Controls.Add(this.panel1); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Name = "TestForm"; + this.Text = "TestForm"; + ((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -128,5 +135,6 @@ private System.Windows.Forms.Button button2; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.BindingSource systemIconsBindingSource; - } + private System.Windows.Forms.Panel panel1; + } } \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/TestForm.cs b/ShiftOS.Main/ShiftOS/Apps/TestForm.cs index 1fd3b18..e8360e0 100644 --- a/ShiftOS.Main/ShiftOS/Apps/TestForm.cs +++ b/ShiftOS.Main/ShiftOS/Apps/TestForm.cs @@ -10,6 +10,7 @@ namespace ShiftOS.Main { public partial class TestForm : Form { + Point loc; public TestForm() { InitializeComponent(); @@ -17,16 +18,25 @@ namespace ShiftOS.Main private void Button1_Click(object sender, EventArgs e) { - ShiftDemo demo = new ShiftDemo {label1 = {Text = textBox2.Text}}; + ShiftDemo demo = new ShiftDemo { label1 = { Text = textBox2.Text } }; - var item = typeof(SystemIcons).GetProperties() - .First(p => p.Name == comboBox1.SelectedItem as string); + var item = typeof(SystemIcons).GetProperties() + .First(p => p.Name == comboBox1.SelectedItem as string); - ShiftWM.Init(demo, textBox1.Text, (item.GetMethod.Invoke(null, new object[0]) as Icon)); - ShiftWM.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.ButtonType.Ok); + ShiftWM.Init(demo, textBox1.Text, (item.GetMethod.Invoke(null, new object[0]) as Icon)); + ShiftWM.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.ButtonType.Ok, InfoboxTemplate.ErrorIcon.Critical); } - private void button2_Click(object sender, EventArgs e) - => ShiftWM.Init(new Shifter(), "Shifter", Properties.Resources.iconShifter.ToIcon()); + private void button2_Click(object sender, EventArgs e) + => ShiftWM.Init(new Shifter(), "Shifter", Properties.Resources.iconShifter.ToIcon()); + + private void panel1_MouseMove(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + loc = new Point(Cursor.Position.X, Cursor.Position.Y); + this.Location = loc; + } + } } } -- cgit v1.2.3