public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var transformGroup = new GeneralTransformGroup(); transformGroup.Children.Add(base.GetDesiredTransform(transform)); transformGroup.Children.Add(new TranslateTransform(_currentPoint.X - _startPoint.X, _currentPoint.Y - _startPoint.Y)); return transformGroup; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform(_leftOffset, _topOffset)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup group = new GeneralTransformGroup(); group.Children.Add(base.GetDesiredTransform(transform)); group.Children.Add(translate); return group; }
private Rect GetBounds(StylusPoint stylusPoint, Point position, IInputElement relativeTo, GeneralTransform elementToRoot, GeneralTransform rootToElement) { // Get width and heith in pixel value double width = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true); double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false); // Get the position with respect to root Point rootPoint; if (elementToRoot == null || !elementToRoot.TryTransform(position, out rootPoint)) { rootPoint = position; } // Create a Rect with respect to root and transform it to element coordinate space Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height); if (rootToElement != null) { rectBounds = rootToElement.TransformBounds(rectBounds); } return rectBounds; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform(_offsetLeft, _offsetTop)); return result; }
/// <summary> /// Forwarded to the annotation component to get desired transform relative to the annotated element /// </summary> /// <param name="transform">Transform to adorned element</param> /// <returns>Transform to annotation component </returns> public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { //if the component is not visual we do not need this if (!(_annotationComponent is UIElement)) return null; // Give the superclass a chance to modify the transform transform = base.GetDesiredTransform(transform); GeneralTransform compTransform = _annotationComponent.GetDesiredTransform(transform); //ToDo. if the annotated element is null this component must be unloaded. //Temporary return null until the PageViewer Load/Unload bug is fixed //Convert it to an exception after that. if (_annotationComponent.AnnotatedElement == null) return null; if (compTransform == null) { // We need to store the element we are registering on. It may not // be available from the annotation component later. _annotatedElement = _annotationComponent.AnnotatedElement; // Wait for valid text view _annotatedElement.LayoutUpdated += OnLayoutUpdated; return transform; } return compTransform; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add (transform); result.Children.Add (new TranslateTransform (this.offset.X, this.offset.Y)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform(this.left, this.top)); return result; }
/// <summary> /// Gets the rectangle that bounds the specified element, relative /// to the client area of the window the element is in. /// </summary> /// <param name='element'>Element to get rectangle for.</param> /// <returns>The System.Windows.Rect that bounds the element.</returns> public static Rect GetClientRelativeRect(UIElement element) { if (element == null) { throw new ArgumentNullException("element"); } Visual parent = GetTopMostVisual(element); LHPoint[] points = GetRenderSizeBoxPoints(element); Matrix m; System.Windows.Media.GeneralTransform gt = element.TransformToAncestor(parent); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } m = t.Value; m.Transform(points); // Calculate the regular Rectangle that encloses all the points. LHPoint topLeft, bottomRight; CalculateBoundingPoints(points, out topLeft, out bottomRight); return(new Rect( topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y)); }
/// <summary> /// Gets the rectangle that bounds the specified element, relative /// to the client area of the window the element is in. /// </summary> /// <param name='element'>Element to get rectangle for.</param> /// <returns>The System.Windows.Rect that bounds the element.</returns> public static Rect GetClientRelativeRect(UIElement element) { Visual parent; // Topmost parent of element. Matrix m; // Matrix to transform corodinates. Point[] points; // Points around element. if (element == null) { throw new ArgumentNullException("element"); } parent = GetTopMostVisual(element); points = GetRenderSizeBoxPoints(element); System.Windows.Media.GeneralTransform gt = element.TransformToAncestor(parent); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } m = t.Value; m.Transform(points); // Assume there is no rotation. return(new Rect(points[0], points[3])); }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform(position.X, position.Y)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var group = new TransformGroup(); group.Children.Add((Transform)transform); group.Children.Add(_tTranslate = new TranslateTransform(HorizontalOffset, VerticalOffset)); return group; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup newTransform = new GeneralTransformGroup(); newTransform.Children.Add(base.GetDesiredTransform(transform)); newTransform.Children.Add(new TranslateTransform(this._adornerOffset.X, this._adornerOffset.Y)); return newTransform; }
private void _ValidateMove(ref Point ptDragDelta) { System.Windows.Media.GeneralTransform transform = this.TransformToVisual((FrameworkElement)this.Parent); Rect R = transform.TransformBounds(new Rect(0, 0, this.ActualWidth, this.ActualHeight)); double _dblHorizontalChange = ptDragDelta.X; double _dblVerticalChange = ptDragDelta.Y; Canvas parent = (Canvas)VisualTreeHelper.GetParent(this); double _dblParentWidth = parent.ActualWidth; double _dblParentHeight = parent.ActualHeight; Point centerPt = new Point((R.Left + R.Right) / 2, (R.Top + R.Bottom) / 2); if ((centerPt.X + _dblHorizontalChange) < 0) { ptDragDelta.X = centerPt.X * -1; } if ((centerPt.Y + _dblVerticalChange) < 0) { ptDragDelta.Y = centerPt.Y * -1; } if ((centerPt.X + _dblHorizontalChange) > _dblParentWidth) { double _dbldiff = ((centerPt.X + _dblHorizontalChange) - _dblParentWidth); ptDragDelta.X -= _dbldiff; } if ((centerPt.Y + _dblVerticalChange) > _dblParentHeight) { double _dbldiff = ((centerPt.Y + _dblVerticalChange) - _dblParentHeight); ptDragDelta.Y -= _dbldiff; } }
public CoordinateTransformer(UIElement container, UIElement child) { Container = container; Child = child; _childToContainerTransform = child.TransformToVisual(container); _containerToChildTransform = container.TransformToVisual(child); }
public SinglePageInfo(double topOffsetInPresenter, double bottomPositionInView, bool intersectsHorizontally, bool intersectsVertically, RadFixedPage page, Rect positionInView, GeneralTransform transformations) : base(page, positionInView, transformations) { this.topOffsetInPresenter = topOffsetInPresenter; this.bottomPositionInView = bottomPositionInView; this.intersectsWithViewportVertically = intersectsVertically; this.intersectsWithViewportHorizontally = intersectsHorizontally; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform( position.X - treeViewEx.ScrollViewer.ContentHorizontalOffset, position.Y - treeViewEx.ScrollViewer.ContentVerticalOffset)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); result.Children.Add(new TranslateTransform(this.MousePosition.X - 4, this.MousePosition.Y - 4)); return result; }
// ------------------------------------------------------------------ // Dump content of the specified DocumentPage. // // writer - stream to be used for dump // element - element to be dumped // parent - parent element // ------------------------------------------------------------------ internal static void DumpDocumentPage(XmlNode writer, DocumentPage page, Visual parent) { if (writer == null) { throw new ArgumentNullException("writer"); } if (page == null) { throw new ArgumentNullException("page"); } if (parent == null) { throw new ArgumentNullException("parent"); } XmlNode node = PropertyDumpCore.xmldoc.CreateElement("DocumentPage"); writer.AppendChild(node); AppendAttribute(node, "Type", page.GetType().FullName); if (page == DocumentPage.Missing) { AppendAttribute(node, "Missing", "True"); } else { DumpSize(writer, "Size", page.Size); // Dump transform relative to its parent Matrix m; System.Windows.Media.GeneralTransform gt = page.Visual.TransformToAncestor(parent); System.Windows.Media.Transform t = (System.Windows.Media.Transform)gt; if (t == null) { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } m = t.Value; Point point = new Point(0, 0) * m; if (point.X != 0 || point.Y != 0) { DumpPoint(writer, "Position", point); } //check for registered handler for this document page DumpCustomDocumentPage dumpDocumentPage = _documentPageToDumpHandler[page.GetType()] as DumpCustomDocumentPage; //Hack: need to itentify if test code should be using the Debug Class //Debug.Assert(dumpDocumentPage == null, String.Format("Unknown documentpage of type {0}", page.GetType())); if (dumpDocumentPage != null) { dumpDocumentPage(node, page); } } }
/// <summary> /// Override. /// </summary> /// <param name="transform"></param> /// <returns></returns> public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); // ReSharper disable AssignNullToNotNullAttribute result.Children.Add(base.GetDesiredTransform(transform)); // ReSharper restore AssignNullToNotNullAttribute result.Children.Add(new TranslateTransform(offsetLeft, offsetTop)); return result; }
//-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors private FixedSOMImage(Rect imageRect, GeneralTransform trans, Uri sourceUri, FixedNode node, DependencyObject o) : base(node, trans) { _boundingRect = trans.TransformBounds(imageRect); _source = sourceUri; _startIndex = 0; _endIndex = 1; _name = AutomationProperties.GetName(o); _helpText = AutomationProperties.GetHelpText(o); }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add(new TranslateTransform(Left, Top)); if (Left > 0) this.Visibility = Visibility.Visible; result.Children.Add(base.GetDesiredTransform(transform)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); var tf = base.GetDesiredTransform(transform); Debug.Assert(tf != null); result.Children.Add(tf); result.Children.Add(new TranslateTransform(_left, _top)); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { return (GeneralTransform) new GeneralTransformGroup() { Children = { transform, (GeneralTransform) new TranslateTransform(30.0, this.position.Y) } }; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); var desired = base.GetDesiredTransform(transform); if (desired != null) { result.Children.Add(desired); } result.Children.Add(new TranslateTransform(_offsetLeft, _offsetTop)); return result; }
public override GeneralTransform GetDesiredTransform( GeneralTransform transform ) { Size gridRenderSize = this.AdornedElement.RenderSize; Size contentDesiredSize = m_content.DesiredSize; GeneralTransformGroup result = new GeneralTransformGroup(); result.Children.Add( base.GetDesiredTransform( transform ) ); result.Children.Add( new TranslateTransform( gridRenderSize.Width - contentDesiredSize.Width - 9, 4 ) ); return result; }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var baseTransform = base.GetDesiredTransform(transform); var translateTransform = new TranslateTransform(MousePosition.X - 4, MousePosition.Y - 4); var result = new GeneralTransformGroup(); if (baseTransform != null) result.Children.Add(baseTransform); result.Children.Add(translateTransform); return result; }
protected FixedSOMElement(FixedNode fixedNode, GeneralTransform transform) { _fixedNode = fixedNode; Transform trans = transform.AffineTransform; if (trans != null) { _mat = trans.Value; } else { _mat = Transform.Identity.Value; } }
public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { var result = new GeneralTransformGroup(); result.Children.Add(base.GetDesiredTransform(transform)); var mousePositionTransform = new TranslateTransform(MousePosition.X, MousePosition.Y); result.Children.Add(mousePositionTransform); var mousePositionOffsetTransform = new TranslateTransform(-4, -4); result.Children.Add(mousePositionOffsetTransform); return result; }
/// <summary> /// Returns a <see cref="T:System.Windows.Media.Transform"/> for the adorner, based on the transform that is currently applied to the adorned element. /// </summary> /// <param name="transform">The transform that is currently applied to the adorned element.</param> /// <returns>A transform to apply to the adorner.</returns> public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { if (PlaceholderReferenceElement == null) { return transform; } var group = new GeneralTransformGroup(); group.Children.Add(transform); var transform2 = TransformToDescendant(PlaceholderReferenceElement); if (transform2 != null) { group.Children.Add(transform2); } return group; }
/// <summary> /// Adorners don't always want to be transformed in the same way as the elements they /// adorn. Adorners which adorn points, such as resize handles, want to be translated /// and rotated but not scaled. Adorners adorning an object, like a marquee, may want /// all transforms. This method is called by AdornerLayer to allow the adorner to /// filter out the transforms it doesn't want and return a new transform with just the /// transforms it wants applied. An adorner can also add an additional translation /// transform at this time, allowing it to be positioned somewhere other than the upper /// left corner of its adorned element. /// </summary> /// <param name="transform">The transform applied to the object the adorner adorns</param> /// <returns>Transform to apply to the adorner</returns> public override GeneralTransform GetDesiredTransform(GeneralTransform transform) { if (ReferenceElement == null) return transform; GeneralTransformGroup group = new GeneralTransformGroup(); group.Children.Add(transform); GeneralTransform t = this.TransformToDescendant(ReferenceElement); if (t != null) { group.Children.Add(t); } return group; }
internal static Matrix CreateMatrix(GeneralTransform transform) { if (transform != null && !IsIdentity(transform)) { Point offset = transform.Transform(new Point(0, 0)); Point i = transform.Transform(new Point(1, 0)).Minus(offset); Point j = transform.Transform(new Point(0, 1)).Minus(offset); Matrix matrix = new Matrix(i.X, i.Y, j.X, j.Y, offset.X, offset.Y); return matrix; } else { return Matrix.Identity; } }
//-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors protected FixedSOMElement(FixedNode fixedNode, int startIndex, int endIndex, GeneralTransform transform) { _fixedNode = fixedNode; _startIndex = startIndex; _endIndex = endIndex; Transform trans = transform.AffineTransform; if (trans != null) { _mat = trans.Value; } else { _mat = Transform.Identity.Value; } }
public static StreamingRectangle FromVisual(Visual target, GeneralTransform transformGlobal) { StreamingRectangle result = new StreamingRectangle(); Rect bounds = TransformHelper.GetVisualBoundingBoxGlobal(target); result.TargetBounds = VisualTreeHelper.GetDescendantBounds(target); result.MatrixTransformGlobal = ((MatrixTransform)transformGlobal).Matrix; if (Settings.SimulatorMode) { bounds.X += (int)Settings.SimulatorOriginOffset.X; bounds.Y += (int)Settings.SimulatorOriginOffset.Y; } result.BoundingBox = new Int32Rect((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height); return result; }
public static System.Drawing.Rectangle GetScreenBoundingRectangle(UIElement target) { PresentationSource source = PresentationSource.FromVisual(target); if (source == null) { throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree."); } Matrix transform; try { System.Windows.Media.GeneralTransform gt = target.TransformToAncestor(source.RootVisual); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t != null) { transform = t.Value; } else { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } } catch (InvalidOperationException) { throw new InvalidOperationException("The specified UiElement is not connected to a rendering Visual Tree."); } Rect targetRect = new Rect(new Point(), target.RenderSize); targetRect.Transform(transform); Point rootOffset = targetRect.TopLeft; System.Windows.Media.CompositionTarget vm = source.CompositionTarget; rootOffset = vm.TransformToDevice.Transform(rootOffset);//vm.DeviceUnitsFromMeasureUnits(rootOffset); System.Drawing.Point topLeft = new System.Drawing.Point((int)rootOffset.X, (int)rootOffset.Y); User32.ClientToScreen(((System.Windows.Interop.HwndSource)source).Handle, ref topLeft); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(topLeft, new System.Drawing.Size(Convert.ToInt32(Monitor.ConvertLogicalToScreen(Dimension.Width, target.RenderSize.Width)), Convert.ToInt32(Monitor.ConvertLogicalToScreen(Dimension.Height, target.RenderSize.Height)))); return(rect); }
/// <summary> /// This returns the position of the element. /// </summary> /// <param element="element"> element as a UIElement </param> /// <param ancestor="ancestor"> ancestor as a UIElement </param> /// <returns> Point of position X and Y of element </returns> public static System.Windows.Point GetElementPosition(UIElement element, UIElement ancestor) { System.Windows.Point position = new System.Windows.Point(); Matrix pt; System.Windows.Media.GeneralTransform gt = element.TransformToAncestor(ancestor); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { //throw new System.ApplicationException("// GlobalLog.LogEvidence(new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change")); } pt = t.Value; position.X = pt.OffsetX; position.Y = pt.OffsetY; return(position); }
// ------------------------------------------------------------------ // Dump paragraph offset. // ------------------------------------------------------------------ private static Visual DumpParagraphOffset(XmlNode writer, ParagraphResultW paragraph, Visual visualParent) { if (writer == null) { throw new ArgumentNullException("writer"); } if (paragraph == null) { throw new ArgumentNullException("paragraph"); } if (visualParent == null) { throw new ArgumentNullException("visualParent"); } object paraClient = paragraph.GetField("_paraClient"); Type paraClientType = paraClient.GetType(); //PropertyInfoSW prop = TypeSW.Wrap(paraClientType).GetProperty("Visual", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); PropertyInfo prop = paraClientType.GetProperty("Visual", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); Visual visual = (Visual)prop.GetValue(paraClient, null); // Dump transform relative to its parent Matrix m; System.Windows.Media.GeneralTransform gt = visual.TransformToAncestor(visualParent); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { //throw new System.ApplicationException("// GlobalLog.LogEvidence(new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change")); } m = t.Value; Point point = new Point(0.0f, 0.0f) * m; if (point.X != 0 || point.Y != 0) { DumpPoint(writer, "Origin", point); } return(visual); }
internal static Rect GetBoundingRectangle(UIElement element) { // get visual size (to get width and height) PresentationSource s = PresentationSource.FromVisual(element); Point size = s.CompositionTarget.TransformToDevice.Transform(new Point(element.RenderSize.Width, element.RenderSize.Height)); // get absolute position Matrix m; System.Windows.Media.GeneralTransform gt = element.TransformToAncestor(s.RootVisual); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } m = t.Value; Rect clientCoordinates = new Rect( m.OffsetX, m.OffsetY, m.OffsetX + size.X, m.OffsetY + size.Y); // get root hwnd HwndSource rootHwnd = (HwndSource)s; // get screen coordinates POINT topLeft = new POINT((int)m.OffsetX, (int)m.OffsetY); POINT screenTopLeft = new POINT(); ClientToScreen(rootHwnd.Handle, ref screenTopLeft); Rect screenCoordinates = new Rect( m.OffsetX + screenTopLeft.x, m.OffsetY + screenTopLeft.y, size.X, size.Y); return(screenCoordinates); }
private static Rectangle GetTopLevelClientRelativeRect( UIElement element) { // Get top-most visual. Visual parent = element; while (VisualTreeHelper.GetParent(parent) != null) { parent = (Visual)VisualTreeHelper.GetParent(parent); } // Get the points for the rectangle and transform them. double height = element.RenderSize.Height; double width = element.RenderSize.Width; LHPoint[] points = new LHPoint[4]; points[0] = new LHPoint(0, 0); points[1] = new LHPoint(width, 0); points[2] = new LHPoint(0, height); points[3] = new LHPoint(width, height); Matrix m; System.Windows.Media.GeneralTransform gt = element.TransformToAncestor(parent); System.Windows.Media.Transform t = gt as System.Windows.Media.Transform; if (t == null) { throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change"); } m = t.Value; m.Transform(points); LHPoint topLeft, bottomRight; CalculateBoundingPoints(points, out topLeft, out bottomRight); return(new Rectangle( (int)topLeft.X, (int)topLeft.Y, (int)bottomRight.X - (int)topLeft.X, (int)bottomRight.Y - (int)topLeft.Y)); }