internal void CreateExtendEditor() { if (Context.SelectConfig == null || NowEditor != EditorConfig) { return; } var type = Context.SelectConfig.GetType(); if (extendType == type && extendWorkView == WorkView) { return; } extendType = type; extendWorkView = WorkView; if (!DesignerManager.ExtendDictionary.TryGetValue(type, out var exts) || exts.Count == 0) { ExtendEditorPanel.Items.Clear(); return; } ExtendEditorPanel.Items.Clear(); foreach (var ext in exts.OrderBy(p => p.Value.Index)) { if (WorkView != null && ext.Value.Filter.Count > 0 && !ext.Value.Filter.Contains(WorkView)) { continue; } CreateExtendEditor(ext.Key, ext.Value); } if (ExtendEditorPanel.Items.Count > 0) { Model.Dispatcher.Invoke(() => { ExtendEditorPanel.UpdateLayout(); ExtendEditorPanel.SelectedIndex = 0; ExtendEditorPanel.UpdateLayout(); }); } }
/// <summary> /// Focus event handler /// </summary> /// <param name="e"></param> protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnPreviewGotKeyboardFocus(e); if (!e.Handled && e.NewFocus == this) { if (!IsSelected && TabControlParent != null) { SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.TrueBox); // If focus moved in result of selection - handle the event to prevent setting focus back on the new item if (e.OldFocus != Keyboard.FocusedElement) { e.Handled = true; } else if (GetBoolField(BoolField.SetFocusOnContent)) { TabControl parentTabControl = TabControlParent; if (parentTabControl != null) { // Save the parent and check for null to make sure that SetCurrentValue didn't have a change handler // that removed the TabItem from the tree. ContentPresenter selectedContentPresenter = parentTabControl.SelectedContentPresenter; if (selectedContentPresenter != null) { parentTabControl.UpdateLayout(); // Wait for layout bool success = selectedContentPresenter.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); // If we successfully move focus inside the content then don't set focus to the header if (success) { e.Handled = true; } } } } } } }
/// <summary> Announces that the keyboard is focused on this element. </summary> /// <param name="e">Keyboard input event arguments.</param> // Token: 0x060056DB RID: 22235 RVA: 0x001805E4 File Offset: 0x0017E7E4 protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnPreviewGotKeyboardFocus(e); if (!e.Handled && e.NewFocus == this) { if (FrameworkAppContextSwitches.SelectionPropertiesCanLagBehindSelectionChangedEvent) { if (!this.IsSelected && this.TabControlParent != null) { base.SetCurrentValueInternal(TabItem.IsSelectedProperty, BooleanBoxes.TrueBox); if (e.OldFocus != Keyboard.FocusedElement) { e.Handled = true; return; } if (this.GetBoolField(TabItem.BoolField.SetFocusOnContent)) { TabControl tabControlParent = this.TabControlParent; if (tabControlParent != null) { ContentPresenter selectedContentPresenter = tabControlParent.SelectedContentPresenter; if (selectedContentPresenter != null) { tabControlParent.UpdateLayout(); bool flag = selectedContentPresenter.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); if (flag) { e.Handled = true; return; } } } } } } else { if (!this.IsSelected && this.TabControlParent != null) { base.SetCurrentValueInternal(TabItem.IsSelectedProperty, BooleanBoxes.TrueBox); if (e.OldFocus != Keyboard.FocusedElement) { e.Handled = true; } } if (!e.Handled && this.GetBoolField(TabItem.BoolField.SetFocusOnContent)) { TabControl tabControlParent2 = this.TabControlParent; if (tabControlParent2 != null) { ContentPresenter selectedContentPresenter2 = tabControlParent2.SelectedContentPresenter; if (selectedContentPresenter2 != null) { tabControlParent2.UpdateLayout(); bool flag2 = selectedContentPresenter2.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); if (flag2) { e.Handled = true; } } } } } } }