--- dao/DaoMqPump2/DaoMqGUI/MainForm.cs 2013/07/03 07:56:52 1986 +++ dao/DaoMqPump2/DaoMqGUI/MainForm.cs 2013/07/05 08:43:21 1994 @@ -7,19 +7,41 @@ using System.Windows.Forms; using DaoMqGUI.ServiceReference1; +using System.ServiceModel; +using Microsoft.Win32; namespace DaoMqGUI { public partial class MainForm : Form { - RemoteControlClient client = new RemoteControlClient(); + RemoteControlClient client = null; List transportNameList = new List(); + string hostname = ""; + public MainForm() { InitializeComponent(); - loadTransports(); + + //initClient(); is now called on shown() event + // loadTransports(); is now called on shown() event + + } + + private void initClient() + { + RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\DAO\\DaoMqGui"); + + hostname = (string) key.GetValue("Hostname", "localhost"); + hostname = hostname.Trim(); + + lnkServer.Text = hostname; + + //Step 1 - initialize client + BasicHttpBinding binding = new BasicHttpBinding(); + EndpointAddress endpoint = new EndpointAddress(new Uri("http://" + hostname + ":8000/RemoteControl/RemoteControl")); + client = new RemoteControlClient(binding, endpoint); } private string[] getSafeTransports() @@ -238,5 +260,27 @@ } } + private void lnkServer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string tmp_hostname = Microsoft.VisualBasic.Interaction.InputBox("Indtast servernavn/ip", "MQ Gui", hostname); + if (tmp_hostname == null || tmp_hostname.Trim().Length == 0) + return; + + hostname = tmp_hostname.Trim(); + + RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\DAO\\DaoMqGui"); + key.SetValue("Hostname", hostname, RegistryValueKind.String); + key.Close(); + + initClient(); + loadTransports(); + } + + private void MainForm_Shown(object sender, EventArgs e) + { + initClient(); + loadTransports(); + } + } }