本文整理汇总了C#中IVisual类的典型用法代码示例。如果您正苦于以下问题:C# IVisual类的具体用法?C# IVisual怎么用?C# IVisual使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVisual类属于命名空间,在下文中一共展示了IVisual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the specified visual.
/// </summary>
/// <param name="visual">The visual to render.</param>
///
/// <param name="context">The drawing context.</param>
public static void Render(this DrawingContext context, IVisual visual)
{
var opacity = visual.Opacity;
if (visual.IsVisible && opacity > 0)
{
var m = Matrix.CreateTranslation(visual.Bounds.Position);
var renderTransform = Matrix.Identity;
if (visual.RenderTransform != null)
{
var origin = visual.TransformOrigin.ToPixels(new Size(visual.Bounds.Width, visual.Bounds.Height));
var offset = Matrix.CreateTranslation(origin);
renderTransform = (-offset)*visual.RenderTransform.Value*(offset);
}
m = renderTransform*m;
using (context.PushPostTransform(m))
using (context.PushOpacity(opacity))
using (visual.ClipToBounds ? context.PushClip(new Rect(visual.Bounds.Size)) : default(DrawingContext.PushedState))
using (context.PushTransformContainer())
{
visual.Render(context);
foreach (var child in visual.VisualChildren.OrderBy(x => x.ZIndex))
{
context.Render(child);
}
}
}
}
示例2: TranslatePoint
/// <summary>
/// Translates a point relative to this visual to coordinates that are relative to the specified visual.
/// The visual and relativeTo should be descendants of the same root window
/// </summary>
/// <param name="visual">The visual.</param>
/// <param name="point">The point value, as relative to this visual.</param>
/// <param name="relativeTo">The visual to translate the given point into.</param>
/// <returns>A point value, now relative to the target visual rather than this source element.</returns>
public static Point TranslatePoint(this IVisual visual, Point point, IVisual relativeTo)
{
var pos = GetRootAndPosition(visual);
var relToPos = GetRootAndPosition(relativeTo);
return point - (relToPos.Item2 - pos.Item2);
}
示例3: GetAdornerLayer
public static AdornerLayer GetAdornerLayer(IVisual visual)
{
return visual.GetVisualAncestors()
.OfType<AdornerDecorator>()
.FirstOrDefault()
?.AdornerLayer;
}
示例4: StartVisuals
public void StartVisuals()
{
ParticleSystem ps = Instantiate(VFXPool.Instance.Sprays[SpellInformation.Elements[0].ToString()], StaffTransform.position, StaffTransform.rotation) as ParticleSystem;
ps.transform.SetParent(StaffTransform);
particleSystemAnchor = ps.GetComponent<IVisual>();
particleSystemAnchor.AuthorizeCollisionDetection(ref SpellInformation);
}
示例5: Render
/// <summary>
/// Renders the specified visual with the specified transform and clip.
/// </summary>
/// <param name="visual">The visual to render.</param>
/// <param name="handle">An optional platform-specific handle.</param>
/// <param name="transform">The transform.</param>
/// <param name="clip">An optional clip rectangle.</param>
public virtual void Render(IVisual visual, IPlatformHandle handle, Matrix transform, Rect? clip = null)
{
using (var context = CreateDrawingContext(handle))
using (clip.HasValue ? context.PushClip(clip.Value) : null)
{
Render(visual, context, Matrix.Identity, transform);
}
}
示例6: InvalidateRender
/// <summary>
/// Invalidates the render for the specified visual and raises <see cref="RenderNeeded"/>.
/// </summary>
/// <param name="visual">The visual.</param>
public void InvalidateRender(IVisual visual)
{
if (!_renderQueued)
{
_renderNeeded.OnNext(Unit.Default);
_renderQueued = true;
}
}
示例7: IsHitTestVisible
private static bool IsHitTestVisible(IVisual visual)
{
var element = visual as IInputElement;
return element != null &&
element.IsVisible &&
element.IsHitTestVisible &&
element.IsEnabledCore;
}
示例8: Render
/// <summary>
/// Renders the specified visual.
/// </summary>
/// <param name="visual">The visual to render.</param>
/// <param name="handle">An optional platform-specific handle.</param>
public virtual void Render(IVisual visual, IPlatformHandle handle)
{
using (var context = this.CreateDrawingContext(handle))
{
this.Render(visual, context, Matrix.Identity, Matrix.Identity);
}
++this.RenderCount;
}
示例9: GetVisualParent
private static IVisual GetVisualParent(IVisual from, IVisual to)
{
var p1 = (from ?? to).VisualParent;
var p2 = (to ?? from).VisualParent;
if (p1 != null && p2 != null && p1 != p2)
{
throw new ArgumentException("Controls for PageSlide must have same parent.");
}
return p1;
}
示例10: GetPosition
public Point GetPosition(IVisual relativeTo)
{
Point p = Position;
IVisual v = relativeTo;
while (v != null)
{
p -= v.Bounds.Position;
v = v.VisualParent;
}
return p;
}
示例11: Core
/// <summary>
/// Initializes a new instance of the Core class.
/// </summary>
public Core(IVisual visual)
{
this.visual = visual;
physics = new Physics(this);
FPS = defaultFPS;
refreshTimer.Tick += (sender, e) =>
{
if (visual.Visible)
{
lock (this) { visual.Refresh(); }
}
};
refreshTimer.Start();
physics.StartSimulation(FPS);
}
示例12: Start
/// <summary>
/// Starts the animation.
/// </summary>
/// <param name="from">
/// The control that is being transitioned away from. May be null.
/// </param>
/// <param name="to">
/// The control that is being transitioned to. May be null.
/// </param>
/// <returns>
/// A <see cref="Task"/> that tracks the progress of the animation.
/// </returns>
public async Task Start(IVisual from, IVisual to)
{
var tasks = new List<Task>();
if (to != null)
{
to.Opacity = 0;
}
if (from != null)
{
tasks.Add(Animate.Property(
(IAvaloniaObject)from,
Visual.OpacityProperty,
from.Opacity,
0,
LinearEasing.For<double>(),
Duration).ToTask());
}
if (to != null)
{
to.Opacity = 0;
to.IsVisible = true;
tasks.Add(Animate.Property(
(IAvaloniaObject)to,
Visual.OpacityProperty,
0,
1,
LinearEasing.For<double>(),
Duration).ToTask());
}
await Task.WhenAll(tasks.ToArray());
if (from != null)
{
from.IsVisible = false;
from.Opacity = 1;
}
if (to != null)
{
to.Opacity = 1;
}
}
示例13: GetRootAndPosition
/// <summary>
/// Gets the root of the control's visual tree and the position of the control
/// in the root's coordinate space.
/// </summary>
/// <param name="v">The visual.</param>
/// <returns>A tuple containing the root and the position of the control.</returns>
private static Tuple<IRenderRoot, Vector> GetRootAndPosition(IVisual v)
{
var result = new Vector();
while (!(v is IRenderRoot))
{
result = new Vector(result.X + v.Bounds.X, result.Y + v.Bounds.Y);
v = v.VisualParent;
if (v == null)
{
throw new InvalidOperationException("Control is not attached to visual tree.");
}
}
return Tuple.Create((IRenderRoot)v, result);
}
示例14: PrintVisualTree
private static void PrintVisualTree(IVisual visual, StringBuilder builder, int indent)
{
Control control = visual as Control;
builder.Append(Indent(indent - 1));
if (indent > 0)
{
builder.Append(" +- ");
}
builder.Append(visual.GetType().Name);
if (control != null)
{
builder.Append(" ");
builder.AppendLine(control.Classes.ToString());
foreach (var property in AvaloniaPropertyRegistry.Instance.GetRegistered(control))
{
var value = control.GetDiagnostic(property);
if (value.Priority != BindingPriority.Unset)
{
builder.Append(Indent(indent));
builder.Append(" | ");
builder.Append(value.Property.Name);
builder.Append(" = ");
builder.Append(value.Value ?? "(null)");
builder.Append(" [");
builder.Append(value.Priority);
builder.AppendLine("]");
}
}
}
else
{
builder.AppendLine();
}
foreach (var child in visual.VisualChildren)
{
PrintVisualTree(child, builder, indent + 1);
}
}
示例15: VisualTreeNode
public VisualTreeNode(IVisual visual)
: base((Control)visual)
{
var host = visual as IVisualTreeHost;
if (host?.Root == null)
{
Children = visual.VisualChildren.CreateDerivedCollection(x => new VisualTreeNode(x));
}
else
{
Children = new ReactiveList<VisualTreeNode>(new[] { new VisualTreeNode(host.Root) });
}
if (Control != null)
{
IsInTemplate = Control.TemplatedParent != null;
}
}