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