Adding status bar and managing control status.
authorsl
Tue, 08 Jul 2014 16:41:29 +0200
changeset 769815d19796c
parent 6 70b26a1ae93b
child 8 5129c03ab7ba
Adding status bar and managing control status.
MainForm.Designer.cs
MainForm.cs
MainForm.resx
     1.1 --- a/MainForm.Designer.cs	Tue Jul 08 15:49:34 2014 +0200
     1.2 +++ b/MainForm.Designer.cs	Tue Jul 08 16:41:29 2014 +0200
     1.3 @@ -38,16 +38,19 @@
     1.4              this.buttonOpen = new System.Windows.Forms.Button();
     1.5              this.buttonCapture = new System.Windows.Forms.Button();
     1.6              this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     1.7 -            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
     1.8 -            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
     1.9              this.buttonFont = new System.Windows.Forms.Button();
    1.10              this.tabPageTests = new System.Windows.Forms.TabPage();
    1.11              this.fontDialog = new System.Windows.Forms.FontDialog();
    1.12              this.timer = new System.Windows.Forms.Timer(this.components);
    1.13 +            this.statusStrip = new System.Windows.Forms.StatusStrip();
    1.14 +            this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
    1.15 +            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    1.16 +            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    1.17              this.tabControl.SuspendLayout();
    1.18              this.tabPageDisplay.SuspendLayout();
    1.19              ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
    1.20              this.tableLayoutPanel.SuspendLayout();
    1.21 +            this.statusStrip.SuspendLayout();
    1.22              this.SuspendLayout();
    1.23              // 
    1.24              // tabControl
    1.25 @@ -60,7 +63,7 @@
    1.26              this.tabControl.Location = new System.Drawing.Point(12, 12);
    1.27              this.tabControl.Name = "tabControl";
    1.28              this.tabControl.SelectedIndex = 0;
    1.29 -            this.tabControl.Size = new System.Drawing.Size(529, 362);
    1.30 +            this.tabControl.Size = new System.Drawing.Size(600, 395);
    1.31              this.tabControl.TabIndex = 0;
    1.32              // 
    1.33              // tabPageDisplay
    1.34 @@ -76,18 +79,20 @@
    1.35              this.tabPageDisplay.Location = new System.Drawing.Point(4, 22);
    1.36              this.tabPageDisplay.Name = "tabPageDisplay";
    1.37              this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3);
    1.38 -            this.tabPageDisplay.Size = new System.Drawing.Size(521, 336);
    1.39 +            this.tabPageDisplay.Size = new System.Drawing.Size(592, 369);
    1.40              this.tabPageDisplay.TabIndex = 0;
    1.41              this.tabPageDisplay.Text = "Display";
    1.42              this.tabPageDisplay.UseVisualStyleBackColor = true;
    1.43              // 
    1.44              // trackBarBrightness
    1.45              // 
    1.46 +            this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    1.47 +            | System.Windows.Forms.AnchorStyles.Right)));
    1.48              this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
    1.49 -            this.trackBarBrightness.Location = new System.Drawing.Point(470, 6);
    1.50 +            this.trackBarBrightness.Location = new System.Drawing.Point(544, 9);
    1.51              this.trackBarBrightness.Name = "trackBarBrightness";
    1.52              this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
    1.53 -            this.trackBarBrightness.Size = new System.Drawing.Size(45, 324);
    1.54 +            this.trackBarBrightness.Size = new System.Drawing.Size(45, 357);
    1.55              this.trackBarBrightness.TabIndex = 10;
    1.56              this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
    1.57              this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
    1.58 @@ -134,7 +139,8 @@
    1.59              // 
    1.60              // buttonCapture
    1.61              // 
    1.62 -            this.buttonCapture.Location = new System.Drawing.Point(6, 278);
    1.63 +            this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    1.64 +            this.buttonCapture.Location = new System.Drawing.Point(6, 311);
    1.65              this.buttonCapture.Name = "buttonCapture";
    1.66              this.buttonCapture.Size = new System.Drawing.Size(75, 23);
    1.67              this.buttonCapture.TabIndex = 5;
    1.68 @@ -190,40 +196,10 @@
    1.69              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
    1.70              this.tableLayoutPanel.TabIndex = 4;
    1.71              // 
    1.72 -            // marqueeLabelTop
    1.73 -            // 
    1.74 -            this.marqueeLabelTop.AutoEllipsis = true;
    1.75 -            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
    1.76 -            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
    1.77 -            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
    1.78 -            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
    1.79 -            this.marqueeLabelTop.Name = "marqueeLabelTop";
    1.80 -            this.marqueeLabelTop.OwnTimer = false;
    1.81 -            this.marqueeLabelTop.PixelsPerSecond = 64;
    1.82 -            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30);
    1.83 -            this.marqueeLabelTop.TabIndex = 2;
    1.84 -            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
    1.85 -            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    1.86 -            this.marqueeLabelTop.UseCompatibleTextRendering = true;
    1.87 -            // 
    1.88 -            // marqueeLabelBottom
    1.89 -            // 
    1.90 -            this.marqueeLabelBottom.AutoEllipsis = true;
    1.91 -            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
    1.92 -            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
    1.93 -            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
    1.94 -            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
    1.95 -            this.marqueeLabelBottom.OwnTimer = false;
    1.96 -            this.marqueeLabelBottom.PixelsPerSecond = 64;
    1.97 -            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31);
    1.98 -            this.marqueeLabelBottom.TabIndex = 3;
    1.99 -            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   1.100 -            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   1.101 -            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   1.102 -            // 
   1.103              // buttonFont
   1.104              // 
   1.105 -            this.buttonFont.Location = new System.Drawing.Point(6, 307);
   1.106 +            this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
   1.107 +            this.buttonFont.Location = new System.Drawing.Point(6, 340);
   1.108              this.buttonFont.Name = "buttonFont";
   1.109              this.buttonFont.Size = new System.Drawing.Size(75, 23);
   1.110              this.buttonFont.TabIndex = 0;
   1.111 @@ -236,7 +212,7 @@
   1.112              this.tabPageTests.Location = new System.Drawing.Point(4, 22);
   1.113              this.tabPageTests.Name = "tabPageTests";
   1.114              this.tabPageTests.Padding = new System.Windows.Forms.Padding(3);
   1.115 -            this.tabPageTests.Size = new System.Drawing.Size(521, 336);
   1.116 +            this.tabPageTests.Size = new System.Drawing.Size(592, 369);
   1.117              this.tabPageTests.TabIndex = 1;
   1.118              this.tabPageTests.Text = "Test";
   1.119              this.tabPageTests.UseVisualStyleBackColor = true;
   1.120 @@ -247,12 +223,61 @@
   1.121              this.timer.Interval = 50;
   1.122              this.timer.Tick += new System.EventHandler(this.timer_Tick);
   1.123              // 
   1.124 +            // statusStrip
   1.125 +            // 
   1.126 +            this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
   1.127 +            this.toolStripStatusLabelConnect});
   1.128 +            this.statusStrip.Location = new System.Drawing.Point(0, 420);
   1.129 +            this.statusStrip.Name = "statusStrip";
   1.130 +            this.statusStrip.Size = new System.Drawing.Size(624, 22);
   1.131 +            this.statusStrip.TabIndex = 1;
   1.132 +            this.statusStrip.Text = "statusStrip";
   1.133 +            // 
   1.134 +            // toolStripStatusLabelConnect
   1.135 +            // 
   1.136 +            this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect";
   1.137 +            this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17);
   1.138 +            this.toolStripStatusLabelConnect.Text = "Not connected";
   1.139 +            // 
   1.140 +            // marqueeLabelTop
   1.141 +            // 
   1.142 +            this.marqueeLabelTop.AutoEllipsis = true;
   1.143 +            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
   1.144 +            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
   1.145 +            this.marqueeLabelTop.Location = new System.Drawing.Point(1, -103);
   1.146 +            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
   1.147 +            this.marqueeLabelTop.Name = "marqueeLabelTop";
   1.148 +            this.marqueeLabelTop.OwnTimer = false;
   1.149 +            this.marqueeLabelTop.PixelsPerSecond = 64;
   1.150 +            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
   1.151 +            this.marqueeLabelTop.TabIndex = 2;
   1.152 +            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
   1.153 +            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   1.154 +            this.marqueeLabelTop.UseCompatibleTextRendering = true;
   1.155 +            // 
   1.156 +            // marqueeLabelBottom
   1.157 +            // 
   1.158 +            this.marqueeLabelBottom.AutoEllipsis = true;
   1.159 +            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   1.160 +            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -19);
   1.161 +            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   1.162 +            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   1.163 +            this.marqueeLabelBottom.OwnTimer = false;
   1.164 +            this.marqueeLabelBottom.PixelsPerSecond = 64;
   1.165 +            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
   1.166 +            this.marqueeLabelBottom.TabIndex = 3;
   1.167 +            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   1.168 +            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   1.169 +            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   1.170 +            // 
   1.171              // MainForm
   1.172              // 
   1.173              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   1.174              this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
   1.175 -            this.ClientSize = new System.Drawing.Size(553, 386);
   1.176 +            this.ClientSize = new System.Drawing.Size(624, 442);
   1.177 +            this.Controls.Add(this.statusStrip);
   1.178              this.Controls.Add(this.tabControl);
   1.179 +            this.MinimumSize = new System.Drawing.Size(640, 480);
   1.180              this.Name = "MainForm";
   1.181              this.Text = "Sharp Display Manager";
   1.182              this.tabControl.ResumeLayout(false);
   1.183 @@ -260,7 +285,10 @@
   1.184              this.tabPageDisplay.PerformLayout();
   1.185              ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
   1.186              this.tableLayoutPanel.ResumeLayout(false);
   1.187 +            this.statusStrip.ResumeLayout(false);
   1.188 +            this.statusStrip.PerformLayout();
   1.189              this.ResumeLayout(false);
   1.190 +            this.PerformLayout();
   1.191  
   1.192          }
   1.193  
   1.194 @@ -281,6 +309,8 @@
   1.195          private System.Windows.Forms.Button buttonClose;
   1.196          private System.Windows.Forms.Button buttonOpen;
   1.197          private System.Windows.Forms.TrackBar trackBarBrightness;
   1.198 +        private System.Windows.Forms.StatusStrip statusStrip;
   1.199 +        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
   1.200      }
   1.201  }
   1.202  
     2.1 --- a/MainForm.cs	Tue Jul 08 15:49:34 2014 +0200
     2.2 +++ b/MainForm.cs	Tue Jul 08 16:41:29 2014 +0200
     2.3 @@ -22,6 +22,7 @@
     2.4              iDisplay = new Display();
     2.5  
     2.6              InitializeComponent();
     2.7 +            UpdateStatus();
     2.8          }
     2.9  
    2.10          private void buttonFont_Click(object sender, EventArgs e)
    2.11 @@ -77,7 +78,7 @@
    2.12                  //Draw to bitmap
    2.13                  System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
    2.14                  tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
    2.15 -                //Send it to our display 
    2.16 +                //Send it to our display
    2.17                  for (int i = 0; i < bmp.Width; i++)
    2.18                  {
    2.19                      for (int j = 0; j < bmp.Height; j++)
    2.20 @@ -99,10 +100,14 @@
    2.21          {
    2.22              if (iDisplay.Open())
    2.23              {
    2.24 -                trackBarBrightness.Minimum = iDisplay.MinBrightness();
    2.25 -                trackBarBrightness.Maximum = iDisplay.MaxBrightness();                
    2.26 +                UpdateStatus();
    2.27              }
    2.28 -            
    2.29 +            else
    2.30 +            {
    2.31 +                UpdateStatus();
    2.32 +                toolStripStatusLabelConnect.Text = "Connection error";
    2.33 +            }
    2.34 +
    2.35          }
    2.36  
    2.37          private void buttonClose_Click(object sender, EventArgs e)
    2.38 @@ -126,5 +131,30 @@
    2.39          {
    2.40              iDisplay.SetBrightness(trackBarBrightness.Value);
    2.41          }
    2.42 +
    2.43 +        private void UpdateStatus()
    2.44 +        {
    2.45 +            if (iDisplay.IsOpen())
    2.46 +            {
    2.47 +                buttonFill.Enabled = true;
    2.48 +                buttonClear.Enabled = true;
    2.49 +                buttonOpen.Enabled = false;
    2.50 +                buttonClose.Enabled = true;
    2.51 +                trackBarBrightness.Enabled = true;
    2.52 +                trackBarBrightness.Minimum = iDisplay.MinBrightness();
    2.53 +                trackBarBrightness.Maximum = iDisplay.MaxBrightness();
    2.54 +                toolStripStatusLabelConnect.Text = "Connected";
    2.55 +            }
    2.56 +            else
    2.57 +            {
    2.58 +                buttonFill.Enabled = false;
    2.59 +                buttonClear.Enabled = false;
    2.60 +                buttonOpen.Enabled = true;
    2.61 +                buttonClose.Enabled = false;
    2.62 +                trackBarBrightness.Enabled = false;
    2.63 +                toolStripStatusLabelConnect.Text = "Not connected";
    2.64 +            }
    2.65 +        }
    2.66 +
    2.67      }
    2.68  }
     3.1 --- a/MainForm.resx	Tue Jul 08 15:49:34 2014 +0200
     3.2 +++ b/MainForm.resx	Tue Jul 08 16:41:29 2014 +0200
     3.3 @@ -123,4 +123,7 @@
     3.4    <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     3.5      <value>126, 17</value>
     3.6    </metadata>
     3.7 +  <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     3.8 +    <value>206, 17</value>
     3.9 +  </metadata>
    3.10  </root>
    3.11 \ No newline at end of file