lixiaojun
2025-03-21 d03e8c5d165426f820c10e0c876e5c6af14d270b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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;
            }
        }
 
 
    }
}