示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }