private void SetPropertyGridObject(NgimuApi.Settings settings)
        {
            m_SettingsTypeDescriptor = new SettingsTypeDescriptor(settings);

            propertyGrid1.SelectedObject = m_SettingsTypeDescriptor;

            propertyGrid1.ExpandAllGridItems();
        }
        public void OnDisconnect()
        {
            m_Settings.Stop();
            m_Reporter.Updated   -= Process_Updated;
            m_Reporter.Exception -= DisplayException;
            m_Reporter.Error     -= Process_Error;
            m_Reporter.Info      -= Process_Info;

            m_Settings.CopyTo(m_BackupSettings);
            m_Settings = m_BackupSettings;
            SetPropertyGridObject(m_Settings);
            CheckChangedState();
        }
        public void OnConnect(Connection comms)
        {
            // Do not copy settings from the backup
            //m_BackupSettings.CopyTo(comms.Settings);

            m_Settings = comms.Settings;
            SetPropertyGridObject(m_Settings);
            CheckChangedState();

            m_Reporter.Updated   += Process_Updated;
            m_Reporter.Exception += DisplayException;
            m_Reporter.Error     += Process_Error;
            m_Reporter.Info      += Process_Info;
        }
        public SettingsPanel()
        {
            InitializeComponent();

            propertyGrid1.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(propertyGrid1_SelectedGridItemChanged);
            propertyGrid1.PropertySort             = PropertySort.Categorized;
            propertyGrid1.PropertyValueChanged    += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged);

            try
            {
                m_BackupSettings = new NgimuApi.Settings();
                m_Settings       = m_BackupSettings;

                SetPropertyGridObject(m_Settings);
            }
            catch (Exception ex)
            {
                DisplayException(this, new ExceptionEventArgs("Failed to load settings.", ex));
            }
        }