sl@18: using System; sl@18: using System.Collections.Generic; sl@18: using System.ComponentModel; sl@18: using System.Data; sl@18: using System.Drawing; sl@18: using System.Linq; sl@18: using System.Text; sl@18: using System.Threading.Tasks; sl@18: using System.Windows.Forms; sl@18: using System.ServiceModel; sl@18: using System.ServiceModel.Channels; sl@20: sl@18: sl@18: namespace SharpDisplayClient sl@18: { sl@18: public partial class MainForm : Form sl@18: { sl@26: Client iClient; sl@26: Callback iCallback; sl@18: sl@18: public MainForm() sl@18: { sl@18: InitializeComponent(); sl@18: } sl@18: sl@18: private void buttonSetText_Click(object sender, EventArgs e) sl@18: { sl@19: //iClient.SetText(0,"Top"); sl@19: //iClient.SetText(1, "Bottom"); sl@26: iClient.SetTexts(new string[] { "Top", "Bottom" }); sl@18: } sl@18: sl@18: private void MainForm_Load(object sender, EventArgs e) sl@18: { sl@26: iCallback = new Callback(); sl@25: //Instance context is then managed by our client class sl@26: InstanceContext instanceContext = new InstanceContext(iCallback); sl@26: iClient = new Client(instanceContext); sl@18: sl@26: iClient.Connect("TestClient"); sl@18: sl@18: } sl@21: sl@21: public void CloseConnection() sl@21: { sl@26: iClient.Close(); sl@26: iClient = null; sl@26: iCallback = null; sl@26: } sl@26: sl@26: private void MainForm_FormClosing(object sender, FormClosingEventArgs e) sl@26: { sl@26: if (iClient != null) //Could catch exception instead sl@26: { sl@26: iClient.Disconnect(); sl@26: CloseConnection(); sl@26: } sl@21: } sl@18: } sl@18: }