private void DisplayUpdate() { // 設定を初期化 Clear(); foreach (var item in CommandObj.Controls) { if (item.Verification()) { string displayName = item.Name; // リストボックスにアイテム追加 //for (int i = 0; i < 100; i++) CommandListBox.Items.Add(displayName); // リストボックスの一番上を選択 CommandListBox.SetSelected(0, true); FormListShow(); editFileOpenToolStripMenuItem.Enabled = true; } else { MessageBox.Show(item.Name + "の登録に失敗しました。\n設定を確認してください、", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void CommandList_MouseDown(object sender, MouseButtonEventArgs e) { // Deselect when click outside of items HitTestResult r = VisualTreeHelper.HitTest(this, e.GetPosition(this)); if (r.VisualHit.GetType() != typeof(ListBoxItem)) { CommandListBox.UnselectAll(); } }
public void Update(object obj) { if (obj.GetType().Name != "CommandCsvObject") { return; } foreach (var item in ((CommandCsvStorage.CommandCsvObject)obj).Items) { CommandListBox.Items.Add(item.Clone()); } CommandListBox.SetSelected(CommandListBox.Items.Count - 1, true); }
public void Add(object obj) { if (obj.GetType().Name != "Item") { return; } CommandJsonStorage.Item item = (CommandJsonStorage.Item)obj; var csvObj = ConvertJsonItemToCsvItem(item); csvObj.Name = new FormInputTextBox("表示名を入力して下さい。", "表示名の入力", item.Name ).GetInputText(); if (csvObj.Name != "") { //for (int i = 0; i < 100; i++) CommandListBox.Items.Add(csvObj.Clone()); // リストボックスの一番上を選択 CommandListBox.SetSelected(CommandListBox.Items.Count - 1, true); } }
private void FocusListBox([NotNull] object sender, [NotNull] KeyEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); if (e.Key == Key.Enter) { ExecuteSingleHit(); return; } if (e.Key != Key.Down) { return; } var selectedItem = CommandListBox.SelectedItem as ListBoxItem; if (selectedItem != null) { CommandListBox.Focus(); selectedItem.Focus(); Keyboard.Focus(selectedItem); e.Handled = true; return; } selectedItem = CommandListBox.Items.OfType <ListBoxItem>().FirstOrDefault(); if (selectedItem != null) { CommandListBox.Focus(); selectedItem.Focus(); Keyboard.Focus(selectedItem); e.Handled = true; } }
private void CommandTypeList_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem; if (item == null) { return; } if (item.Content.GetType() != typeof(CommandType)) { return; } CommandType commandType = (CommandType)item.Content; switch (commandType.commandTypeID) { case CommandType.Type.Stream: Commands.Add(new StreamCommand(obs)); break; case CommandType.Type.Record: Commands.Add(new RecordingCommand(obs)); break; case CommandType.Type.Profile: Commands.Add(new ProfileCommand(obs)); break; case CommandType.Type.Scene: Commands.Add(new SceneCommand(obs)); break; case CommandType.Type.Source: Commands.Add(new SourceCommand(obs)); break; case CommandType.Type.Filter: Commands.Add(new FilterCommand(obs)); break; case CommandType.Type.Audio: Commands.Add(new AudioCommand(obs)); break; case CommandType.Type.Transition: Commands.Add(new TransitionCommand(obs)); break; case CommandType.Type.StudioMode: Commands.Add(new StudioModeCommand(obs)); break; case CommandType.Type.Screenshot: Commands.Add(new ScreenshotCommand(obs)); break; case CommandType.Type.ReplayBuffer: Commands.Add(new ReplayBufferCommand(obs)); break; case CommandType.Type.Projector: Commands.Add(new ProjectorCommand(obs)); break; case CommandType.Type.Delay: Commands.Add(new DelayCommand(obs)); break; default: Commands.Add(new CustomCommand(obs)); break; } // Scroll to end of list CommandListBox.ScrollIntoView(CommandListBox.Items[CommandListBox.Items.Count - 1]); }