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.
1.1 --- a/Client/MainForm.cs Wed Feb 04 21:55:45 2015 +0100
1.2 +++ b/Client/MainForm.cs Thu Feb 05 17:04:59 2015 +0100
1.3 @@ -17,11 +17,18 @@
1.4 {
1.5 public partial class MainForm : Form
1.6 {
1.7 + public StartParams Params { get; set; }
1.8 +
1.9 + //
1.10 DisplayClient iClient;
1.11 -
1.12 + //
1.13 ContentAlignment Alignment;
1.14 DataField iTextFieldTop;
1.15
1.16 +
1.17 + /// <summary>
1.18 + /// Constructor
1.19 + /// </summary>
1.20 public MainForm()
1.21 {
1.22 InitializeComponent();
1.23 @@ -29,7 +36,11 @@
1.24 iTextFieldTop = new DataField(0);
1.25 }
1.26
1.27 -
1.28 + /// <summary>
1.29 + ///
1.30 + /// </summary>
1.31 + /// <param name="sender"></param>
1.32 + /// <param name="e"></param>
1.33 private void MainForm_Load(object sender, EventArgs e)
1.34 {
1.35 iClient = new DisplayClient(this);
1.36 @@ -46,6 +57,24 @@
1.37 textBoxTop.Text = iClient.Name;
1.38 textBoxBottom.Text = iClient.SessionId;
1.39
1.40 + if (Params != null)
1.41 + {
1.42 + //Parameters where specified use them
1.43 + if (Params.TopText != "")
1.44 + {
1.45 + textBoxTop.Text = Params.TopText;
1.46 + }
1.47 +
1.48 + if (Params.BottomText != "")
1.49 + {
1.50 + textBoxBottom.Text = Params.BottomText;
1.51 + }
1.52 +
1.53 + Location = Params.Location;
1.54 + //
1.55 + SetBasicLayoutAndText();
1.56 + }
1.57 +
1.58 }
1.59
1.60
1.61 @@ -146,17 +175,23 @@
1.62
1.63 private void buttonSetText_Click(object sender, EventArgs e)
1.64 {
1.65 - //Set one column two lines layout
1.66 - TableLayout layout = new TableLayout(1, 2);
1.67 - iClient.SetLayout(layout);
1.68 + SetBasicLayoutAndText();
1.69 + }
1.70
1.71 - //Set our fields
1.72 - iClient.CreateFields(new DataField[]
1.73 + void SetBasicLayoutAndText()
1.74 + {
1.75 + //Set one column two lines layout
1.76 + TableLayout layout = new TableLayout(1, 2);
1.77 + iClient.SetLayout(layout);
1.78 +
1.79 + //Set our fields
1.80 + iClient.CreateFields(new DataField[]
1.81 {
1.82 new DataField(0, textBoxTop.Text, Alignment),
1.83 new DataField(1, textBoxBottom.Text, Alignment)
1.84 });
1.85 - }
1.86 +
1.87 + }
1.88
1.89 private void buttonLayoutUpdate_Click(object sender, EventArgs e)
1.90 {
2.1 --- a/Client/Program.cs Wed Feb 04 21:55:45 2015 +0100
2.2 +++ b/Client/Program.cs Thu Feb 05 17:04:59 2015 +0100
2.3 @@ -3,6 +3,7 @@
2.4 using System.Linq;
2.5 using System.Threading.Tasks;
2.6 using System.Windows.Forms;
2.7 +using System.Drawing;
2.8
2.9 namespace SharpDisplayClient
2.10 {
2.11 @@ -19,7 +20,35 @@
2.12
2.13 Application.EnableVisualStyles();
2.14 Application.SetCompatibleTextRenderingDefault(false);
2.15 - Application.Run(new MainForm());
2.16 + Application.Run(new MainForm());
2.17 }
2.18 +
2.19 + [STAThread]
2.20 + static public void MainWithParams(object aParams)
2.21 + {
2.22 + //Set high priority to our process to avoid lags when rendering to our screen
2.23 + System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal;
2.24 +
2.25 + Application.EnableVisualStyles();
2.26 + Application.SetCompatibleTextRenderingDefault(false);
2.27 + MainForm mainForm = new MainForm();
2.28 + mainForm.Params = (StartParams)aParams;
2.29 + Application.Run(mainForm);
2.30 + }
2.31 +
2.32 }
2.33 +
2.34 + public class StartParams
2.35 + {
2.36 + public StartParams(Point aLocation, string aTopText="", string aBottomText="")
2.37 + {
2.38 + TopText = aTopText;
2.39 + BottomText = aBottomText;
2.40 + Location = aLocation;
2.41 + }
2.42 +
2.43 + public string TopText { get; set; }
2.44 + public string BottomText { get; set; }
2.45 + public Point Location { get; set; }
2.46 + }
2.47 }
3.1 --- a/Server/DisplaySettings.cs Wed Feb 04 21:55:45 2015 +0100
3.2 +++ b/Server/DisplaySettings.cs Thu Feb 05 17:04:59 2015 +0100
3.3 @@ -29,7 +29,8 @@
3.4 FontName = "Microsoft Sans Serif, 9.75pt";
3.5 ScaleToFit = true;
3.6 MinFontSize = 15.0f;
3.7 - Separator = " ";
3.8 + Separator = " ";
3.9 + ScrollingSpeedInPixelsPerSecond = 64;
3.10 }
3.11
3.12 [DataMember]
3.13 @@ -44,6 +45,9 @@
3.14 [DataMember]
3.15 public int TimerInterval { get; set; }
3.16
3.17 + [DataMember]
3.18 + public int ScrollingSpeedInPixelsPerSecond { get; set; }
3.19 +
3.20 [DataMember]
3.21 public bool ReverseScreen { get; set; }
3.22
4.1 --- a/Server/MainForm.Designer.cs Wed Feb 04 21:55:45 2015 +0100
4.2 +++ b/Server/MainForm.Designer.cs Thu Feb 05 17:04:59 2015 +0100
4.3 @@ -98,6 +98,8 @@
4.4 this.labelFontWidth = new System.Windows.Forms.Label();
4.5 this.labelFontHeight = new System.Windows.Forms.Label();
4.6 this.pictureBoxDemo = new System.Windows.Forms.PictureBox();
4.7 + this.maskedTextBoxScrollingSpeed = new System.Windows.Forms.MaskedTextBox();
4.8 + this.labelScrollingSpeed = new System.Windows.Forms.Label();
4.9 this.panelDisplay.SuspendLayout();
4.10 this.tableLayoutPanel.SuspendLayout();
4.11 this.statusStrip.SuspendLayout();
4.12 @@ -515,6 +517,8 @@
4.13 //
4.14 // tabPageDesign
4.15 //
4.16 + this.tabPageDesign.Controls.Add(this.labelScrollingSpeed);
4.17 + this.tabPageDesign.Controls.Add(this.maskedTextBoxScrollingSpeed);
4.18 this.tabPageDesign.Controls.Add(this.labelScrollLoopSeparator);
4.19 this.tabPageDesign.Controls.Add(this.textBoxScrollLoopSeparator);
4.20 this.tabPageDesign.Controls.Add(this.labelMinFontSize);
4.21 @@ -543,7 +547,7 @@
4.22 // labelScrollLoopSeparator
4.23 //
4.24 this.labelScrollLoopSeparator.AutoSize = true;
4.25 - this.labelScrollLoopSeparator.Location = new System.Drawing.Point(84, 145);
4.26 + this.labelScrollLoopSeparator.Location = new System.Drawing.Point(90, 145);
4.27 this.labelScrollLoopSeparator.Name = "labelScrollLoopSeparator";
4.28 this.labelScrollLoopSeparator.Size = new System.Drawing.Size(109, 13);
4.29 this.labelScrollLoopSeparator.TabIndex = 26;
4.30 @@ -768,6 +772,25 @@
4.31 this.pictureBoxDemo.TabIndex = 21;
4.32 this.pictureBoxDemo.TabStop = false;
4.33 //
4.34 + // maskedTextBoxScrollingSpeed
4.35 + //
4.36 + this.maskedTextBoxScrollingSpeed.Location = new System.Drawing.Point(205, 116);
4.37 + this.maskedTextBoxScrollingSpeed.Mask = "000";
4.38 + this.maskedTextBoxScrollingSpeed.Name = "maskedTextBoxScrollingSpeed";
4.39 + this.maskedTextBoxScrollingSpeed.PromptChar = ' ';
4.40 + this.maskedTextBoxScrollingSpeed.Size = new System.Drawing.Size(24, 20);
4.41 + this.maskedTextBoxScrollingSpeed.TabIndex = 27;
4.42 + this.maskedTextBoxScrollingSpeed.TextChanged += new System.EventHandler(this.maskedTextBoxScrollingSpeed_TextChanged);
4.43 + //
4.44 + // labelScrollingSpeed
4.45 + //
4.46 + this.labelScrollingSpeed.AutoSize = true;
4.47 + this.labelScrollingSpeed.Location = new System.Drawing.Point(84, 119);
4.48 + this.labelScrollingSpeed.Name = "labelScrollingSpeed";
4.49 + this.labelScrollingSpeed.Size = new System.Drawing.Size(115, 13);
4.50 + this.labelScrollingSpeed.TabIndex = 28;
4.51 + this.labelScrollingSpeed.Text = "Scrolling speed (px/s) :";
4.52 + //
4.53 // MainForm
4.54 //
4.55 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
4.56 @@ -869,6 +892,8 @@
4.57 private System.Windows.Forms.Label labelMinFontSize;
4.58 private System.Windows.Forms.Label labelScrollLoopSeparator;
4.59 private System.Windows.Forms.TextBox textBoxScrollLoopSeparator;
4.60 + private System.Windows.Forms.Label labelScrollingSpeed;
4.61 + private System.Windows.Forms.MaskedTextBox maskedTextBoxScrollingSpeed;
4.62 }
4.63 }
4.64
5.1 --- a/Server/MainForm.cs Wed Feb 04 21:55:45 2015 +0100
5.2 +++ b/Server/MainForm.cs Thu Feb 05 17:04:59 2015 +0100
5.3 @@ -103,6 +103,52 @@
5.4 }
5.5
5.6 /// <summary>
5.7 + ///
5.8 + /// </summary>
5.9 + /// <param name="sender"></param>
5.10 + /// <param name="e"></param>
5.11 + private void MainForm_Load(object sender, EventArgs e)
5.12 + {
5.13 + //Check if we are running a Click Once deployed application
5.14 + if (ApplicationDeployment.IsNetworkDeployed)
5.15 + {
5.16 + //This is a proper Click Once installation, fetch and show our version number
5.17 + this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
5.18 + }
5.19 + else
5.20 + {
5.21 + //Not a proper Click Once installation, assuming development build then
5.22 + this.Text += " - development";
5.23 + }
5.24 +
5.25 + //Setup notification icon
5.26 + SetupTrayIcon();
5.27 +
5.28 + // To make sure start up with minimize to tray works
5.29 + if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
5.30 + {
5.31 + Visible = false;
5.32 + }
5.33 +
5.34 +#if !DEBUG
5.35 + //When not debugging we want the screen to be empty until a client takes over
5.36 + ClearLayout();
5.37 +#else
5.38 + //When developing we want at least one client for testing
5.39 + StartNewClient("abcdefghijklmnopqrst-0123456789","ABCDEFGHIJKLMNOPQRST-0123456789");
5.40 +#endif
5.41 +
5.42 + //Open display connection on start-up if needed
5.43 + if (Properties.Settings.Default.DisplayConnectOnStartup)
5.44 + {
5.45 + OpenDisplayConnection();
5.46 + }
5.47 +
5.48 + //Start our server so that we can get client requests
5.49 + StartServer();
5.50 + }
5.51 +
5.52 + /// <summary>
5.53 /// Called when our display is opened.
5.54 /// </summary>
5.55 /// <param name="aDisplay"></param>
5.56 @@ -139,58 +185,15 @@
5.57 {
5.58 int count = Display.TypeCount();
5.59
5.60 - for (int i=0; i<count; i++)
5.61 + for (int i = 0; i < count; i++)
5.62 {
5.63 comboBoxDisplayType.Items.Add(Display.TypeName((Display.TMiniDisplayType)i));
5.64 - }
5.65 + }
5.66 }
5.67
5.68 /// <summary>
5.69 ///
5.70 /// </summary>
5.71 - /// <param name="sender"></param>
5.72 - /// <param name="e"></param>
5.73 - private void MainForm_Load(object sender, EventArgs e)
5.74 - {
5.75 - //Check if we are running a Click Once deployed application
5.76 - if (ApplicationDeployment.IsNetworkDeployed)
5.77 - {
5.78 - //This is a proper Click Once installation, fetch and show our version number
5.79 - this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
5.80 - }
5.81 - else
5.82 - {
5.83 - //Not a proper Click Once installation, assuming development build then
5.84 - this.Text += " - development";
5.85 - }
5.86 -
5.87 - //Setup notification icon
5.88 - SetupTrayIcon();
5.89 -
5.90 - // To make sure start up with minimize to tray works
5.91 - if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
5.92 - {
5.93 - Visible = false;
5.94 - }
5.95 -
5.96 -#if !DEBUG
5.97 - //When not debugging we want the screen to be empty until a client takes over
5.98 - ClearLayout();
5.99 -#endif
5.100 -
5.101 - //Open display connection on start-up if needed
5.102 - if (Properties.Settings.Default.DisplayConnectOnStartup)
5.103 - {
5.104 - OpenDisplayConnection();
5.105 - }
5.106 -
5.107 - //Start our server so that we can get client requests
5.108 - StartServer();
5.109 - }
5.110 -
5.111 - /// <summary>
5.112 - ///
5.113 - /// </summary>
5.114 private void SetupTrayIcon()
5.115 {
5.116 iNotifyIcon.Icon = GetIcon("vfd.ico");
5.117 @@ -688,6 +691,7 @@
5.118 maskedTextBoxMinFontSize.Enabled = cds.ScaleToFit;
5.119 labelMinFontSize.Enabled = cds.ScaleToFit;
5.120 maskedTextBoxMinFontSize.Text = cds.MinFontSize.ToString();
5.121 + maskedTextBoxScrollingSpeed.Text = cds.ScrollingSpeedInPixelsPerSecond.ToString();
5.122 comboBoxDisplayType.SelectedIndex = cds.DisplayType;
5.123 timer.Interval = cds.TimerInterval;
5.124 maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
5.125 @@ -772,6 +776,7 @@
5.126 toolStripStatusLabelConnect.Text = "Disconnected";
5.127 toolStripStatusLabelPower.Text = "N/A";
5.128 }
5.129 +
5.130 }
5.131
5.132
5.133 @@ -936,11 +941,20 @@
5.134 tableLayoutPanel.ColumnStyles.Clear();
5.135 }
5.136
5.137 + /// <summary>
5.138 + /// Just launch a demo client.
5.139 + /// </summary>
5.140 + private void StartNewClient(string aTopText = "", string aBottomText = "")
5.141 + {
5.142 + Thread clientThread = new Thread(SharpDisplayClient.Program.MainWithParams);
5.143 + SharpDisplayClient.StartParams myParams = new SharpDisplayClient.StartParams(new Point(this.Right, this.Top),aTopText,aBottomText);
5.144 + clientThread.Start(myParams);
5.145 + BringToFront();
5.146 + }
5.147 +
5.148 private void buttonStartClient_Click(object sender, EventArgs e)
5.149 {
5.150 - Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
5.151 - clientThread.Start();
5.152 - BringToFront();
5.153 + StartNewClient();
5.154 }
5.155
5.156 private void buttonSuspend_Click(object sender, EventArgs e)
5.157 @@ -1381,6 +1395,13 @@
5.158 /// <param name="aLayout"></param>
5.159 private void UpdateTableLayoutPanel(ClientData aClient)
5.160 {
5.161 + if (aClient == null)
5.162 + {
5.163 + //Just drop it
5.164 + return;
5.165 + }
5.166 +
5.167 +
5.168 TableLayout layout = aClient.Layout;
5.169 int fieldCount = 0;
5.170
5.171 @@ -1472,7 +1493,7 @@
5.172 label.Margin = new System.Windows.Forms.Padding(0);
5.173 label.Name = "marqueeLabel" + aField.Index;
5.174 label.OwnTimer = false;
5.175 - label.PixelsPerSecond = 64;
5.176 + label.PixelsPerSecond = cds.ScrollingSpeedInPixelsPerSecond;
5.177 label.Separator = cds.Separator;
5.178 label.MinFontSize = cds.MinFontSize;
5.179 label.ScaleToFit = cds.ScaleToFit;
5.180 @@ -1480,7 +1501,7 @@
5.181 //control.TabIndex = 2;
5.182 label.Font = cds.Font;
5.183
5.184 - label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
5.185 + label.TextAlign = aField.Alignment;
5.186 label.UseCompatibleTextRendering = true;
5.187 label.Text = aField.Text;
5.188 //
5.189 @@ -1577,13 +1598,31 @@
5.190
5.191 if (minFontSize > 0)
5.192 {
5.193 - //TODO: re-create layout? update our fields?
5.194 cds.MinFontSize = minFontSize;
5.195 Properties.Settings.Default.Save();
5.196 + //We need to recreate our layout for that change to take effect
5.197 + UpdateTableLayoutPanel(iCurrentClientData);
5.198 }
5.199 }
5.200 }
5.201
5.202 +
5.203 + private void maskedTextBoxScrollingSpeed_TextChanged(object sender, EventArgs e)
5.204 + {
5.205 + if (maskedTextBoxScrollingSpeed.Text != "")
5.206 + {
5.207 + int scrollingSpeed = Convert.ToInt32(maskedTextBoxScrollingSpeed.Text);
5.208 +
5.209 + if (scrollingSpeed > 0)
5.210 + {
5.211 + cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed;
5.212 + Properties.Settings.Default.Save();
5.213 + //We need to recreate our layout for that change to take effect
5.214 + UpdateTableLayoutPanel(iCurrentClientData);
5.215 + }
5.216 + }
5.217 + }
5.218 +
5.219 private void textBoxScrollLoopSeparator_TextChanged(object sender, EventArgs e)
5.220 {
5.221 //TODO: re-create layout? update our fields?