• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.UIElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Controls.UIElement的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UIElement类属于System.Windows.Controls命名空间,在下文中一共展示了UIElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: OnOwnerMouseEnterInternal

        internal static void OnOwnerMouseEnterInternal(object sender, object source)
        {
            if ((ToolTipService._lastEnterSource != null) && object.ReferenceEquals(ToolTipService._lastEnterSource, source)) 
            {
                // ToolTipService had processed this event once before, when it fired on the child
                // skip it now 
                return; 
            }
 
            UIElement senderElement = (UIElement)sender;
            if (ToolTipService._currentToolTip != null)
            { 
                if (ToolTipService._toolTipDictionary[senderElement] != ToolTipService._currentToolTip)
                {
                    // first close the previous ToolTip if entering nested elements with tooltips 
                    CloseAutomaticToolTip(null, EventArgs.Empty); 
                }
                else 
                {
                    // reentering the same element
                    return; 
                }
            }
 
            ToolTipService._owner = senderElement; 
            ToolTipService._lastEnterSource = source;
 
            Debug.Assert(ToolTipService._currentToolTip == null);

            SetRootVisual(); 

            TimeSpan sinceLastOpen = DateTime.Now - ToolTipService._lastToolTipOpenedTime; 
            if (TimeSpan.Compare(sinceLastOpen, new TimeSpan(0, 0, 0, 0, TOOLTIPSERVICE_betweenShowDelay)) <= 0) 
            {
                // open the ToolTip immediately 
                OpenAutomaticToolTip(null, EventArgs.Empty);
            }
            else 
            {
                // open the ToolTip after the InitialShowDelay interval expires
                if (ToolTipService._openTimer == null) 
                { 
                    ToolTipService._openTimer = new DispatcherTimer();
                    ToolTipService._openTimer.Tick += new EventHandler(OpenAutomaticToolTip); 
                }
                ToolTipService._openTimer.Interval = new TimeSpan(0, 0, 0, 0, TOOLTIPSERVICE_initialShowDelay); 
                ToolTipService._openTimer.Start();
            }
        } 
开发者ID:kangaroo,项目名称:moon,代码行数:49,代码来源:ToolTipService.cs


示例17: OnChildDesiredSizeChangedCore

 /// <summary>
 /// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
 /// </summary>
 /// <param name="child">
 /// Child element whose DesiredSize has changed
 /// </param>
 protected virtual void OnChildDesiredSizeChangedCore(UIElement child)
 {
     this.OnChildDesiredSizeChanged(child);
 }
开发者ID:salim18,项目名称:DemoProject2,代码行数:10,代码来源:TextBlock.cs


示例18:

 /// <summary>
 /// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
 /// NOTE: This method already exists for this class and is not specially implemented for IContentHost.
 /// If this method is called through IContentHost for this class it will fire an assert
 /// </summary>
 /// <param name="child">
 /// Child element whose DesiredSize has changed
 /// </param>
 void IContentHost.OnChildDesiredSizeChanged(UIElement child)
 {
     this.OnChildDesiredSizeChangedCore(child);
 }
开发者ID:salim18,项目名称:DemoProject2,代码行数:12,代码来源:TextBlock.cs


示例19: Within

        internal static bool Within(this Point referencePoint, UIElement referenceElement, FrameworkElement targetElement, bool ignoreVertical)
        {
            Point position = referenceElement.Translate(targetElement, referencePoint);

            return position.X > 0 && position.X < targetElement.ActualWidth
                && (ignoreVertical
                    || (position.Y > 0 && position.Y < targetElement.ActualHeight)
                );
        }
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:Extensions.cs


示例20: OnChildDesiredSizeChanged

        /// <summary>
        /// OnChildDesiredSizeChanged
        /// Called from FlowDocumentPage for IContentHost implementation
        /// 



        internal void OnChildDesiredSizeChanged(UIElement child)
        {
            if (_structuralCache != null && _structuralCache.IsFormattedOnce && !_structuralCache.ForceReformat)
            {
                // If executed during formatting process, delay invalidation.
                // This may happen during formatting when text host notifies its about
                // baseline changes.
                if (_structuralCache.IsFormattingInProgress)
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                        new DispatcherOperationCallback(OnChildDesiredSizeChangedAsync), child);
                    return;
                }

                // Get start and end positions
                int childStartIndex = TextContainerHelper.GetCPFromEmbeddedObject(child, ElementEdge.BeforeStart);
                if (childStartIndex < 0)
                {
                    return;
                }

                TextPointer childStart = new TextPointer(_structuralCache.TextContainer.Start);
                childStart.MoveByOffset(childStartIndex);
                TextPointer childEnd = new TextPointer(childStart);
                childEnd.MoveByOffset(TextContainerHelper.EmbeddedObjectLength);

                // Create new DTR for changing UIElement and add it to DRTList.
                DirtyTextRange dtr = new DirtyTextRange(childStartIndex, TextContainerHelper.EmbeddedObjectLength, TextContainerHelper.EmbeddedObjectLength);
                _structuralCache.AddDirtyTextRange(dtr);

                // Notify formatter about content invalidation.
                if (_formatter != null)
                {
                    _formatter.OnContentInvalidated(true, childStart, childEnd);
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:44,代码来源:FlowDocument.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.UIElementCollection类代码示例发布时间:2022-05-26
下一篇:
C# Controls.TreeViewItem类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap