private void buttonOK_Click(object sender, RoutedEventArgs e) { var driveName = this.comboBoxAvailableDrives.SelectedItem as string; var enableHddLoad = this.checkBoxEnableHddLoad.IsChecked.Value; var hddLoad = this.upDownHddLoad.Value.Value; var hdd = new HddToMonitor(); hdd.Drive = driveName; hdd.EnableCheckHddLoad = enableHddLoad; hdd.HddLoad = hddLoad; // Avoid to add a element twice. if (this.editHddToMonitor == null) { // Add new mode. if (this.allDrives != null) { for (int i = 0; i < this.allDrives.Length; i++) { if (this.allDrives[i] == hdd) { MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.AddHddWindow_HddAlreadyAdded, hdd.Drive), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } } } } else { // Edit mode. if (hdd != this.editHddToMonitor) { // Element was changed. if (this.allDrives != null) { for (int i = 0; i < this.allDrives.Length; i++) { if (this.allDrives[i] == hdd) { MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.AddHddWindow_HddAlreadyAdded, hdd.Drive), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } } } } } this.hddToMonitor = hdd; this.DialogResult = true; this.Close(); }
public AddHddWindow(HddToMonitor hddToMonitorToEdit, HddToMonitor[] allDrives) : this(allDrives) { this.Title = Wsapm.Resources.Wsapm.AddHddWindow_TitleEdit; this.editHddToMonitor = hddToMonitorToEdit.Copy(); }