lixiaojun
6 天以前 fba4613d6b8dcbcaea6c7dc83bda14ed49d2f6de
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
using OpenTK.Graphics.ES20;
 
namespace Yw.WinFrmUI.Hydro
{
    /// <summary>
    /// 
    /// </summary>
    internal static class Network2dExtensions
    {
        /// <summary>
        /// 绘制2d
        /// </summary>
        public static void Draw2d(this NetworkL3d nw, float zoom)
        {
            if (nw == null)
            {
                return;
            }
            nw.Links.ForEach(x =>
            {
                if (x is PumpL3d pump)
                {
                    pump.Draw2d(zoom);
                }
                else
                {
                    x.Draw2d();
                }
 
            });
 
            nw.Nodes.ForEach(x =>
            {
                if (x is SourceL3d source)
                {
                    source.Draw2d(zoom);
                }
                else
                {
                    x.Draw2d();
                }
 
            });
        }
 
        /// <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;
            }
        }
 
 
    }
}