| | |
| | | |
| | | using Newtonsoft.Json; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.IO; |
| | | using System.Numerics; |
| | | using System.Text; |
| | | using static Hydro.MapViewEnum; |
| | |
| | | |
| | | namespace Hydro |
| | | { |
| | | public partial class MapViewer : UserControl |
| | | public partial class MapViewer : XtraUserControl |
| | | { |
| | | |
| | | #region 一、全局 |
| | |
| | | if (this.statusStrip1 != null) this.statusStrip1.Visible = value; |
| | | } |
| | | } |
| | | |
| | | private bool _showPropertyForm = true; |
| | | [DisplayName("显示属性栏")] |
| | | public bool ShowPropertyForm |
| | | { |
| | | get |
| | | { |
| | | return _showPropertyForm;// this.panel1==null?true:Visible; |
| | | } |
| | | set |
| | | { |
| | | _showPropertyForm = value; |
| | | if (this.propertyForm != null) this.propertyForm.Visible = value; |
| | | } |
| | | } |
| | | |
| | | //public MapViewer() |
| | | //{ |
| | | // this.showToolBar = false; |
| | |
| | | } |
| | | |
| | | |
| | | Dictionary<TemplateType, bool> _ViewModel = null; |
| | | Dictionary<PBS.eModelTemplateType, bool> _ViewModel = null; |
| | | public void Clear() |
| | | { |
| | | _Template = null; |
| | |
| | | RotationF = 90; |
| | | SetMapInvalidate(); |
| | | } |
| | | public void SetData(Template template, dict<string, dynamic> param = null, Dictionary<TemplateType, bool> viewMode = null) |
| | | public void SetData(Template template, dict<string, dynamic> param = null, Dictionary<PBS.eModelTemplateType, bool> viewMode = null) |
| | | { |
| | | this.param = param; |
| | | bool reLoad = _Template == template; |
| | |
| | | this._ViewModel = viewMode; |
| | | |
| | | |
| | | //if ( _Template?.Floors!=null) |
| | | //{ |
| | | |
| | | // _Template.Floors.ForEach(f=> |
| | | // { |
| | | // var btn = new ToolStripButton(" "+f.Name+" "); |
| | | // btn.Click += (s, e) => |
| | | // { |
| | | // this.mapOption.ShowFloor = f.FloorIndex; |
| | | // if (f.MapView != null ) |
| | | // { |
| | | // this.mapOption= f.MapView.Copy(); |
| | | // } |
| | | // this.SetInvalidated(); |
| | | // }; |
| | | // ToolStripMenuItem_Floor.DropDownItems.Add(btn); |
| | | |
| | | // }); |
| | | //} |
| | | |
| | | //_Template.network = null; |
| | | |
| | | if (!LoadData()) return; |
| | | //LoadData(); |
| | | // temp.network.LoadRepeaters(); |
| | | |
| | | // map.SetStartEndPoint(temp.Node1, temp.Node2); |
| | | |
| | | if (!reLoad) |
| | | { |
| | | if (_Template.view == null) |
| | | InitCenter(); |
| | | else |
| | | { |
| | | //MapCenter = _Template.view.Center; |
| | | //zoom = _Template.view.zoom; |
| | | //Rotation = _Template.view.rotation; |
| | | //RotationF = _Template.view.rotationF; |
| | | this.mapOption = _Template.view.Copy(); |
| | | SetMapInvalidate(); |
| | | } |
| | |
| | | label_center.Text = $"center:({MapCenter.X.ToString("0.00")} ,{MapCenter.Y.ToString("0.00")})"; |
| | | label_zoom.Text = $"Zoom:{zoom.ToString("0.000")}"; |
| | | toolStripStatusLabel_rotation.Text = $"Rotation:({Rotation.ToString("0")},{RotationF.ToString("0")})"; |
| | | //SetInvalidated(); |
| | | |
| | | } |
| | | |
| | | private void InitCenter() |
| | |
| | | var result = ofd.ShowDialog(); |
| | | if (result == DialogResult.OK) |
| | | { |
| | | _Template = new Template(new Guid().ToString(), "新建", "复制", TemplateType.其他); |
| | | _Template = new Template(new Guid().ToString(), "新建", "复制", PBS.eModelTemplateType.Custom); |
| | | string json = File.ReadAllText(ofd.FileName); |
| | | _Template.network = JsonConvert.DeserializeObject<MapViewNetWork>(json); |
| | | _Template.network.BuildRelation(); |
| | |
| | | |
| | | // 计算点投影到直线上的坐标 |
| | | |
| | | List<PointF3D> projectedPoints = new List<PointF3D>(); |
| | | List<PointF3D> modelTemplateedPoints = new List<PointF3D>(); |
| | | |
| | | foreach (PointF3D point in points) |
| | | { |
| | | double projectedY = slope * point.X + interceptY; |
| | | double projectedZ = slope * point.X + interceptZ; |
| | | double modelTemplateedY = slope * point.X + interceptY; |
| | | double modelTemplateedZ = slope * point.X + interceptZ; |
| | | |
| | | projectedPoints.Add(new PointF3D(point.X, (float)projectedY, (float)projectedZ)); |
| | | modelTemplateedPoints.Add(new PointF3D(point.X, (float)modelTemplateedY, (float)modelTemplateedZ)); |
| | | } |
| | | |
| | | return projectedPoints; |
| | | return modelTemplateedPoints; |
| | | } |
| | | |
| | | public void 添加底图ToolStripMenuItem_Click(object sender, EventArgs e) |