private void ConfirmDelete(object sender, RoutedEventArgs e) { RegistryKey RegKey, SubRegKey; switch (this.PathValue1.SelectedIndex) { case 0: RegKey = Registry.ClassesRoot; break; case 1: RegKey = Registry.CurrentUser; break; case 2: RegKey = Registry.LocalMachine; break; case 3: RegKey = Registry.Users; break; case 4: RegKey = Registry.CurrentConfig; break; default: RegKey = null; break; } SubRegKey = RegKey.OpenSubKey(this.PathValue2.Text, true); if (SubRegKey != null) { try { if (SubRegKey.GetValue(this.NameValue.Text) == null) { this.ConfirmMsg.Content = Msg[LanguageIdx, 0] + this.PathValue1.Text + "\\" + this.PathValue2.Text + ":" + this.NameValue.Text; this.ConfirmMsg.Foreground = new SolidColorBrush(Colors.Red); } else { SubRegKey.DeleteValue(this.NameValue.Text); this.ConfirmMsg.Content = Msg[LanguageIdx, 1] + this.PathValue1.Text + "\\" + this.PathValue2.Text + ":" + this.NameValue.Text; this.ConfirmMsg.Foreground = new SolidColorBrush(Colors.Black); } } catch { } } else { this.ConfirmMsg.Content = Msg[LanguageIdx, 2] + this.PathValue1.Text + "\\" + this.PathValue2.Text; this.ConfirmMsg.Foreground = new SolidColorBrush(Colors.Red); } this.ConfirmDeleteBtn.Visibility = Visibility.Hidden; this.CancelDeleteBtn.Visibility = Visibility.Hidden; this.OKBtn.Visibility = Visibility.Visible; }
private void ConfirmAdd(object sender, RoutedEventArgs e) { RegistryKey RegKey, SubRegKey; switch (this.PathValue1.SelectedIndex) { case 0: RegKey = Registry.ClassesRoot; break; case 1: RegKey = Registry.CurrentUser; break; case 2: RegKey = Registry.LocalMachine; break; case 3: RegKey = Registry.Users; break; case 4: RegKey = Registry.CurrentConfig; break; default: RegKey = null; break; } SubRegKey = RegKey.OpenSubKey(this.PathValue2.Text, true); if (SubRegKey == null) { RegKey.CreateSubKey(this.PathValue2.Text, true); SubRegKey = RegKey.OpenSubKey(this.PathValue2.Text, true); } switch (this.TypeValue.SelectedIndex) { case 0: case 5: { string DataValue = this.DataValue1.Text; SubRegKey.SetValue(this.NameValue.Text, DataValue); } break; case 1: { List <byte> DataValue = new List <byte>(); for (int i = 0; i < this.DataValue2.LineCount; i++) { string[] parts = this.DataValue2.GetLineText(i).Replace("\r", "").Replace("\n", "").Split(' '); foreach (string b in parts) { if (b != "") { DataValue.Add(Convert.ToByte(b)); } } } SubRegKey.SetValue(this.NameValue.Text, DataValue.ToArray()); } break; case 2: { string DataValue = this.DataValue1.Text.Replace("\r", "").Replace("\n", ""); if (DigitCheck(DataValue)) { SetLabelStyle(this.Data, NormalColor, NormalBackGround, NormalOpacity, FontWeights.Normal, NormalSize); try { SubRegKey.SetValue(this.NameValue.Text, Convert.ToInt32(DataValue)); } catch { } } else { this.ConfirmBorder.Visibility = Visibility.Hidden; this.ConfirmBox.Visibility = Visibility.Hidden; this.ConfirmAddBtn.Visibility = Visibility.Hidden; this.ConfirmDeleteBtn.Visibility = Visibility.Hidden; this.CancelDeleteBtn.Visibility = Visibility.Hidden; this.OKBtn.Visibility = Visibility.Hidden; SetIsEnabled(true); SetLabelStyle(this.Data, ErrorColor, ErrorBackGround, ErrorOpacity, FontWeights.Normal, ErrorSize); } } break; //case 3: // { // string DataValue = this.DataValue1.Text.Replace("\r", "").Replace("\n", ""); // if (DigitCheck(DataValue)) // { // try // { // SubRegKey.SetValue(this.NameValue.Text, Convert.ToInt32(DataValue)); // } // catch // { // } // } // } // break; case 4: { List <string> DataValue = new List <string>(); for (int i = 0; i < this.DataValue2.LineCount; i++) { DataValue.Add(this.DataValue2.GetLineText(i).Replace("\r", "")); } SubRegKey.SetValue(this.NameValue.Text, DataValue.ToArray()); } break; } this.ConfirmMsg.Content = Msg[LanguageIdx, 5] + this.PathValue1.Text + "\\" + this.PathValue2.Text + ":" + this.NameValue.Text; this.ConfirmMsg.Foreground = new SolidColorBrush(Colors.Black); this.ConfirmAddBtn.Visibility = Visibility.Hidden; this.CancelDeleteBtn.Visibility = Visibility.Hidden; this.OKBtn.Visibility = Visibility.Visible; }