private void SaveData() { DeviceSettings ds = new DeviceSettings(); DeviceSettingsArgs device = new DeviceSettingsArgs(); device.Exist = true; device.Name = textBoxNameDevice.Text; device.Object = comboBoxObjects.SelectedIndex; device.Port = comboBoxCOMPorts.SelectedIndex; device.TimeZone = comboBoxTimeZone.SelectedIndex; device.Number = numericUpDownNumber.Value; device.Invert = checkBoxInvert.Checked; device.Zoom = checkBoxZoom.Checked; device.ZoomNumber = numericUpDownZoom.Value; ds.SaveDevicesSettings(device, _nameSelectedNode); if (MessageBox.Show("Настройки успешно сохранены") == DialogResult.OK) { buttonSave.Enabled = false; buttonCancel.Enabled = false; chengedSettingsIndicator = false; } }
/// <summary> /// удаление устройства /// </summary> /// <param name="nameDevice"></param> private void DeleteNodeInTree(string nameDevice) { DeviceSettingsArgs dsa = new DeviceSettingsArgs(); DeviceSettings ds = new DeviceSettings(); dsa.Exist = false; ds.SaveDevicesSettings(dsa, nameDevice); RemoveTree(); CreatTree(); }
/// <summary> /// заполнение полей настроек устройства /// </summary> /// <param name="nameDevice"></param> private void CreateControls(string nameDevice) { DeviceSettings ds = new DeviceSettings(); var device = ds.ReturnDevicesSettings(nameDevice); textBoxNameDevice.Text = device.Name; CreateComboBoxCOMPorts(device.Port); CreateComboBoxObjects(device.Object); CreateComboBoxTimeZone(device.TimeZone); numericUpDownNumber.Value = device.Number; checkBoxInvert.Checked = device.Invert; checkBoxZoom.Checked = device.Zoom; if (device.Zoom) groupBoxZoom.Enabled = true; numericUpDownZoom.Value = device.ZoomNumber; buttonSave.Enabled = false; buttonCancel.Enabled = false; chengedSettingsIndicator = false; }
/// <summary> /// создания дерева используя данные из настроек /// </summary> private void CreatTree() { DeviceSettings ds = new DeviceSettings(); var list = ds.ReturnAllDevicesSettings(2); foreach (var deviceArgs in list) { if (deviceArgs.Exist) AddNodeInTree(deviceArgs.Name); } treeViewDevice.ExpandAll(); }
/// <summary> /// контекстное меню добавления нового устройства /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void contextMenuStripOnNodeObject_Click(object sender, EventArgs e) { AddNodeInTree(); DeviceSettingsArgs dsa = new DeviceSettingsArgs(); DeviceSettings ds = new DeviceSettings(); dsa.Exist = true; ds.SaveDevicesSettings(dsa, "Device" + _countNode.ToString()); }