private void OkBTN_Click(object sender, EventArgs e)
{
try
{
if (ServersLV.SelectedItems.Count != 1)
{
return;
}
// extract the wrapper configuration from the application configuration.
ComWrapperServerConfiguration wrapperConfig = m_configuration.ParseExtension<ComWrapperServerConfiguration>();
if (wrapperConfig == null)
{
wrapperConfig = new ComWrapperServerConfiguration();
}
if (wrapperConfig.WrappedServers == null)
{
wrapperConfig.WrappedServers = new ComClientConfigurationCollection();
}
// get the selected server.
Item item = (Item)ServersLV.SelectedItems[0].Tag;
// create a new new COM client entry for the selected server.
ComClientConfiguration clientConfig = null;
if (item.Specification == Specification.Da20 || item.Specification == Specification.Da30)
{
clientConfig = new ComDaClientConfiguration();
}
else if (item.Specification == Specification.Ae10)
{
clientConfig = new ComAeClientConfiguration();
}
else if (item.Specification == Specification.Hda10)
{
clientConfig = new ComHdaClientConfiguration();
}
clientConfig.ServerUrl = item.Server.Url;
clientConfig.ServerName = item.Server.VersionIndependentProgId;
clientConfig.MaxReconnectWait = 100000;
wrapperConfig.WrappedServers.Add(clientConfig);
// update the configuration.
m_configuration.UpdateExtension<ComWrapperServerConfiguration>(null, wrapperConfig);
// close the dialog.
DialogResult = DialogResult.OK;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}