Persisting brightness, fixing brightness tracker steps, adding show borders option.
authorsl
Tue, 08 Jul 2014 20:02:12 +0200
changeset 97c363a7a975e
parent 8 5129c03ab7ba
child 10 54671755add3
Persisting brightness, fixing brightness tracker steps, adding show borders option.
App.config
MainForm.Designer.cs
MainForm.cs
Properties/Settings.Designer.cs
Properties/Settings.settings
     1.1 --- a/App.config	Tue Jul 08 18:59:07 2014 +0200
     1.2 +++ b/App.config	Tue Jul 08 20:02:12 2014 +0200
     1.3 @@ -16,6 +16,9 @@
     1.4              <setting name="DisplayFont" serializeAs="String">
     1.5                  <value>Microsoft Sans Serif, 9.75pt</value>
     1.6              </setting>
     1.7 +            <setting name="DisplayShowBorders" serializeAs="String">
     1.8 +                <value>False</value>
     1.9 +            </setting>
    1.10          </SharpDisplayManager.Properties.Settings>
    1.11      </userSettings>
    1.12  </configuration>
    1.13 \ No newline at end of file
     2.1 --- a/MainForm.Designer.cs	Tue Jul 08 18:59:07 2014 +0200
     2.2 +++ b/MainForm.Designer.cs	Tue Jul 08 20:02:12 2014 +0200
     2.3 @@ -38,8 +38,6 @@
     2.4              this.buttonOpen = new System.Windows.Forms.Button();
     2.5              this.buttonCapture = new System.Windows.Forms.Button();
     2.6              this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     2.7 -            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
     2.8 -            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
     2.9              this.buttonFont = new System.Windows.Forms.Button();
    2.10              this.tabPageTests = new System.Windows.Forms.TabPage();
    2.11              this.fontDialog = new System.Windows.Forms.FontDialog();
    2.12 @@ -48,6 +46,9 @@
    2.13              this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
    2.14              this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
    2.15              this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
    2.16 +            this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
    2.17 +            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    2.18 +            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    2.19              this.tabControl.SuspendLayout();
    2.20              this.tabPageDisplay.SuspendLayout();
    2.21              ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
    2.22 @@ -70,6 +71,7 @@
    2.23              // 
    2.24              // tabPageDisplay
    2.25              // 
    2.26 +            this.tabPageDisplay.Controls.Add(this.checkBoxShowBorders);
    2.27              this.tabPageDisplay.Controls.Add(this.trackBarBrightness);
    2.28              this.tabPageDisplay.Controls.Add(this.buttonFill);
    2.29              this.tabPageDisplay.Controls.Add(this.buttonClear);
    2.30 @@ -198,39 +200,6 @@
    2.31              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
    2.32              this.tableLayoutPanel.TabIndex = 4;
    2.33              // 
    2.34 -            // marqueeLabelTop
    2.35 -            // 
    2.36 -            this.marqueeLabelTop.AutoEllipsis = true;
    2.37 -            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
    2.38 -            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
    2.39 -            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
    2.40 -            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
    2.41 -            this.marqueeLabelTop.Name = "marqueeLabelTop";
    2.42 -            this.marqueeLabelTop.OwnTimer = false;
    2.43 -            this.marqueeLabelTop.PixelsPerSecond = 64;
    2.44 -            this.marqueeLabelTop.Separator = "";
    2.45 -            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30);
    2.46 -            this.marqueeLabelTop.TabIndex = 2;
    2.47 -            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
    2.48 -            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    2.49 -            this.marqueeLabelTop.UseCompatibleTextRendering = true;
    2.50 -            // 
    2.51 -            // marqueeLabelBottom
    2.52 -            // 
    2.53 -            this.marqueeLabelBottom.AutoEllipsis = true;
    2.54 -            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
    2.55 -            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
    2.56 -            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
    2.57 -            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
    2.58 -            this.marqueeLabelBottom.OwnTimer = false;
    2.59 -            this.marqueeLabelBottom.PixelsPerSecond = 64;
    2.60 -            this.marqueeLabelBottom.Separator = " | ";
    2.61 -            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31);
    2.62 -            this.marqueeLabelBottom.TabIndex = 3;
    2.63 -            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
    2.64 -            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    2.65 -            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
    2.66 -            // 
    2.67              // buttonFont
    2.68              // 
    2.69              this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    2.70 @@ -289,6 +258,50 @@
    2.71              this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
    2.72              this.toolStripStatusLabelFps.Text = "FPS";
    2.73              // 
    2.74 +            // checkBoxShowBorders
    2.75 +            // 
    2.76 +            this.checkBoxShowBorders.AutoSize = true;
    2.77 +            this.checkBoxShowBorders.Location = new System.Drawing.Point(113, 344);
    2.78 +            this.checkBoxShowBorders.Name = "checkBoxShowBorders";
    2.79 +            this.checkBoxShowBorders.Size = new System.Drawing.Size(91, 17);
    2.80 +            this.checkBoxShowBorders.TabIndex = 11;
    2.81 +            this.checkBoxShowBorders.Text = "Show borders";
    2.82 +            this.checkBoxShowBorders.UseVisualStyleBackColor = true;
    2.83 +            this.checkBoxShowBorders.CheckedChanged += new System.EventHandler(this.checkBoxShowBorders_CheckedChanged);
    2.84 +            // 
    2.85 +            // marqueeLabelTop
    2.86 +            // 
    2.87 +            this.marqueeLabelTop.AutoEllipsis = true;
    2.88 +            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
    2.89 +            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
    2.90 +            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
    2.91 +            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
    2.92 +            this.marqueeLabelTop.Name = "marqueeLabelTop";
    2.93 +            this.marqueeLabelTop.OwnTimer = false;
    2.94 +            this.marqueeLabelTop.PixelsPerSecond = 64;
    2.95 +            this.marqueeLabelTop.Separator = "";
    2.96 +            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 9);
    2.97 +            this.marqueeLabelTop.TabIndex = 2;
    2.98 +            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
    2.99 +            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.100 +            this.marqueeLabelTop.UseCompatibleTextRendering = true;
   2.101 +            // 
   2.102 +            // marqueeLabelBottom
   2.103 +            // 
   2.104 +            this.marqueeLabelBottom.AutoEllipsis = true;
   2.105 +            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   2.106 +            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 21);
   2.107 +            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   2.108 +            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   2.109 +            this.marqueeLabelBottom.OwnTimer = false;
   2.110 +            this.marqueeLabelBottom.PixelsPerSecond = 64;
   2.111 +            this.marqueeLabelBottom.Separator = null;
   2.112 +            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
   2.113 +            this.marqueeLabelBottom.TabIndex = 3;
   2.114 +            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   2.115 +            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.116 +            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   2.117 +            // 
   2.118              // MainForm
   2.119              // 
   2.120              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   2.121 @@ -332,6 +345,7 @@
   2.122          private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
   2.123          private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps;
   2.124          private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring;
   2.125 +        private System.Windows.Forms.CheckBox checkBoxShowBorders;
   2.126      }
   2.127  }
   2.128  
     3.1 --- a/MainForm.cs	Tue Jul 08 18:59:07 2014 +0200
     3.2 +++ b/MainForm.cs	Tue Jul 08 20:02:12 2014 +0200
     3.3 @@ -26,6 +26,7 @@
     3.4              //Load settings
     3.5              marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
     3.6              marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
     3.7 +            checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
     3.8          }
     3.9  
    3.10          private void buttonFont_Click(object sender, EventArgs e)
    3.11 @@ -89,7 +90,7 @@
    3.12                          unchecked
    3.13                          {
    3.14                          uint color=(uint)bmp.GetPixel(i, j).ToArgb();
    3.15 -                        iDisplay.SetPixel(i, j, Convert.ToInt32(color!=0xFFFFFFFF));
    3.16 +                        iDisplay.SetPixel(i, j, Convert.ToInt32((checkBoxShowBorders.Checked?color!=0xFFFFFFFF:color == 0xFF000000)));
    3.17                          }
    3.18                      }
    3.19                  }
    3.20 @@ -122,6 +123,7 @@
    3.21          private void buttonClose_Click(object sender, EventArgs e)
    3.22          {
    3.23              iDisplay.Close();
    3.24 +            UpdateStatus();
    3.25          }
    3.26  
    3.27          private void buttonClear_Click(object sender, EventArgs e)
    3.28 @@ -138,7 +140,10 @@
    3.29  
    3.30          private void trackBarBrightness_Scroll(object sender, EventArgs e)
    3.31          {
    3.32 +            Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
    3.33 +            Properties.Settings.Default.Save();
    3.34              iDisplay.SetBrightness(trackBarBrightness.Value);
    3.35 +
    3.36          }
    3.37  
    3.38          private void UpdateStatus()
    3.39 @@ -151,7 +156,12 @@
    3.40                  buttonClose.Enabled = true;
    3.41                  trackBarBrightness.Enabled = true;
    3.42                  trackBarBrightness.Minimum = iDisplay.MinBrightness();
    3.43 -                trackBarBrightness.Maximum = iDisplay.MaxBrightness();
    3.44 +                trackBarBrightness.Maximum = iDisplay.MaxBrightness();                
    3.45 +                trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
    3.46 +                trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
    3.47 +                trackBarBrightness.SmallChange = 1;
    3.48 +                iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
    3.49 +
    3.50                  toolStripStatusLabelConnect.Text = "Connected";
    3.51              }
    3.52              else
    3.53 @@ -161,8 +171,14 @@
    3.54                  buttonOpen.Enabled = true;
    3.55                  buttonClose.Enabled = false;
    3.56                  trackBarBrightness.Enabled = false;
    3.57 -                toolStripStatusLabelConnect.Text = "Not connected";
    3.58 +                toolStripStatusLabelConnect.Text = "Disconnected";
    3.59              }
    3.60          }
    3.61 +
    3.62 +        private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
    3.63 +        {
    3.64 +            Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
    3.65 +            Properties.Settings.Default.Save();
    3.66 +        }
    3.67      }
    3.68  }
     4.1 --- a/Properties/Settings.Designer.cs	Tue Jul 08 18:59:07 2014 +0200
     4.2 +++ b/Properties/Settings.Designer.cs	Tue Jul 08 20:02:12 2014 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4  //------------------------------------------------------------------------------
     4.5  // <auto-generated>
     4.6  //     This code was generated by a tool.
     4.7 -//     Runtime Version:4.0.30319.18063
     4.8 +//     Runtime Version:4.0.30319.18444
     4.9  //
    4.10  //     Changes to this file may cause incorrect behavior and will be lost if
    4.11  //     the code is regenerated.
    4.12 @@ -46,5 +46,17 @@
    4.13                  this["DisplayFont"] = value;
    4.14              }
    4.15          }
    4.16 +        
    4.17 +        [global::System.Configuration.UserScopedSettingAttribute()]
    4.18 +        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    4.19 +        [global::System.Configuration.DefaultSettingValueAttribute("False")]
    4.20 +        public bool DisplayShowBorders {
    4.21 +            get {
    4.22 +                return ((bool)(this["DisplayShowBorders"]));
    4.23 +            }
    4.24 +            set {
    4.25 +                this["DisplayShowBorders"] = value;
    4.26 +            }
    4.27 +        }
    4.28      }
    4.29  }
     5.1 --- a/Properties/Settings.settings	Tue Jul 08 18:59:07 2014 +0200
     5.2 +++ b/Properties/Settings.settings	Tue Jul 08 20:02:12 2014 +0200
     5.3 @@ -8,5 +8,8 @@
     5.4      <Setting Name="DisplayFont" Type="System.Drawing.Font" Scope="User">
     5.5        <Value Profile="(Default)">Microsoft Sans Serif, 9.75pt</Value>
     5.6      </Setting>
     5.7 +    <Setting Name="DisplayShowBorders" Type="System.Boolean" Scope="User">
     5.8 +      <Value Profile="(Default)">False</Value>
     5.9 +    </Setting>
    5.10    </Settings>
    5.11  </SettingsFile>
    5.12 \ No newline at end of file