本文整理汇总了C#中IVisual类的典型用法代码示例。如果您正苦于以下问题:C# IVisual类的具体用法?C# IVisual怎么用?C# IVisual使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVisual类属于命名空间,在下文中一共展示了IVisual类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
}
开发者ID:rdterner,项目名称:Perspex,代码行数:36,代码来源:RendererBase.cs
示例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);
}
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:15,代码来源:VisualExtensions.cs
示例3: GetAdornerLayer
public static AdornerLayer GetAdornerLayer(IVisual visual)
{
return visual.GetVisualAncestors()
.OfType<AdornerDecorator>()
.FirstOrDefault()
?.AdornerLayer;
}
开发者ID:Scellow,项目名称:Perspex,代码行数:7,代码来源:AdornerLayer.cs
示例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);
}
开发者ID:DaOnlyOwner,项目名称:PrototypeSuccessor,代码行数:7,代码来源:Spray.cs
示例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);
}
}
开发者ID:healtech,项目名称:Perspex,代码行数:15,代码来源:RendererBase.cs
示例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;
}
}
开发者ID:healtech,项目名称:Perspex,代码行数:12,代码来源:RenderManager.cs
示例7: IsHitTestVisible
private static bool IsHitTestVisible(IVisual visual)
{
var element = visual as IInputElement;
return element != null &&
element.IsVisible &&
element.IsHitTestVisible &&
element.IsEnabledCore;
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:8,代码来源:InputExtensions.cs
示例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;
}
开发者ID:Scellow,项目名称:Perspex,代码行数:14,代码来源:RendererBase.cs
示例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;
}
开发者ID:Robertofon,项目名称:Perspex,代码行数:12,代码来源:PageSlide.cs
示例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;
}
开发者ID:rdterner,项目名称:Perspex,代码行数:13,代码来源:MouseDevice.cs
示例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);
}
开发者ID:marcinp7,项目名称:ChrumGraph,代码行数:19,代码来源:Core.cs
示例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;
}
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:59,代码来源:CrossFade.cs
示例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);
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:23,代码来源:VisualExtensions.cs
示例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);
}
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:45,代码来源:Debug.cs
示例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;
}
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:19,代码来源:VisualTreeNode.cs
示例16: 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>
/// <param name="forward">
/// If true, the new page is slid in from the right, or if false from the left.
/// </param>
/// <returns>
/// A <see cref="Task"/> that tracks the progress of the animation.
/// </returns>
public async Task Start(IVisual from, IVisual to, bool forward)
{
var tasks = new List<Task>();
var parent = GetVisualParent(from, to);
var distance = parent.Bounds.Width;
if (from != null)
{
var transform = new TranslateTransform();
from.RenderTransform = transform;
tasks.Add(Animate.Property(
transform,
TranslateTransform.XProperty,
0.0,
forward ? -distance : distance,
LinearEasing.For<double>(),
Duration).ToTask());
}
if (to != null)
{
var transform = new TranslateTransform();
to.RenderTransform = transform;
to.IsVisible = true;
tasks.Add(Animate.Property(
transform,
TranslateTransform.XProperty,
forward ? distance : -distance,
0.0,
LinearEasing.For<double>(),
Duration).ToTask());
}
await Task.WhenAll(tasks.ToArray());
if (from != null)
{
from.IsVisible = false;
}
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:55,代码来源:PageSlide.cs
示例17: ValidateVisualChild
/// <summary>
/// Ensures a visual child is not null and not already parented.
/// </summary>
/// <param name="c">The visual child.</param>
private static void ValidateVisualChild(IVisual c)
{
if (c == null)
{
throw new ArgumentNullException("Cannot add null to VisualChildren.");
}
if (c.VisualParent != null)
{
throw new InvalidOperationException("The control already has a visual parent.");
}
}
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:16,代码来源:Visual.cs
示例18: GetSource
private IInteractive GetSource(IVisual hit)
{
return Captured ??
(hit as IInteractive) ??
hit.GetSelfAndVisualAncestors().OfType<IInteractive>().FirstOrDefault();
}
开发者ID:rdterner,项目名称:Perspex,代码行数:6,代码来源:MouseDevice.cs
示例19: ValidateLogicalChild
/// <summary>
/// Ensures a visual child is not null.
/// </summary>
/// <param name="c">The visual child.</param>
private static void ValidateLogicalChild(IVisual c)
{
if (c == null)
{
throw new ArgumentNullException("Cannot add null to VisualChildren.");
}
}
开发者ID:KvanTTT,项目名称:Perspex,代码行数:11,代码来源:Visual.cs
示例20: GetOffsetFrom
/// <summary>
/// Gets the visual offset from the specified ancestor.
/// </summary>
/// <param name="ancestor">The ancestor visual.</param>
/// <param name="visual">The visual.</param>
/// <returns>The visual offset.</returns>
private static Vector GetOffsetFrom(IVisual ancestor, IVisual visual)
{
var result = new Vector();
while (visual != ancestor)
{
result = new Vector(result.X + visual.Bounds.X, result.Y + visual.Bounds.Y);
visual = visual.VisualParent;
if (visual == null)
{
throw new ArgumentException("'visual' is not a descendent of 'ancestor'.");
}
}
return result;
}
开发者ID:KvanTTT,项目名称:Perspex,代码行数:23,代码来源:Visual.cs
注:本文中的IVisual类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论