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


C# UIElement.TransformToAncestor方法代码示例

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


在下文中一共展示了UIElement.TransformToAncestor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetValues

		public void SetValues (UIElement SourceControl, String TextToModifyInput, String IDToModifyInput)
			{
			m_SourceControl = SourceControl;
			TextToModify = TextToModifyInput;
			IDToModify = IDToModifyInput;
			GeneralTransform TransformToVisual = m_SourceControl.TransformToAncestor (Application.Current.MainWindow);
			this.WindowStartupLocation = WindowStartupLocation.Manual;
			Point StartLocationOnScreen = TransformToVisual.Transform (new Point
						(Application.Current.MainWindow.Left, Application.Current.MainWindow.Top));
			this.Owner = Application.Current.MainWindow;
			this.Left = StartLocationOnScreen.X;
			this.Top = StartLocationOnScreen.Y;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:13,代码来源:FastTextEditWindow.xaml.cs

示例2: GetCurrentLayoutInfo

        protected virtual Transform GetCurrentLayoutInfo(UIElement element, out Point arrangePosition)
        {
            // Figure out where child actually is right now. This is a combination of where the
              // panel put it and any render transform currently applied
              Point currentPosition = element.TransformToAncestor(this).Transform(new Point());

              // See what transform is being applied
              Transform currentTransform = element.RenderTransform;

              // Compute where the panel actually arranged it to
              arrangePosition = currentPosition;
              if (currentTransform != null && currentTransform != MatrixTransform.Identity)
              {
            // Undo any transform we applied
            arrangePosition = currentTransform.Inverse.Transform(arrangePosition);
              }

              return currentTransform;
        }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:19,代码来源:AnimatedWrapPanel.cs

示例3: CalculateVisibleBoundingRect

        ///<summary>
        /// This eliminates the part of bounding rectangle if it is at all being overlapped/clipped by any of the visual ancestor up in the parent chain
        ///</summary>
        internal static Rect CalculateVisibleBoundingRect(UIElement uiElement)
        {
            Rect boundingRect = Rect.Empty;

            boundingRect = new Rect(uiElement.RenderSize);
            // Compute visible portion of the rectangle.

            Visual visual = VisualTreeHelper.GetParent(uiElement) as Visual;
            while (visual != null && boundingRect != Rect.Empty && boundingRect.Height != 0 && boundingRect.Width != 0)
            {
                Geometry clipGeometry = VisualTreeHelper.GetClip(visual);
                if (clipGeometry != null)
                {
                    GeneralTransform transform = uiElement.TransformToAncestor(visual).Inverse;
                    // Safer version of transform to descendent (doing the inverse ourself and saves us changing the co-ordinate space of the owner's bounding rectangle), 
                    // we want the rect inside of our space. (Which is always rectangular and much nicer to work with)
                    if (transform != null)
                    {
                        Rect clipBounds = clipGeometry.Bounds;
                        clipBounds = transform.TransformBounds(clipBounds);
                        boundingRect.Intersect(clipBounds);
                    }
                    else
                    {
                        // No visibility if non-invertable transform exists.
                        boundingRect = Rect.Empty;
                    }
                }
                visual = VisualTreeHelper.GetParent(visual) as Visual;
            }

            return boundingRect;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:36,代码来源:DataGridAutomationPeer.cs

示例4: DumpUIElement

        // ------------------------------------------------------------------
        // Dump content of UIElement.
        // ------------------------------------------------------------------
        private static void DumpUIElement(XmlTextWriter writer, UIElement element, Visual parent, bool uiElementsOnly)
        {
            writer.WriteStartElement(element.GetType().Name);

            // Dump layout information
            DumpSize(writer, "DesiredSize", element.DesiredSize);
            DumpSize(writer, "ComputedSize", element.RenderSize);
            Geometry clip = VisualTreeHelper.GetClip(element);
            if (clip != null)
            {
                DumpRect(writer, "Clip.Bounds", clip.Bounds);
            }

            // Dump transform relative to its parent
            GeneralTransform g = element.TransformToAncestor(parent);
            Point point = new Point(0, 0);
            g.TryTransform(point, out point);
            if (point.X != 0 || point.Y != 0)
            {
                DumpPoint(writer, "Position", point);
            }

            // Dump element specific information
            bool childrenHandled = false;
            Type t = element.GetType();
            DumpCustomUIElement dumpElement = null;
            while(dumpElement==null && t!=null)
            {                
                dumpElement = _elementToDumpHandler[t] as DumpCustomUIElement;
                t = t.BaseType;
            }
            if (dumpElement != null)
            {
                childrenHandled = dumpElement(writer, element, uiElementsOnly);
            }
            
            if (!childrenHandled)
            {
                if (uiElementsOnly)
                {
                    DumpUIElementChildren(writer, "Children", element);
                }
                else
                {
                    DumpVisualChildren(writer, "Children", element);
                }
            }

            writer.WriteEndElement();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:53,代码来源:LayoutDump.cs

示例5: NudgeToRibbonGroupAxis

        /// <summary>
        ///     Helper method to nudge the vertical postion of keytip,
        ///     to RibbonGroup's top/bottom axis if applicable.
        /// </summary>
        private double NudgeToRibbonGroupAxis(UIElement placementTarget, double verticalPosition)
        {
            if (OwnerRibbonGroup != null)
            {
                ItemsPresenter itemsPresenter = OwnerRibbonGroup.ItemsPresenter;
                if (itemsPresenter != null)
                {
                    GeneralTransform transform = placementTarget.TransformToAncestor(itemsPresenter);
                    Point targetOrigin = transform.Transform(new Point());
                    double keyTipTopY = verticalPosition + targetOrigin.Y;
                    double keyTipCenterY = keyTipTopY;
                    double keyTipBottomY = keyTipTopY;
                    if (_keyTipControl != null)
                    {
                        keyTipBottomY += _keyTipControl.ActualHeight;
                        keyTipCenterY += _keyTipControl.ActualHeight / 2;
                    }

                    if (DoubleUtil.LessThan(Math.Abs(keyTipTopY), RibbonGroupKeyTipAxisNudgeSpace))
                    {
                        // Nudge to top axis
                        verticalPosition -= (keyTipCenterY - RibbonGroupKeyTipAxisOffset);
                    }
                    else if (DoubleUtil.LessThan(Math.Abs(itemsPresenter.ActualHeight - keyTipBottomY), RibbonGroupKeyTipAxisNudgeSpace))
                    {
                        // Nudge to bottom axis
                        double centerOffsetFromGroupBottom = keyTipCenterY - itemsPresenter.ActualHeight;
                        verticalPosition -= (centerOffsetFromGroupBottom + RibbonGroupKeyTipAxisOffset);
                    }
                }
            }
            return verticalPosition;
        }
开发者ID:amitkr2007,项目名称:groups-dct-sms,代码行数:37,代码来源:KeyTipAdorner.cs

示例6: UpdateElementBounds

        /// <summary>
        /// UpdateElementBounds:
        ///     Called by   InkCanvasSelection.UpdateElementBounds
        ///                 ClipboardProcessor.CopySelectionInXAML
        /// </summary>
        /// <param name="originalElement"></param>
        /// <param name="updatedElement"></param>
        /// <param name="transform"></param>
        internal void UpdateElementBounds(UIElement originalElement, UIElement updatedElement, Matrix transform)
        {
            if ( originalElement.DependencyObjectType.Id == updatedElement.DependencyObjectType.Id )
            {
                // Get the transform from element to Canvas
                GeneralTransform elementToCanvas = originalElement.TransformToAncestor(_inkCanvas.InnerCanvas);

                //cast to a FrameworkElement, nothing inherits from UIElement besides it right now
                FrameworkElement frameworkElement = originalElement as FrameworkElement;
                Size size;
                Thickness thickness = new Thickness();
                if ( frameworkElement == null )
                {
                    // Get the element's render size.
                    size = originalElement.RenderSize;
                }
                else
                {
                    size = new Size(frameworkElement.ActualWidth, frameworkElement.ActualHeight);
                    thickness = frameworkElement.Margin;
                }

                Rect elementBounds = new Rect(0, 0, size.Width, size.Height);   // Rect in element space
                elementBounds = elementToCanvas.TransformBounds(elementBounds); // Rect in Canvas space

                // Now apply the matrix to the element bounds
                Rect newBounds = Rect.Transform(elementBounds, transform);

                if ( !DoubleUtil.AreClose(elementBounds.Width, newBounds.Width) )
                {
                    if ( frameworkElement == null )
                    {
                        Size newSize = originalElement.RenderSize;
                        newSize.Width = newBounds.Width;
                        updatedElement.RenderSize = newSize;
                    }
                    else
                    {
                        ((FrameworkElement)updatedElement).Width = newBounds.Width;
                    }
                }

                if ( !DoubleUtil.AreClose(elementBounds.Height, newBounds.Height) )
                {
                    if ( frameworkElement == null )
                    {
                        Size newSize = originalElement.RenderSize;
                        newSize.Height = newBounds.Height;
                        updatedElement.RenderSize = newSize;
                    }
                    else
                    {
                        ( (FrameworkElement)updatedElement ).Height = newBounds.Height;
                    }
                }

                double left = InkCanvas.GetLeft(originalElement);
                double top = InkCanvas.GetTop(originalElement);
                double right = InkCanvas.GetRight(originalElement);
                double bottom = InkCanvas.GetBottom(originalElement);

                Point originalPosition = new Point(); // Default as (0, 0)
                if ( !double.IsNaN(left) )
                {
                    originalPosition.X = left;
                }
                else if ( !double.IsNaN(right) )
                {
                    originalPosition.X = right;
                }

                if ( !double.IsNaN(top) )
                {
                    originalPosition.Y = top;
                }
                else if ( !double.IsNaN(bottom) )
                {
                    originalPosition.Y = bottom;
                }

                Point newPosition = originalPosition * transform;

                if ( !double.IsNaN(left) )
                {
                    InkCanvas.SetLeft(updatedElement, newPosition.X - thickness.Left);           // Left wasn't auto
                }
                else if ( !double.IsNaN(right) )
                {
                    // NOTICE-2005/05/05-WAYNEZEN
                    // Canvas.RightProperty means the distance between element right side and its parent Canvas
                    // right side. The same definition is applied to Canvas.BottomProperty
                    InkCanvas.SetRight(updatedElement, ( right - ( newPosition.X - originalPosition.X ) )); // Right wasn't not auto
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:InkCanvasSelection.cs

示例7: ScrollToElement

 public void ScrollToElement(UIElement element)
 {
     GeneralTransform gt = element.TransformToAncestor(this); 
 }
开发者ID:JackWangCUMT,项目名称:extensions,代码行数:4,代码来源:ZoomViewer.cs

示例8: GetChildRectangle

 /// <summary>
 /// Returns the rectangle that defines the outer bounds of a child control.
 /// </summary>
 /// <param name="uieChild">The child/control for which to return the bounding rectangle.</param>
 private Rect GetChildRectangle(UIElement uieChild)
 {
     //Retrieve the position of the requested child inside the ScrollViewer control
     GeneralTransform childTransform = uieChild.TransformToAncestor(this.ScrollOwner);
     return childTransform.TransformBounds(new Rect(new Point(0, 0), uieChild.RenderSize));
 }
开发者ID:net-shell,项目名称:quantum-vaginer,代码行数:10,代码来源:ScrollableTabPanel.cs

示例9: GetTransformedElementCornerPoints

        /// <summary>
        /// Private helper that takes an element and transforms it's 4 points
        /// into the InkCanvas's space 
        /// </summary>
        private static ElementCornerPoints GetTransformedElementCornerPoints(InkCanvasInnerCanvas canvas, UIElement childElement) 
        { 
            Debug.Assert(canvas != null);
            Debug.Assert(childElement != null); 

            Debug.Assert(canvas.CheckAccess());

            ElementCornerPoints elementPoints = new ElementCornerPoints(); 
            elementPoints.Set = false;
 
            if (childElement.Visibility != Visibility.Visible) 
            {
                // 
                // this little one's not worth it...
                //
                return elementPoints;
            } 

            // 
            // get the transform from us to our parent InkCavas 
            //
            GeneralTransform parentTransform = childElement.TransformToAncestor(canvas); 

            //

            parentTransform.TryTransform(new Point(0, 0), out elementPoints.UpperLeft); 
            parentTransform.TryTransform(new Point(childElement.RenderSize.Width, 0), out elementPoints.UpperRight);
            parentTransform.TryTransform(new Point(0, childElement.RenderSize.Height), out elementPoints.LowerLeft); 
            parentTransform.TryTransform(new Point(childElement.RenderSize.Width, childElement.RenderSize.Height), out elementPoints.LowerRight); 

            elementPoints.Set = true; 
            return elementPoints;
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:37,代码来源:LassoSelectionBehavior.cs

示例10: IsItemInView

    internal static bool IsItemInView( UIElement item, UIElement itemsHost )
    {
      GeneralTransform childTransform = item.TransformToAncestor( itemsHost );
      Rect rectangle = childTransform.TransformBounds( new Rect( new Point( 0, 0 ), item.RenderSize ) );

      //Check if the elements Rect intersects with that of the scrollviewer's
      Rect result = Rect.Intersect( new Rect( new Point( 0, 0 ), itemsHost.RenderSize ), rectangle );

      //if result is Empty then the element is not in view
      return ( result != Rect.Empty );
    }
开发者ID:Torion,项目名称:WpfExToolkit,代码行数:11,代码来源:ScrollTip.cs

示例11: GetAbsolutePath

 private static Point GetAbsolutePath(UIElement element)
 {
     return element.TransformToAncestor(window).Transform(new Point(0, 0));
 }
开发者ID:susemeee,项目名称:YangpaH,代码行数:4,代码来源:YangpaObject.cs

示例12: GetElementViewportPosition

        /// <summary>
        /// Determines if the given element is
        ///     1) Completely in the current visible page along the given axis.
        ///     2) Partially in the current visible page.
        ///     3) Before the current page along the given axis.
        ///     4) After the current page along the given axis.
        /// fullyVisible parameter specifies if the element needs to be completely
        /// in the current visible page along the perpendicular axis (if it is
        /// completely in the page along the major axis)
        /// </summary>
        internal static ElementViewportPosition GetElementViewportPosition(FrameworkElement viewPort,
            UIElement element,
            FocusNavigationDirection axis,
            bool fullyVisible,
            out Rect elementRect)
        {
            elementRect = Rect.Empty;

            // If there's no ScrollHost or ItemsHost, the element is not on the page
            if (viewPort == null)
            {
                return ElementViewportPosition.None;
            }

            if (element == null || !viewPort.IsAncestorOf(element))
            {
                return ElementViewportPosition.None;
            }

            Rect viewPortBounds = new Rect(new Point(), viewPort.RenderSize);
            Rect elementBounds = new Rect(new Point(), element.RenderSize);
            elementBounds = element.TransformToAncestor(viewPort).TransformBounds(elementBounds);
            bool northSouth = (axis == FocusNavigationDirection.Up || axis == FocusNavigationDirection.Down);
            bool eastWest = (axis == FocusNavigationDirection.Left || axis == FocusNavigationDirection.Right);

            elementRect = elementBounds;

            // Return true if the element is completely contained within the page along the given axis.

            if (fullyVisible)
            {
                if (viewPortBounds.Contains(elementBounds))
                {
                    return ElementViewportPosition.CompletelyInViewport;
                }
            }
            else
            {
                if (northSouth)
                {
                    if (DoubleUtil.LessThanOrClose(viewPortBounds.Top, elementBounds.Top)
                        && DoubleUtil.LessThanOrClose(elementBounds.Bottom, viewPortBounds.Bottom))
                    {
                        return ElementViewportPosition.CompletelyInViewport;
                    }
                }
                else if (eastWest)
                {
                    if (DoubleUtil.LessThanOrClose(viewPortBounds.Left, elementBounds.Left)
                        && DoubleUtil.LessThanOrClose(elementBounds.Right, viewPortBounds.Right))
                    {
                        return ElementViewportPosition.CompletelyInViewport;
                    }
                }
            }

            if (ElementIntersectsViewport(viewPortBounds, elementBounds))
            {
                return ElementViewportPosition.PartiallyInViewport;
            }
            else if ((northSouth && DoubleUtil.LessThanOrClose(elementBounds.Bottom, viewPortBounds.Top)) ||
                (eastWest && DoubleUtil.LessThanOrClose(elementBounds.Right, viewPortBounds.Left)))
            {
                return ElementViewportPosition.BeforeViewport;
            }
            else if ((northSouth && DoubleUtil.LessThanOrClose(viewPortBounds.Bottom, elementBounds.Top)) ||
                (eastWest && DoubleUtil.LessThanOrClose(viewPortBounds.Right, elementBounds.Left)))
            {
                return ElementViewportPosition.AfterViewport;
            }
            return ElementViewportPosition.None;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:82,代码来源:ItemsControl.cs

示例13: GetTansformedRect

 protected Rect GetTansformedRect(UIElement elem)
 {
     // we clip the top and use only 90% of the parents height.
     double height = AvailbleHeight;
     var toPoint = elem.TransformToAncestor(this.AdornedElement).Transform(new Point(0, this.TopOffset));
     var targetRect = new Rect(toPoint.X, toPoint.Y,
                             elem.DesiredSize.Width,
                             Math.Max(height, 1));
     return targetRect;
 }
开发者ID:aelij,项目名称:svcperf,代码行数:10,代码来源:ConnectorAdorner.cs


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