//using CloudWaterNetwork.Magnifier;
//using dict_py_Inner;
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 Yw.WinFrmUI.Q3d;
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;
//using System.Windows.Forms.DataVisualization.Charting;
using static Yw.WinFrmUI.Q3d.MapViewEnum;
using Cursor = System.Windows.Forms.Cursor;
namespace Yw.WinFrmUI.Q3d
{
public partial class empty
{
}
public class TContainer
{
public MapDimensions mapOption = new MapDimensions();
public Settings newTemplate = null;
public Settings settings = null;
}
public partial class Drawer
{
#region 核心属性
TContainer TC = new TContainer();
///
/// 地图选项
///
public MapDimensions mapOption
{
get { return TC.mapOption; }
set { TC.mapOption = value; }
}
///
/// 地图选项_起始操作时
///
private MapDimensions mapOption0 = new MapDimensions();
///
/// 临时管网层
///
[Browsable(false)]
private Settings _newTemplate
{
get { return TC.newTemplate; }
set { TC.newTemplate = value; }
}
[Browsable(false)]
private Settings _Template
{
get { return TC.settings; }
set
{
TC.settings = value;
}
}
#endregion
#region 交互属性
///
/// 悬停对象
///
private List hoveredObjs = new List();
///
/// 选中对象
///
public List selectedObjs = new List();
private List selectedNodes => selectedObjs.FindAll(o => o is NodeViewModel).Select(o => (NodeViewModel)o).ToList();
private List selectedLinks => selectedObjs.FindAll(o => o is LinkViewModel).Select(o => (LinkViewModel)o).ToList();
MouseState _mouseState = MouseState.无;
private NodeViewModel _OperaNode = null;
PointF _HookPoint = new PointF(-1, -1);
public PointF mouseXY = new PointF(0, 0);
PointF DragStartPos;
PointF _ClickStartPos;
PointF RotaStartPos;
PointF BackGroudPicLeftPos;
bool _isPanning;
///
/// 拖拽选择
///
bool _isDragging;
bool _isRotating;
bool _isPainting;
PointF mousePosition;
// control+鼠标中间按下缩放
bool _isInsertingObject = false;
bool _isMovingObject = false;
bool _isPastingObject = false;
Cursor _lastCursor;
object _undoOldValue = null;
private List polygonPoints = new List();
private bool _isDrawingPolygon;
#endregion
#region 新增管网(辅助)
NetworkViewModel _NewNet
{
get
{
return null;
//if (_newTemplate==null) _newTemplate = new Settings();
//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 this.mapOption?.isEditMode ?? true; }
set
{
if (this.mapOption != null) this.mapOption.isEditMode = value;
}
}
[Browsable(false)]
private 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)]
private 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("显示阀门")]
private bool IsShowValve
{
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("显示节点")]
private bool IsShowJunction
{
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;
}
}
string _filePath
{
get
{
if (string.IsNullOrEmpty(_Template?.filePath))
return null;
string path = _Template.filePath.TrimStart('\\');
return
Path.Combine(Directory.GetCurrentDirectory(), path);
}
//set
//{
// _Template.路径 = value;
//}
}
private NetworkViewModel _network;
public NetworkViewModel Network
{
get
{
return _network;
}
}
#endregion
#region 管网属性(辅助)
[Browsable(false)]
public NodeViewModelList _Nodes
{
get { return Network?.Nodes ?? new NodeViewModelList(); }
}
[Browsable(false)]
public LinkViewModelList _Links
{
get { return Network?.Links ?? new LinkViewModelList(); }
}
private List _areas = new List();
[Browsable(false)]
public List _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
{
ZoomChanged?.Invoke(this, zoom.ToString("0.000"));
mapOption.zoom = value;
}
}
[DisplayName("旋转角度")]
private double Rotation
{
get
{
return mapOption.rotation;
}
set
{
//将旋转角度转换为-180~180
value = value % 360;
if (value > 180)
value -= 360;
else if (value < -180)
value += 360;
mapOption.rotation = value;
}
}
private double Rotation0 = 0;
[Browsable(false)]
public PointF3D MapCenter
{
get
{
if (mapOption?.Center == null) return new PointF3D(0, 0, 0);
return mapOption.Center;
}
set
{
//将$"{MapCenter.X.ToString("0.00")},{MapCenter.Y.ToString("0.00")}"通过CenterChanged传出
CenterChanged?.Invoke(this, $"{MapCenter.X.ToString("0.00")},{MapCenter.Y.ToString("0.00")}");
mapOption.Center = value;
}
}
private PointF3D MapCenter0;
private bool is3Dview = false;
double 俯视角度_start = 90;
private bool IsLock2DView
{
get
{
return mapOption.Lock2DView;
}
set
{
mapOption.Lock2DView = value;
}
}
///
/// 俯视线与底面的夹角,投影用sin
///
[DisplayName("俯视角度")]
private double RotationF
{
get
{
return mapOption.rotationF;
}
set
{
mapOption.rotationF = value;
}
}
[Browsable(false)]
private 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 颜色分级(辅助)
public Colour NodeColour
{
set
{
var type = value.Type;
value.isChoosed = true;
_Template?.Colours?.RemoveAll(cl => cl.Type == type);
_Template.Colours.Add(value);
mapOption.ColourNode = type;
}
private get
{
return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourNode);
}
}
public Colour LinkColour
{
set
{
var type = value.Type;
value.isChoosed = true;
_Template?.Colours?.RemoveAll(cl => cl.Type == type);
_Template.Colours.Add(value);
mapOption.ColourLink = type;
}
private get
{
return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourLink);
}
}
//private bool __isOrtho = true;
#endregion
#region 正交模式
private bool _isOrtho
{
get
{
return mapOption.IsOrtho;
}
set
{
mapOption.IsOrtho = value;
}
}
#endregion
#region 事件
//按帧数判断是否重绘,减少计算量(每帧最多重绘一次)
bool _timerDraw = false;
//按帧数判断鼠标悬停对象,减少计算量(每帧最多判断一次)
bool _mouseHoverCheckFlag = false;
#endregion
}
}