Client/MainForm.cs
author sl
Thu, 14 Aug 2014 10:19:53 +0200
changeset 27 9c49c04fc620
parent 25 6f10207a89a8
child 29 c4e03315035c
permissions -rw-r--r--
Adding suspend/resume button.
Setting our server process to higher priority to avoid render lags.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 using System.ServiceModel;
    11 using System.ServiceModel.Channels;
    12 
    13 
    14 namespace SharpDisplayClient
    15 {
    16     public partial class MainForm : Form
    17     {
    18         Client iClient;
    19         Callback iCallback;
    20 
    21         public MainForm()
    22         {
    23             InitializeComponent();
    24         }
    25 
    26         private void buttonSetText_Click(object sender, EventArgs e)
    27         {
    28             //iClient.SetText(0,"Top");
    29             //iClient.SetText(1, "Bottom");
    30             iClient.SetTexts(new string[] { "Top", "Bottom" });
    31         }
    32 
    33         private void MainForm_Load(object sender, EventArgs e)
    34         {
    35             iCallback = new Callback();
    36             //Instance context is then managed by our client class
    37             InstanceContext instanceContext = new InstanceContext(iCallback);
    38             iClient = new Client(instanceContext);
    39 
    40             iClient.Connect("TestClient");
    41 
    42         }
    43 
    44         public void CloseConnection()
    45         {
    46             iClient.Close();
    47             iClient = null;
    48             iCallback = null;
    49         }
    50 
    51         private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
    52         {
    53             if (iClient != null) //Could catch exception instead
    54             {
    55                 iClient.Disconnect();
    56                 CloseConnection();
    57             }
    58         }
    59     }
    60 }