本文整理汇总了C#中System.Windows.Controls.UIElement类的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIElement类属于System.Windows.Controls命名空间,在下文中一共展示了UIElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFixedSOMElement
//--------------------------------------------------------------------
//
// Public Properties
//
//---------------------------------------------------------------------
#region Static methods
public static FixedSOMElement CreateFixedSOMElement(FixedPage page, UIElement uiElement, FixedNode fixedNode, int startIndex, int endIndex)
{
FixedSOMElement element = null;
if (uiElement is Glyphs)
{
Glyphs glyphs = uiElement as Glyphs;
if (glyphs.UnicodeString.Length > 0)
{
GlyphRun glyphRun = glyphs.ToGlyphRun();
Rect alignmentBox = glyphRun.ComputeAlignmentBox();
alignmentBox.Offset(glyphs.OriginX, glyphs.OriginY);
GeneralTransform transform = glyphs.TransformToAncestor(page);
if (startIndex < 0)
{
startIndex = 0;
}
if (endIndex < 0)
{
endIndex = glyphRun.Characters == null ? 0 : glyphRun.Characters.Count;
}
element = FixedSOMTextRun.Create(alignmentBox, transform, glyphs, fixedNode, startIndex, endIndex, false);
}
}
else if (uiElement is Image)
{
element = FixedSOMImage.Create(page, uiElement as Image, fixedNode);
}
else if (uiElement is Path)
{
element = FixedSOMImage.Create(page, uiElement as Path, fixedNode);
}
return element;
}
示例2: BuildNameHashTable
public void BuildNameHashTable(String Name, UIElement e, int indexToFixedNodes)
{
if (!_nameHashTable.ContainsKey(Name))
{
_nameHashTable.Add(Name,
new NameHashFixedNode(e,indexToFixedNodes));
}
}
示例3: GetFocusScope
public static UIElement GetFocusScope(UIElement element)
{
while (element != null && !GetIsFocusScope(element))
{
element = (UIElement)(element.LogicalParent ?? element.VisualParent);
}
return element;
}
示例4: DragValidator
/// <summary>
/// Create an instance of the DragValidator class
/// </summary>
/// <param name="targetElement">UIElement that represents the source of the drag operation</param>
public DragValidator(UIElement targetElement)
{
Debug.Assert(targetElement != null);
_targetElement = targetElement;
_targetElement.MouseLeftButtonDown += new MouseButtonEventHandler(TargetElement_MouseLeftButtonDown);
_targetElement.MouseLeftButtonUp += new MouseButtonEventHandler(TargetElement_MouseLeftButtonUp);
_targetElement.MouseMove += new MouseEventHandler(TargetElement_MouseMove);
}
示例5: ColumnResizeAdorner
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
#region Constructors
/// <summary>
/// C'tor for adorner
/// </summary>
/// <param name="scope">
/// FramwerokElement with TextView to which this element is attached
/// as adorner.
/// </param>
internal ColumnResizeAdorner(UIElement scope) : base(scope)
{
Debug.Assert(scope != null);
// position
_pen = new Pen(new SolidColorBrush(Colors.LightSlateGray), 2.0);
_x = Double.NaN;
_top = Double.NaN;
_height = Double.NaN;
}
示例6: FixedHighlight
//-------------------------------------------------------------------
//
// Connstructors
//
//----------------------------------------------------------------------
#region Constructors
/// <summary>
/// Create a new FixedHighlight for a Glyphs with character offset of
/// beginOffset to endOffset, to be rendered with a given brush.
/// </summary>
internal FixedHighlight(UIElement element, int beginOffset, int endOffset, FixedHighlightType t,
Brush foreground, Brush background)
{
Debug.Assert(element != null && beginOffset >= 0 && endOffset >= 0);
_element = element;
_gBeginOffset = beginOffset;
_gEndOffset = endOffset;
_type = t;
_foregroundBrush = foreground;
_backgroundBrush = background;
}
示例7: UIElementCollection
/// <summary>
/// The colleciton is the children collection of the visualParent. The logicalParent
/// is used to do logical parenting. The flags is used to invalidate
/// the resource properties in the child tree, if an Application object exists.
/// </summary>
/// <param name="visualParent">The element of whom this is a children collection</param>
/// <param name="logicalParent">The logicalParent of the elements of this collection.
/// if overriding Panel.CreateUIElementCollection, pass the logicalParent parameter of that method here.
/// </param>
public UIElementCollection(UIElement visualParent, FrameworkElement logicalParent)
{
if (visualParent == null)
{
throw new ArgumentNullException(SR.Get(SRID.Panel_NoNullVisualParent, "visualParent", this.GetType()));
}
_visualChildren = new VisualCollection(visualParent);
_visualParent = visualParent;
_logicalParent = logicalParent;
}
示例8: Focus
public static IDisposable Focus(UIElement element)
{
if (!element.Focusable)
{
return null;
}
UIElement focusScope = GetFocusScope(element);
if (focusScope != null)
{
SetFocusedElement(focusScope, element);
return new Disposable(() =>
{
if (GetFocusedElement(focusScope) == element)
{
SetFocusedElement(focusScope, null);
}
});
}
return null;
}
示例9: Translate
internal static Point Translate(this UIElement fromElement, UIElement toElement, Point fromPoint)
{
return fromElement.TransformToVisual(toElement).Transform(fromPoint);
}
示例10: SetDock
/// <summary>
/// Writes the attached property Dock to the given element.
/// </summary>
/// <param name="element">UIElement to which to write the attached property.</param>
/// <param name="dock">The property value to set</param>
/// <seealso cref="DockPanel.DockProperty" />
public static void SetDock(UIElement element, Dock dock)
{
if (element == null) { throw new ArgumentNullException("element"); }
element.SetValue(DockProperty, dock);
}
示例11: GetDock
public static Dock GetDock(UIElement element)
{
if (element == null) { throw new ArgumentNullException("element"); }
return (Dock) element.GetValue(DockProperty);
}
示例12: _HitTest
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
// hit testing to find the inner most UIElement that was hit
// as well as the containing fixed page.
private bool _HitTest(Point pt, out UIElement e)
{
e = null;
HitTestResult result = VisualTreeHelper.HitTest(this.FixedPage, pt);
DependencyObject v = (result != null) ? result.VisualHit : null;
while (v != null)
{
DependencyObjectType t = v.DependencyObjectType;
if (t == UIElementType || t.IsSubclassOf(UIElementType))
{
e = (UIElement) v;
return true;
}
v = VisualTreeHelper.GetParent(v);
}
return false;
}
示例13: InsertInternalChild
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void InsertInternalChild(UIElementCollection children, int index, UIElement child)
{
children.InsertInternal(index, child);
}
示例14: AddFixedNodeInFlow
private void AddFixedNodeInFlow(int index, UIElement e)
{
if (_visitedArray[index])
{
// this has already been added to the document structure
// Debug.Assert(false, "An element is referenced in the document structure multiple times");
return; // ignore this reference
}
FixedNode fn = (FixedNode)_fixedNodes[index];
if (e == null)
{
e = _fixedPage.GetElement(fn) as UIElement;
}
_visitedArray[index] = true;
FixedSOMElement somElement = FixedSOMElement.CreateFixedSOMElement(_fixedPage, e, fn, -1, -1);
if (somElement != null)
{
_flowBuilder.AddElement(somElement);
}
}
示例15: OnChildDesiredSizeChanged
/// <summary>
/// Lets the page recalculate the rectangles for this element when its desired
/// size has changed.
/// </summary>
public void OnChildDesiredSizeChanged(UIElement child)
{
if (_basePage != null)
{
_basePage.OnChildDesiredSizeChanged(child);
}
}