1.1 --- a/MainForm.cs Mon Aug 11 23:18:45 2014 +0200
1.2 +++ b/MainForm.cs Tue Aug 12 20:37:57 2014 +0200
1.3 @@ -10,6 +10,7 @@
1.4 using System.IO;
1.5 using CodeProject.Dialog;
1.6 using System.Drawing.Imaging;
1.7 +using System.ServiceModel;
1.8
1.9
1.10 namespace SharpDisplayManager
1.11 @@ -20,6 +21,7 @@
1.12 Display iDisplay;
1.13 System.Drawing.Bitmap iBmp;
1.14 bool iCreateBitmap; //Workaround render to bitmap issues when minimized
1.15 + ServiceHost iServiceHost;
1.16
1.17 public MainForm()
1.18 {
1.19 @@ -44,6 +46,8 @@
1.20
1.21 private void MainForm_Load(object sender, EventArgs e)
1.22 {
1.23 + StartServer();
1.24 +
1.25 if (Properties.Settings.Default.DisplayConnectOnStartup)
1.26 {
1.27 iDisplay.Open();
1.28 @@ -92,6 +96,8 @@
1.29 //Bitmap bmpToSave = new Bitmap(bmp);
1.30 bmp.Save("D:\\capture.png");
1.31
1.32 + marqueeLabelTop.Text = "Sweet";
1.33 +
1.34 /*
1.35 string outputFileName = "d:\\capture.png";
1.36 using (MemoryStream memory = new MemoryStream())
1.37 @@ -334,5 +340,29 @@
1.38 }
1.39 }
1.40
1.41 + private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
1.42 + {
1.43 + StopServer();
1.44 + }
1.45 +
1.46 + public void StartServer()
1.47 + {
1.48 + iServiceHost = new ServiceHost
1.49 + (
1.50 + typeof(DisplayServer),
1.51 + new Uri[] { new Uri("net.pipe://localhost") }
1.52 + );
1.53 +
1.54 + iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService");
1.55 + iServiceHost.Open();
1.56 + }
1.57 +
1.58 + public void StopServer()
1.59 + {
1.60 + //Tell connected client first? Is that possible?
1.61 + iServiceHost.Close();
1.62 + }
1.63 +
1.64 +
1.65 }
1.66 }