void CreateInternalGrid() { _internalGrid = new Grid() { FlowDirection = System.Windows.FlowDirection.LeftToRight }; _internalGrid.SetBinding(Grid.BackgroundProperty, new Binding("Background") { Source = this }); _internalHost = new LayoutAnchorableControl() { Model = _model, Style = AnchorableStyle }; _internalHost.SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this }); KeyboardNavigation.SetTabNavigation(_internalGrid, KeyboardNavigationMode.Cycle); _resizer = new LayoutGridResizerControl(); _resizer.DragStarted += new System.Windows.Controls.Primitives.DragStartedEventHandler(OnResizerDragStarted); _resizer.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler(OnResizerDragDelta); _resizer.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler(OnResizerDragCompleted); if (_side == AnchorSide.Right) { _internalGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(_manager.GridSplitterWidth) }); _internalGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel) }); Grid.SetColumn(_resizer, 0); Grid.SetColumn(_internalHost, 1); _resizer.Cursor = Cursors.SizeWE; HorizontalAlignment = System.Windows.HorizontalAlignment.Right; VerticalAlignment = System.Windows.VerticalAlignment.Stretch; } else if (_side == AnchorSide.Left) { _internalGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel), }); _internalGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(_manager.GridSplitterWidth) }); Grid.SetColumn(_internalHost, 0); Grid.SetColumn(_resizer, 1); _resizer.Cursor = Cursors.SizeWE; HorizontalAlignment = System.Windows.HorizontalAlignment.Left; VerticalAlignment = System.Windows.VerticalAlignment.Stretch; } else if (_side == AnchorSide.Top) { _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel), }); _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(_manager.GridSplitterHeight) }); Grid.SetRow(_internalHost, 0); Grid.SetRow(_resizer, 1); _resizer.Cursor = Cursors.SizeNS; VerticalAlignment = System.Windows.VerticalAlignment.Top; HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; } else if (_side == AnchorSide.Bottom) { _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(_manager.GridSplitterHeight) }); _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel), }); Grid.SetRow(_resizer, 0); Grid.SetRow(_internalHost, 1); _resizer.Cursor = Cursors.SizeNS; VerticalAlignment = System.Windows.VerticalAlignment.Bottom; HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; } _internalGrid.Children.Add(_resizer); _internalGrid.Children.Add(_internalHost); _internalHostPresenter.Content = _internalGrid; }
private void saveButton_Click(object sender, RoutedEventArgs e) { ViewMSOTcSystem.ChangeModalAndEditState(false, this); KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Continue); }
/// <summary> /// Default constructor /// </summary> public ContextMenu() { KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.Cycle); }
/// <summary> /// Updates the selection for an item based on user interaction. /// </summary> /// <param name="index">The index of the item.</param> /// <param name="select">Whether the item should be selected or unselected.</param> /// <param name="rangeModifier">Whether the range modifier is enabled (i.e. shift key).</param> /// <param name="toggleModifier">Whether the toggle modifier is enabled (i.e. ctrl key).</param> protected void UpdateSelection( int index, bool select = true, bool rangeModifier = false, bool toggleModifier = false) { if (index != -1) { if (select) { var mode = SelectionMode; var toggle = toggleModifier || (mode & SelectionMode.Toggle) != 0; var multi = (mode & SelectionMode.Multiple) != 0; var range = multi && SelectedIndex != -1 && rangeModifier; if (!toggle && !range) { SelectedIndex = index; } else if (multi && range) { SynchronizeItems( SelectedItems, GetRange(Items, SelectedIndex, index)); } else { var item = ElementAt(Items, index); var i = SelectedItems.IndexOf(item); if (i != -1 && (!AlwaysSelected || SelectedItems.Count > 1)) { SelectedItems.Remove(item); } else { if (multi) { SelectedItems.Add(item); } else { SelectedIndex = index; } } } if (Presenter?.Panel != null) { var container = ItemContainerGenerator.ContainerFromIndex(index); KeyboardNavigation.SetTabOnceActiveElement( (InputElement)Presenter.Panel, container); } } else { LostSelection(); } } }
private void UpdateChildScrollViewers() { bool isAtTop = (this.VerticalOffset == 0); bool isAtLeft = (this.HorizontalOffset == 0); bool isAtBottom = ((this.VerticalOffset + this.ViewportHeight) == this.ExtentHeight); bool isAtRight = ((this.HorizontalOffset + this.ViewportWidth) == this.ExtentWidth); foreach (SynchronizedScrollViewer scrollViewer in m_childScrollViewers) { SynchronizedScrollViewerPosition position = TableViewScrollViewer.GetSynchronizedScrollViewerPosition(scrollViewer); bool handled = false; switch (position) { case SynchronizedScrollViewerPosition.Top: if (isAtTop == true) { KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue); KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue); handled = true; } break; case SynchronizedScrollViewerPosition.Bottom: if (isAtBottom == true) { KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue); KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue); handled = true; } break; case SynchronizedScrollViewerPosition.Left: if (isAtLeft == true) { KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue); KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue); handled = true; } break; case SynchronizedScrollViewerPosition.Right: if (isAtRight == true) { KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue); KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue); handled = true; } break; case SynchronizedScrollViewerPosition.None: default: break; } if (handled == false) { KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.None); KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.None); } } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); SetInitialSelection(); KeyboardNavigation.SetIsTabStop(this, false); }
private void Presets_PreviewMouseDown(object sender, MouseButtonEventArgs e) { // Focus the keyboard navigation onto the floating panel and show it. KeyboardNavigation.SetTabNavigation(this.mainBodyGrid, ((MainViewModel)this.DataContext).IsPresetPaneDisplayed ? KeyboardNavigationMode.Continue : KeyboardNavigationMode.None); ((MainViewModel)this.DataContext).TogglePresetPane(); }
public CustomDataGrid() : base() { this.PreviewKeyDown += CustomDataGrid_PreviewKeyDown; KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Once); }
public void SetTabIndex(TFrameworkElement view, int tabIndex) { KeyboardNavigation.SetTabIndex(view, tabIndex); }
// Token: 0x060054A4 RID: 21668 RVA: 0x00176F84 File Offset: 0x00175184 private void UpdateRadioButtonGroup() { string groupName = this.GroupName; if (!string.IsNullOrEmpty(groupName)) { Visual visualRoot = KeyboardNavigation.GetVisualRoot(this); if (RadioButton._groupNameToElements == null) { RadioButton._groupNameToElements = new Hashtable(1); } Hashtable groupNameToElements = RadioButton._groupNameToElements; lock (groupNameToElements) { ArrayList arrayList = (ArrayList)RadioButton._groupNameToElements[groupName]; int i = 0; while (i < arrayList.Count) { WeakReference weakReference = (WeakReference)arrayList[i]; RadioButton radioButton = weakReference.Target as RadioButton; if (radioButton == null) { arrayList.RemoveAt(i); } else { if (radioButton != this && radioButton.IsChecked == true && visualRoot == KeyboardNavigation.GetVisualRoot(radioButton)) { radioButton.UncheckRadioButton(); } i++; } } return; } } DependencyObject parent = base.Parent; if (parent != null) { IEnumerable children = LogicalTreeHelper.GetChildren(parent); foreach (object obj in children) { RadioButton radioButton2 = obj as RadioButton; if (radioButton2 != null && radioButton2 != this && string.IsNullOrEmpty(radioButton2.GroupName) && radioButton2.IsChecked == true) { radioButton2.UncheckRadioButton(); } } } }
public ConfigureController() { InitializeComponent(); // textbox context menu TBCM = new ContextMenu(); // Mouse Buttons MenuItem LMB = new MenuItem { Header = "Insert LeftMouseButton", Name = "menuLMB" }; LMB.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(LMB); MenuItem RMB = new MenuItem { Header = "Insert RightMouseButton", Name = "menuRMB" }; RMB.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(RMB); MenuItem MMB = new MenuItem { Header = "Insert MiddleMouseButton", Name = "menuMMB" }; MMB.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MMB); MenuItem MSU = new MenuItem { Header = "Insert MouseScrollUp", Name = "menuMSU" }; MSU.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSU); MenuItem MSD = new MenuItem { Header = "Insert MouseScrollDown", Name = "menuMSD" }; MSD.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSD); MenuItem MSB3 = new MenuItem { Header = "Insert MouseButton3", Name = "menuMSB3" }; MSB3.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSB3); MenuItem MSB4 = new MenuItem { Header = "Insert MouseButton4", Name = "menuMSB4" }; MSB4.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSB4); MenuItem MSB5 = new MenuItem { Header = "Insert MouseButton5", Name = "menuMSB5" }; MSB5.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSB5); TBCM.Items.Add(new Separator()); // Mouse Axis MenuItem MSXAXIS = new MenuItem { Header = "Insert Mouse X-Axis", Name = "menuMSXAXIS" }; MSXAXIS.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSXAXIS); MenuItem MSYAXIS = new MenuItem { Header = "Insert Mouse Y-Axis", Name = "menuMSYAXIS" }; MSYAXIS.Click += new RoutedEventHandler(Macro_Click); TBCM.Items.Add(MSYAXIS); // get the mainwindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); //Input.Initialize(mw); // clear all queued presses Input.Instance.ClearEvents(); this.PreviewKeyDown += new KeyEventHandler(HandleEsc); _timer.Tick += Timer_Tick; // set the controller definition from mainwindow if (mw.ControllerDefinition == null) { this.Close(); } ControllerDefinition = mw.ControllerDefinition; string vPortStr = ""; if (ControllerDefinition.VirtualPort > 0) { vPortStr = " - Virtual Port: " + ControllerDefinition.VirtualPort; } // set the title titleTextBlock.Text = "Configure " + ControllerDefinition.DeviceName + vPortStr; // headers Label headDesc = new Label(); headDesc.Content = "Binding"; headDesc.SetValue(Grid.ColumnProperty, 0); headDesc.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headDesc); Label headConfig1 = new Label(); headConfig1.Content = "Primary"; headConfig1.SetValue(Grid.ColumnProperty, 1); headConfig1.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig1); Label headConfig2 = new Label(); headConfig2.Content = "Secondary"; headConfig2.SetValue(Grid.ColumnProperty, 3); headConfig2.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig2); Label headConfig3 = new Label(); headConfig3.Content = "Tertiary"; headConfig3.SetValue(Grid.ColumnProperty, 5); headConfig3.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig3); /* * Label headCustom = new Label(); * headCustom.Content = "Custom Insert"; * headCustom.SetValue(Grid.ColumnProperty, 4); * headCustom.SetValue(Grid.RowProperty, 0); * DynamicDataGrid.Children.Add(headCustom); */ // loop through maplist and populate the dynamic data grid row by row for (int i = 0; i < ControllerDefinition.MapList.Count; i++) { // description Label desc = new Label(); desc.Content = ControllerDefinition.MapList[i].Description; desc.SetValue(Grid.ColumnProperty, 0); desc.SetValue(Grid.RowProperty, i + 1); ToolTip tt = new System.Windows.Controls.ToolTip(); tt.Content = ControllerDefinition.MapList[i].MednafenCommand; desc.ToolTip = tt; KeyboardNavigation.SetIsTabStop(desc, false); DynamicDataGrid.Children.Add(desc); // Config Primary TextBox configInfo = new TextBox(); configInfo.Name = "Primary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); //configInfo.Text = KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Primary), KeyboardType.UK); //ControllerDefinition.MapList[i].Config; //configInfo.Text = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Primary); //ControllerDefinition.MapList[i].Config; string primTxt = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Primary); //ControllerDefinition.MapList[i].Config; configInfo.Text = ConvertText(primTxt, ConversionOrder.Load); configInfo.GotFocus += TextBox_GotFocus; configInfo.LostFocus += TextBox_LostFocus; configInfo.KeyDown += TextBox_KeyDownHandler; configInfo.IsReadOnly = true; configInfo.MinWidth = 100; configInfo.SetValue(Grid.ColumnProperty, 1); configInfo.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo, i + 1); configInfo.ContextMenu = TBCM; configInfo.MouseEnter += tb_MouseEnter; DynamicDataGrid.Children.Add(configInfo); // Config Secondary TextBox configInfo2 = new TextBox(); configInfo2.Name = "Secondary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); //configInfo2.Text = /*KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Secondary), KeyboardType.UK); //*/ControllerDefinition.MapList[i].Config; //configInfo2.Text = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Secondary); string secTxt = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Secondary); //ControllerDefinition.MapList[i].Config; configInfo2.Text = ConvertText(secTxt, ConversionOrder.Load); configInfo2.GotFocus += TextBox_GotFocus; configInfo2.LostFocus += TextBox_LostFocus; configInfo2.KeyDown += TextBox_KeyDownHandler; configInfo2.IsReadOnly = true; configInfo2.MinWidth = 100; configInfo2.SetValue(Grid.ColumnProperty, 3); configInfo2.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo2, i + 1 + ControllerDefinition.MapList.Count); configInfo2.ContextMenu = TBCM; configInfo2.MouseEnter += tb_MouseEnter; DynamicDataGrid.Children.Add(configInfo2); // Config Tertiary TextBox configInfo3 = new TextBox(); configInfo3.Name = "Tertiary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); //configInfo3.Text = /*KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Tertiary), KeyboardType.UK); //*/ControllerDefinition.MapList[i].Config; //configInfo3.Text = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Tertiary); string terTxt = GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Tertiary); //ControllerDefinition.MapList[i].Config; configInfo3.Text = ConvertText(terTxt, ConversionOrder.Load); configInfo3.GotFocus += TextBox_GotFocus; configInfo3.LostFocus += TextBox_LostFocus; configInfo3.KeyDown += TextBox_KeyDownHandler; configInfo3.IsReadOnly = true; configInfo3.MinWidth = 100; configInfo3.SetValue(Grid.ColumnProperty, 5); configInfo3.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo3, i + 1 + (ControllerDefinition.MapList.Count * 2)); configInfo3.ContextMenu = TBCM; configInfo3.MouseEnter += tb_MouseEnter; DynamicDataGrid.Children.Add(configInfo3); // configure button /* * Button btn = new Button(); * btn.Content = "Configure"; * btn.Name = "btn" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); * btn.Click += btnConfigureSingle_Click; * * btn.SetValue(Grid.ColumnProperty, 4); * btn.SetValue(Grid.RowProperty, i + 1); */ //KeyboardNavigation.SetIsTabStop(btn, false); //DynamicDataGrid.Children.Add(btn); } // populate the image BitmapImage b = GetImage(ControllerDefinition.DeviceName); if (b != null) { img.Source = b; } }
/// <summary> /// This is the method that responds to the KeyDown event. /// </summary> /// <param name="e">Event Arguments</param> protected override void OnKeyDown(KeyEventArgs e) { bool handled = true; Key key = e.Key; switch (key) { case Key.Divide: case Key.Oem2: // Ctrl-Fowardslash = Select All if (((Keyboard.Modifiers & ModifierKeys.Control) == (ModifierKeys.Control)) && (SelectionMode == SelectionMode.Extended)) { SelectAll(); } else { handled = false; } break; case Key.Oem5: // Ctrl-Backslash = Select the item with focus. if (((Keyboard.Modifiers & ModifierKeys.Control) == (ModifierKeys.Control)) && (SelectionMode == SelectionMode.Extended)) { ListBoxItem focusedItemUI = (FocusedInfo != null) ? FocusedInfo.Container as ListBoxItem : null; if (focusedItemUI != null) { MakeSingleSelection(focusedItemUI); } } else { handled = false; } break; case Key.Up: case Key.Left: case Key.Down: case Key.Right: { KeyboardNavigation.ShowFocusVisual(); // Depend on logical orientation we decide to move focus or just scroll // shouldScroll also detects if we can scroll more in this direction bool shouldScroll = ScrollHost != null; if (shouldScroll) { shouldScroll = ((key == Key.Down && IsLogicalHorizontal && DoubleUtil.GreaterThan(ScrollHost.ScrollableHeight, ScrollHost.VerticalOffset))) || ((key == Key.Up && IsLogicalHorizontal && DoubleUtil.GreaterThan(ScrollHost.VerticalOffset, 0d))) || ((key == Key.Right && IsLogicalVertical && DoubleUtil.GreaterThan(ScrollHost.ScrollableWidth, ScrollHost.HorizontalOffset))) || ((key == Key.Left && IsLogicalVertical && DoubleUtil.GreaterThan(ScrollHost.HorizontalOffset, 0d))); } if (shouldScroll) { ScrollHost.ScrollInDirection(e); } else { if ((ItemsHost != null && ItemsHost.IsKeyboardFocusWithin) || IsKeyboardFocused) { if (!NavigateByLine(KeyboardNavigation.KeyToTraversalDirection(key), new ItemNavigateArgs(e.Device, Keyboard.Modifiers))) { handled = false; } } else { handled = false; } } } break; case Key.Home: NavigateToStart(new ItemNavigateArgs(e.Device, Keyboard.Modifiers)); break; case Key.End: NavigateToEnd(new ItemNavigateArgs(e.Device, Keyboard.Modifiers)); break; case Key.Space: case Key.Enter: { if (e.Key == Key.Enter && (bool)GetValue(KeyboardNavigation.AcceptsReturnProperty) == false) { handled = false; break; } // If the event came from a ListBoxItem that's a child of ours, then look at it. ListBoxItem source = e.OriginalSource as ListBoxItem; // If ALT is down & Ctrl is up, then we shouldn't handle this. (system menu) if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Alt)) == ModifierKeys.Alt) { handled = false; break; } // If the user hits just "space" while text searching, do not handle the event // Note: Space cannot be the first character in a string sent to ITS. if (IsTextSearchEnabled && Keyboard.Modifiers == ModifierKeys.None) { TextSearch instance = TextSearch.EnsureInstance(this); // If TextSearch enabled and Prefix is not empty // then let this SPACE go so ITS can process it. if (instance != null && (instance.GetCurrentPrefix() != String.Empty)) { handled = false; break; } } if (source != null && ItemsControlFromItemContainer(source) == this) { switch (SelectionMode) { case SelectionMode.Single: if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { MakeToggleSelection(source); } else { MakeSingleSelection(source); } break; case SelectionMode.Multiple: MakeToggleSelection(source); break; case SelectionMode.Extended: if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) { // Only CONTROL MakeToggleSelection(source); } else if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Shift) { // Only SHIFT MakeAnchorSelection(source, true /* clearCurrent */); } else if ((Keyboard.Modifiers & ModifierKeys.Shift) == 0) { MakeSingleSelection(source); } else { handled = false; } break; } } else { handled = false; } } break; case Key.PageUp: NavigateByPage(FocusNavigationDirection.Up, new ItemNavigateArgs(e.Device, Keyboard.Modifiers)); break; case Key.PageDown: NavigateByPage(FocusNavigationDirection.Down, new ItemNavigateArgs(e.Device, Keyboard.Modifiers)); break; default: handled = false; break; } if (handled) { e.Handled = true; } else { base.OnKeyDown(e); } }
private void editButton_Click(object sender, RoutedEventArgs e) { ViewMSOTcSystem.ChangeModalAndEditState(true, this); KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle); }
/// <summary> /// Initializes a new instance of the CheckBox class. /// </summary> public CheckBox() { // Ignore the ENTER key by default KeyboardNavigation.SetAcceptsReturn(this, false); }
public ConfigureController() { InitializeComponent(); this.PreviewKeyDown += new KeyEventHandler(HandleEsc); _timer.Tick += Timer_Tick; // get the mainwindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); //Input.Initialize(mw); // set the controller definition from mainwindow if (mw.ControllerDefinition == null) { this.Close(); } ControllerDefinition = mw.ControllerDefinition; string vPortStr = ""; if (ControllerDefinition.VirtualPort > 0) { vPortStr = " - Virtual Port: " + ControllerDefinition.VirtualPort; } // set the title titleTextBlock.Text = "Configure " + ControllerDefinition.DeviceName + vPortStr; // headers Label headDesc = new Label(); headDesc.Content = "Binding"; headDesc.SetValue(Grid.ColumnProperty, 0); headDesc.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headDesc); Label headConfig1 = new Label(); headConfig1.Content = "Primary"; headConfig1.SetValue(Grid.ColumnProperty, 1); headConfig1.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig1); Label headConfig2 = new Label(); headConfig2.Content = "Secondary"; headConfig2.SetValue(Grid.ColumnProperty, 2); headConfig2.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig2); Label headConfig3 = new Label(); headConfig3.Content = "Tertiary"; headConfig3.SetValue(Grid.ColumnProperty, 3); headConfig3.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headConfig3); Label headCustom = new Label(); headCustom.Content = "Custom Insert"; headCustom.SetValue(Grid.ColumnProperty, 4); headCustom.SetValue(Grid.RowProperty, 0); DynamicDataGrid.Children.Add(headCustom); // loop through maplist and populate the dynamic data grid row by row for (int i = 0; i < ControllerDefinition.MapList.Count; i++) { // description Label desc = new Label(); desc.Content = ControllerDefinition.MapList[i].Description; desc.SetValue(Grid.ColumnProperty, 0); desc.SetValue(Grid.RowProperty, i + 1); ToolTip tt = new System.Windows.Controls.ToolTip(); tt.Content = ControllerDefinition.MapList[i].MednafenCommand; desc.ToolTip = tt; KeyboardNavigation.SetIsTabStop(desc, false); DynamicDataGrid.Children.Add(desc); // Config Primary TextBox configInfo = new TextBox(); configInfo.Name = "Primary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); configInfo.Text = KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Primary), KeyboardType.UK); //ControllerDefinition.MapList[i].Config; configInfo.GotFocus += TextBox_GotFocus; configInfo.LostFocus += TextBox_LostFocus; configInfo.KeyDown += TextBox_KeyDownHandler; configInfo.IsReadOnly = true; configInfo.MinWidth = 100; configInfo.SetValue(Grid.ColumnProperty, 1); configInfo.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo, i + 1); DynamicDataGrid.Children.Add(configInfo); // Config Secondary TextBox configInfo2 = new TextBox(); configInfo2.Name = "Secondary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); configInfo2.Text = KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Secondary), KeyboardType.UK); //ControllerDefinition.MapList[i].Config; configInfo2.GotFocus += TextBox_GotFocus; configInfo2.LostFocus += TextBox_LostFocus; configInfo2.KeyDown += TextBox_KeyDownHandler; configInfo2.IsReadOnly = true; configInfo2.MinWidth = 100; configInfo2.SetValue(Grid.ColumnProperty, 2); configInfo2.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo2, i + 1 + ControllerDefinition.MapList.Count); DynamicDataGrid.Children.Add(configInfo2); // Config Tertiary TextBox configInfo3 = new TextBox(); configInfo3.Name = "Tertiary_" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); configInfo3.Text = KeyboardTranslation.SDLCodetoDx(GetConfigItem(ControllerDefinition.MapList[i].MednafenCommand, ConfigOrder.Tertiary), KeyboardType.UK); //ControllerDefinition.MapList[i].Config; configInfo3.GotFocus += TextBox_GotFocus; configInfo3.LostFocus += TextBox_LostFocus; configInfo3.KeyDown += TextBox_KeyDownHandler; configInfo3.IsReadOnly = true; configInfo3.MinWidth = 100; configInfo3.SetValue(Grid.ColumnProperty, 3); configInfo3.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetTabIndex(configInfo3, i + 1 + (ControllerDefinition.MapList.Count * 2)); DynamicDataGrid.Children.Add(configInfo3); // configure button Button btn = new Button(); btn.Content = "Configure"; btn.Name = "btn" + TranslateConfigName(ControllerDefinition.MapList[i].MednafenCommand); btn.Click += btnConfigureSingle_Click; btn.SetValue(Grid.ColumnProperty, 4); btn.SetValue(Grid.RowProperty, i + 1); KeyboardNavigation.SetIsTabStop(btn, false); DynamicDataGrid.Children.Add(btn); } // populate the image BitmapImage b = GetImage(ControllerDefinition.DeviceName); if (b != null) { img.Source = b; } }
public Menu() { Background = System.Windows.Media.Brushes.Transparent; BorderThickness = new Thickness(0); FontSize = 20; MaxHeight = 40; Margin = new Thickness(2, 2, 10, 2); Padding = new Thickness(6, 0, 6, 0); VerticalAlignment = System.Windows.VerticalAlignment.Stretch; itemsControl = new ItemsControl() { Background = System.Windows.Media.Brushes.White, BorderBrush = System.Windows.Media.Brushes.LightGray, BorderThickness = new Thickness(1), IsTabStop = false }; itemsControl.SetBinding(ItemsControl.MinWidthProperty, new Binding("ActualWidth") { Source = this }); KeyboardNavigation.SetTabNavigation(itemsControl, KeyboardNavigationMode.Continue); base.Loaded += (o, e) => { var parent = this.GetParent <IView>(); if (parent != null) { ((INotifyPropertyChanged)this).SetBinding(new UI.Binding("Foreground", "TitleColor") { Source = parent, Mode = UI.BindingMode.OneWayToTarget, ValueConverter = new ColorToBrushConverter() }); } }; base.Unloaded += (o, e) => { ((INotifyPropertyChanged)this).ClearBinding("Foreground"); }; popup = new Popup() { AllowsTransparency = false, Child = itemsControl, Focusable = false, PlacementTarget = this, Placement = PlacementMode.Bottom, PopupAnimation = PopupAnimation.Slide, StaysOpen = false }; popup.KeyUp += (o, e) => { if (e.Key == Key.Escape) { popup.IsOpen = false; } }; Title = null; }
public void KeyboardDirectionalNavigationCanvasTest() { Control child1 = new Control { Name = "child1", Width = 100, Height = 100 }; Control child2 = new Control { Name = "child2", Width = 100, Height = 100 }; Control child3 = new Control { Name = "child3", Width = 100, Height = 100 }; Control child4 = new Control { Name = "child4", Width = 100, Height = 100 }; Control child5 = new Control { Name = "child5", Width = 100, Height = 100 }; Canvas.SetLeft(child1, 0); Canvas.SetTop(child1, 0); Canvas.SetLeft(child2, 400); Canvas.SetTop(child2, 10); Canvas.SetLeft(child3, 200); Canvas.SetTop(child3, 200); Canvas.SetLeft(child4, 10); Canvas.SetTop(child4, 400); Canvas.SetLeft(child5, 410); Canvas.SetTop(child5, 410); Canvas canvas = new Canvas { Width = 600, Height = 600, IsRootElement = true }; canvas.Children.Add(child1); canvas.Children.Add(child2); canvas.Children.Add(child3); canvas.Children.Add(child4); canvas.Children.Add(child5); canvas.Measure(new Size(1000, 1000)); canvas.Arrange(new Rect(1000, 1000)); KeyboardNavigation.SetTabNavigation(canvas, KeyboardNavigationMode.Contained); Assert.AreEqual(child1, KeyboardNavigationTarget.FindTarget(child1, FocusNavigationDirection.Left, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child1, FocusNavigationDirection.Right, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child1, KeyboardNavigationTarget.FindTarget(child1, FocusNavigationDirection.Up, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child1, FocusNavigationDirection.Down, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child2, FocusNavigationDirection.Left, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child2, KeyboardNavigationTarget.FindTarget(child2, FocusNavigationDirection.Right, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child2, KeyboardNavigationTarget.FindTarget(child2, FocusNavigationDirection.Up, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child2, FocusNavigationDirection.Down, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child4, KeyboardNavigationTarget.FindTarget(child3, FocusNavigationDirection.Left, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child2, KeyboardNavigationTarget.FindTarget(child3, FocusNavigationDirection.Right, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child2, KeyboardNavigationTarget.FindTarget(child3, FocusNavigationDirection.Up, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child4, KeyboardNavigationTarget.FindTarget(child3, FocusNavigationDirection.Down, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child4, KeyboardNavigationTarget.FindTarget(child4, FocusNavigationDirection.Left, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child4, FocusNavigationDirection.Right, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child4, FocusNavigationDirection.Up, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child4, KeyboardNavigationTarget.FindTarget(child4, FocusNavigationDirection.Down, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child5, FocusNavigationDirection.Left, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child5, KeyboardNavigationTarget.FindTarget(child5, FocusNavigationDirection.Right, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child3, KeyboardNavigationTarget.FindTarget(child5, FocusNavigationDirection.Up, KeyboardNavigation.TabNavigationProperty)); Assert.AreEqual(child5, KeyboardNavigationTarget.FindTarget(child5, FocusNavigationDirection.Down, KeyboardNavigation.TabNavigationProperty)); }
public DockablePane() { this.Loaded += new RoutedEventHandler(DockablePane_Loaded); this.Unloaded += new RoutedEventHandler(DockablePane_Unloaded); KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle); }
public DataListView() { InitializeComponent(); KeyboardNavigation.SetTabNavigation(ScalarExplorer, KeyboardNavigationMode.Cycle); }
public PlayWindow() : base() { GameSettings = Program.GameSettings; IsHost = Program.IsHost; if (Program.GameEngine.Spectator) { CanChat = Program.GameSettings.MuteSpectators == false; } else { CanChat = true; } GameMessages = new ObservableCollection <IGameMessage>(); _gameMessageReader = new GameMessageDispatcherReader(Program.GameMess); var isLocal = Program.GameEngine.IsLocal; //GameLogWindow.Show(); //GameLogWindow.Visibility = Visibility.Hidden; Program.Dispatcher = Dispatcher; DataContext = Program.GameEngine; InitializeComponent(); _isLocal = isLocal; //Application.Current.MainWindow = this; Version oversion = Assembly.GetExecutingAssembly().GetName().Version; Title = "Octgn version : " + oversion + " : " + Program.GameEngine.Definition.Name; Program.GameEngine.ComposeParts(this); this.Loaded += OnLoaded; this.chat.MouseEnter += ChatOnMouseEnter; this.chat.MouseLeave += ChatOnMouseLeave; this.playerTabs.MouseEnter += PlayerTabsOnMouseEnter; this.playerTabs.MouseLeave += PlayerTabsOnMouseLeave; this.PreGameLobby.OnClose += delegate { if (this.PreGameLobby.StartingGame) { PreGameLobby.Visibility = Visibility.Collapsed; if (Player.LocalPlayer.Spectator == false) { Program.GameEngine.ScriptEngine.SetupEngine(false); } table = new TableControl { DataContext = Program.GameEngine.Table, IsTabStop = true }; KeyboardNavigation.SetIsTabStop(table, true); TableHolder.Child = table; table.UpdateSided(); Keyboard.Focus(table); Program.GameEngine.Ready(); if (Program.DeveloperMode && Player.LocalPlayer.Spectator == false) { MenuConsole.Visibility = Visibility.Visible; var wnd = new DeveloperWindow() { Owner = this }; wnd.Show(); } Program.GameSettings.PropertyChanged += (sender, args) => { if (Program.GameEngine.Spectator) { CanChat = Program.GameSettings.MuteSpectators == false; } if (Program.IsHost) { Program.Client.Rpc.Settings(Program.GameSettings.UseTwoSidedTable, Program.GameSettings.AllowSpectators, Program.GameSettings.MuteSpectators); } }; // Select proper player tab if (Player.LocalPlayer.Spectator) { Dispatcher.BeginInvoke(new Action(() => { playerTabs.SelectedIndex = 0; })); } } else { IsRealClosing = true; this.TryClose(); } }; this.Loaded += delegate { Program.OnOptionsChanged += ProgramOnOnOptionsChanged; _gameMessageReader.Start( x => { Dispatcher.Invoke(new Action( () => { bool gotOne = false; foreach (var m in x) { var b = Octgn.Play.Gui.ChatControl.GameMessageToBlock(m); if (b == null) { continue; } if (m is NotifyBarMessage) { GameMessages.Insert(0, m); gotOne = true; while (GameMessages.Count > 60) { GameMessages.Remove(GameMessages.Last()); } } } if (!gotOne) { return; } if (_showBottomBar != null && _showBottomBar.GetCurrentProgress(BottomBar) > 0) { _showBottomBar.Seek(BottomBar, TimeSpan.FromMilliseconds(500), TimeSeekOrigin.BeginTime); } else { if (_showBottomBar == null) { _showBottomBar = BottomBar.Resources["ShowBottomBar"] as Storyboard; } _showBottomBar.Begin(BottomBar, HandoffBehavior.Compose, true); } if (this.IsActive == false) { this.FlashWindow(); } if (this.IsActive == false && Prefs.EnableGameSound && DateTime.Now > lastMessageSoundTime.AddSeconds(10)) { Octgn.Utils.Sounds.PlayGameMessageSound(); lastMessageSoundTime = DateTime.Now; } })); }); }; this.Activated += delegate { this.StopFlashingWindow(); }; this.Unloaded += delegate { Program.OnOptionsChanged -= ProgramOnOnOptionsChanged; _gameMessageReader.Stop(); }; //this.chat.NewMessage = x => //{ // GameMessages.Insert(0, x); //}; }
public TimePickerPresenter() { Time = DateTime.Now.TimeOfDay; KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle); }
public PDFRendererControl(PDFDocument pdf_document, bool remember_last_read_page, ZoomType force_zoom_type) { WPFDoEvents.AssertThisCodeIsRunningInTheUIThread(); Theme.Initialize(); InitializeComponent(); //Unloaded += PDFRendererControl_Unloaded; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; pdf_renderer_control_stats = new PDFRendererControlStats(pdf_document); this.remember_last_read_page = remember_last_read_page; ObjPagesPanel.Background = ThemeColours.Background_Brush_Blue_LightToDark; PageRenderArea.SizeChanged += PDFRendererControl_SizeChanged; KeyUp += PDFRendererControl_KeyUp; KeyDown += PDFRendererControl_KeyDown; TextInput += PDFRendererControl_TextInput; PreviewMouseWheel += PDFRendererControl_MouseWheel; ScrollPages.PreviewMouseDown += ScrollPages_PreviewMouseDown; ScrollPages.ScrollChanged += ScrollPages_ScrollChanged; KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.None); KeyboardNavigation.SetDirectionalNavigation(ScrollPages, KeyboardNavigationMode.None); KeyboardNavigation.SetDirectionalNavigation(ObjPagesPanel, KeyboardNavigationMode.None); // Set the initial zoom ZoomType zoom_type = ZoomType.Other; switch (ConfigurationManager.Instance.ConfigurationRecord.GUI_LastPagesUp) { case "1": zoom_type = ZoomType.Zoom1Up; break; case "2": zoom_type = ZoomType.Zoom2Up; break; case "N": zoom_type = ZoomType.ZoomNUp; break; case "W": zoom_type = ZoomType.ZoomWholeUp; break; default: zoom_type = ZoomType.Zoom1Up; break; } // Is the zoom type forced? (e.g. by the metadata panel or the sniffer) if (ZoomType.Other != force_zoom_type) { zoom_type = force_zoom_type; } PageZoom(zoom_type); var doc = pdf_renderer_control_stats.pdf_document; SafeThreadPool.QueueUserWorkItem(o => { // Add the child pages bool add_bells_and_whistles = (doc.PageCount > 0 && doc.PageCount < 50); WPFDoEvents.InvokeAsyncInUIThread(() => { Logging.Info("+Creating child page controls"); for (int page = 1; page <= doc.PageCount; ++page) { PDFRendererPageControl page_control = new PDFRendererPageControl(this, page, add_bells_and_whistles); ObjPagesPanel.Children.Add(page_control); } Logging.Info("-Creating child page controls"); }); }); Logging.Info("+Setting initial viewport"); ReconsiderOperationMode(OperationMode.Hand); SetSearchKeywords(); // Eventually this should move into the ReconsiderOperationMode ScrollPages.Focus(); Logging.Info("-Setting initial viewport"); }
public void createList() { Listbox.ItemsSource = factormap; Listbox.Width = 400; KeyboardNavigation.SetTabNavigation(Listbox, KeyboardNavigationMode.Cycle); }
/// <summary> /// Updates the selection for an item based on user interaction. /// </summary> /// <param name="index">The index of the item.</param> /// <param name="select">Whether the item should be selected or unselected.</param> /// <param name="rangeModifier">Whether the range modifier is enabled (i.e. shift key).</param> /// <param name="toggleModifier">Whether the toggle modifier is enabled (i.e. ctrl key).</param> /// <param name="rightButton">Whether the event is a right-click.</param> protected void UpdateSelection( int index, bool select = true, bool rangeModifier = false, bool toggleModifier = false, bool rightButton = false) { if (index != -1) { if (select) { var mode = SelectionMode; var multi = (mode & SelectionMode.Multiple) != 0; var toggle = (toggleModifier || (mode & SelectionMode.Toggle) != 0); var range = multi && rangeModifier; if (rightButton) { if (!_selection.Contains(index)) { UpdateSelectedItem(index); } } else if (range) { UpdateSelectedItems(() => { var start = SelectedIndex != -1 ? SelectedIndex : 0; var step = start < index ? 1 : -1; _selection.Clear(); for (var i = start; i != index; i += step) { _selection.Add(i); } _selection.Add(index); var first = Math.Min(start, index); var last = Math.Max(start, index); foreach (var container in ItemContainerGenerator.Containers) { MarkItemSelected( container.Index, container.Index >= first && container.Index <= last); } ResetSelectedItems(); }); } else if (multi && toggle) { UpdateSelectedItems(() => { if (!_selection.Contains(index)) { _selection.Add(index); MarkItemSelected(index, true); SelectedItems.Add(ElementAt(Items, index)); } else { _selection.Remove(index); MarkItemSelected(index, false); if (index == _selectedIndex) { UpdateSelectedItem(_selection.First(), false); } SelectedItems.Remove(ElementAt(Items, index)); } }); } else if (toggle) { SelectedIndex = (SelectedIndex == index) ? -1 : index; } else { UpdateSelectedItem(index); } if (Presenter?.Panel != null) { var container = ItemContainerGenerator.ContainerFromIndex(index); KeyboardNavigation.SetTabOnceActiveElement( (InputElement)Presenter.Panel, container); } } else { LostSelection(); } } }
/// <summary> /// Update this button's entire group /// </summary> private void UpdateRadioButtonGroup() { string groupName = GroupName; if (!string.IsNullOrEmpty(groupName)) { // Get the root of this RadioButton's visual tree DependencyObject visualRoot = KeyboardNavigation.GetVisualRoot(this); Debug.Assert(_groupNameToElements != null, "_groupNameToElements should already exist!"); List <WeakReference> elements = _groupNameToElements[groupName]; Debug.Assert(elements != null, string.Format(CultureInfo.InvariantCulture, "GroupName {0} not found in _groupNameToElements!", groupName)); // Synchronize the rest of the elements in the group int index = 0; while (index < elements.Count) { RadioButton button = elements[index].Target as RadioButton; if (button == null) { // Remove any weak references that were collected elements.RemoveAt(index); } else { // Uncheck the button if it's in the same group and // was already checked if ((button != this) && (button.IsChecked == true) && (visualRoot == KeyboardNavigation.GetVisualRoot(button))) { button.IsChecked = false; } index++; } } } else { // Synchronize the rest of the elements in the nameless group Panel parent = Parent as Panel; if (parent != null) { // foreach (UIElement element in parent.Children) { RadioButton button = element as RadioButton; // Uncheck the button if it's in the same nameless group // and was already checked if ((button != null) && (button != this) && string.IsNullOrEmpty(button.GroupName) && (button.IsChecked == true)) { button.IsChecked = false; } } } } }
public static void NavigateKeyboard(ArrayList list, object element, ContainerControl container, KeyboardNavigation navig) { for (int i = 0; i < list.Count; i++) { if (navig == KeyboardNavigation.Down) { if (i == list.Count - 1) { if (element == list[i]) { container.ActiveControl = list[0] as Control; } } else { if (element == list[i]) { container.ActiveControl = list[i + 1] as Control; } } } else if (navig == KeyboardNavigation.Up) { if (i == 0) { if (element == list[i]) { container.ActiveControl = list[list.Count - 1] as Control; } } else { if (element == list[i]) { container.ActiveControl = list[i - 1] as Control; } } } } }
private void CanvasView_KeyUp(object sender, KeyEventArgs e) { KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.Continue); }
/// <summary>Responds to the <see cref="E:System.Windows.UIElement.KeyDown" /> event. </summary> /// <param name="e">Provides data for <see cref="T:System.Windows.Input.KeyEventArgs" />.</param> // Token: 0x06005131 RID: 20785 RVA: 0x0016C2F0 File Offset: 0x0016A4F0 protected override void OnKeyDown(KeyEventArgs e) { bool flag = true; Key key = e.Key; if (key <= Key.Down) { if (key != Key.Return) { switch (key) { case Key.Space: break; case Key.Prior: base.NavigateByPage(FocusNavigationDirection.Up, new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers)); goto IL_379; case Key.Next: base.NavigateByPage(FocusNavigationDirection.Down, new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers)); goto IL_379; case Key.End: base.NavigateToEnd(new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers)); goto IL_379; case Key.Home: base.NavigateToStart(new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers)); goto IL_379; case Key.Left: case Key.Up: case Key.Right: case Key.Down: { KeyboardNavigation.ShowFocusVisual(); bool flag2 = base.ScrollHost != null; if (flag2) { flag2 = ((key == Key.Down && base.IsLogicalHorizontal && DoubleUtil.GreaterThan(base.ScrollHost.ScrollableHeight, base.ScrollHost.VerticalOffset)) || (key == Key.Up && base.IsLogicalHorizontal && DoubleUtil.GreaterThan(base.ScrollHost.VerticalOffset, 0.0)) || (key == Key.Right && base.IsLogicalVertical && DoubleUtil.GreaterThan(base.ScrollHost.ScrollableWidth, base.ScrollHost.HorizontalOffset)) || (key == Key.Left && base.IsLogicalVertical && DoubleUtil.GreaterThan(base.ScrollHost.HorizontalOffset, 0.0))); } if (flag2) { base.ScrollHost.ScrollInDirection(e); goto IL_379; } if ((base.ItemsHost == null || !base.ItemsHost.IsKeyboardFocusWithin) && !base.IsKeyboardFocused) { flag = false; goto IL_379; } if (!base.NavigateByLine(KeyboardNavigation.KeyToTraversalDirection(key), new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers))) { flag = false; goto IL_379; } goto IL_379; } default: goto IL_377; } } if (e.Key == Key.Return && !(bool)base.GetValue(KeyboardNavigation.AcceptsReturnProperty)) { flag = false; goto IL_379; } ListBoxItem listBoxItem = e.OriginalSource as ListBoxItem; if ((Keyboard.Modifiers & (ModifierKeys.Alt | ModifierKeys.Control)) == ModifierKeys.Alt) { flag = false; goto IL_379; } if (base.IsTextSearchEnabled && Keyboard.Modifiers == ModifierKeys.None) { TextSearch textSearch = TextSearch.EnsureInstance(this); if (textSearch != null && textSearch.GetCurrentPrefix() != string.Empty) { flag = false; goto IL_379; } } if (listBoxItem == null || ItemsControl.ItemsControlFromItemContainer(listBoxItem) != this) { flag = false; goto IL_379; } switch (this.SelectionMode) { case SelectionMode.Single: if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { this.MakeToggleSelection(listBoxItem); goto IL_379; } this.MakeSingleSelection(listBoxItem); goto IL_379; case SelectionMode.Multiple: this.MakeToggleSelection(listBoxItem); goto IL_379; case SelectionMode.Extended: if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) { this.MakeToggleSelection(listBoxItem); goto IL_379; } if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Shift) { this.MakeAnchorSelection(listBoxItem, true); goto IL_379; } if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.None) { this.MakeSingleSelection(listBoxItem); goto IL_379; } flag = false; goto IL_379; default: goto IL_379; } } else if (key != Key.Divide && key != Key.Oem2) { if (key == Key.Oem5) { if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control || this.SelectionMode != SelectionMode.Extended) { flag = false; goto IL_379; } ListBoxItem listBoxItem2 = (base.FocusedInfo != null) ? (base.FocusedInfo.Container as ListBoxItem) : null; if (listBoxItem2 != null) { this.MakeSingleSelection(listBoxItem2); goto IL_379; } goto IL_379; } } else { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && this.SelectionMode == SelectionMode.Extended) { this.SelectAll(); goto IL_379; } flag = false; goto IL_379; } IL_377: flag = false; IL_379: if (flag) { e.Handled = true; return; } base.OnKeyDown(e); }
public StockChartControl() { keyboardNavigation = new KeyboardNavigation(this); }