cloudflight
2024-06-10 4db7d08bb295be33e80f1353f58fcea4a8da6127
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
using Hydro.Core.Model;
using Hydro.MapView;
using Hydro.MapView.Base;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using static Hydro.MapView.MapViewEnum;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.AxHost;
using static System.Windows.Forms.LinkLabel;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
 
namespace Hydro.WinfrmUI
{
    public class TContainer
    {
        public MapDimensions mapOption = new MapDimensions();
 
        public Template newTemplate = null;
 
        public Template template = null;
    }
 
    public partial class ViewBrowser
    {
        #region 核心属性
 
        private TContainer TC = new TContainer();
 
        /// <summary>
        /// 地图选项
        /// </summary>
        public MapDimensions mapOption
        {
            get { return TC.mapOption; }
            set { TC.mapOption = value; }
        }
 
        /// <summary>
        /// 地图选项_起始操作时
        /// </summary>
        private MapDimensions mapOption0 = new MapDimensions();
 
        /// <summary>
        /// 临时管网层
        /// </summary>
        [Browsable(false)]
        public Template _newTemplate
        {
            get { return TC.newTemplate; }
            set { TC.newTemplate = value; }
        }
 
        [Browsable(false)]
        public Template _Template
        {
            get { return TC.template; }
            set
            {
                TC.template = value;
            }
        }
 
        #endregion 核心属性
 
        #region 交互属性
 
        /// <summary>
        /// 悬停对象
        /// </summary>
        private List<IBaseViewModel> hoveredObjs = new List<IBaseViewModel>();
 
        /// <summary>
        /// 选中对象
        /// </summary>
        public List<IBaseViewModel> selectedObjs = new List<IBaseViewModel>();
 
        private List<NodeViewModel> selectedNodes => selectedObjs.FindAll(o => o is NodeViewModel).Select(o => (NodeViewModel)o).ToList();
        private List<LinkViewModel> selectedLinks => selectedObjs.FindAll(o => o is LinkViewModel).Select(o => (LinkViewModel)o).ToList();
 
        private MouseState _mouseState = MouseState.无;
        private NodeViewModel _OperaNode = null;
        public PointF mouseXY = new PointF(0, 0);
 
        private PointF DragStartPos;
        private PointF _ClickStartPos;
        private PointF RotaStartPos;
        private PointF BackGroudPicLeftPos;
        private bool _isPanning;
 
        /// <summary>
        /// 拖拽选择
        /// </summary>
        private bool _isDragging;
 
        private bool _isRotating;
        private bool _isPainting;
 
        private PointF mousePosition;
 
        // control+鼠标中间按下缩放
        private bool _isInsertingObject = false;
 
        private bool _isMovingObject = false;
        private bool _isPastingObject = false;
        private System.Windows.Forms.Cursor _lastCursor;
        private object _undoOldValue = null;
        private List<PointF> polygonPoints = new List<PointF>();
 
        private bool _isDrawingPolygon;
 
        #endregion 交互属性
 
        #region 新增管网(辅助)
 
        private MapViewNetWork _NewNet
        {
            get
            {
                if (_newTemplate == null) _newTemplate = new Template();
                if (_newTemplate.network == null) _newTemplate.network = new MapViewNetWork();
                return _newTemplate.network;
            }
        }
 
        #endregion 新增管网(辅助)
 
        #region 显示选项(辅助)
 
        private string _StartPoint = null;
        private string _EndPoint = null;
        private bool __isEditMode = true;
 
        [Browsable(false)]
        public bool _IsEditMode
        {
            get { return __isEditMode; }
            set
            {
                __isEditMode = value;
                toolStripComboBox_浏览模式.Text = __isEditMode ? "编辑模式" : "浏览模式";
            }
        }
 
        [Browsable(false)]
        public float Link_multiply
        {
            get
            {
                if (_Template == null || _Template.mapOption == null) return 1.0f;
                return _Template.mapOption.Link_multiply;
            }
            set
            {
                if (_Template == null || _Template.mapOption == null) return; _Template.mapOption.Link_multiply = value;
            }
        }
 
        [Browsable(false)]
        public float junction_multiply
        {
            get
            {
                if (_Template == null || _Template.mapOption == null) return 1.0f;
                return _Template.mapOption.junction_multiply;
            }
            set
            {
                if (_Template == null || _Template.mapOption == null) return; _Template.mapOption.junction_multiply = value;
            }
        }
 
        [DisplayName("显示阀门")]
        public bool _ShowValve
        {
            get
            {
                if (_Template == null || _Template.mapOption == null) return true;
                return _Template.mapOption._ShowValve;
            }
            set
            {
                if (_Template == null || _Template.mapOption == null) return; _Template.mapOption._ShowValve = value;
            }
        }
 
