// -----------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex
{
using System;
using System.Collections.Generic;
using System.Linq;
using Perspex.Controls;
using Perspex.Media;
public abstract class Visual : PerspexObject, IVisual, ILogical
{
public static readonly ReadOnlyPerspexProperty ParentProperty =
new ReadOnlyPerspexProperty(ParentPropertyRW);
internal static readonly PerspexProperty ParentPropertyRW =
PerspexProperty.Register("Parent");
private ILogical logicalParent;
private IVisual visualParent;
public Rect Bounds
{
get;
protected set;
}
public Control Parent
{
get { return this.GetValue(ParentPropertyRW); }
protected set { this.SetValue(ParentPropertyRW, value); }
}
ILogical ILogical.LogicalParent
{
get
{
return this.logicalParent;
}
set
{
this.logicalParent = value;
this.Parent = value as Control;
}
}
IEnumerable ILogical.LogicalChildren
{
get { return new ILogical[0]; }
}
IEnumerable IVisual.VisualChildren
{
get { return Enumerable.Empty(); }
}
IVisual IVisual.VisualParent
{
get
{
return this.visualParent;
}
set
{
if (this.visualParent != value)
{
this.visualParent = value;
this.InheritanceParent = (PerspexObject)value;
}
}
}
public virtual void Render(IDrawingContext context)
{
Contract.Requires(context != null);
}
}
}