C# Class Microsoft.Windows.Controls.Ribbon.RibbonHelper

A static class which defines various helper methods.
Exibir arquivo Open project: kasicass/kasicass

Public Methods

Method Description
AsyncSetFocusAndCapture ( UIElement element, Func getter, UIElement targetCapture, UIElement targetFocus ) : void
Beep ( ) : void

Produces default system beep.

CalculateVisibleBoundingRect ( UIElement element ) : Rect

Calculates the real visible rectangle within parent chain, borrowed from 4.0 IsOffScreen fix for UIA.

CoerceRibbonToolTip ( DependencyObject d, object value ) : object

Helper method which serves as the coercion callback for ToolTip property of ribbon controls. It creates and updates a RibbonToolTip if needed and if possible and returns that as the coerced value.

DelayCoerceProperty ( DependencyObject element, DependencyProperty property ) : void

Helper method to coerce the given property of the element at input priority.

FindAccessKeyMarker ( string text ) : int
FixMeasureInvalidationPaths ( DependencyObject element ) : bool

Recursively patches the measure invalidation across the descendant paths

Focus ( DependencyObject element ) : bool
GetContainingUIElement ( DependencyObject element ) : UIElement

Returns the first UIElement in the ancestral chain including the element itself.

GetCultureInfo ( DependencyObject element ) : CultureInfo
GetIsContentTooltip ( FrameworkElement visualChild, object content ) : bool

Determines whether a ToolTip is available on the first Visual child of a FrameworkElement.

GetPresentationSourceFromVisual ( Visual visual ) : System.Windows.PresentationSource
GetValueAndValueSource ( DependencyObject d, DependencyProperty property ) : ValueAndValueSource
HandleIsDropDownChanged ( UIElement element, Func getter, UIElement targetCapture, UIElement targetFocus ) : void
HandleLostMouseCapture ( UIElement element, System.Windows.Input.MouseEventArgs e, Func getter, Action setter, UIElement targetCapture, UIElement targetFocus ) : void
IgnoreDPInheritedFromParentItemsControl ( ItemsControl itemsControl, ItemsControl parentItemsControl, ValueAndValueSource itemTemplate, ValueAndValueSource itemTemplateSelector, ValueAndValueSource itemStringFormat, ValueAndValueSource itemContainerStyle, ValueAndValueSource itemContainerStyleSelector, ValueAndValueSource alternationCount, ValueAndValueSource itemBindingGroup, ValueAndValueSource headerTemplate, ValueAndValueSource headerTemplateSelector, ValueAndValueSource headerStringFormat ) : void

This is an helper function to overcome the restriction on WPF framework to have hetrogenious hierarchy ItemsControl. The problem is an ItemsControl in it's internal logic fetches Item related properties from it's parent if that is an ItemsControl. That approach can only be successful only in homogenous hierarchy of controls from first layer as in case of TreeViewItem. In Ribbon control it is not true at various places and most common example could RibbonGalleryCategory. RibbonGalleryCategory's parent is RibbonGallery which is an ItemsControl and hence the above explained fetch happens. But the property specified on RibbonGallery are applicable to RibbonGalleryCategory only. Now, RibbonGalleryCategory's Item are not RibbonGalleryCategory but RibbonGalleryItem and hence a conflict. This function gets called from PrepareContainerOverride after the base.PrepareContainerOverride is being called and if the properties being fetched from the parent (changed) it sets them back to original values passed as arguments.

InitializeStarLayoutManager ( DependencyObject starLayoutProvider ) : void
IsCaptureInSubtree ( UIElement element ) : bool
IsCaptureInVisualSubtree ( UIElement element ) : bool
IsISupportStarLayout ( DependencyObject d ) : bool
IsMousePhysicallyOver ( UIElement element ) : bool
IsOurWindow ( IntPtr hwnd, DependencyObject element ) : bool

Helper method which determines if given hwnd belongs to the same Dispatcher as that of given element.

MoveFocus ( FocusNavigationDirection direction ) : bool
OnApplicationMenuItemUpDownKeyDown ( KeyEventArgs e, RibbonMenuItem menuItem ) : void
OnRibbonToolTipPropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Helper method which serves as the property changed callback for properties which impact ToolTip (like ToolTipTitle etc.). It calls the coercion on ToolTip property.

