# HG changeset patch # User sl # Date 1404764966 -7200 # Node ID 0825370a79470d4da5b3c1e5a488bafa1e3d5838 # Parent 71b55cfd8c05f2890429b01980dcc4993567d3e6 Display is now updated as labels are scrolling. diff -r 71b55cfd8c05 -r 0825370a7947 Display.cs --- a/Display.cs Mon Jul 07 21:32:02 2014 +0200 +++ b/Display.cs Mon Jul 07 22:29:26 2014 +0200 @@ -71,6 +71,23 @@ MiniDisplaySetBrightness(iDevice, aBrightness); } + public int WidthInPixels() + { + return MiniDisplayWidthInPixels(iDevice); + } + + public int HeightInPixels() + { + return MiniDisplayHeightInPixels(iDevice); + } + + public void SetPixel(int aX, int aY, int aValue) + { + MiniDisplaySetPixel(iDevice,aX,aY,aValue); + } + + + //Our display device handle IntPtr iDevice; @@ -98,6 +115,15 @@ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] public static extern int MiniDisplayMaxBrightness(IntPtr aDevice); + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern int MiniDisplayWidthInPixels(IntPtr aDevice); + + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern int MiniDisplayHeightInPixels(IntPtr aDevice); + + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue); + } } diff -r 71b55cfd8c05 -r 0825370a7947 MainForm.Designer.cs --- a/MainForm.Designer.cs Mon Jul 07 21:32:02 2014 +0200 +++ b/MainForm.Designer.cs Mon Jul 07 22:29:26 2014 +0200 @@ -31,23 +31,23 @@ this.components = new System.ComponentModel.Container(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabPageDisplay = new System.Windows.Forms.TabPage(); + this.trackBarBrightness = new System.Windows.Forms.TrackBar(); + this.buttonFill = new System.Windows.Forms.Button(); + this.buttonClear = new System.Windows.Forms.Button(); + this.buttonClose = new System.Windows.Forms.Button(); + 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.buttonOpen = new System.Windows.Forms.Button(); - this.buttonClose = new System.Windows.Forms.Button(); - this.buttonClear = new System.Windows.Forms.Button(); - this.buttonFill = new System.Windows.Forms.Button(); - this.trackBarBrightness = new System.Windows.Forms.TrackBar(); - 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(); - ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit(); this.SuspendLayout(); // // tabControl @@ -81,6 +81,57 @@ this.tabPageDisplay.Text = "Display"; this.tabPageDisplay.UseVisualStyleBackColor = true; // + // trackBarBrightness + // + this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window; + this.trackBarBrightness.Location = new System.Drawing.Point(470, 6); + this.trackBarBrightness.Name = "trackBarBrightness"; + this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical; + this.trackBarBrightness.Size = new System.Drawing.Size(45, 324); + this.trackBarBrightness.TabIndex = 10; + this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both; + this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll); + // + // buttonFill + // + this.buttonFill.Location = new System.Drawing.Point(6, 93); + this.buttonFill.Name = "buttonFill"; + this.buttonFill.Size = new System.Drawing.Size(75, 23); + this.buttonFill.TabIndex = 9; + this.buttonFill.Text = "Fill"; + this.buttonFill.UseVisualStyleBackColor = true; + this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click); + // + // buttonClear + // + this.buttonClear.Location = new System.Drawing.Point(6, 64); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(75, 23); + this.buttonClear.TabIndex = 8; + this.buttonClear.Text = "Clear"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click); + // + // buttonClose + // + this.buttonClose.Location = new System.Drawing.Point(6, 35); + this.buttonClose.Name = "buttonClose"; + this.buttonClose.Size = new System.Drawing.Size(75, 23); + this.buttonClose.TabIndex = 7; + this.buttonClose.Text = "Close"; + this.buttonClose.UseVisualStyleBackColor = true; + this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); + // + // buttonOpen + // + this.buttonOpen.Location = new System.Drawing.Point(6, 6); + this.buttonOpen.Name = "buttonOpen"; + this.buttonOpen.Size = new System.Drawing.Size(75, 23); + this.buttonOpen.TabIndex = 6; + this.buttonOpen.Text = "Open"; + this.buttonOpen.UseVisualStyleBackColor = true; + this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click); + // // buttonCapture // this.buttonCapture.Location = new System.Drawing.Point(6, 278); @@ -124,9 +175,52 @@ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); 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); @@ -153,86 +247,6 @@ this.timer.Interval = 50; this.timer.Tick += new System.EventHandler(this.timer_Tick); // - // buttonOpen - // - this.buttonOpen.Location = new System.Drawing.Point(6, 6); - this.buttonOpen.Name = "buttonOpen"; - this.buttonOpen.Size = new System.Drawing.Size(75, 23); - this.buttonOpen.TabIndex = 6; - this.buttonOpen.Text = "Open"; - this.buttonOpen.UseVisualStyleBackColor = true; - this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click); - // - // buttonClose - // - this.buttonClose.Location = new System.Drawing.Point(6, 35); - this.buttonClose.Name = "buttonClose"; - this.buttonClose.Size = new System.Drawing.Size(75, 23); - this.buttonClose.TabIndex = 7; - this.buttonClose.Text = "Close"; - this.buttonClose.UseVisualStyleBackColor = true; - this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); - // - // buttonClear - // - this.buttonClear.Location = new System.Drawing.Point(6, 64); - this.buttonClear.Name = "buttonClear"; - this.buttonClear.Size = new System.Drawing.Size(75, 23); - this.buttonClear.TabIndex = 8; - this.buttonClear.Text = "Clear"; - this.buttonClear.UseVisualStyleBackColor = true; - this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click); - // - // buttonFill - // - this.buttonFill.Location = new System.Drawing.Point(6, 93); - this.buttonFill.Name = "buttonFill"; - this.buttonFill.Size = new System.Drawing.Size(75, 23); - this.buttonFill.TabIndex = 9; - this.buttonFill.Text = "Fill"; - this.buttonFill.UseVisualStyleBackColor = true; - this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click); - // - // trackBarBrightness - // - this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window; - this.trackBarBrightness.Location = new System.Drawing.Point(470, 6); - this.trackBarBrightness.Name = "trackBarBrightness"; - this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical; - this.trackBarBrightness.Size = new System.Drawing.Size(45, 324); - this.trackBarBrightness.TabIndex = 10; - this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both; - this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll); - // - // marqueeLabelTop - // - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelTop.Location = new System.Drawing.Point(1, -313); - 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.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -166); - 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); @@ -244,8 +258,8 @@ this.tabControl.ResumeLayout(false); this.tabPageDisplay.ResumeLayout(false); this.tabPageDisplay.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit(); this.tableLayoutPanel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit(); this.ResumeLayout(false); } diff -r 71b55cfd8c05 -r 0825370a7947 MainForm.cs --- a/MainForm.cs Mon Jul 07 21:32:02 2014 +0200 +++ b/MainForm.cs Mon Jul 07 22:29:26 2014 +0200 @@ -43,10 +43,11 @@ if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel) { - MsgBox.Show("MessageBox MsgBox", "MsgBox caption"); + //MsgBox.Show("MessageBox MsgBox", "MsgBox caption"); //MessageBox.Show("Ok"); - //textBox1.Font = fontDlg.Font; + marqueeLabelTop.Font = fontDialog.Font; + marqueeLabelBottom.Font = fontDialog.Font; //label1.Font = fontDlg.Font; //textBox1.BackColor = fontDlg.Color; //label1.ForeColor = fontDlg.Color; @@ -69,6 +70,29 @@ marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime); LastTickTime = NewTickTime; + + //Update our display + if (iDisplay.IsOpen()) + { + //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 + for (int i = 0; i < bmp.Width; i++) + { + for (int j = 0; j < bmp.Height; j++) + { + unchecked + { + uint color=(uint)bmp.GetPixel(i, j).ToArgb(); + iDisplay.SetPixel(i, j, Convert.ToInt32(color!=0xFFFFFFFF)); + } + } + } + + iDisplay.SwapBuffers(); + + } } private void buttonOpen_Click(object sender, EventArgs e)