# HG changeset patch # User sl # Date 1404830489 -7200 # Node ID 69815d19796c8ba1d7e897c53f23b0dc358edf0c # Parent 70b26a1ae93b6872abe5caef183b7cc8210c7066 Adding status bar and managing control status. diff -r 70b26a1ae93b -r 69815d19796c MainForm.Designer.cs --- a/MainForm.Designer.cs Tue Jul 08 15:49:34 2014 +0200 +++ b/MainForm.Designer.cs Tue Jul 08 16:41:29 2014 +0200 @@ -38,16 +38,19 @@ this.buttonOpen = new System.Windows.Forms.Button(); this.buttonCapture = new System.Windows.Forms.Button(); this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.buttonFont = new System.Windows.Forms.Button(); this.tabPageTests = new System.Windows.Forms.TabPage(); this.fontDialog = new System.Windows.Forms.FontDialog(); this.timer = new System.Windows.Forms.Timer(this.components); + this.statusStrip = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel(); + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.tabControl.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit(); this.tableLayoutPanel.SuspendLayout(); + this.statusStrip.SuspendLayout(); this.SuspendLayout(); // // tabControl @@ -60,7 +63,7 @@ this.tabControl.Location = new System.Drawing.Point(12, 12); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(529, 362); + this.tabControl.Size = new System.Drawing.Size(600, 395); this.tabControl.TabIndex = 0; // // tabPageDisplay @@ -76,18 +79,20 @@ this.tabPageDisplay.Location = new System.Drawing.Point(4, 22); this.tabPageDisplay.Name = "tabPageDisplay"; this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3); - this.tabPageDisplay.Size = new System.Drawing.Size(521, 336); + this.tabPageDisplay.Size = new System.Drawing.Size(592, 369); this.tabPageDisplay.TabIndex = 0; this.tabPageDisplay.Text = "Display"; this.tabPageDisplay.UseVisualStyleBackColor = true; // // trackBarBrightness // + this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window; - this.trackBarBrightness.Location = new System.Drawing.Point(470, 6); + this.trackBarBrightness.Location = new System.Drawing.Point(544, 9); this.trackBarBrightness.Name = "trackBarBrightness"; this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical; - this.trackBarBrightness.Size = new System.Drawing.Size(45, 324); + this.trackBarBrightness.Size = new System.Drawing.Size(45, 357); this.trackBarBrightness.TabIndex = 10; this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both; this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll); @@ -134,7 +139,8 @@ // // buttonCapture // - this.buttonCapture.Location = new System.Drawing.Point(6, 278); + this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCapture.Location = new System.Drawing.Point(6, 311); this.buttonCapture.Name = "buttonCapture"; this.buttonCapture.Size = new System.Drawing.Size(75, 23); this.buttonCapture.TabIndex = 5; @@ -190,40 +196,10 @@ this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); this.tableLayoutPanel.TabIndex = 4; // - // marqueeLabelTop - // - this.marqueeLabelTop.AutoEllipsis = true; - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); - this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); - this.marqueeLabelTop.Name = "marqueeLabelTop"; - this.marqueeLabelTop.OwnTimer = false; - this.marqueeLabelTop.PixelsPerSecond = 64; - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30); - this.marqueeLabelTop.TabIndex = 2; - this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; - this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.marqueeLabelTop.UseCompatibleTextRendering = true; - // - // marqueeLabelBottom - // - this.marqueeLabelBottom.AutoEllipsis = true; - this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32); - this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); - this.marqueeLabelBottom.Name = "marqueeLabelBottom"; - this.marqueeLabelBottom.OwnTimer = false; - this.marqueeLabelBottom.PixelsPerSecond = 64; - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31); - this.marqueeLabelBottom.TabIndex = 3; - this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; - this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.marqueeLabelBottom.UseCompatibleTextRendering = true; - // // buttonFont // - this.buttonFont.Location = new System.Drawing.Point(6, 307); + this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonFont.Location = new System.Drawing.Point(6, 340); this.buttonFont.Name = "buttonFont"; this.buttonFont.Size = new System.Drawing.Size(75, 23); this.buttonFont.TabIndex = 0; @@ -236,7 +212,7 @@ this.tabPageTests.Location = new System.Drawing.Point(4, 22); this.tabPageTests.Name = "tabPageTests"; this.tabPageTests.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTests.Size = new System.Drawing.Size(521, 336); + this.tabPageTests.Size = new System.Drawing.Size(592, 369); this.tabPageTests.TabIndex = 1; this.tabPageTests.Text = "Test"; this.tabPageTests.UseVisualStyleBackColor = true; @@ -247,12 +223,61 @@ this.timer.Interval = 50; this.timer.Tick += new System.EventHandler(this.timer_Tick); // + // statusStrip + // + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabelConnect}); + this.statusStrip.Location = new System.Drawing.Point(0, 420); + this.statusStrip.Name = "statusStrip"; + this.statusStrip.Size = new System.Drawing.Size(624, 22); + this.statusStrip.TabIndex = 1; + this.statusStrip.Text = "statusStrip"; + // + // toolStripStatusLabelConnect + // + this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect"; + this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17); + this.toolStripStatusLabelConnect.Text = "Not connected"; + // + // marqueeLabelTop + // + this.marqueeLabelTop.AutoEllipsis = true; + this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; + this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; + this.marqueeLabelTop.Location = new System.Drawing.Point(1, -103); + this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); + this.marqueeLabelTop.Name = "marqueeLabelTop"; + this.marqueeLabelTop.OwnTimer = false; + this.marqueeLabelTop.PixelsPerSecond = 64; + this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20); + this.marqueeLabelTop.TabIndex = 2; + this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; + this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.marqueeLabelTop.UseCompatibleTextRendering = true; + // + // marqueeLabelBottom + // + this.marqueeLabelBottom.AutoEllipsis = true; + this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -19); + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); + this.marqueeLabelBottom.Name = "marqueeLabelBottom"; + this.marqueeLabelBottom.OwnTimer = false; + this.marqueeLabelBottom.PixelsPerSecond = 64; + this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20); + this.marqueeLabelBottom.TabIndex = 3; + this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; + this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.marqueeLabelBottom.UseCompatibleTextRendering = true; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(553, 386); + this.ClientSize = new System.Drawing.Size(624, 442); + this.Controls.Add(this.statusStrip); this.Controls.Add(this.tabControl); + this.MinimumSize = new System.Drawing.Size(640, 480); this.Name = "MainForm"; this.Text = "Sharp Display Manager"; this.tabControl.ResumeLayout(false); @@ -260,7 +285,10 @@ this.tabPageDisplay.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit(); this.tableLayoutPanel.ResumeLayout(false); + this.statusStrip.ResumeLayout(false); + this.statusStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -281,6 +309,8 @@ private System.Windows.Forms.Button buttonClose; private System.Windows.Forms.Button buttonOpen; private System.Windows.Forms.TrackBar trackBarBrightness; + private System.Windows.Forms.StatusStrip statusStrip; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect; } } diff -r 70b26a1ae93b -r 69815d19796c MainForm.cs --- a/MainForm.cs Tue Jul 08 15:49:34 2014 +0200 +++ b/MainForm.cs Tue Jul 08 16:41:29 2014 +0200 @@ -22,6 +22,7 @@ iDisplay = new Display(); InitializeComponent(); + UpdateStatus(); } private void buttonFont_Click(object sender, EventArgs e) @@ -77,7 +78,7 @@ //Draw to bitmap System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height); tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle); - //Send it to our display + //Send it to our display for (int i = 0; i < bmp.Width; i++) { for (int j = 0; j < bmp.Height; j++) @@ -99,10 +100,14 @@ { if (iDisplay.Open()) { - trackBarBrightness.Minimum = iDisplay.MinBrightness(); - trackBarBrightness.Maximum = iDisplay.MaxBrightness(); + UpdateStatus(); } - + else + { + UpdateStatus(); + toolStripStatusLabelConnect.Text = "Connection error"; + } + } private void buttonClose_Click(object sender, EventArgs e) @@ -126,5 +131,30 @@ { iDisplay.SetBrightness(trackBarBrightness.Value); } + + private void UpdateStatus() + { + if (iDisplay.IsOpen()) + { + buttonFill.Enabled = true; + buttonClear.Enabled = true; + buttonOpen.Enabled = false; + buttonClose.Enabled = true; + trackBarBrightness.Enabled = true; + trackBarBrightness.Minimum = iDisplay.MinBrightness(); + trackBarBrightness.Maximum = iDisplay.MaxBrightness(); + toolStripStatusLabelConnect.Text = "Connected"; + } + else + { + buttonFill.Enabled = false; + buttonClear.Enabled = false; + buttonOpen.Enabled = true; + buttonClose.Enabled = false; + trackBarBrightness.Enabled = false; + toolStripStatusLabelConnect.Text = "Not connected"; + } + } + } } diff -r 70b26a1ae93b -r 69815d19796c MainForm.resx --- a/MainForm.resx Tue Jul 08 15:49:34 2014 +0200 +++ b/MainForm.resx Tue Jul 08 16:41:29 2014 +0200 @@ -123,4 +123,7 @@ 126, 17 + + 206, 17 + \ No newline at end of file