# HG changeset patch
# User StephaneLenclud
# Date 1423152299 -3600
# Node ID 32270ff62819de0d3f2e6760eb4ac8c58d4454ad
# Parent 4196b0ca97d96bd4922c879da8ba8513c9b73cfc
Server: Adding scrolling speed setting.
Fixing issue with alignment of newly created text field not being set properly.
Client: Now starting-up first client automatically in debug mode.
diff -r 4196b0ca97d9 -r 32270ff62819 Client/MainForm.cs
--- a/Client/MainForm.cs Wed Feb 04 21:55:45 2015 +0100
+++ b/Client/MainForm.cs Thu Feb 05 17:04:59 2015 +0100
@@ -17,11 +17,18 @@
{
public partial class MainForm : Form
{
+ public StartParams Params { get; set; }
+
+ //
DisplayClient iClient;
-
+ //
ContentAlignment Alignment;
DataField iTextFieldTop;
+
+ ///
+ /// Constructor
+ ///
public MainForm()
{
InitializeComponent();
@@ -29,7 +36,11 @@
iTextFieldTop = new DataField(0);
}
-
+ ///
+ ///
+ ///
+ ///
+ ///
private void MainForm_Load(object sender, EventArgs e)
{
iClient = new DisplayClient(this);
@@ -46,6 +57,24 @@
textBoxTop.Text = iClient.Name;
textBoxBottom.Text = iClient.SessionId;
+ if (Params != null)
+ {
+ //Parameters where specified use them
+ if (Params.TopText != "")
+ {
+ textBoxTop.Text = Params.TopText;
+ }
+
+ if (Params.BottomText != "")
+ {
+ textBoxBottom.Text = Params.BottomText;
+ }
+
+ Location = Params.Location;
+ //
+ SetBasicLayoutAndText();
+ }
+
}
@@ -146,17 +175,23 @@
private void buttonSetText_Click(object sender, EventArgs e)
{
- //Set one column two lines layout
- TableLayout layout = new TableLayout(1, 2);
- iClient.SetLayout(layout);
+ SetBasicLayoutAndText();
+ }
- //Set our fields
- iClient.CreateFields(new DataField[]
+ void SetBasicLayoutAndText()
+ {
+ //Set one column two lines layout
+ TableLayout layout = new TableLayout(1, 2);
+ iClient.SetLayout(layout);
+
+ //Set our fields
+ iClient.CreateFields(new DataField[]
{
new DataField(0, textBoxTop.Text, Alignment),
new DataField(1, textBoxBottom.Text, Alignment)
});
- }
+
+ }
private void buttonLayoutUpdate_Click(object sender, EventArgs e)
{
diff -r 4196b0ca97d9 -r 32270ff62819 Client/Program.cs
--- a/Client/Program.cs Wed Feb 04 21:55:45 2015 +0100
+++ b/Client/Program.cs Thu Feb 05 17:04:59 2015 +0100
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Drawing;
namespace SharpDisplayClient
{
@@ -19,7 +20,35 @@
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainForm());
+ Application.Run(new MainForm());
}
+
+ [STAThread]
+ static public void MainWithParams(object aParams)
+ {
+ //Set high priority to our process to avoid lags when rendering to our screen
+ System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal;
+
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ MainForm mainForm = new MainForm();
+ mainForm.Params = (StartParams)aParams;
+ Application.Run(mainForm);
+ }
+
}
+
+ public class StartParams
+ {
+ public StartParams(Point aLocation, string aTopText="", string aBottomText="")
+ {
+ TopText = aTopText;
+ BottomText = aBottomText;
+ Location = aLocation;
+ }
+
+ public string TopText { get; set; }
+ public string BottomText { get; set; }
+ public Point Location { get; set; }
+ }
}
diff -r 4196b0ca97d9 -r 32270ff62819 Server/DisplaySettings.cs
--- a/Server/DisplaySettings.cs Wed Feb 04 21:55:45 2015 +0100
+++ b/Server/DisplaySettings.cs Thu Feb 05 17:04:59 2015 +0100
@@ -29,7 +29,8 @@
FontName = "Microsoft Sans Serif, 9.75pt";
ScaleToFit = true;
MinFontSize = 15.0f;
- Separator = " ";
+ Separator = " ";
+ ScrollingSpeedInPixelsPerSecond = 64;
}
[DataMember]
@@ -44,6 +45,9 @@
[DataMember]
public int TimerInterval { get; set; }
+ [DataMember]
+ public int ScrollingSpeedInPixelsPerSecond { get; set; }
+
[DataMember]
public bool ReverseScreen { get; set; }
diff -r 4196b0ca97d9 -r 32270ff62819 Server/MainForm.Designer.cs
--- a/Server/MainForm.Designer.cs Wed Feb 04 21:55:45 2015 +0100
+++ b/Server/MainForm.Designer.cs Thu Feb 05 17:04:59 2015 +0100
@@ -98,6 +98,8 @@
this.labelFontWidth = new System.Windows.Forms.Label();
this.labelFontHeight = new System.Windows.Forms.Label();
this.pictureBoxDemo = new System.Windows.Forms.PictureBox();
+ this.maskedTextBoxScrollingSpeed = new System.Windows.Forms.MaskedTextBox();
+ this.labelScrollingSpeed = new System.Windows.Forms.Label();
this.panelDisplay.SuspendLayout();
this.tableLayoutPanel.SuspendLayout();
this.statusStrip.SuspendLayout();
@@ -515,6 +517,8 @@
//
// tabPageDesign
//
+ this.tabPageDesign.Controls.Add(this.labelScrollingSpeed);
+ this.tabPageDesign.Controls.Add(this.maskedTextBoxScrollingSpeed);
this.tabPageDesign.Controls.Add(this.labelScrollLoopSeparator);
this.tabPageDesign.Controls.Add(this.textBoxScrollLoopSeparator);
this.tabPageDesign.Controls.Add(this.labelMinFontSize);
@@ -543,7 +547,7 @@
// labelScrollLoopSeparator
//
this.labelScrollLoopSeparator.AutoSize = true;
- this.labelScrollLoopSeparator.Location = new System.Drawing.Point(84, 145);
+ this.labelScrollLoopSeparator.Location = new System.Drawing.Point(90, 145);
this.labelScrollLoopSeparator.Name = "labelScrollLoopSeparator";
this.labelScrollLoopSeparator.Size = new System.Drawing.Size(109, 13);
this.labelScrollLoopSeparator.TabIndex = 26;
@@ -768,6 +772,25 @@
this.pictureBoxDemo.TabIndex = 21;
this.pictureBoxDemo.TabStop = false;
//
+ // maskedTextBoxScrollingSpeed
+ //
+ this.maskedTextBoxScrollingSpeed.Location = new System.Drawing.Point(205, 116);
+ this.maskedTextBoxScrollingSpeed.Mask = "000";
+ this.maskedTextBoxScrollingSpeed.Name = "maskedTextBoxScrollingSpeed";
+ this.maskedTextBoxScrollingSpeed.PromptChar = ' ';
+ this.maskedTextBoxScrollingSpeed.Size = new System.Drawing.Size(24, 20);
+ this.maskedTextBoxScrollingSpeed.TabIndex = 27;
+ this.maskedTextBoxScrollingSpeed.TextChanged += new System.EventHandler(this.maskedTextBoxScrollingSpeed_TextChanged);
+ //
+ // labelScrollingSpeed
+ //
+ this.labelScrollingSpeed.AutoSize = true;
+ this.labelScrollingSpeed.Location = new System.Drawing.Point(84, 119);
+ this.labelScrollingSpeed.Name = "labelScrollingSpeed";
+ this.labelScrollingSpeed.Size = new System.Drawing.Size(115, 13);
+ this.labelScrollingSpeed.TabIndex = 28;
+ this.labelScrollingSpeed.Text = "Scrolling speed (px/s) :";
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -869,6 +892,8 @@
private System.Windows.Forms.Label labelMinFontSize;
private System.Windows.Forms.Label labelScrollLoopSeparator;
private System.Windows.Forms.TextBox textBoxScrollLoopSeparator;
+ private System.Windows.Forms.Label labelScrollingSpeed;
+ private System.Windows.Forms.MaskedTextBox maskedTextBoxScrollingSpeed;
}
}
diff -r 4196b0ca97d9 -r 32270ff62819 Server/MainForm.cs
--- a/Server/MainForm.cs Wed Feb 04 21:55:45 2015 +0100
+++ b/Server/MainForm.cs Thu Feb 05 17:04:59 2015 +0100
@@ -103,6 +103,52 @@
}
///
+ ///
+ ///
+ ///
+ ///
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ //Check if we are running a Click Once deployed application
+ if (ApplicationDeployment.IsNetworkDeployed)
+ {
+ //This is a proper Click Once installation, fetch and show our version number
+ this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
+ }
+ else
+ {
+ //Not a proper Click Once installation, assuming development build then
+ this.Text += " - development";
+ }
+
+ //Setup notification icon
+ SetupTrayIcon();
+
+ // To make sure start up with minimize to tray works
+ if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
+ {
+ Visible = false;
+ }
+
+#if !DEBUG
+ //When not debugging we want the screen to be empty until a client takes over
+ ClearLayout();
+#else
+ //When developing we want at least one client for testing
+ StartNewClient("abcdefghijklmnopqrst-0123456789","ABCDEFGHIJKLMNOPQRST-0123456789");
+#endif
+
+ //Open display connection on start-up if needed
+ if (Properties.Settings.Default.DisplayConnectOnStartup)
+ {
+ OpenDisplayConnection();
+ }
+
+ //Start our server so that we can get client requests
+ StartServer();
+ }
+
+ ///
/// Called when our display is opened.
///
///
@@ -139,58 +185,15 @@
{
int count = Display.TypeCount();
- for (int i=0; i
///
///
- ///
- ///
- private void MainForm_Load(object sender, EventArgs e)
- {
- //Check if we are running a Click Once deployed application
- if (ApplicationDeployment.IsNetworkDeployed)
- {
- //This is a proper Click Once installation, fetch and show our version number
- this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
- }
- else
- {
- //Not a proper Click Once installation, assuming development build then
- this.Text += " - development";
- }
-
- //Setup notification icon
- SetupTrayIcon();
-
- // To make sure start up with minimize to tray works
- if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
- {
- Visible = false;
- }
-
-#if !DEBUG
- //When not debugging we want the screen to be empty until a client takes over
- ClearLayout();
-#endif
-
- //Open display connection on start-up if needed
- if (Properties.Settings.Default.DisplayConnectOnStartup)
- {
- OpenDisplayConnection();
- }
-
- //Start our server so that we can get client requests
- StartServer();
- }
-
- ///
- ///
- ///
private void SetupTrayIcon()
{
iNotifyIcon.Icon = GetIcon("vfd.ico");
@@ -688,6 +691,7 @@
maskedTextBoxMinFontSize.Enabled = cds.ScaleToFit;
labelMinFontSize.Enabled = cds.ScaleToFit;
maskedTextBoxMinFontSize.Text = cds.MinFontSize.ToString();
+ maskedTextBoxScrollingSpeed.Text = cds.ScrollingSpeedInPixelsPerSecond.ToString();
comboBoxDisplayType.SelectedIndex = cds.DisplayType;
timer.Interval = cds.TimerInterval;
maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
@@ -772,6 +776,7 @@
toolStripStatusLabelConnect.Text = "Disconnected";
toolStripStatusLabelPower.Text = "N/A";
}
+
}
@@ -936,11 +941,20 @@
tableLayoutPanel.ColumnStyles.Clear();
}
+ ///
+ /// Just launch a demo client.
+ ///
+ private void StartNewClient(string aTopText = "", string aBottomText = "")
+ {
+ Thread clientThread = new Thread(SharpDisplayClient.Program.MainWithParams);
+ SharpDisplayClient.StartParams myParams = new SharpDisplayClient.StartParams(new Point(this.Right, this.Top),aTopText,aBottomText);
+ clientThread.Start(myParams);
+ BringToFront();
+ }
+
private void buttonStartClient_Click(object sender, EventArgs e)
{
- Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
- clientThread.Start();
- BringToFront();
+ StartNewClient();
}
private void buttonSuspend_Click(object sender, EventArgs e)
@@ -1381,6 +1395,13 @@
///
private void UpdateTableLayoutPanel(ClientData aClient)
{
+ if (aClient == null)
+ {
+ //Just drop it
+ return;
+ }
+
+
TableLayout layout = aClient.Layout;
int fieldCount = 0;
@@ -1472,7 +1493,7 @@
label.Margin = new System.Windows.Forms.Padding(0);
label.Name = "marqueeLabel" + aField.Index;
label.OwnTimer = false;
- label.PixelsPerSecond = 64;
+ label.PixelsPerSecond = cds.ScrollingSpeedInPixelsPerSecond;
label.Separator = cds.Separator;
label.MinFontSize = cds.MinFontSize;
label.ScaleToFit = cds.ScaleToFit;
@@ -1480,7 +1501,7 @@
//control.TabIndex = 2;
label.Font = cds.Font;
- label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ label.TextAlign = aField.Alignment;
label.UseCompatibleTextRendering = true;
label.Text = aField.Text;
//
@@ -1577,13 +1598,31 @@
if (minFontSize > 0)
{
- //TODO: re-create layout? update our fields?
cds.MinFontSize = minFontSize;
Properties.Settings.Default.Save();
+ //We need to recreate our layout for that change to take effect
+ UpdateTableLayoutPanel(iCurrentClientData);
}
}
}
+
+ private void maskedTextBoxScrollingSpeed_TextChanged(object sender, EventArgs e)
+ {
+ if (maskedTextBoxScrollingSpeed.Text != "")
+ {
+ int scrollingSpeed = Convert.ToInt32(maskedTextBoxScrollingSpeed.Text);
+
+ if (scrollingSpeed > 0)
+ {
+ cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed;
+ Properties.Settings.Default.Save();
+ //We need to recreate our layout for that change to take effect
+ UpdateTableLayoutPanel(iCurrentClientData);
+ }
+ }
+ }
+
private void textBoxScrollLoopSeparator_TextChanged(object sender, EventArgs e)
{
//TODO: re-create layout? update our fields?