当前位置: 首页>>代码示例>>C#>>正文


C# Controls.UIElement类代码示例

本文整理汇总了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;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:42,代码来源:FixedSOMElement.cs

示例2: BuildNameHashTable

 public void BuildNameHashTable(String Name, UIElement e, int indexToFixedNodes)
 {
     if (!_nameHashTable.ContainsKey(Name))
     {
         _nameHashTable.Add(Name,
             new NameHashFixedNode(e,indexToFixedNodes));
     }
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:8,代码来源:FixedDSBuilder.cs

示例3: GetFocusScope

        public static UIElement GetFocusScope(UIElement element)
        {
            while (element != null && !GetIsFocusScope(element))
            {
                element = (UIElement)(element.LogicalParent ?? element.VisualParent);
            }

            return element;
        }
开发者ID:diab0l,项目名称:Granular,代码行数:9,代码来源:FocusManager.cs

示例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);
        }
开发者ID:dfr0,项目名称:moon,代码行数:14,代码来源:DragValidator.cs

示例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;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:ColumnResizeAdorner.cs

示例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; 
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:22,代码来源:FixedHighlight.cs

示例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;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:20,代码来源:UIElementCollection.cs

示例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;
        }
开发者ID:diab0l,项目名称:Granular,代码行数:23,代码来源:FocusManager.cs

示例9: Translate

 internal static Point Translate(this UIElement fromElement, UIElement toElement, Point fromPoint)
 {
     return fromElement.TransformToVisual(toElement).Transform(fromPoint);
 }
开发者ID:dfr0,项目名称:moon,代码行数:4,代码来源:Extensions.cs

示例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); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:DockPanel.cs

示例11: GetDock

        public static Dock GetDock(UIElement element)
        { 
            if (element == null) { throw new ArgumentNullException("element"); } 

            return (Dock) element.GetValue(DockProperty); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:6,代码来源:DockPanel.cs

示例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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:FixedTextView.cs

示例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);
 }
开发者ID:salim18,项目名称:DemoProject2,代码行数:5,代码来源:VirtualizingPanel.cs

示例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);
            }

        }
开发者ID:JianwenSun,项目名称:cc,代码行数:24,代码来源:FixedDSBuilder.cs

示例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); 
     }
 } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:11,代码来源:AnnotationDocumentPaginator.cs


注:本文中的System.Windows.Controls.UIElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。