/// <summary> /// Displays the dialog. /// </summary> public EndpointComIdentity ShowDialog(ConfiguredEndpoint endpoint) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } m_comIdentity = endpoint.ComIdentity; // assign a default prog id/clsid. if (String.IsNullOrEmpty(m_comIdentity.ProgId)) { m_comIdentity.ProgId = PseudoComServer.CreateProgIdFromUrl(ComSpecification.DA, endpoint.EndpointUrl.ToString()); m_comIdentity.Clsid = ConfigUtils.CLSIDFromProgID(m_comIdentity.ProgId); if (m_comIdentity.Clsid == Guid.Empty) { m_comIdentity.Clsid = Guid.NewGuid(); } } SpecificationCB.SelectedItem = m_comIdentity.Specification; ClsidTB.Text = m_comIdentity.Clsid.ToString(); ProgIdTB.Text = m_comIdentity.ProgId; if (ShowDialog() != DialogResult.OK) { return(null); } return(m_comIdentity); }
private void ConfigureMI_Click(object sender, EventArgs e) { try { ConfiguredEndpoint endpoint = SelectedTag as ConfiguredEndpoint; if (endpoint == null) { return; } EndpointComIdentity comIdentity = new PseudoComServerDlg().ShowDialog(endpoint); if (comIdentity == null) { return; } endpoint.ComIdentity = comIdentity; PseudoComServer.Save(endpoint); UpdateItem(ItemsLV.SelectedItems[0], endpoint); AdjustColumns(); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
/// <summary> /// Displays a list of servers in the control. /// </summary> public void Initialize(ApplicationConfiguration configuration) { Interlocked.Exchange(ref m_configuration, configuration); ItemsLV.Items.Clear(); foreach (ConfiguredEndpoint server in PseudoComServer.Enumerate()) { if (server.ComIdentity != null) { AddItem(server); } } AdjustColumns(); }
private void DeleteMI_Click(object sender, EventArgs e) { try { ConfiguredEndpoint endpoint = SelectedTag as ConfiguredEndpoint; if (endpoint == null) { return; } PseudoComServer.Delete(endpoint.ComIdentity.Clsid); ItemsLV.SelectedItems[0].Remove(); AdjustColumns(); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void File_ExportMI_Click(object sender, EventArgs e) { try { if (m_exportFile == null) { m_exportFile = "ComServers.endpoints.xml"; } FileInfo fileInfo = new FileInfo(m_exportFile); SaveFileDialog dialog = new SaveFileDialog(); dialog.CheckFileExists = false; dialog.CheckPathExists = true; dialog.DefaultExt = ".xml"; dialog.Filter = "Configuration Files (*.xml)|*.xml|All Files (*.*)|*.*"; dialog.ValidateNames = true; dialog.Title = "Save Endpoint Configuration File"; dialog.FileName = fileInfo.Name; dialog.InitialDirectory = fileInfo.DirectoryName; if (dialog.ShowDialog() != DialogResult.OK) { return; } m_exportFile = dialog.FileName; ConfiguredEndpointCollection endpoints = new ConfiguredEndpointCollection(m_configuration); foreach (ConfiguredEndpoint endpoint in PseudoComServer.Enumerate()) { endpoints.Add(endpoint); } endpoints.Save(m_exportFile); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void NewMI_Click(object sender, EventArgs e) { try { ApplicationDescription server = new DiscoveredServerListDlg().ShowDialog(null, m_configuration); if (server == null) { return; } ConfiguredEndpoint endpoint = new ConfiguredEndpoint(server, null); endpoint.ComIdentity = new EndpointComIdentity(); endpoint.ComIdentity.Specification = ComSpecification.DA; endpoint = new ConfiguredServerDlg().ShowDialog(endpoint, m_configuration); if (endpoint == null) { return; } EndpointComIdentity comIdentity = new PseudoComServerDlg().ShowDialog(endpoint); if (comIdentity == null) { return; } endpoint.ComIdentity = comIdentity; PseudoComServer.Save(endpoint); AddItem(endpoint); AdjustColumns(); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void File_ImportMI_Click(object sender, EventArgs e) { try { if (m_exportFile == null) { m_exportFile = "ComServers.endpoints.xml"; } FileInfo fileInfo = new FileInfo(Utils.GetAbsoluteFilePath(m_exportFile)); OpenFileDialog dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.DefaultExt = ".xml"; dialog.Filter = "Configuration Files (*.xml)|*.xml|All Files (*.*)|*.*"; dialog.Multiselect = false; dialog.ValidateNames = true; dialog.Title = "Open Endpoint Configuration File"; dialog.FileName = fileInfo.Name; dialog.InitialDirectory = fileInfo.DirectoryName; if (dialog.ShowDialog() != DialogResult.OK) { return; } m_exportFile = dialog.FileName; // load the endpoints from the file. ConfiguredEndpointCollection endpoints = ConfiguredEndpointCollection.Load(m_exportFile); // update the endpoint configuration. StringBuilder buffer = new StringBuilder(); foreach (ConfiguredEndpoint endpoint in endpoints.Endpoints) { if (endpoint.ComIdentity == null) { continue; } try { PseudoComServer.Save(endpoint); } catch (Exception exception) { if (buffer.Length > 0) { buffer.Append("\r\n"); } buffer.AppendFormat( "Error Registering COM pseudo-server '{0}': {1}", endpoint.ComIdentity.ProgId, exception.Message); } } // display warning. if (buffer.Length > 0) { MessageBox.Show( buffer.ToString(), "Endpoint Import Errors", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ServersCTRL.Initialize(m_configuration); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }