# HG changeset patch # User sl # Date 1407868677 -7200 # Node ID 19c1aaf900dcc6c420cb49c93eaf0d8ab015ab49 # Parent 985ca4b6e099d8e29d8d3fe71813cbea54ec74c1 Adding WCF server implementation. diff -r 985ca4b6e099 -r 19c1aaf900dc MainForm.Designer.cs --- a/MainForm.Designer.cs Mon Aug 11 23:18:45 2014 +0200 +++ b/MainForm.Designer.cs Tue Aug 12 20:37:57 2014 +0200 @@ -35,8 +35,6 @@ this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox(); this.panelDisplay = new System.Windows.Forms.Panel(); this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.checkBoxShowBorders = new System.Windows.Forms.CheckBox(); this.trackBarBrightness = new System.Windows.Forms.TrackBar(); this.buttonFill = new System.Windows.Forms.Button(); @@ -53,6 +51,8 @@ this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel(); + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.tabControl.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); this.panelDisplay.SuspendLayout(); @@ -202,39 +202,6 @@ this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); this.tableLayoutPanel.TabIndex = 5; // - // 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 = null; - 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; - // // checkBoxShowBorders // this.checkBoxShowBorders.AutoSize = true; @@ -375,6 +342,39 @@ this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17); this.toolStripStatusLabelFps.Text = "FPS"; // + // 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, -124); + 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, 20); + 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, -40); + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); + this.marqueeLabelBottom.Name = "marqueeLabelBottom"; + this.marqueeLabelBottom.OwnTimer = false; + this.marqueeLabelBottom.PixelsPerSecond = 64; + this.marqueeLabelBottom.Separator = null; + 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); @@ -385,6 +385,7 @@ this.MinimumSize = new System.Drawing.Size(640, 480); this.Name = "MainForm"; this.Text = "Sharp Display Manager"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); this.Resize += new System.EventHandler(this.MainForm_Resize); this.tabControl.ResumeLayout(false); @@ -422,8 +423,8 @@ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower; private System.Windows.Forms.Panel panelDisplay; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; - private MarqueeLabel marqueeLabelTop; - private MarqueeLabel marqueeLabelBottom; + public MarqueeLabel marqueeLabelTop; + public MarqueeLabel marqueeLabelBottom; private System.Windows.Forms.CheckBox checkBoxConnectOnStartup; private System.Windows.Forms.CheckBox checkBoxReverseScreen; } diff -r 985ca4b6e099 -r 19c1aaf900dc MainForm.cs --- a/MainForm.cs Mon Aug 11 23:18:45 2014 +0200 +++ b/MainForm.cs Tue Aug 12 20:37:57 2014 +0200 @@ -10,6 +10,7 @@ using System.IO; using CodeProject.Dialog; using System.Drawing.Imaging; +using System.ServiceModel; namespace SharpDisplayManager @@ -20,6 +21,7 @@ Display iDisplay; System.Drawing.Bitmap iBmp; bool iCreateBitmap; //Workaround render to bitmap issues when minimized + ServiceHost iServiceHost; public MainForm() { @@ -44,6 +46,8 @@ private void MainForm_Load(object sender, EventArgs e) { + StartServer(); + if (Properties.Settings.Default.DisplayConnectOnStartup) { iDisplay.Open(); @@ -92,6 +96,8 @@ //Bitmap bmpToSave = new Bitmap(bmp); bmp.Save("D:\\capture.png"); + marqueeLabelTop.Text = "Sweet"; + /* string outputFileName = "d:\\capture.png"; using (MemoryStream memory = new MemoryStream()) @@ -334,5 +340,29 @@ } } + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + StopServer(); + } + + public void StartServer() + { + iServiceHost = new ServiceHost + ( + typeof(DisplayServer), + new Uri[] { new Uri("net.pipe://localhost") } + ); + + iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService"); + iServiceHost.Open(); + } + + public void StopServer() + { + //Tell connected client first? Is that possible? + iServiceHost.Close(); + } + + } } diff -r 985ca4b6e099 -r 19c1aaf900dc MarqueeLabel.cs --- a/MarqueeLabel.cs Mon Aug 11 23:18:45 2014 +0200 +++ b/MarqueeLabel.cs Tue Aug 12 20:37:57 2014 +0200 @@ -12,7 +12,7 @@ namespace SharpDisplayManager { [System.ComponentModel.DesignerCategory("Code")] - class MarqueeLabel : Label + public class MarqueeLabel : Label { private bool iOwnTimer; private StringFormat iStringFormat; diff -r 985ca4b6e099 -r 19c1aaf900dc Program.cs --- a/Program.cs Mon Aug 11 23:18:45 2014 +0200 +++ b/Program.cs Tue Aug 12 20:37:57 2014 +0200 @@ -8,6 +8,7 @@ { static class Program { + public static MainForm iMainForm; /// /// The main entry point for the application. /// @@ -16,7 +17,8 @@ { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MainForm()); + iMainForm = new MainForm(); + Application.Run(iMainForm); } } } diff -r 985ca4b6e099 -r 19c1aaf900dc Servers.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servers.cs Tue Aug 12 20:37:57 2014 +0200 @@ -0,0 +1,27 @@ +using System; +using System.Windows.Forms; + +namespace SharpDisplayManager +{ + /// + /// Implement our display service. + /// This class is instantiated anew whenever a client send a request. + /// + class DisplayServer : IDisplayService + { + //From IDisplayService + public void SetText(int aLineIndex, string aText) + { + if (aLineIndex == 0) + { + Program.iMainForm.marqueeLabelTop.Text = aText; + } + else if (aLineIndex == 1) + { + Program.iMainForm.marqueeLabelBottom.Text = aText; + } + } + + } + +} diff -r 985ca4b6e099 -r 19c1aaf900dc Services.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services.cs Tue Aug 12 20:37:57 2014 +0200 @@ -0,0 +1,12 @@ +using System; +using System.ServiceModel; + +namespace SharpDisplayManager +{ + [ServiceContract] + public interface IDisplayService + { + [OperationContract] + void SetText(int aLineIndex, string aText); + } +} diff -r 985ca4b6e099 -r 19c1aaf900dc SharpDisplayManager.csproj --- a/SharpDisplayManager.csproj Mon Aug 11 23:18:45 2014 +0200 +++ b/SharpDisplayManager.csproj Tue Aug 12 20:37:57 2014 +0200 @@ -36,6 +36,7 @@ + @@ -58,6 +59,8 @@ + +