public void SetMode(PresetEdit chgMode, string title = "プリセット") { Title = title + new[] { "追加", "変更", "削除" }[(int)chgMode]; button_ok.Content = new[] { "追加", "変更", "削除" }[(int)chgMode]; label_chgMsg.Text = new[] { "", "(※設定内容も同時に変更されます)", "(※プリセットを削除します)" }[(int)chgMode]; textBox_name.SetReadOnlyWithEffect(chgMode == PresetEdit.Delete); }
private void button_Click(PresetEdit mode, object sender, RoutedEventArgs e) { try { var item = comboBox_preSet.SelectedItem as S; if (mode != PresetEdit.Add && item == null) { return; } var setting = new AddPresetWindow { Owner = CommonUtil.GetTopWindow(this) }; setting.SetMode(mode, this.txt_title.Text); if (mode != PresetEdit.Add) { setting.SetName(item.DisplayName); } if (setting.ShowDialog() == true) { int index = comboBox_preSet.SelectedIndex; switch (mode) { case PresetEdit.Add: index = Items.Count(it => it.IsCustom == false); var newInfo = new S { DisplayName = setting.GetName(), ID = 0, Data = dView.GetData() }; comboBox_preSet.Items.Insert(index, newInfo); break; case PresetEdit.Change: item.DisplayName = setting.GetName(); item.Data = dView.GetData(); break; case PresetEdit.Delete: index = Math.Max(0, Math.Min(index, comboBox_preSet.Items.Count - 2)); comboBox_preSet.Items.Remove(item); break; } comboBox_preSet.Items.Refresh(); ChangeSelect(index, null, true); PresetEdited(mode); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
private void PresetEdited(List <RecPresetItem> list, PresetEdit mode) { Settings.Instance.RecPresetList = list; SettingWindow.UpdatesInfo("録画プリセット変更"); if (CommonManager.Instance.NWMode == false) { CommonManager.CreateSrvCtrl().SendNotifyProfileUpdate(); ViewUtil.MainWindow.RefreshAllViewsReserveInfo(MainWindow.UpdateViewMode.ReserveInfoNoTuner); } SetCustomPresetDisplayName(); if (mode == PresetEdit.Set) { preEdit.ChangeSelect(MatchPresetOrDefault() ?? preEdit.Items.Last(), PresetSelectMode.SelectOnly); } SelectedPreset_Changed(false); }