| | |
| | | |
| | | using Hydro.Core.Model; |
| | | using Hydro.Core.Model; |
| | | using Hydro.MapView; |
| | | using Hydro.MapView.Base; |
| | | using System; |
| | |
| | | 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 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> |
| | |
| | | set { TC.newTemplate = value; } |
| | | } |
| | | |
| | | |
| | | [Browsable(false)] |
| | | public Template _Template |
| | | { |
| | | get {return TC.template; } |
| | | get { return TC.template; } |
| | | set |
| | | { |
| | | TC.template = value; |
| | | TC.template = value; |
| | | } |
| | | } |
| | | |
| | | #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; |
| | | System.Windows.Forms.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 |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | [Browsable(false)] |
| | | public float Link_multiply |
| | | { |
| | |
| | | } |
| | | 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 |
| | | { |
| | |
| | | } |
| | | 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 |
| | |
| | | } |
| | | 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 |
| | | { |
| | |
| | | } |
| | | 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 |
| | |
| | | { |
| | | OnChangeViewZoom.Invoke(zoom); |
| | | } |
| | | mapOption.zoom = value; |
| | | } |
| | | mapOption.zoom = value; |
| | | } |
| | | } |
| | | |
| | | [DisplayName("旋转角度")] |
| | | public double Rotation |
| | | public double Rotation |
| | | { |
| | | get |
| | | { |
| | | return mapOption.rotation; |
| | | } |
| | | set |
| | | return mapOption.rotation; |
| | | } |
| | | set |
| | | { |
| | | if (OnChangeViewRotation != null) |
| | | { |
| | | OnChangeViewRotation.Invoke(Rotation, RotationF); |
| | | } |
| | | mapOption.rotation = value; |
| | | } |
| | | mapOption.rotation = value; |
| | | } |
| | | } |
| | | |
| | | |
| | | private double Rotation0 = 0; |
| | | |
| | | [Browsable(false)] |
| | | public PointF MapCenter |
| | | { |
| | | get |
| | | { |
| | | return mapOption.Center; |
| | | } |
| | | set |
| | | public PointF MapCenter |
| | | { |
| | | get |
| | | { |
| | | return mapOption.Center; |
| | | } |
| | | set |
| | | { |
| | | if (OnChangeViewCenter != null) |
| | | { |
| | | OnChangeViewCenter.Invoke(MapCenter); |
| | | } |
| | | mapOption.Center = value; |
| | | } |
| | | mapOption.Center = value; |
| | | } |
| | | } |
| | | |
| | | private PointF MapCenter0; |
| | | private bool is3Dview = false; |
| | | double 俯视角度_start = 90; |
| | | |
| | | |
| | | private double 俯视角度_start = 90; |
| | | |
| | | public bool Lock2DView |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 俯视线与底面的夹角,投影用sin |
| | | /// </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 俯视弧度 |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | 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 |
| | | { |
| | |
| | | |
| | | //private bool __isOrtho = true; |
| | | |
| | | #endregion |
| | | #endregion 颜色分级(辅助) |
| | | |
| | | #region 正交模式 |
| | | |
| | | public Action<bool> OnChangeViewOrtho = null; |
| | | |
| | | public bool IsOrtho |
| | | { |
| | | get |
| | |
| | | set |
| | | { |
| | | mapOption.IsOrtho = value; |
| | | if(OnChangeViewOrtho != null) |
| | | if (OnChangeViewOrtho != null) |
| | | { |
| | | OnChangeViewOrtho.Invoke(mapOption.IsOrtho); |
| | | } |
| | | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion 正交模式 |
| | | |
| | | #region 事件 |
| | | |
| | | //按帧数判断是否重绘,减少计算量(每帧最多重绘一次) |
| | | bool _timerDraw = false; |
| | | private bool _timerDraw = false; |
| | | |
| | | //按帧数判断鼠标悬停对象,减少计算量(每帧最多判断一次) |
| | | bool _mouseHoverCheckFlag = false; |
| | | #endregion |
| | | private bool _mouseHoverCheckFlag = false; |
| | | |
| | | #endregion 事件 |
| | | } |
| | | } |
| | | } |