From 42dca92454e38840815302165a900e411acef5a9 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 30 Mar 2020 11:48:24 +0100 Subject: [PATCH] WIP: custom user control base --- LinearAppLauncher.csproj | 12 +++ MainForm.Designer.cs | 82 +++++++++++++++++++ MainForm.cs | 10 +++ Windows/Forms/AUserControl.cs | 75 +++++++++++++++++ Windows/Forms/HeadingPanel.cs | 12 +-- Windows/Forms/TilePanel.Designer.cs | 84 +++++++++++++++++++ Windows/Forms/TilePanel.cs | 27 +++++++ Windows/Forms/TilePanel.resx | 120 ++++++++++++++++++++++++++++ 8 files changed, 413 insertions(+), 9 deletions(-) create mode 100644 Windows/Forms/AUserControl.cs create mode 100644 Windows/Forms/TilePanel.Designer.cs create mode 100644 Windows/Forms/TilePanel.cs create mode 100644 Windows/Forms/TilePanel.resx diff --git a/LinearAppLauncher.csproj b/LinearAppLauncher.csproj index 070d176..6ac1a46 100644 --- a/LinearAppLauncher.csproj +++ b/LinearAppLauncher.csproj @@ -60,12 +60,21 @@ Form + + UserControl + UserControl HeadingPanel.cs + + UserControl + + + TilePanel.cs + UserControl @@ -88,6 +97,9 @@ HeadingPanel.cs + + TilePanel.cs + TitlePanel.cs diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 44f4a6a..0c8ee28 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -48,6 +48,11 @@ this.panel14 = new System.Windows.Forms.Panel(); this.panel15 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel(); + this.button2 = new System.Windows.Forms.Button(); + this.panel16 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.tilePanel1 = new AppLauncher.Windows.Forms.TilePanel(); + this.tilePanel2 = new AppLauncher.Windows.Forms.TilePanel(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -120,6 +125,8 @@ // // headingPanel1 // + this.headingPanel1.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.headingPanel1.AutoScrollMinSize = new System.Drawing.Size(0, 0); this.headingPanel1.Checked = false; this.headingPanel1.Location = new System.Drawing.Point(12, 64); this.headingPanel1.MinimumSize = new System.Drawing.Size(100, 20); @@ -250,6 +257,71 @@ this.panel1.Size = new System.Drawing.Size(70, 70); this.panel1.TabIndex = 3; // + // button2 + // + this.button2.Location = new System.Drawing.Point(160, 340); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(78, 40); + this.button2.TabIndex = 21; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // panel16 + // + this.panel16.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); + this.panel16.BackgroundImage = global::AppLauncher.Properties.Resources.mail_ea_32; + this.panel16.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.panel16.Location = new System.Drawing.Point(365, 120); + this.panel16.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); + this.panel16.Name = "panel16"; + this.panel16.Size = new System.Drawing.Size(70, 70); + this.panel16.TabIndex = 22; + // + // label1 + // + this.label1.AutoEllipsis = true; + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); + this.label1.Location = new System.Drawing.Point(362, 190); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(73, 13); + this.label1.TabIndex = 23; + this.label1.Text = "OpenOffice OpenOffice"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // tilePanel1 + // + this.tilePanel1.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.tilePanel1.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.tilePanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); + this.tilePanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); + this.tilePanel1.IconImage = global::AppLauncher.Properties.Resources.mail_ea_32; + this.tilePanel1.Location = new System.Drawing.Point(321, 236); + this.tilePanel1.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); + this.tilePanel1.MaximumSize = new System.Drawing.Size(70, 70); + this.tilePanel1.MinimumSize = new System.Drawing.Size(70, 70); + this.tilePanel1.Name = "tilePanel1"; + this.tilePanel1.Size = new System.Drawing.Size(70, 70); + this.tilePanel1.TabIndex = 24; + this.tilePanel1.TitleText = "Mail"; + // + // tilePanel2 + // + this.tilePanel2.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.tilePanel2.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.tilePanel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); + this.tilePanel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); + this.tilePanel2.IconImage = global::AppLauncher.Properties.Resources.mail_ea_32; + this.tilePanel2.Location = new System.Drawing.Point(394, 236); + this.tilePanel2.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); + this.tilePanel2.MaximumSize = new System.Drawing.Size(70, 70); + this.tilePanel2.MinimumSize = new System.Drawing.Size(70, 70); + this.tilePanel2.Name = "tilePanel2"; + this.tilePanel2.Size = new System.Drawing.Size(70, 70); + this.tilePanel2.TabIndex = 25; + this.tilePanel2.TitleText = "Mail"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -257,6 +329,11 @@ this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(83)))), ((int)(((byte)(93))))); this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(800, 440); + this.Controls.Add(this.tilePanel2); + this.Controls.Add(this.tilePanel1); + this.Controls.Add(this.label1); + this.Controls.Add(this.panel16); + this.Controls.Add(this.button2); this.Controls.Add(this.panel12); this.Controls.Add(this.panel13); this.Controls.Add(this.panel14); @@ -303,6 +380,11 @@ private System.Windows.Forms.Panel panel13; private System.Windows.Forms.Panel panel14; private System.Windows.Forms.Panel panel15; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Panel panel16; + private System.Windows.Forms.Label label1; + private Windows.Forms.TilePanel tilePanel1; + private Windows.Forms.TilePanel tilePanel2; } } diff --git a/MainForm.cs b/MainForm.cs index a06fa49..c5f4e69 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; @@ -46,6 +47,15 @@ namespace AppLauncher } + private void button2_Click(object sender, EventArgs e) + { + ProcessStartInfo process = new ProcessStartInfo(); + process.FileName = @"C:\B\Portable Files (pure)\Build and Deploy Utility\v0.2.0.046 alpha\badutil.exe"; + process.Verb = "runas"; + + Process.Start(process); + } + diff --git a/Windows/Forms/AUserControl.cs b/Windows/Forms/AUserControl.cs new file mode 100644 index 0000000..d48b1d6 --- /dev/null +++ b/Windows/Forms/AUserControl.cs @@ -0,0 +1,75 @@ +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace AppLauncher.Windows.Forms +{ + public class AUserControl : UserControl + { + + public AUserControl() : base() + { + + } + + [Browsable(false)] + public override Image BackgroundImage { get => base.BackgroundImage; set => base.BackgroundImage = value; } + + [Browsable(false)] + public override ImageLayout BackgroundImageLayout { get => base.BackgroundImageLayout; set => base.BackgroundImageLayout = value; } + + [Browsable(false)] + public new BorderStyle BorderStyle { get => base.BorderStyle; set => base.BorderStyle = value; } + + [Browsable(false)] + public override Cursor Cursor { get => base.Cursor; set => base.Cursor = value; } + + [Browsable(false)] + public override Font Font { get => base.Font; set => base.Font = value; } + + [Browsable(false)] + public override Color ForeColor { get => base.ForeColor; set => base.ForeColor = value; } + + [Browsable(false)] + public override RightToLeft RightToLeft { get => base.RightToLeft; set => base.RightToLeft = value; } + + [Browsable(false)] + public new bool UseWaitCursor { get => base.UseWaitCursor; set => base.UseWaitCursor = value; } + + + [Browsable(false)] + public override bool AllowDrop { get => base.AllowDrop; set => base.AllowDrop = value; } + + [Browsable(false)] + public override AutoValidate AutoValidate { get => base.AutoValidate; set => base.AutoValidate = value; } + + [Browsable(false)] + public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; } + + [Browsable(false)] + public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; } + + + [Browsable(false)] + public override bool AutoScroll { get => base.AutoScroll; set => base.AutoScroll = value; } + + [Browsable(false)] + public new Size AutoScrollMargin { get => base.AutoScrollMargin; set => base.AutoScrollMargin = value; } + + [Browsable(false)] + public new Size AutoScrollMinSize { get => base.AutoScrollMinSize; set => base.AutoScrollMinSize = value; } + + [Browsable(false)] + public override bool AutoSize { get => base.AutoSize; set => base.AutoSize = value; } + + [Browsable(false)] + public new AutoSizeMode AutoSizeMode { get => base.AutoSizeMode; set => base.AutoSizeMode = value; } + + [Browsable(false)] + public override Size MaximumSize { get => base.MaximumSize; set => base.MaximumSize = value; } + + [Browsable(false)] + public override Size MinimumSize { get => base.MinimumSize; set => base.MinimumSize = value; } + + } +} \ No newline at end of file diff --git a/Windows/Forms/HeadingPanel.cs b/Windows/Forms/HeadingPanel.cs index 85e200b..405f268 100644 --- a/Windows/Forms/HeadingPanel.cs +++ b/Windows/Forms/HeadingPanel.cs @@ -1,13 +1,12 @@ using System.ComponentModel; -using System.Windows.Forms; namespace AppLauncher.Windows.Forms { - public partial class HeadingPanel : UserControl + public partial class HeadingPanel : AUserControl { protected bool isChecked = false; - public HeadingPanel() + public HeadingPanel() : base() { InitializeComponent(); @@ -15,11 +14,7 @@ namespace AppLauncher.Windows.Forms } [Category("Appearance"), Browsable(true)] - public string TitleText - { - get => label1.Text; - set => label1.Text = value; - } + public string TitleText { get => label1.Text; set => label1.Text = value; } [Category("Appearance"), Browsable(true)] public bool Checked @@ -30,7 +25,6 @@ namespace AppLauncher.Windows.Forms isChecked = value; pictureBox1.BackgroundImage = (value) ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16; - } } diff --git a/Windows/Forms/TilePanel.Designer.cs b/Windows/Forms/TilePanel.Designer.cs new file mode 100644 index 0000000..12eb908 --- /dev/null +++ b/Windows/Forms/TilePanel.Designer.cs @@ -0,0 +1,84 @@ +namespace AppLauncher.Windows.Forms +{ + partial class TilePanel + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoEllipsis = true; + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); + this.label1.Location = new System.Drawing.Point(0, 47); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(70, 13); + this.label1.TabIndex = 24; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pictureBox1 + // + this.pictureBox1.BackColor = System.Drawing.Color.Transparent; + this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.pictureBox1.ErrorImage = null; + this.pictureBox1.InitialImage = null; + this.pictureBox1.Location = new System.Drawing.Point(0, 8); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(70, 38); + this.pictureBox1.TabIndex = 25; + this.pictureBox1.TabStop = false; + // + // TilePanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.label1); + this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); + this.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); + this.MaximumSize = new System.Drawing.Size(70, 70); + this.MinimumSize = new System.Drawing.Size(70, 70); + this.Name = "TilePanel"; + this.Size = new System.Drawing.Size(70, 70); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.PictureBox pictureBox1; + } +} diff --git a/Windows/Forms/TilePanel.cs b/Windows/Forms/TilePanel.cs new file mode 100644 index 0000000..315bf62 --- /dev/null +++ b/Windows/Forms/TilePanel.cs @@ -0,0 +1,27 @@ +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 AppLauncher.Windows.Forms +{ + public partial class TilePanel : AUserControl + { + public TilePanel() : base() + { + InitializeComponent(); + } + + [Category("Appearance"), Browsable(true)] + public string TitleText { get => label1.Text; set => label1.Text = value; } + + [Category("Appearance"), Browsable(true)] + public Image IconImage { get => pictureBox1.BackgroundImage; set => pictureBox1.BackgroundImage = value; } + + } +} \ No newline at end of file diff --git a/Windows/Forms/TilePanel.resx b/Windows/Forms/TilePanel.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Windows/Forms/TilePanel.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