OpenParentRibbonGroupDropDownSync ( FrameworkElement fe, bool templateApplied ) : void
PredictFocus ( DependencyObject element, FocusNavigationDirection direction ) : DependencyObject
RestoreFocusAndCapture ( UIElement targetCapture, UIElement targetFocus ) : void
SetContentAsToolTip ( FrameworkElement element, FrameworkElement visualChild, object content, bool value ) : void

Sets ToolTip on the first Visual child of a FrameworkElement.

SetDefaultQatKeyTipPlacement ( ActivatingKeyTipEventArgs e ) : void
SetDropDownHeight ( FrameworkElement itemsPresenter, bool hasGallery, double dropDownHeight ) : void
SetKeyTipPlacementForButton ( DependencyObject element, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void

Helper method to determine the keytip position for RibbonButton, RibbonToggleButton, RibbonMenuButton, and RibbonRadioButton.

SetKeyTipPlacementForSplitButtonDropDown ( Microsoft.Windows.Controls.Ribbon.RibbonSplitButton splitButton, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void
SetKeyTipPlacementForSplitButtonHeader ( Microsoft.Windows.Controls.Ribbon.RibbonSplitButton splitButton, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void
SetKeyTipPlacementForTextBox ( DependencyObject element, ActivatingKeyTipEventArgs e, UIElement nonLargePlacementTarget ) : void

Helper method which determines the keytip position for RibbonTextBox, RibbonCheckBox and RibbonComboBox.

TryGetChild ( this popup ) : UIElement

Private Methods

Method Description
AddHandler ( DependencyObject element, System.Windows.RoutedEvent routedEvent, Delegate handler ) : void
ClearPseudoInheritedProperties ( DependencyObject child ) : void
CoerceIsSubmenuOpenForTopLevelItem ( RibbonMenuItem menuItem, ItemsControl parentItemsControl, bool baseValue ) : bool
CreateClone ( object original ) : object
CreateClone ( object original, bool allowTransformations ) : object
CreateInstance ( FrameworkElement original, bool allowTransformations ) : FrameworkElement
CreatePeer ( UIElement element ) : System.Windows.Automation.Peers.AutomationPeer
DisableFocusVisual ( DependencyObject d ) : void
EnableFocusVisual ( DependencyObject d ) : void
ExistsInQAT ( DependencyObject element ) : bool

Determines whether or not an item exists in the QAT.

FindAndHookPopup ( DependencyObject element, System.Windows.Controls.Primitives.Popup &popup ) : void
FindContainer ( ItemsControl itemsControl, int startIndex, int direction, Action bringIntoViewCallback, bool>.Func additionalCheck ) : FrameworkElement
GetTransformToDevice ( Visual targetVisual ) : Matrix
HandleClickThrough ( object sender, System.Windows.Input.MouseButtonEventArgs e, UIElement alternateCaptureHost ) : void
HandleDismissPopup ( RibbonDismissPopupEventArgs e, Action setter, Predicate cancelPredicate, UIElement mouseOverTarget, UIElement alternateMouseOverTarget ) : void
HandleDropDownKeyDown ( object sender, KeyEventArgs e, Func gettor, Action settor, UIElement targetFocusOnFalse, UIElement targetFocusContainerOnTrue ) : void
HookPopupForTopLevelMenuItem ( RibbonMenuItem menuItem, ItemsControl parentItemsControl ) : void
InvalidateScrollBarVisibility ( ScrollViewer submenuScrollViewer ) : void
IsAncestorOf ( DependencyObject ancestor, DependencyObject element ) : bool
IsContainerFocusable ( FrameworkElement container ) : bool
IsContainerVisible ( FrameworkElement container ) : bool
IsEndFocusableMenuItem ( RibbonMenuItem menuItem, bool isFirst ) : bool

Helper method to determine if the given menu item is the first / last focusable item of its parent.

IsKeyboardMostRecentInputDevice ( ) : bool
IsMenuItemFocusable ( FrameworkElement container ) : bool
NavigateAndHighlightGalleryItem ( RibbonGalleryItem focusedElement, FocusNavigationDirection direction ) : bool
NavigateDownToGallery ( RibbonGallery gallery ) : bool
NavigatePageAndHighlightRibbonGalleryItem ( RibbonGallery gallery, RibbonGalleryItem galleryItem, FocusNavigationDirection direction ) : bool
NavigatePageAndHighlightRibbonGalleryItem ( RibbonGallery gallery, RibbonGalleryItem galleryItem, FocusNavigationDirection direction, RibbonGalleryItem &highlightedGalleryItem ) : bool
NavigateToFirstItem ( ItemsControl itemsControl, Action bringIntoViewCallback, bool>.Func additionalCheck ) : bool
NavigateToItem ( ItemsControl parent, int itemIndex, Action bringIntoViewCallback ) : bool
NavigateToLastItem ( ItemsControl itemsControl, Action bringIntoViewCallback, bool>.Func additionalCheck ) : bool
NavigateToNextMenuItemOrGallery ( ItemsControl parent, int startIndex, Action bringIntoViewCallback ) : bool
NavigateToPreviousMenuItemOrGallery ( ItemsControl parent, int startIndex, Action bringIntoViewCallback ) : bool
NavigateUpToGallery ( RibbonGallery gallery ) : bool
OnCanAddToQuickAccessToolBarDirectlyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnCoerceCanAddToQuickAccessToolBarDirectly ( DependencyObject d, object baseValue ) : object
OnCoerceContextMenu ( DependencyObject d, object baseValue ) : object
OnCoerceQuickAccessToolBarId ( DependencyObject d, object baseValue ) : object
OnCommandChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnContextMenuChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnIsInQATChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnPopupOpenedOrClosed ( object sender, EventArgs e ) : void
PopulatePropertyLists ( ) : void
ReacquireCapture ( UIElement targetCapture, UIElement targetFocus ) : void
RemoveHandler ( DependencyObject element, System.Windows.RoutedEvent routedEvent, Delegate handler ) : void
RestoreValue ( DependencyObject d, DependencyProperty property, ValueAndValueSource v ) : void
SetApplicationMenuLevel ( bool parentIsTopLevel, DependencyObject element ) : void
TransferItems ( ItemsControl originalItemsControl, ItemsControl cloneItemsControl ) : void
TransferMarkupProperties ( object original, object clone ) : void
TransferProperties ( FrameworkElement original, FrameworkElement clone, PropertyAndTransferMode properties ) : void
TransferProperties ( FrameworkElement original, FrameworkElement clone, bool cloningForTemplatePart ) : void
TransferProperty ( UIElement original, UIElement clone, DependencyProperty originalProperty, DependencyProperty cloneProperty, TransferMode mode ) : void
TransferProperty ( UIElement original, UIElement clone, DependencyProperty dp, TransferMode mode ) : void
TransferPseudoInheritedProperties ( DependencyObject parent, DependencyObject child ) : void
UnhookPopupForTopLevelMenuItem ( RibbonMenuItem menuItem ) : void
UpdatePopupAnimation ( System.Windows.Controls.Primitives.Popup popup ) : void
WrapClone ( FrameworkElement clone, bool allowTransformations ) : FrameworkElement

Method Details

AsyncSetFocusAndCapture() public static method

public static AsyncSetFocusAndCapture ( UIElement element, Func getter, UIElement targetCapture, UIElement targetFocus ) : void
element UIElement
getter Func
targetCapture UIElement
targetFocus UIElement
return void

Beep() public static method

Produces default system beep.
public static Beep ( ) : void
return void

CalculateVisibleBoundingRect() public static method

Calculates the real visible rectangle within parent chain, borrowed from 4.0 IsOffScreen fix for UIA.
public static CalculateVisibleBoundingRect ( UIElement element ) : Rect
element UIElement
return System.Windows.Rect

CoerceRibbonToolTip() public static method

Helper method which serves as the coercion callback for ToolTip property of ribbon controls. It creates and updates a RibbonToolTip if needed and if possible and returns that as the coerced value.
public static CoerceRibbonToolTip ( DependencyObject d, object value ) : object
d System.Windows.DependencyObject
value object
return object

DelayCoerceProperty() public static method

Helper method to coerce the given property of the element at input priority.
public static DelayCoerceProperty ( DependencyObject element, DependencyProperty property ) : void
element System.Windows.DependencyObject
property System.Windows.DependencyProperty
return void

FindAccessKeyMarker() public static method

public static FindAccessKeyMarker ( string text ) : int
text string
return int

FixMeasureInvalidationPaths() public static method

Recursively patches the measure invalidation across the descendant paths
public static FixMeasureInvalidationPaths ( DependencyObject element ) : bool
element System.Windows.DependencyObject
return bool

Focus() public static method

public static Focus ( DependencyObject element ) : bool
element System.Windows.DependencyObject
return bool

GetContainingUIElement() public static method

Returns the first UIElement in the ancestral chain including the element itself.
public static GetContainingUIElement ( DependencyObject element ) : UIElement
element System.Windows.DependencyObject
return UIElement

GetCultureInfo() public static method

public static GetCultureInfo ( DependencyObject element ) : CultureInfo
element System.Windows.DependencyObject
return System.Globalization.CultureInfo

GetIsContentTooltip() public static method

Determines whether a ToolTip is available on the first Visual child of a FrameworkElement.
public static GetIsContentTooltip ( FrameworkElement visualChild, object content ) : bool
visualChild System.Windows.FrameworkElement First visual child of control
content object Content to be set as ToolTip
return bool

GetPresentationSourceFromVisual() public static method

public static GetPresentationSourceFromVisual ( Visual visual ) : System.Windows.PresentationSource
visual Visual
return System.Windows.PresentationSource

GetValueAndValueSource() public static method

public static GetValueAndValueSource ( DependencyObject d, DependencyProperty property ) : ValueAndValueSource
d System.Windows.DependencyObject
property System.Windows.DependencyProperty
return ValueAndValueSource

HandleIsDropDownChanged() public static method

public static HandleIsDropDownChanged ( UIElement element, Func getter, UIElement targetCapture, UIElement targetFocus ) : void
element UIElement
getter Func
targetCapture UIElement
targetFocus UIElement
return void

HandleLostMouseCapture() public static method

public static HandleLostMouseCapture ( UIElement element, System.Windows.Input.MouseEventArgs e, Func getter, Action setter, UIElement targetCapture, UIElement targetFocus ) : void
element UIElement
e System.Windows.Input.MouseEventArgs
getter Func
setter Action
targetCapture UIElement
targetFocus UIElement
return void

IgnoreDPInheritedFromParentItemsControl() public static method

This is an helper function to overcome the restriction on WPF framework to have hetrogenious hierarchy ItemsControl. The problem is an ItemsControl in it's internal logic fetches Item related properties from it's parent if that is an ItemsControl. That approach can only be successful only in homogenous hierarchy of controls from first layer as in case of TreeViewItem. In Ribbon control it is not true at various places and most common example could RibbonGalleryCategory. RibbonGalleryCategory's parent is RibbonGallery which is an ItemsControl and hence the above explained fetch happens. But the property specified on RibbonGallery are applicable to RibbonGalleryCategory only. Now, RibbonGalleryCategory's Item are not RibbonGalleryCategory but RibbonGalleryItem and hence a conflict. This function gets called from PrepareContainerOverride after the base.PrepareContainerOverride is being called and if the properties being fetched from the parent (changed) it sets them back to original values passed as arguments.
public static IgnoreDPInheritedFromParentItemsControl ( ItemsControl itemsControl, ItemsControl parentItemsControl, ValueAndValueSource itemTemplate, ValueAndValueSource itemTemplateSelector, ValueAndValueSource itemStringFormat, ValueAndValueSource itemContainerStyle, ValueAndValueSource itemContainerStyleSelector, ValueAndValueSource alternationCount, ValueAndValueSource itemBindingGroup, ValueAndValueSource headerTemplate, ValueAndValueSource headerTemplateSelector, ValueAndValueSource headerStringFormat ) : void
itemsControl System.Windows.Controls.ItemsControl current ItemsControl
parentItemsControl System.Windows.Controls.ItemsControl
itemTemplate ValueAndValueSource
itemTemplateSelector ValueAndValueSource
itemStringFormat ValueAndValueSource
itemContainerStyle ValueAndValueSource
itemContainerStyleSelector ValueAndValueSource
alternationCount ValueAndValueSource
itemBindingGroup ValueAndValueSource
headerTemplate ValueAndValueSource
headerTemplateSelector ValueAndValueSource
headerStringFormat ValueAndValueSource
return void

InitializeStarLayoutManager() public static method

public static InitializeStarLayoutManager ( DependencyObject starLayoutProvider ) : void
starLayoutProvider System.Windows.DependencyObject
return void

IsCaptureInSubtree() public static method

public static IsCaptureInSubtree ( UIElement element ) : bool
element UIElement
return bool

IsCaptureInVisualSubtree() public static method

public static IsCaptureInVisualSubtree ( UIElement element ) : bool
element UIElement
return bool

IsISupportStarLayout() public static method

public static IsISupportStarLayout ( DependencyObject d ) : bool
d System.Windows.DependencyObject
return bool

IsMousePhysicallyOver() public static method

public static IsMousePhysicallyOver ( UIElement element ) : bool
element UIElement
return bool

IsOurWindow() public static method

Helper method which determines if given hwnd belongs to the same Dispatcher as that of given element.
public static IsOurWindow ( IntPtr hwnd, DependencyObject element ) : bool
hwnd System.IntPtr
element System.Windows.DependencyObject
return bool

MoveFocus() public static method

public static MoveFocus ( FocusNavigationDirection direction ) : bool
direction FocusNavigationDirection
return bool

OnApplicationMenuItemUpDownKeyDown() public static method

public static OnApplicationMenuItemUpDownKeyDown ( KeyEventArgs e, RibbonMenuItem menuItem ) : void
e KeyEventArgs
menuItem RibbonMenuItem
return void

OnRibbonToolTipPropertyChanged() public static method

Helper method which serves as the property changed callback for properties which impact ToolTip (like ToolTipTitle etc.). It calls the coercion on ToolTip property.
public static OnRibbonToolTipPropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
d System.Windows.DependencyObject
e System.Windows.DependencyPropertyChangedEventArgs
return void

OpenParentRibbonGroupDropDownSync() public static method

public static OpenParentRibbonGroupDropDownSync ( FrameworkElement fe, bool templateApplied ) : void
fe System.Windows.FrameworkElement
templateApplied bool
return void

PredictFocus() public static method

public static PredictFocus ( DependencyObject element, FocusNavigationDirection direction ) : DependencyObject
element System.Windows.DependencyObject
direction FocusNavigationDirection
return System.Windows.DependencyObject

RestoreFocusAndCapture() public static method

public static RestoreFocusAndCapture ( UIElement targetCapture, UIElement targetFocus ) : void
targetCapture UIElement
targetFocus UIElement
return void

SetContentAsToolTip() public static method

Sets ToolTip on the first Visual child of a FrameworkElement.
public static SetContentAsToolTip ( FrameworkElement element, FrameworkElement visualChild, object content, bool value ) : void
element System.Windows.FrameworkElement
visualChild System.Windows.FrameworkElement First visual child of control
content object content to be set as ToolTip
value bool Set or Unset ToolTip
return void

SetDefaultQatKeyTipPlacement() public static method

public static SetDefaultQatKeyTipPlacement ( ActivatingKeyTipEventArgs e ) : void
e ActivatingKeyTipEventArgs
return void

SetDropDownHeight() public static method

public static SetDropDownHeight ( FrameworkElement itemsPresenter, bool hasGallery, double dropDownHeight ) : void
itemsPresenter System.Windows.FrameworkElement
hasGallery bool
dropDownHeight double
return void

SetKeyTipPlacementForButton() public static method

Helper method to determine the keytip position for RibbonButton, RibbonToggleButton, RibbonMenuButton, and RibbonRadioButton.
public static SetKeyTipPlacementForButton ( DependencyObject element, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void
element System.Windows.DependencyObject
e ActivatingKeyTipEventArgs
mediumPlacementTarget UIElement
return void

SetKeyTipPlacementForSplitButtonDropDown() public static method

public static SetKeyTipPlacementForSplitButtonDropDown ( Microsoft.Windows.Controls.Ribbon.RibbonSplitButton splitButton, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void
splitButton Microsoft.Windows.Controls.Ribbon.RibbonSplitButton
e ActivatingKeyTipEventArgs
mediumPlacementTarget UIElement
return void

SetKeyTipPlacementForSplitButtonHeader() public static method

public static SetKeyTipPlacementForSplitButtonHeader ( Microsoft.Windows.Controls.Ribbon.RibbonSplitButton splitButton, ActivatingKeyTipEventArgs e, UIElement mediumPlacementTarget ) : void
splitButton Microsoft.Windows.Controls.Ribbon.RibbonSplitButton
e ActivatingKeyTipEventArgs
mediumPlacementTarget UIElement
return void

SetKeyTipPlacementForTextBox() public static method

Helper method which determines the keytip position for RibbonTextBox, RibbonCheckBox and RibbonComboBox.
public static SetKeyTipPlacementForTextBox ( DependencyObject element, ActivatingKeyTipEventArgs e, UIElement nonLargePlacementTarget ) : void
element System.Windows.DependencyObject
e ActivatingKeyTipEventArgs
nonLargePlacementTarget UIElement
return void

TryGetChild() public static method

public static TryGetChild ( this popup ) : UIElement
popup this
return UIElement