1.1 --- a/Server/MainForm.cs Wed Feb 04 21:55:45 2015 +0100
1.2 +++ b/Server/MainForm.cs Thu Feb 05 17:04:59 2015 +0100
1.3 @@ -103,6 +103,52 @@
1.4 }
1.5
1.6 /// <summary>
1.7 + ///
1.8 + /// </summary>
1.9 + /// <param name="sender"></param>
1.10 + /// <param name="e"></param>
1.11 + private void MainForm_Load(object sender, EventArgs e)
1.12 + {
1.13 + //Check if we are running a Click Once deployed application
1.14 + if (ApplicationDeployment.IsNetworkDeployed)
1.15 + {
1.16 + //This is a proper Click Once installation, fetch and show our version number
1.17 + this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
1.18 + }
1.19 + else
1.20 + {
1.21 + //Not a proper Click Once installation, assuming development build then
1.22 + this.Text += " - development";
1.23 + }
1.24 +
1.25 + //Setup notification icon
1.26 + SetupTrayIcon();
1.27 +
1.28 + // To make sure start up with minimize to tray works
1.29 + if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
1.30 + {
1.31 + Visible = false;
1.32 + }
1.33 +
1.34 +#if !DEBUG
1.35 + //When not debugging we want the screen to be empty until a client takes over
1.36 + ClearLayout();
1.37 +#else
1.38 + //When developing we want at least one client for testing
1.39 + StartNewClient("abcdefghijklmnopqrst-0123456789","ABCDEFGHIJKLMNOPQRST-0123456789");
1.40 +#endif
1.41 +
1.42 + //Open display connection on start-up if needed
1.43 + if (Properties.Settings.Default.DisplayConnectOnStartup)
1.44 + {
1.45 + OpenDisplayConnection();
1.46 + }
1.47 +
1.48 + //Start our server so that we can get client requests
1.49 + StartServer();
1.50 + }
1.51 +
1.52 + /// <summary>
1.53 /// Called when our display is opened.
1.54 /// </summary>
1.55 /// <param name="aDisplay"></param>
1.56 @@ -139,58 +185,15 @@
1.57 {
1.58 int count = Display.TypeCount();
1.59
1.60 - for (int i=0; i<count; i++)
1.61 + for (int i = 0; i < count; i++)
1.62 {
1.63 comboBoxDisplayType.Items.Add(Display.TypeName((Display.TMiniDisplayType)i));
1.64 - }
1.65 + }
1.66 }
1.67
1.68 /// <summary>
1.69 ///
1.70 /// </summary>
1.71 - /// <param name="sender"></param>
1.72 - /// <param name="e"></param>
1.73 - private void MainForm_Load(object sender, EventArgs e)
1.74 - {
1.75 - //Check if we are running a Click Once deployed application
1.76 - if (ApplicationDeployment.IsNetworkDeployed)
1.77 - {
1.78 - //This is a proper Click Once installation, fetch and show our version number
1.79 - this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
1.80 - }
1.81 - else
1.82 - {
1.83 - //Not a proper Click Once installation, assuming development build then
1.84 - this.Text += " - development";
1.85 - }
1.86 -
1.87 - //Setup notification icon
1.88 - SetupTrayIcon();
1.89 -
1.90 - // To make sure start up with minimize to tray works
1.91 - if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
1.92 - {
1.93 - Visible = false;
1.94 - }
1.95 -
1.96 -#if !DEBUG
1.97 - //When not debugging we want the screen to be empty until a client takes over
1.98 - ClearLayout();
1.99 -#endif
1.100 -
1.101 - //Open display connection on start-up if needed
1.102 - if (Properties.Settings.Default.DisplayConnectOnStartup)
1.103 - {
1.104 - OpenDisplayConnection();
1.105 - }
1.106 -
1.107 - //Start our server so that we can get client requests
1.108 - StartServer();
1.109 - }
1.110 -
1.111 - /// <summary>
1.112 - ///
1.113 - /// </summary>
1.114 private void SetupTrayIcon()
1.115 {
1.116 iNotifyIcon.Icon = GetIcon("vfd.ico");
1.117 @@ -688,6 +691,7 @@
1.118 maskedTextBoxMinFontSize.Enabled = cds.ScaleToFit;
1.119 labelMinFontSize.Enabled = cds.ScaleToFit;
1.120 maskedTextBoxMinFontSize.Text = cds.MinFontSize.ToString();
1.121 + maskedTextBoxScrollingSpeed.Text = cds.ScrollingSpeedInPixelsPerSecond.ToString();
1.122 comboBoxDisplayType.SelectedIndex = cds.DisplayType;
1.123 timer.Interval = cds.TimerInterval;
1.124 maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
1.125 @@ -772,6 +776,7 @@
1.126 toolStripStatusLabelConnect.Text = "Disconnected";
1.127 toolStripStatusLabelPower.Text = "N/A";
1.128 }
1.129 +
1.130 }
1.131
1.132
1.133 @@ -936,11 +941,20 @@
1.134 tableLayoutPanel.ColumnStyles.Clear();
1.135 }
1.136
1.137 + /// <summary>
1.138 + /// Just launch a demo client.
1.139 + /// </summary>
1.140 + private void StartNewClient(string aTopText = "", string aBottomText = "")
1.141 + {
1.142 + Thread clientThread = new Thread(SharpDisplayClient.Program.MainWithParams);
1.143 + SharpDisplayClient.StartParams myParams = new SharpDisplayClient.StartParams(new Point(this.Right, this.Top),aTopText,aBottomText);
1.144 + clientThread.Start(myParams);
1.145 + BringToFront();
1.146 + }
1.147 +
1.148 private void buttonStartClient_Click(object sender, EventArgs e)
1.149 {
1.150 - Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
1.151 - clientThread.Start();
1.152 - BringToFront();
1.153 + StartNewClient();
1.154 }
1.155
1.156 private void buttonSuspend_Click(object sender, EventArgs e)
1.157 @@ -1381,6 +1395,13 @@
1.158 /// <param name="aLayout"></param>
1.159 private void UpdateTableLayoutPanel(ClientData aClient)
1.160 {
1.161 + if (aClient == null)
1.162 + {
1.163 + //Just drop it
1.164 + return;
1.165 + }
1.166 +
1.167 +
1.168 TableLayout layout = aClient.Layout;
1.169 int fieldCount = 0;
1.170
1.171 @@ -1472,7 +1493,7 @@
1.172 label.Margin = new System.Windows.Forms.Padding(0);
1.173 label.Name = "marqueeLabel" + aField.Index;
1.174 label.OwnTimer = false;
1.175 - label.PixelsPerSecond = 64;
1.176 + label.PixelsPerSecond = cds.ScrollingSpeedInPixelsPerSecond;
1.177 label.Separator = cds.Separator;
1.178 label.MinFontSize = cds.MinFontSize;
1.179 label.ScaleToFit = cds.ScaleToFit;
1.180 @@ -1480,7 +1501,7 @@
1.181 //control.TabIndex = 2;
1.182 label.Font = cds.Font;
1.183
1.184 - label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
1.185 + label.TextAlign = aField.Alignment;
1.186 label.UseCompatibleTextRendering = true;
1.187 label.Text = aField.Text;
1.188 //
1.189 @@ -1577,13 +1598,31 @@
1.190
1.191 if (minFontSize > 0)
1.192 {
1.193 - //TODO: re-create layout? update our fields?
1.194 cds.MinFontSize = minFontSize;
1.195 Properties.Settings.Default.Save();
1.196 + //We need to recreate our layout for that change to take effect
1.197 + UpdateTableLayoutPanel(iCurrentClientData);
1.198 }
1.199 }
1.200 }
1.201
1.202 +
1.203 + private void maskedTextBoxScrollingSpeed_TextChanged(object sender, EventArgs e)
1.204 + {
1.205 + if (maskedTextBoxScrollingSpeed.Text != "")
1.206 + {
1.207 + int scrollingSpeed = Convert.ToInt32(maskedTextBoxScrollingSpeed.Text);
1.208 +
1.209 + if (scrollingSpeed > 0)
1.210 + {
1.211 + cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed;
1.212 + Properties.Settings.Default.Save();
1.213 + //We need to recreate our layout for that change to take effect
1.214 + UpdateTableLayoutPanel(iCurrentClientData);
1.215 + }
1.216 + }
1.217 + }
1.218 +
1.219 private void textBoxScrollLoopSeparator_TextChanged(object sender, EventArgs e)
1.220 {
1.221 //TODO: re-create layout? update our fields?