Example #1
0
 /// <summary>
 /// Serializes the list and saves to disk.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     addDeviceToStorage();
     try
     {
         DeviceConfigurationList.SaveDeviceList(ConfigurationSettings.DeviceSettingsPath, storedDevices);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to save device configuration information." + System.Environment.NewLine + System.Environment.NewLine + ex.Message,
                         "An error has occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     btnSave.Enabled = false;
 }
Example #2
0
        /// <summary>
        /// Remove the selected item from the list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // Remove the device from the storage instance on this form.
            storedDevices.Devices.Remove(
                storedDevices.Devices.Find(d => d.Name == listDevices.SelectedItem.ToString())
                );

            // Remove from the user-visible lis.t
            listDevices.Items.Remove(listDevices.SelectedItem);

            // Serialize the object to disk once more.
            DeviceConfigurationList.SaveDeviceList(ConfigurationSettings.DeviceSettingsPath, storedDevices);

            ClearFormContents();

            grpGeneral.Enabled     = false;
            grpCommunities.Enabled = false;
            grpSecPriv.Enabled     = false;
            btnDelete.Enabled      = false;
        }