19,468
社区成员
发帖
与我相关
我的任务
分享
public abstract class BaseGraph
{
public Rectange localRect { get; set; } = Vector2.Zero; // 相对父节点的坐标
public Rectangle worldRect // 视图坐标系坐标
{
get{ return LocalRectangleToWorldRectangle( localRect ); }
set { localRect = WorldRectangleToLocalRectangle( value ); }
}
public BaseGrpah Parent {get;set;} = null; // 父节点
public abstract void OnDraw(); // 绘制
public Rectangle LocalRectangleToWorldRectangle( Rectangle rc ); // 本地坐标转换为世界坐标
public Rectangle WorldRectangleToLocalRectangle( Rectangle rc ); // 世界坐标转换为本地坐标
}
public class Line : BaseGraph
{
public overwrite void OnDraw()
{
DrawLine( worldRect.left, worldRect.top, worldRect.right, worldRect.bottom );
}
}
...................其他节点.............
public class CombinNode: BaseGraph
{
List<BaseGraph> childrens ;
public void AddChildren( BaseGraph node )
{
node.parent = this;
childrens.add( node );
}
public overrite void OnDraw()
{
foreach( var node in childrens )
{
node.OnDraw();
}
}
}
// ...........................................