當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。