Display is now updated as labels are scrolling.
authorsl
Mon, 07 Jul 2014 22:29:26 +0200
changeset 40825370a7947
parent 3 71b55cfd8c05
child 5 02716ce36263
Display is now updated as labels are scrolling.
Display.cs
MainForm.Designer.cs
MainForm.cs
     1.1 --- a/Display.cs	Mon Jul 07 21:32:02 2014 +0200
     1.2 +++ b/Display.cs	Mon Jul 07 22:29:26 2014 +0200
     1.3 @@ -71,6 +71,23 @@
     1.4              MiniDisplaySetBrightness(iDevice, aBrightness);
     1.5          }
     1.6  
     1.7 +        public int WidthInPixels()
     1.8 +        {
     1.9 +            return MiniDisplayWidthInPixels(iDevice);
    1.10 +        }
    1.11 +
    1.12 +        public int HeightInPixels()
    1.13 +        {
    1.14 +            return MiniDisplayHeightInPixels(iDevice);
    1.15 +        }
    1.16 +
    1.17 +        public void SetPixel(int aX, int aY, int aValue)
    1.18 +        {
    1.19 +            MiniDisplaySetPixel(iDevice,aX,aY,aValue);
    1.20 +        }
    1.21 +
    1.22 +
    1.23 +
    1.24          //Our display device handle
    1.25          IntPtr iDevice;
    1.26  
    1.27 @@ -98,6 +115,15 @@
    1.28          [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.29          public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
    1.30  
    1.31 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.32 +        public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
    1.33 +
    1.34 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.35 +        public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
    1.36 +
    1.37 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.38 +        public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
    1.39 +
    1.40  
    1.41      }
    1.42  }
     2.1 --- a/MainForm.Designer.cs	Mon Jul 07 21:32:02 2014 +0200
     2.2 +++ b/MainForm.Designer.cs	Mon Jul 07 22:29:26 2014 +0200
     2.3 @@ -31,23 +31,23 @@
     2.4              this.components = new System.ComponentModel.Container();
     2.5              this.tabControl = new System.Windows.Forms.TabControl();
     2.6              this.tabPageDisplay = new System.Windows.Forms.TabPage();
     2.7 +            this.trackBarBrightness = new System.Windows.Forms.TrackBar();
     2.8 +            this.buttonFill = new System.Windows.Forms.Button();
     2.9 +            this.buttonClear = new System.Windows.Forms.Button();
    2.10 +            this.buttonClose = new System.Windows.Forms.Button();
    2.11 +            this.buttonOpen = new System.Windows.Forms.Button();
    2.12              this.buttonCapture = new System.Windows.Forms.Button();
    2.13              this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
    2.14 +            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    2.15 +            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    2.16              this.buttonFont = new System.Windows.Forms.Button();
    2.17              this.tabPageTests = new System.Windows.Forms.TabPage();
    2.18              this.fontDialog = new System.Windows.Forms.FontDialog();
    2.19              this.timer = new System.Windows.Forms.Timer(this.components);
    2.20 -            this.buttonOpen = new System.Windows.Forms.Button();
    2.21 -            this.buttonClose = new System.Windows.Forms.Button();
    2.22 -            this.buttonClear = new System.Windows.Forms.Button();
    2.23 -            this.buttonFill = new System.Windows.Forms.Button();
    2.24 -            this.trackBarBrightness = new System.Windows.Forms.TrackBar();
    2.25 -            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    2.26 -            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    2.27              this.tabControl.SuspendLayout();
    2.28              this.tabPageDisplay.SuspendLayout();
    2.29 +            ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
    2.30              this.tableLayoutPanel.SuspendLayout();
    2.31 -            ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
    2.32              this.SuspendLayout();
    2.33              // 
    2.34              // tabControl
    2.35 @@ -81,6 +81,57 @@
    2.36              this.tabPageDisplay.Text = "Display";
    2.37              this.tabPageDisplay.UseVisualStyleBackColor = true;
    2.38              // 
    2.39 +            // trackBarBrightness
    2.40 +            // 
    2.41 +            this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
    2.42 +            this.trackBarBrightness.Location = new System.Drawing.Point(470, 6);
    2.43 +            this.trackBarBrightness.Name = "trackBarBrightness";
    2.44 +            this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
    2.45 +            this.trackBarBrightness.Size = new System.Drawing.Size(45, 324);
    2.46 +            this.trackBarBrightness.TabIndex = 10;
    2.47 +            this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
    2.48 +            this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
    2.49 +            // 
    2.50 +            // buttonFill
    2.51 +            // 
    2.52 +            this.buttonFill.Location = new System.Drawing.Point(6, 93);
    2.53 +            this.buttonFill.Name = "buttonFill";
    2.54 +            this.buttonFill.Size = new System.Drawing.Size(75, 23);
    2.55 +            this.buttonFill.TabIndex = 9;
    2.56 +            this.buttonFill.Text = "Fill";
    2.57 +            this.buttonFill.UseVisualStyleBackColor = true;
    2.58 +            this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
    2.59 +            // 
    2.60 +            // buttonClear
    2.61 +            // 
    2.62 +            this.buttonClear.Location = new System.Drawing.Point(6, 64);
    2.63 +            this.buttonClear.Name = "buttonClear";
    2.64 +            this.buttonClear.Size = new System.Drawing.Size(75, 23);
    2.65 +            this.buttonClear.TabIndex = 8;
    2.66 +            this.buttonClear.Text = "Clear";
    2.67 +            this.buttonClear.UseVisualStyleBackColor = true;
    2.68 +            this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
    2.69 +            // 
    2.70 +            // buttonClose
    2.71 +            // 
    2.72 +            this.buttonClose.Location = new System.Drawing.Point(6, 35);
    2.73 +            this.buttonClose.Name = "buttonClose";
    2.74 +            this.buttonClose.Size = new System.Drawing.Size(75, 23);
    2.75 +            this.buttonClose.TabIndex = 7;
    2.76 +            this.buttonClose.Text = "Close";
    2.77 +            this.buttonClose.UseVisualStyleBackColor = true;
    2.78 +            this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
    2.79 +            // 
    2.80 +            // buttonOpen
    2.81 +            // 
    2.82 +            this.buttonOpen.Location = new System.Drawing.Point(6, 6);
    2.83 +            this.buttonOpen.Name = "buttonOpen";
    2.84 +            this.buttonOpen.Size = new System.Drawing.Size(75, 23);
    2.85 +            this.buttonOpen.TabIndex = 6;
    2.86 +            this.buttonOpen.Text = "Open";
    2.87 +            this.buttonOpen.UseVisualStyleBackColor = true;
    2.88 +            this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
    2.89 +            // 
    2.90              // buttonCapture
    2.91              // 
    2.92              this.buttonCapture.Location = new System.Drawing.Point(6, 278);
    2.93 @@ -124,9 +175,52 @@
    2.94              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.95              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.96              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.97 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.98 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.99 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.100 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.101 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.102 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.103 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.104 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.105 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.106 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.107 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.108 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
   2.109              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
   2.110              this.tableLayoutPanel.TabIndex = 4;
   2.111              // 
   2.112 +            // marqueeLabelTop
   2.113 +            // 
   2.114 +            this.marqueeLabelTop.AutoEllipsis = true;
   2.115 +            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
   2.116 +            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
   2.117 +            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
   2.118 +            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
   2.119 +            this.marqueeLabelTop.Name = "marqueeLabelTop";
   2.120 +            this.marqueeLabelTop.OwnTimer = false;
   2.121 +            this.marqueeLabelTop.PixelsPerSecond = 64;
   2.122 +            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30);
   2.123 +            this.marqueeLabelTop.TabIndex = 2;
   2.124 +            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
   2.125 +            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.126 +            this.marqueeLabelTop.UseCompatibleTextRendering = true;
   2.127 +            // 
   2.128 +            // marqueeLabelBottom
   2.129 +            // 
   2.130 +            this.marqueeLabelBottom.AutoEllipsis = true;
   2.131 +            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   2.132 +            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
   2.133 +            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   2.134 +            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   2.135 +            this.marqueeLabelBottom.OwnTimer = false;
   2.136 +            this.marqueeLabelBottom.PixelsPerSecond = 64;
   2.137 +            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31);
   2.138 +            this.marqueeLabelBottom.TabIndex = 3;
   2.139 +            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   2.140 +            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.141 +            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   2.142 +            // 
   2.143              // buttonFont
   2.144              // 
   2.145              this.buttonFont.Location = new System.Drawing.Point(6, 307);
   2.146 @@ -153,86 +247,6 @@
   2.147              this.timer.Interval = 50;
   2.148              this.timer.Tick += new System.EventHandler(this.timer_Tick);
   2.149              // 
   2.150 -            // buttonOpen
   2.151 -            // 
   2.152 -            this.buttonOpen.Location = new System.Drawing.Point(6, 6);
   2.153 -            this.buttonOpen.Name = "buttonOpen";
   2.154 -            this.buttonOpen.Size = new System.Drawing.Size(75, 23);
   2.155 -            this.buttonOpen.TabIndex = 6;
   2.156 -            this.buttonOpen.Text = "Open";
   2.157 -            this.buttonOpen.UseVisualStyleBackColor = true;
   2.158 -            this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
   2.159 -            // 
   2.160 -            // buttonClose
   2.161 -            // 
   2.162 -            this.buttonClose.Location = new System.Drawing.Point(6, 35);
   2.163 -            this.buttonClose.Name = "buttonClose";
   2.164 -            this.buttonClose.Size = new System.Drawing.Size(75, 23);
   2.165 -            this.buttonClose.TabIndex = 7;
   2.166 -            this.buttonClose.Text = "Close";
   2.167 -            this.buttonClose.UseVisualStyleBackColor = true;
   2.168 -            this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
   2.169 -            // 
   2.170 -            // buttonClear
   2.171 -            // 
   2.172 -            this.buttonClear.Location = new System.Drawing.Point(6, 64);
   2.173 -            this.buttonClear.Name = "buttonClear";
   2.174 -            this.buttonClear.Size = new System.Drawing.Size(75, 23);
   2.175 -            this.buttonClear.TabIndex = 8;
   2.176 -            this.buttonClear.Text = "Clear";
   2.177 -            this.buttonClear.UseVisualStyleBackColor = true;
   2.178 -            this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
   2.179 -            // 
   2.180 -            // buttonFill
   2.181 -            // 
   2.182 -            this.buttonFill.Location = new System.Drawing.Point(6, 93);
   2.183 -            this.buttonFill.Name = "buttonFill";
   2.184 -            this.buttonFill.Size = new System.Drawing.Size(75, 23);
   2.185 -            this.buttonFill.TabIndex = 9;
   2.186 -            this.buttonFill.Text = "Fill";
   2.187 -            this.buttonFill.UseVisualStyleBackColor = true;
   2.188 -            this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
   2.189 -            // 
   2.190 -            // trackBarBrightness
   2.191 -            // 
   2.192 -            this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
   2.193 -            this.trackBarBrightness.Location = new System.Drawing.Point(470, 6);
   2.194 -            this.trackBarBrightness.Name = "trackBarBrightness";
   2.195 -            this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
   2.196 -            this.trackBarBrightness.Size = new System.Drawing.Size(45, 324);
   2.197 -            this.trackBarBrightness.TabIndex = 10;
   2.198 -            this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
   2.199 -            this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
   2.200 -            // 
   2.201 -            // marqueeLabelTop
   2.202 -            // 
   2.203 -            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
   2.204 -            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
   2.205 -            this.marqueeLabelTop.Location = new System.Drawing.Point(1, -313);
   2.206 -            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
   2.207 -            this.marqueeLabelTop.Name = "marqueeLabelTop";
   2.208 -            this.marqueeLabelTop.OwnTimer = false;
   2.209 -            this.marqueeLabelTop.PixelsPerSecond = 64;
   2.210 -            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
   2.211 -            this.marqueeLabelTop.TabIndex = 2;
   2.212 -            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
   2.213 -            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.214 -            this.marqueeLabelTop.UseCompatibleTextRendering = true;
   2.215 -            // 
   2.216 -            // marqueeLabelBottom
   2.217 -            // 
   2.218 -            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   2.219 -            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -166);
   2.220 -            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   2.221 -            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   2.222 -            this.marqueeLabelBottom.OwnTimer = false;
   2.223 -            this.marqueeLabelBottom.PixelsPerSecond = 64;
   2.224 -            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
   2.225 -            this.marqueeLabelBottom.TabIndex = 3;
   2.226 -            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   2.227 -            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   2.228 -            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   2.229 -            // 
   2.230              // MainForm
   2.231              // 
   2.232              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   2.233 @@ -244,8 +258,8 @@
   2.234              this.tabControl.ResumeLayout(false);
   2.235              this.tabPageDisplay.ResumeLayout(false);
   2.236              this.tabPageDisplay.PerformLayout();
   2.237 +            ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
   2.238              this.tableLayoutPanel.ResumeLayout(false);
   2.239 -            ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
   2.240              this.ResumeLayout(false);
   2.241  
   2.242          }
     3.1 --- a/MainForm.cs	Mon Jul 07 21:32:02 2014 +0200
     3.2 +++ b/MainForm.cs	Mon Jul 07 22:29:26 2014 +0200
     3.3 @@ -43,10 +43,11 @@
     3.4              if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
     3.5              {
     3.6  
     3.7 -                MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
     3.8 +                //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
     3.9  
    3.10                  //MessageBox.Show("Ok");
    3.11 -                //textBox1.Font = fontDlg.Font;
    3.12 +                marqueeLabelTop.Font = fontDialog.Font;
    3.13 +                marqueeLabelBottom.Font = fontDialog.Font;
    3.14                  //label1.Font = fontDlg.Font;
    3.15                  //textBox1.BackColor = fontDlg.Color;
    3.16                  //label1.ForeColor = fontDlg.Color;
    3.17 @@ -69,6 +70,29 @@
    3.18              marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
    3.19  
    3.20              LastTickTime = NewTickTime;
    3.21 +
    3.22 +            //Update our display
    3.23 +            if (iDisplay.IsOpen())
    3.24 +            {
    3.25 +                //Draw to bitmap
    3.26 +                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
    3.27 +                tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
    3.28 +                //Send it to our display 
    3.29 +                for (int i = 0; i < bmp.Width; i++)
    3.30 +                {
    3.31 +                    for (int j = 0; j < bmp.Height; j++)
    3.32 +                    {
    3.33 +                        unchecked
    3.34 +                        {
    3.35 +                        uint color=(uint)bmp.GetPixel(i, j).ToArgb();
    3.36 +                        iDisplay.SetPixel(i, j, Convert.ToInt32(color!=0xFFFFFFFF));
    3.37 +                        }
    3.38 +                    }
    3.39 +                }
    3.40 +
    3.41 +                iDisplay.SwapBuffers();
    3.42 +
    3.43 +            }
    3.44          }
    3.45  
    3.46          private void buttonOpen_Click(object sender, EventArgs e)