--- dao/DaoMqPump2/DaoMqGUI/MainForm.cs 2013/07/03 09:54:25 1991 +++ dao/DaoMqPump2/DaoMqGUI/MainForm.cs 2013/07/04 08:05:04 1992 @@ -7,21 +7,43 @@ 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(); + + initClient(); + loadTransports(); } + 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() { string[] result = new string[] { }; @@ -238,5 +260,21 @@ } } + 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(); + } + } }