ningshuxia
2 天以前 71c12ff40d58c3dbdde6867396dd99224e57fc32
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Yw.WinFrmUI.Q3d.MapViewEnum;
 
namespace Yw.WinFrmUI.Q3d
{
 
    public static class Global
    {
 
        //public static TemplateList TemplateList;
 
 
        public static List<MapObjectRecord> mapObjectRecords = new List<MapObjectRecord>();
        public static int RecordIndex = 0;
        public static List<string> curveStrings = new List<string>() { "流量扬程曲线", "流量功率曲线", "流量效率曲线" };
        public static void ClearFileReadOnly(string filePath)
        {
            if (File.Exists(filePath))
            {
                // 获取当前文件属性
                FileAttributes attributes = File.GetAttributes(filePath);
 
                // 如果文件被设置为只读,则移除只读属性
                if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    attributes &= ~FileAttributes.ReadOnly; // 移除只读标志
 
                    // 设置新的文件属性
                    File.SetAttributes(filePath, attributes);
 
 
                }
 
            }
        }
    }
    public static class PointFExtansion
    {
        public static Point ToPoint(this PointF p)
        {
            return new Point((int)p.X, (int)p.Y);
        }
    }
 
 
    public static class GlobalExtension
    {
        public static Type GetObjType(this MapObjectType type)
        {
            switch (type)
            {
                case MapObjectType.全部: return null;
                case MapObjectType.节点: return typeof(JunctionViewModel);
                case MapObjectType.水表: return typeof(MeterViewModel);
                case MapObjectType.水库: return typeof(ReservoirViewModel);
                case MapObjectType.水池: return typeof(TankViewModel);
                case MapObjectType.喷头: return typeof(NozzleViewModel);
                case MapObjectType.管线: return typeof(PipeViewModel);
                case MapObjectType.阀门: return typeof(ValveViewModel);
 
                case MapObjectType.水泵: return typeof(PumpViewModel);
 
                default: return null;
            }
 
        }
        public static bool isNodeType(this MapObjectType type)
        {
            switch (type)
            {
                case MapObjectType.全部: return true;
                case MapObjectType.节点: return true;
                case MapObjectType.水库: return true;
                case MapObjectType.水池: return true;
                case MapObjectType.喷头: return true;
                case MapObjectType.阀门点: return true;
                case MapObjectType.水泵点: return true;
 
 
 
                default: return false;
            }
 
        }
 
    }
 
    public class MapObjectRecord
    {
        public IBaseViewModel mapObject { get; set; }
        public string ValueName { get; set; }
 
        public dynamic Value { get; set; }
 
    }
 
 
}