namespace Yw.WinFrmUI.Hydro
{
///
///
///
internal static class Network2dExtensions
{
///
/// 绘制2d
///
public static void Draw2d(this NetworkL3d nw)
{
if (nw == null)
{
return;
}
nw.Links.ForEach(x =>
{
if (!x.IsSelected && !x.IsHovered)
{
Draw2dHelper.DrawLine(x.Style2d.Normal.Width, x.Style2d.Normal.Color, x.StartPosition, x.EndPosition);
}
else
{
if (x.IsHovered)
{
Draw2dHelper.DrawLine(x.Style2d.Hovered.Width, x.Style2d.Hovered.Color, x.StartPosition, x.EndPosition);
}
else
{
Draw2dHelper.DrawLine(x.Style2d.Selected.Width, x.Style2d.Selected.Color, x.StartPosition, x.EndPosition);
}
}
});
nw.Nodes.ForEach(x =>
{
if (!x.IsSelected && !x.IsHovered)
{
Draw2dHelper.DrawPoint(x.Style2d.Normal.Radiu * 2, x.Style2d.Normal.Color, x.Position);
}
else
{
if (x.IsHovered)
{
Draw2dHelper.DrawPoint(x.Style2d.Hovered.Radiu * 2, x.Style2d.Hovered.Color, x.Position);
}
else
{
Draw2dHelper.DrawPoint(x.Style2d.Selected.Radiu * 2, x.Style2d.Selected.Color, x.Position);
}
}
});
}
///
/// 悬停2d
///
public static void Hover2d(this NetworkL3d nw, Ray3 ray, BoundingBox32dCacheHelper bxcache)
{
nw.Visuals.ForEach(x => x.IsHovered = false);
var visual = ray.CastingClosest(nw, bxcache);
if (visual != null)
{
visual.IsHovered = true;
}
}
///
/// 选择2d
///
public static void Select2d(this NetworkL3d nw, Ray3 ray, BoundingBox32dCacheHelper bxcache)
{
nw.Visuals.ForEach(x => x.IsSelected = false);
var visual = ray.CastingClosest(nw, bxcache);
if (visual != null)
{
visual.IsSelected = true;
return;
}
}
}
}