        [DisplayName("显示节点")]
        public bool _ShowJunction
        {
            get
            {
                if (_Template == null || _Template.mapOption == null) return true;
                return _Template.mapOption._ShowJunction;
            }
            set
            {
                if (_Template == null || _Template.mapOption == null) return; _Template.mapOption._ShowJunction = value;
            }
        }
 
        private string _filePath
        {
            get
            {
                if (string.IsNullOrEmpty(_Template?.filePath))
                    return null;
                string path = _Template.filePath.TrimStart('\\');
                return
                    Path.Combine(Directory.GetCurrentDirectory(), path);
            }
            //set
            //{
            //    _Template.路径 = value;
            //}
        }
 
        public MapViewNetWork _Network
        {
            get
            {
                return _Template?.network;
            }
        }
 
        #endregion 显示选项(辅助)
 
        #region 管网属性(辅助)
 
        [Browsable(false)]
        public List<NodeCalcModel> _Nodes
        {
            get { return _Network?.Nodes ?? new List<NodeCalcModel>(); }
        }
 
        [Browsable(false)]
        public List<LinkCalcModel> _Links
        {
            get { return _Network?.Links ?? new List<LinkCalcModel>(); }
        }
 
        private List<Area> _areas = new List<Area>();
 
        [Browsable(false)]
        public List<Area> _Areas
        {
            get { return _areas; }
        }
 
        #endregion 管网属性(辅助)
 
        #region 视角设置(辅助)
 
        private const float MinZoom = 0.1f;
        private const float MaxZoom = 1000.0f;
 
        [DisplayName("缩放系数")]
        public float zoom
        {
            get
            {
                return mapOption.zoom;
            }
            set
            {
                if (OnChangeViewZoom != null)
                {
                    OnChangeViewZoom.Invoke(zoom);
                }
                mapOption.zoom = value;
            }
        }
 
        [DisplayName("旋转角度")]
        public double Rotation
        {
            get
            {
                return mapOption.rotation;
            }
            set
            {
                if (OnChangeViewRotation != null)
                {
                    OnChangeViewRotation.Invoke(Rotation, RotationF);
                }
                mapOption.rotation = value;
            }
        }
 
        private double Rotation0 = 0;
 
        [Browsable(false)]
        public PointF MapCenter
        {
            get
            {
                return mapOption.Center;
            }
            set
            {
                if (OnChangeViewCenter != null)
                {
                    OnChangeViewCenter.Invoke(MapCenter);
                }
                mapOption.Center = value;
            }
        }
 
        private PointF MapCenter0;
        private bool is3Dview = false;
        private double 俯视角度_start = 90;
 
        public bool Lock2DView
        {
            get
            {
                return mapOption.Lock2DView;
            }
            set
            {
                mapOption.Lock2DView = value;
            }
        }
 
        /// <summary>
        /// 俯视线与底面的夹角,投影用sin
        /// </summary>
        [DisplayName("俯视角度")]
        public double RotationF
        {
            get
            {
                return mapOption.rotationF;
            }
            set
            {
                mapOption.rotationF = value;
            }
        }
 
        [Browsable(false)]
        public double 俯视弧度
        {
            get
            {
                return RotationF / 180 * Math.PI;
            }
        }
 
        [Browsable(false)]
        public PointF Zoom
        {
            get
            {
                return new PointF(zoom, -zoom);
            }
        }
 
        private PointF Z(float z)
        {
            return new PointF(0, 0);
        }
 
        #endregion 视角设置(辅助)
 
        #region 颜色分级(辅助)
 
        private Colour _NodeColour
        {
            get
            {
                return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourNode);
            }
        }
 
        private Colour _LinkColour
        {
            get
            {
                return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourLink);
            }
        }
 
        //private bool __isOrtho = true;
 
        #endregion 颜色分级(辅助)
 
        #region 正交模式
 
        public Action<bool> OnChangeViewOrtho = null;
 
        public bool IsOrtho
        {
            get
            {
                return mapOption.IsOrtho;
            }
            set
            {
                mapOption.IsOrtho = value;
                if (OnChangeViewOrtho != null)
                {
                    OnChangeViewOrtho.Invoke(mapOption.IsOrtho);
                }
            }
        }
 
        #endregion 正交模式
 
        #region 事件
 
        //按帧数判断是否重绘,减少计算量(每帧最多重绘一次)
        private bool _timerDraw = false;
 
        //按帧数判断鼠标悬停对象,减少计算量(每帧最多判断一次)
        private bool _mouseHoverCheckFlag = false;
 
        #endregion 事件
    }
}