From 4db7d08bb295be33e80f1353f58fcea4a8da6127 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期一, 10 六月 2024 19:11:39 +0800 Subject: [PATCH] 2024年6月10日 --- WinfrmUI/Hydro.WinfrmUI.Browser/Viewer.Model.cs | 254 +++++++++++++++++++++++++++----------------------- 1 files changed, 138 insertions(+), 116 deletions(-) diff --git a/WinfrmUI/Hydro.WinfrmUI.Browser/Viewer.Model.cs b/WinfrmUI/Hydro.WinfrmUI.Browser/Viewer.Model.cs index 2af07f6..9adef11 100644 --- a/WinfrmUI/Hydro.WinfrmUI.Browser/Viewer.Model.cs +++ b/WinfrmUI/Hydro.WinfrmUI.Browser/Viewer.Model.cs @@ -1,6 +1,4 @@ -锘�//using CloudWaterNetwork.Magnifier; -//using dict_py_Inner; -using Hydro.Core.Model; +锘縰sing Hydro.Core.Model; using Hydro.MapView; using Hydro.MapView.Base; using System; @@ -27,40 +25,38 @@ using static System.Windows.Forms.LinkLabel; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; -using Cursor = System.Windows.Forms.Cursor; namespace Hydro.WinfrmUI { - public class TContainer { - public MapDimensions mapOption = new MapDimensions(); - public Template newTemplate = null; + public Template newTemplate = null; public Template template = null; - } + public partial class ViewBrowser { - #region 鏍稿績灞炴�� - TContainer TC = new TContainer(); + private TContainer TC = new TContainer(); /// <summary> /// 鍦板浘閫夐」 /// </summary> - public MapDimensions mapOption + public MapDimensions mapOption { get { return TC.mapOption; } set { TC.mapOption = value; } } + /// <summary> /// 鍦板浘閫夐」_璧峰鎿嶄綔鏃� /// </summary> private MapDimensions mapOption0 = new MapDimensions(); + /// <summary> /// 涓存椂绠$綉灞� /// </summary> @@ -71,81 +67,86 @@ set { TC.newTemplate = value; } } - [Browsable(false)] public Template _Template { - get {return TC.template; } + get { return TC.template; } set { TC.template = value; - - label_file.Text = TC.template?.filePath; } } - #endregion + #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(); - MouseState _mouseState = MouseState.鏃�; + private MouseState _mouseState = MouseState.鏃�; private NodeViewModel _OperaNode = null; public PointF mouseXY = new PointF(0, 0); - PointF DragStartPos; - PointF _ClickStartPos; - PointF RotaStartPos; - PointF BackGroudPicLeftPos; - bool _isPanning; + private PointF DragStartPos; + private PointF _ClickStartPos; + private PointF RotaStartPos; + private PointF BackGroudPicLeftPos; + private bool _isPanning; + /// <summary> /// 鎷栨嫿閫夋嫨 /// </summary> - bool _isDragging; - bool _isRotating; - bool _isPainting; - + private bool _isDragging; - PointF mousePosition; + private bool _isRotating; + private bool _isPainting; + + private PointF mousePosition; + // control+榧犳爣涓棿鎸変笅缂╂斁 - bool _isInsertingObject = false; - bool _isMovingObject = false; - bool _isPastingObject = false; - Cursor _lastCursor; - object _undoOldValue = null; + 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 + #endregion 浜や簰灞炴�� + #region 鏂板绠$綉锛堣緟鍔╋級 - MapViewNetWork _NewNet + private MapViewNetWork _NewNet { get { - if (_newTemplate==null) _newTemplate = new Template(); - if (_newTemplate.network == null) _newTemplate.network = new MapViewNetWork(); + if (_newTemplate == null) _newTemplate = new Template(); + if (_newTemplate.network == null) _newTemplate.network = new MapViewNetWork(); return _newTemplate.network; } } - #endregion - #region 鏄剧ず閫夐」锛堣緟鍔╋級 + #endregion 鏂板绠$綉锛堣緟鍔╋級 + + #region 鏄剧ず閫夐」锛堣緟鍔╋級 private string _StartPoint = null; private string _EndPoint = null; private bool __isEditMode = true; + [Browsable(false)] public bool _IsEditMode { @@ -157,7 +158,6 @@ } } - [Browsable(false)] public float Link_multiply { @@ -168,9 +168,10 @@ } set { - if (_Template == null || _Template.mapOption == null) return;_Template.mapOption.Link_multiply = value; + if (_Template == null || _Template.mapOption == null) return; _Template.mapOption.Link_multiply = value; } } + [Browsable(false)] public float junction_multiply { @@ -181,11 +182,11 @@ } set { - if (_Template == null || _Template.mapOption == null) return;_Template.mapOption.junction_multiply = value; + if (_Template == null || _Template.mapOption == null) return; _Template.mapOption.junction_multiply = value; } } + [DisplayName("鏄剧ず闃�闂�")] - public bool _ShowValve { get @@ -195,9 +196,10 @@ } set { - if (_Template == null || _Template.mapOption == null) return;_Template.mapOption._ShowValve = value; + if (_Template == null || _Template.mapOption == null) return; _Template.mapOption._ShowValve = value; } } + [DisplayName("鏄剧ず鑺傜偣")] public bool _ShowJunction { @@ -208,109 +210,121 @@ } set { - - if (_Template == null || _Template.mapOption == null) return;_Template.mapOption._ShowJunction = value; + if (_Template == null || _Template.mapOption == null) return; _Template.mapOption._ShowJunction = value; } } - string _filePath + + private string _filePath { get { if (string.IsNullOrEmpty(_Template?.filePath)) return null; - string path=_Template.filePath.TrimStart('\\'); + string path = _Template.filePath.TrimStart('\\'); return Path.Combine(Directory.GetCurrentDirectory(), path); } - //set + //set //{ - - // _Template.璺緞 = value; - //} + // _Template.璺緞 = value; + //} } - private MapViewNetWork _Network + + public MapViewNetWork _Network { get { return _Template?.network; } } - #endregion + + #endregion 鏄剧ず閫夐」锛堣緟鍔╋級 + #region 绠$綉灞炴�э紙杈呭姪锛� + [Browsable(false)] public List<NodeCalcModel> _Nodes { - get { return _Network?.Nodes??new List<NodeCalcModel>(); } - + get { return _Network?.Nodes ?? new List<NodeCalcModel>(); } } + [Browsable(false)] public List<LinkCalcModel> _Links { - get { return _Network?.Links??new List<LinkCalcModel>(); } - + 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 瑙嗚璁剧疆锛堣緟鍔╋級 - + #endregion 绠$綉灞炴�э紙杈呭姪锛� + + #region 瑙嗚璁剧疆锛堣緟鍔╋級 private const float MinZoom = 0.1f; private const float MaxZoom = 1000.0f; [DisplayName("缂╂斁绯绘暟")] - public float zoom - { + public float zoom + { get - { + { return mapOption.zoom; } set { - label_zoom.Text = $"Zoom锛歿zoom.ToString("0.000")}"; - mapOption.zoom = value; - } + if (OnChangeViewZoom != null) + { + OnChangeViewZoom.Invoke(zoom); + } + mapOption.zoom = value; + } } + [DisplayName("鏃嬭浆瑙掑害")] - public double Rotation + public double Rotation { get { - return mapOption.rotation; - } - set + return mapOption.rotation; + } + set { - toolStripStatusLabel_rotation.Text = $"Rotation锛�({Rotation.ToString("0")}锛寋RotationF.ToString("0")})"; - mapOption.rotation = value; - } + if (OnChangeViewRotation != null) + { + OnChangeViewRotation.Invoke(Rotation, RotationF); + } + mapOption.rotation = value; + } } - + private double Rotation0 = 0; + [Browsable(false)] - public PointF MapCenter - { - get - { - return mapOption.Center; - } - set + public PointF MapCenter + { + get { - label_center.Text = $"center锛�({MapCenter.X.ToString("0.00")} 锛寋MapCenter.Y.ToString("0.00")}锛�"; - mapOption.Center = value; - } + return mapOption.Center; + } + set + { + if (OnChangeViewCenter != null) + { + OnChangeViewCenter.Invoke(MapCenter); + } + mapOption.Center = value; + } } + private PointF MapCenter0; private bool is3Dview = false; - double 淇瑙掑害_start = 90; - - + private double 淇瑙掑害_start = 90; public bool Lock2DView { @@ -324,22 +338,22 @@ } } - /// <summary> /// 淇绾夸笌搴曢潰鐨勫す瑙掞紝鎶曞奖鐢╯in /// </summary> [DisplayName("淇瑙掑害")] - public double RotationF - { - get + public double RotationF + { + get { - return mapOption.rotationF; - } - set - { + return mapOption.rotationF; + } + set + { mapOption.rotationF = value; - } + } } + [Browsable(false)] public double 淇寮у害 { @@ -358,33 +372,40 @@ } } - private PointF Z(float z) { return new PointF(0, 0); } - #endregion + + #endregion 瑙嗚璁剧疆锛堣緟鍔╋級 + #region 棰滆壊鍒嗙骇锛堣緟鍔╋級 - Colour _NodeColour + + private Colour _NodeColour { get { return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourNode); } } - Colour _LinkColour + + private Colour _LinkColour { get { return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourLink); } } - + //private bool __isOrtho = true; - #endregion + #endregion 棰滆壊鍒嗙骇锛堣緟鍔╋級 + #region 姝d氦妯″紡 - private bool _isOrtho + + public Action<bool> OnChangeViewOrtho = null; + + public bool IsOrtho { get { @@ -393,22 +414,23 @@ set { mapOption.IsOrtho = value; - if (mapOption.IsOrtho) + if (OnChangeViewOrtho != null) { - label_ZZ.Text = "姝d氦妯″紡:寮�"; - } - else - { - label_ZZ.Text = "姝d氦妯″紡:鍏�"; + OnChangeViewOrtho.Invoke(mapOption.IsOrtho); } } } - #endregion + + #endregion 姝d氦妯″紡 + #region 浜嬩欢 + //鎸夊抚鏁板垽鏂槸鍚﹂噸缁橈紝鍑忓皯璁$畻閲忥紙姣忓抚鏈�澶氶噸缁樹竴娆★級 - bool _timerDraw = false; + private bool _timerDraw = false; + //鎸夊抚鏁板垽鏂紶鏍囨偓鍋滃璞★紝鍑忓皯璁$畻閲忥紙姣忓抚鏈�澶氬垽鏂竴娆★級 - bool _mouseHoverCheckFlag = false; - #endregion + private bool _mouseHoverCheckFlag = false; + + #endregion 浜嬩欢 } -} +} \ No newline at end of file -- Gitblit v1.9.3