using OpenTK.Mathematics;
|
using System.Windows.Forms;
|
|
namespace Yw.WinFrmUI.Hydro
|
{
|
/// <summary>
|
///
|
/// </summary>
|
internal static class Network2dExtensions
|
{
|
/// <summary>
|
/// 绘制2d
|
/// </summary>
|
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);
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 悬停2d
|
/// </summary>
|
public static void Hover2d(this NetworkL3d nw, Ray3 ray, float zoom, Vector3CacheHelper vecache)
|
{
|
nw.Visuals.ForEach(x => x.IsHovered = false);
|
var visual = ray.CastingClosest(zoom, nw, vecache);
|
if (visual != null)
|
{
|
visual.IsHovered = true;
|
}
|
}
|
|
/// <summary>
|
/// 选择2d
|
/// </summary>
|
public static void Select2d(this NetworkL3d nw, Ray3 ray, float zoom, Vector3CacheHelper vecache)
|
{
|
nw.Visuals.ForEach(x => x.IsSelected = false);
|
var visual = ray.CastingClosest(zoom, nw, vecache);
|
if (visual != null)
|
{
|
visual.IsSelected = true;
|
return;
|
}
|
}
|
|
|
}
|
}
|