本文整理汇总了C#中System.Windows.UIElement.TransformToVisual方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.TransformToVisual方法的具体用法?C# UIElement.TransformToVisual怎么用?C# UIElement.TransformToVisual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.TransformToVisual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new InfoTextEnterArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.Background;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
var tb = new TextBlock(){Text = text};
tb.FontSize = 10;
tb.ClipToBounds = true;
tb.Width = ((FrameworkElement) activeContainer).ActualWidth;
tb.Height = ((FrameworkElement) activeContainer).ActualHeight;
tb.VerticalAlignment = VerticalAlignment.Top;
tb.HorizontalAlignment = HorizontalAlignment.Left;
tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement);
grayOut.adornerPanel.Children.Add(tb);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}
示例2: Show
public void Show(UIElement relativeTo, double offsetX, double offsetY)
{
#if SILVERLIGHT
if (relativeTo == null) { return; }
try
{
GeneralTransform gt = relativeTo.TransformToVisual((UIElement)this.Parent);
Point offset = gt.Transform(new Point(offsetX, offsetY));
AbilityPopup.VerticalOffset = offset.Y + 18;
AbilityPopup.HorizontalOffset = offset.X;
AbilityPopup.IsOpen = true;
/*AbilityGrid.Measure(Rawr.UI.App.Current.RootVisual.DesiredSize);
GeneralTransform transform = relativeTo.TransformToVisual(App.Current.RootVisual);
double distBetweenBottomOfPopupAndBottomOfWindow =
App.Current.RootVisual.RenderSize.Height - offsetY -
transform.Transform(new Point(0, AbilityGrid.DesiredSize.Height)).Y;
if (distBetweenBottomOfPopupAndBottomOfWindow < 0)
{
AbilityPopup.VerticalOffset += distBetweenBottomOfPopupAndBottomOfWindow;
}*/
}
catch (ArgumentException)
{
// Value does not fall within the expected range
// apparently happens if you call while it's still loading the visual tree or something
}
#else
AbilityPopup.PlacementTarget = relativeTo;
AbilityPopup.PlacementRectangle = new Rect(0, offsetY, offsetX, relativeTo.RenderSize.Height);
AbilityPopup.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
AbilityPopup.IsOpen = true;
#endif
}
示例3: GetOffset
// Gets the offset point relative to the zoom marker (used for the lines)
public static Point GetOffset(UIElement element, UIElement offsetVisual)
{
if (element == null)
return new Point();
GeneralTransform gt = element.TransformToVisual(offsetVisual);
Point offset = gt.Transform(new Point(0, 0));
return offset;
}
示例4: CoordinateTransformer
public CoordinateTransformer(UIElement container, UIElement child)
{
Container = container;
Child = child;
_childToContainerTransform = child.TransformToVisual(container);
_containerToChildTransform = container.TransformToVisual(child);
}
示例5:
public static IEnumerable<UIElement> GetElementsAtHostCoordinates
(Point location, UIElement uiComponent)
{
//The API FindElementsInHostCoordinates in SL work based on global system coordinate
GeneralTransform generalTransform = uiComponent.TransformToVisual(Application.Current.RootVisual);
Point pnts = generalTransform.Transform(location);
IEnumerable<UIElement> elements = VisualTreeHelper.FindElementsInHostCoordinates(pnts, Application.Current.RootVisual);
return elements;
}
示例6: Show
public void Show(UIElement relativeTo, double offsetX, double offsetY)
{
#if SILVERLIGHT
try
{
GeneralTransform gt = relativeTo.TransformToVisual((UIElement)this.Parent);
Point offset = gt.Transform(new Point(offsetX, offsetY));
StatPopup.VerticalOffset = offset.Y;
StatPopup.HorizontalOffset = offset.X;
StatPopup.IsOpen = true && (!String.IsNullOrEmpty(Message) || !String.IsNullOrEmpty(Header));
StatGrid.Measure(App.Current.RootVisual.DesiredSize);
GeneralTransform transform = relativeTo.TransformToVisual(App.Current.RootVisual);
// Lets make sure that we don't clip from the bottom
double distBetweenBottomOfPopupAndBottomOfWindow =
App.Current.RootVisual.RenderSize.Height - offsetY -
transform.Transform(new Point(0, StatGrid.DesiredSize.Height)).Y;
if (distBetweenBottomOfPopupAndBottomOfWindow < 0)
{
StatPopup.VerticalOffset += distBetweenBottomOfPopupAndBottomOfWindow;
}
// Lets make sure that we don't clip from the right side
double distBetweenRightSideOfPopupAndBottomOfWindow =
App.Current.RootVisual.RenderSize.Width - offsetX -
transform.Transform(new Point(StatGrid.DesiredSize.Width, 0)).X;
if (distBetweenRightSideOfPopupAndBottomOfWindow < 0)
{
StatPopup.HorizontalOffset += distBetweenRightSideOfPopupAndBottomOfWindow;
}
}
catch (ArgumentException)
{
// Value does not fall within the expected range
// apparently happens if you call while it's still loading the visual tree or something
}
#else
StatPopup.PlacementTarget = relativeTo;
StatPopup.PlacementRectangle = new Rect(0, offsetY, offsetX, relativeTo.RenderSize.Height);
StatPopup.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
StatPopup.IsOpen = true;
#endif
}
示例7: Show
public void Show(UIElement relativeTo, double offsetX, double offsetY)
{
ContextList.SelectedIndex = -1;
GeneralTransform gt = relativeTo.TransformToVisual((UIElement)this.Parent);
Point offset = gt.Transform(new Point(offsetX, offsetY));
ContextPopup.VerticalOffset = offset.Y;
ContextPopup.HorizontalOffset = offset.X;
ContextPopup.IsOpen = true;
ContextGrid.Measure(App.Current.RootVisual.DesiredSize);
GeneralTransform transform = relativeTo.TransformToVisual(App.Current.RootVisual);
double distBetweenBottomOfPopupAndBottomOfWindow =
App.Current.RootVisual.RenderSize.Height - offsetY -
transform.Transform(new Point(0, ContextGrid.DesiredSize.Height)).Y;
if (distBetweenBottomOfPopupAndBottomOfWindow < 0)
{
ContextPopup.VerticalOffset += distBetweenBottomOfPopupAndBottomOfWindow;
}
ContextList.Focus();
}
示例8: GetPosition
/// <summary>
/// Returns the x- and y-coordinates of the mouse pointer position,
/// optionally evaluated against a coordinate origin of a supplied <see cref="T:System.Windows.UIElement" />.
/// </summary>
/// <returns>
/// A <see cref="T:System.Windows.Point" /> that represents the current x- and
/// y-coordinates of the mouse pointer position. If null was passed as <paramref name="relativeTo" />,
/// this coordinate is for the overall Silverlight plug-in content area.
/// If a non-null <paramref name="relativeTo" /> was passed, this coordinate
/// is relative to the object referenced by <paramref name="relativeTo" />.
/// </returns>
/// <param name="relativeTo">
/// Any <see cref="T:System.Windows.UIElement" />-derived object
/// that is contained by the Silverlight plug-in and connected to the object tree.
/// To specify the object relative to the overall Silverlight coordinate system,
/// set the <paramref name="relativeTo" /> parameter to null.
/// </param>
public Point GetPosition(UIElement relativeTo)
{
if (relativeTo == null)
{
return this.MousePosition;
}
else
{
GeneralTransform gt = relativeTo.TransformToVisual(Application.Current.RootVisual as UIElement);
Point p = gt.Transform(new Point(0, 0));
return new Point(this.MousePosition.X - p.X, this.MousePosition.Y - p.Y);
}
}
示例9: GetPosition
/// <summary>
/// Returns the position of a given point relative to a given UIElement.
/// </summary>
/// <param name="relativeTo">The return value will be relative to this element.</param>
/// <param name="point">The point to translate.</param>
/// <returns>The given point relative to the given UIElement.</returns>
protected static Point GetPosition(UIElement relativeTo, Point point)
{
if (relativeTo == null)
{
// Transform relative to RootVisual
relativeTo = Application.Current.RootVisual;
}
if (relativeTo != null)
{
// Determine position
GeneralTransform transform = relativeTo.TransformToVisual(null).Inverse;
return transform.Transform(point);
}
else
{
// Unable to transform; return point as-is
return point;
}
}
示例10: GetPosition
/// <summary>
/// Gets the mouse position.
/// </summary>
/// <param name="element">The element to get the position on.</param>
/// <returns>The mouse position.</returns>
public Point GetPosition(UIElement element)
{
GeneralTransform transform = element.TransformToVisual((UIElement)Application.Current.RootVisual);
return transform.Transform(this.pluginPosition);
}
示例11: GetManipulationPoint
private Point GetManipulationPoint(Point origin, UIElement container)
{
UIElement visual = PageCanvas;
Point point = container == visual ? origin : container.TransformToVisual(visual).Transform(origin);
return new Point(point.X - _offsetX, point.Y - _offsetY);
}
示例12: LetGoPage
public void LetGoPage(UIElement source, Point p)
{
if ((Status == PageStatus.None)
|| (Status == PageStatus.DropAnimation)
|| (Status == PageStatus.TurnAnimation))
return;
Status = PageStatus.None;
Point relPoint = source.TransformToVisual(this).Transform(p);
if (IsOnNextPage(relPoint, this, origin))
{
Status = PageStatus.TurnAnimation;
TurnPage(animationDuration);
}
else
{
Status = PageStatus.DropAnimation;
DropPage(ComputeAnimationDuration(source, p, origin));
}
}
示例13: getPosition
private static Point? getPosition(UIElement element)
{
Point? p = null;
if (Application.Current == null || Application.Current.RootVisual == null)
throw new Exception(Strings.RootVisualError);
GeneralTransform gt = element.TransformToVisual(Application.Current.RootVisual);
if (gt != null)
p = gt.Transform(new Point());
return p;
}
示例14: SafeTransformToVisual
/// <summary>
/// Calls TransformToVisual on the specified element for the specified visual, suppressing the ArgumentException that can occur in some cases.
/// </summary>
/// <param name="element">Element on which to call TransformToVisual.</param>
/// <param name="visual">Visual to pass to the call to TransformToVisual.</param>
/// <returns>Resulting GeneralTransform object.</returns>
private static GeneralTransform SafeTransformToVisual(UIElement element, UIElement visual)
{
GeneralTransform result;
try
{
result = element.TransformToVisual(visual);
}
catch (ArgumentException)
{
// Not perfect, but better than throwing an exception
result = new TranslateTransform();
}
return result;
}
示例15: Start
internal static void Start(ref GrayOutDesignerExceptActiveArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new GrayOutDesignerExceptActiveArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.BehindForeground;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.adornerPanel.Children.Add(grayOut);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
Animate(grayOut.GrayOutBrush, Brush.OpacityProperty, MaxOpacity);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}