diff --git a/src/Taskbar/Enum/Enums.cs b/src/Taskbar/Enum/Enums.cs new file mode 100644 index 0000000..c85d69f --- /dev/null +++ b/src/Taskbar/Enum/Enums.cs @@ -0,0 +1,123 @@ +namespace Taskbar.Enum +{ + /// + /// + /// + public class Enums + { + #region Enums + /// + /// + /// + public enum LocationType + { + /// + /// + /// + Unknown = -1, + /// + /// + /// + Left, + /// + /// + /// + Top, + /// + /// + /// + Right, + /// + /// + /// + Bot + } + + /// + /// + /// + public enum EdgeType : uint + { + /// + /// + /// + Left = 0, + /// + /// + /// + Top = 1, + /// + /// + /// + Right = 2, + /// + /// + /// + Bottom = 3 + } + + /// + /// + /// + public enum MessageType : uint + { + /// + /// + /// + New = 0x00000000, + /// + /// + /// + Remove = 0x00000001, + /// + /// + /// + QueryPos = 0x00000002, + /// + /// + /// + SetPos = 0x00000003, + /// + /// + /// + GetState = 0x00000004, + /// + /// + /// + GetTaskbarPos = 0x00000005, + /// + /// + /// + Activate = 0x00000006, + /// + /// + /// + GetAutoHideBar = 0x00000007, + /// + /// + /// + SetAutoHideBar = 0x00000008, + /// + /// + /// + WindowPosChanged = 0x00000009, + /// + /// + /// + SetState = 0x0000000A, + } + + public enum StateType + { + /// + /// + /// + Hide = 0x01, + /// + /// + /// + Show = 0x02 + } + #endregion + } +} \ No newline at end of file diff --git a/src/Taskbar/Taskbar.cs b/src/Taskbar/Taskbar.cs index 5c4ddf0..2310a07 100644 --- a/src/Taskbar/Taskbar.cs +++ b/src/Taskbar/Taskbar.cs @@ -1,5 +1,11 @@ #region Imports +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using Taskbar.Enum; #endregion @@ -19,11 +25,108 @@ namespace Taskbar public class Taskbar { - public const string Author = "Taiizor"; + /// + /// + /// + private const string Exception = "It only works on the Windows platform."; + /// + /// + /// + private const string OnlyWindows = "It only works on the Windows platform."; - public void Detect() + /// + /// + /// + public class Simple { + /// + /// + /// + /// + /// + private static Enums.LocationType Detect(Screen Screen) + { + if (Screen.WorkingArea.Width == Screen.Bounds.Width) + { + if (Screen.WorkingArea.Top > 0) + { + return Enums.LocationType.Top; + } + else + { + return Enums.LocationType.Bot; + } + } + else + { + if (Screen.WorkingArea.Left > 0) + { + return Enums.LocationType.Left; + } + else + { + return Enums.LocationType.Right; + } + } + } + /// + /// + /// + public static Enums.LocationType SingleDetect + { + get + { + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Detect(Screen.PrimaryScreen); + } + else + { + throw new Exception(OnlyWindows); + } + } + catch + { + throw new Exception(Exception); + } + } + } + + /// + /// + /// + public static Dictionary MultiDetect + { + get + { + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Dictionary Type = new(); + int Count = 0; + + foreach (Screen Screen in Screen.AllScreens) + { + Type.Add(Count++, Detect(Screen)); + } + + return Type; + } + else + { + throw new Exception(OnlyWindows); + } + } + catch + { + throw new Exception(Exception); + } + } + } } } diff --git a/src/Taskbar/Taskbar.csproj b/src/Taskbar/Taskbar.csproj index f6a02d9..196f4f8 100644 --- a/src/Taskbar/Taskbar.csproj +++ b/src/Taskbar/Taskbar.csproj @@ -53,6 +53,10 @@ Changes are detailed at https://github.com/Soferity/Taskbar/releases + + + + True diff --git a/src/Taskbar_CR/Form1.Designer.cs b/src/Taskbar_CR/Form1.Designer.cs index ff8156b..f568300 100644 --- a/src/Taskbar_CR/Form1.Designer.cs +++ b/src/Taskbar_CR/Form1.Designer.cs @@ -30,116 +30,47 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.button1 = new System.Windows.Forms.Button(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.radioButton1 = new System.Windows.Forms.RadioButton(); - this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(72, 45); + this.button1.Location = new System.Drawing.Point(12, 12); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.Size = new System.Drawing.Size(150, 64); this.button1.TabIndex = 0; - this.button1.Text = "button1"; + this.button1.Text = "Simple\r\nSingle Detect"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.Button1_Click); // - // comboBox1 + // button2 // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(346, 316); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(121, 21); - this.comboBox1.TabIndex = 1; - // - // groupBox1 - // - this.groupBox1.Location = new System.Drawing.Point(35, 293); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 100); - this.groupBox1.TabIndex = 2; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "groupBox1"; - // - // radioButton1 - // - this.radioButton1.AutoSize = true; - this.radioButton1.Location = new System.Drawing.Point(358, 135); - this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(85, 17); - this.radioButton1.TabIndex = 3; - this.radioButton1.TabStop = true; - this.radioButton1.Text = "radioButton1"; - this.radioButton1.UseVisualStyleBackColor = true; - // - // vScrollBar1 - // - this.vScrollBar1.Location = new System.Drawing.Point(299, 190); - this.vScrollBar1.Name = "vScrollBar1"; - this.vScrollBar1.Size = new System.Drawing.Size(17, 80); - this.vScrollBar1.TabIndex = 4; - // - // pictureBox1 - // - this.pictureBox1.BackColor = System.Drawing.Color.Red; - this.pictureBox1.Location = new System.Drawing.Point(331, 392); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(100, 68); - this.pictureBox1.TabIndex = 5; - this.pictureBox1.TabStop = false; - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(299, 45); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(100, 20); - this.textBox1.TabIndex = 6; - // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(85, 135); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(100, 23); - this.progressBar1.TabIndex = 7; - this.progressBar1.Value = 50; + this.button2.Location = new System.Drawing.Point(171, 12); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(150, 64); + this.button2.TabIndex = 1; + this.button2.Text = "Simple\r\nMulti Detect"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.Button2_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(496, 473); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.vScrollBar1); - this.Controls.Add(this.radioButton1); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.comboBox1); + this.ClientSize = new System.Drawing.Size(333, 473); + this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion private System.Windows.Forms.Button button1; - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.RadioButton radioButton1; - private System.Windows.Forms.VScrollBar vScrollBar1; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Button button2; } } \ No newline at end of file diff --git a/src/Taskbar_CR/Form1.cs b/src/Taskbar_CR/Form1.cs index 07429b8..3f5bcd4 100644 --- a/src/Taskbar_CR/Form1.cs +++ b/src/Taskbar_CR/Form1.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using System.Windows.Forms; +using Taskbar.Enum; +using static Taskbar.Taskbar; namespace Taskbar_CR { @@ -9,5 +12,20 @@ public Form1() { InitializeComponent(); } + + private void Button1_Click(object sender, EventArgs e) + { + MessageBox.Show(Simple.SingleDetect.ToString()); + } + + private void Button2_Click(object sender, EventArgs e) + { + Dictionary Screen = Simple.MultiDetect; + + foreach (KeyValuePair Var in Screen) + { + MessageBox.Show(Var.Key + ": " + Var.Value); + } + } } } \ No newline at end of file