# HG changeset patch # User sl # Date 1404838747 -7200 # Node ID 5129c03ab7badc40ab870a9593f1b4ede5299e2a # Parent 69815d19796c8ba1d7e897c53f23b0dc358edf0c Adding persistent settings and marquee separator. diff -r 69815d19796c -r 5129c03ab7ba App.config --- a/App.config Tue Jul 08 16:41:29 2014 +0200 +++ b/App.config Tue Jul 08 18:59:07 2014 +0200 @@ -1,6 +1,21 @@  + + +
+ + + + + + 1 + + + Microsoft Sans Serif, 9.75pt + + + \ No newline at end of file diff -r 69815d19796c -r 5129c03ab7ba MainForm.Designer.cs --- a/MainForm.Designer.cs Tue Jul 08 16:41:29 2014 +0200 +++ b/MainForm.Designer.cs Tue Jul 08 18:59:07 2014 +0200 @@ -38,14 +38,16 @@ 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.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel(); this.tabControl.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit(); @@ -196,6 +198,39 @@ 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.Separator = ""; + 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.Separator = " | "; + 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -226,9 +261,12 @@ // statusStrip // this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelConnect}); + this.toolStripStatusLabelConnect, + this.toolStripStatusLabelSpring, + this.toolStripStatusLabelFps}); this.statusStrip.Location = new System.Drawing.Point(0, 420); this.statusStrip.Name = "statusStrip"; + this.statusStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; this.statusStrip.Size = new System.Drawing.Size(624, 22); this.statusStrip.TabIndex = 1; this.statusStrip.Text = "statusStrip"; @@ -239,36 +277,17 @@ this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17); this.toolStripStatusLabelConnect.Text = "Not connected"; // - // marqueeLabelTop + // toolStripStatusLabelSpring // - 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; + this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring"; + this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(497, 17); + this.toolStripStatusLabelSpring.Spring = true; // - // marqueeLabelBottom + // toolStripStatusLabelFps // - 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; + this.toolStripStatusLabelFps.Name = "toolStripStatusLabelFps"; + this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17); + this.toolStripStatusLabelFps.Text = "FPS"; // // MainForm // @@ -311,6 +330,8 @@ private System.Windows.Forms.TrackBar trackBarBrightness; private System.Windows.Forms.StatusStrip statusStrip; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring; } } diff -r 69815d19796c -r 5129c03ab7ba MainForm.cs --- a/MainForm.cs Tue Jul 08 16:41:29 2014 +0200 +++ b/MainForm.cs Tue Jul 08 18:59:07 2014 +0200 @@ -23,6 +23,9 @@ InitializeComponent(); UpdateStatus(); + //Load settings + marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont; + marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont; } private void buttonFont_Click(object sender, EventArgs e) @@ -49,6 +52,8 @@ //MessageBox.Show("Ok"); marqueeLabelTop.Font = fontDialog.Font; marqueeLabelBottom.Font = fontDialog.Font; + Properties.Settings.Default.DisplayFont = fontDialog.Font; + Properties.Settings.Default.Save(); //label1.Font = fontDlg.Font; //textBox1.BackColor = fontDlg.Color; //label1.ForeColor = fontDlg.Color; @@ -70,8 +75,6 @@ marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime); marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime); - LastTickTime = NewTickTime; - //Update our display if (iDisplay.IsOpen()) { @@ -94,6 +97,12 @@ iDisplay.SwapBuffers(); } + + //Compute instant FPS + toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS"; + + LastTickTime = NewTickTime; + } private void buttonOpen_Click(object sender, EventArgs e) @@ -155,6 +164,5 @@ toolStripStatusLabelConnect.Text = "Not connected"; } } - } } diff -r 69815d19796c -r 5129c03ab7ba MarqueeLabel.cs --- a/MarqueeLabel.cs Tue Jul 08 16:41:29 2014 +0200 +++ b/MarqueeLabel.cs Tue Jul 08 18:59:07 2014 +0200 @@ -17,6 +17,13 @@ private StringFormat iStringFormat; private SolidBrush iBrush; private SizeF iTextSize; + private SizeF iSeparatorSize; + + [Category("Appearance")] + [Description("Separator in our scrolling loop.")] + [DefaultValue(" | ")] + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)] + public string Separator { get; set; } [Category("Behavior")] [Description("How fast is our text scrolling, in pixels per second.")] @@ -80,9 +87,9 @@ return; } - while (CurrentPosition > (iTextSize.Width)) + while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width)) { - CurrentPosition -= ((int)iTextSize.Width); + CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width)); } PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond; @@ -194,6 +201,7 @@ Graphics g = this.CreateGraphics(); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; iTextSize = g.MeasureString(Text, Font); + iSeparatorSize = g.MeasureString(Separator, Font); iStringFormat = GetStringFormatFromContentAllignment(TextAlign); if (NeedToScroll()) @@ -234,8 +242,11 @@ //Draw the first one e.Graphics.TranslateTransform(-(float)CurrentPosition, 0); e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat); + //Draw separator + e.Graphics.TranslateTransform(iTextSize.Width, 0); + e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat); //Draw the last one - e.Graphics.TranslateTransform(iTextSize.Width, 0); + e.Graphics.TranslateTransform(iSeparatorSize.Width, 0); e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat); } else diff -r 69815d19796c -r 5129c03ab7ba Properties/Settings.Designer.cs --- a/Properties/Settings.Designer.cs Tue Jul 08 16:41:29 2014 +0200 +++ b/Properties/Settings.Designer.cs Tue Jul 08 18:59:07 2014 +0200 @@ -8,23 +8,43 @@ // //------------------------------------------------------------------------------ -namespace SharpDisplayManager.Properties -{ - - +namespace SharpDisplayManager.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public int DisplayBrightness { + get { + return ((int)(this["DisplayBrightness"])); + } + set { + this["DisplayBrightness"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Microsoft Sans Serif, 9.75pt")] + public global::System.Drawing.Font DisplayFont { + get { + return ((global::System.Drawing.Font)(this["DisplayFont"])); + } + set { + this["DisplayFont"] = value; + } + } } } diff -r 69815d19796c -r 5129c03ab7ba Properties/Settings.settings --- a/Properties/Settings.settings Tue Jul 08 16:41:29 2014 +0200 +++ b/Properties/Settings.settings Tue Jul 08 18:59:07 2014 +0200 @@ -1,7 +1,12 @@  - - - - - - + + + + + 1 + + + Microsoft Sans Serif, 9.75pt + + + \ No newline at end of file