//右键工具菜单 private void InitRightMousePencilToolMenu() { if (_rightMousePencilToolMenu == null) { _rightMousePencilToolMenu = new List <ToolStripItem>(); } else { _rightMousePencilToolMenu.ForEach((item) => { item.Click -= new EventHandler(canclePencilTool_Click); }); _rightMousePencilToolMenu.Clear(); } if (_canvas.CurrentViewControl is PencilToolLayer) { PencilToolLayer pencilTool = _canvas.CurrentViewControl as PencilToolLayer; string pencilToolAlias = _currentPencilToolText; if (pencilTool.PencilType == enumPencilType.ControlFreeCurve) { pencilToolAlias = string.IsNullOrWhiteSpace(pencilTool.Alias) ? "冰缘线绘制" : pencilTool.Alias; } //停止当前激活的PencilTool ToolStripMenuItem canclePencilTool = new ToolStripMenuItem("停止[" + (string.IsNullOrWhiteSpace(pencilToolAlias) ? "绘制" : pencilToolAlias) + "]工具"); canclePencilTool.Click += new EventHandler(canclePencilTool_Click); _rightMousePencilToolMenu.Add(canclePencilTool); _rightMousePencilToolMenu.Add(new ToolStripSeparator()); } }
private PencilToolLayer CreateToolLayer() { PencilToolLayer toolLayer = new PencilToolLayer(); toolLayer.PencilType = enumPencilType.Rectangle; toolLayer.PencilIsFinished = (geometry) => { CoordEnvelope env = GeometryToCoordEnvelope(geometry); if (env == null) { return; } Dictionary <int, CoordPoint> points = GetSelectedPoints(env); if (_maskIsDelete) { _maskLayer.Add(points); } else { _maskLayer.Remove(points); } _labeledPt = _maskLayer.MaskPoints.Count; canvasHost1.Canvas.Refresh(enumRefreshType.All); UpdateMaskText(); }; return(toolLayer); }
private void button34_Click(object sender, EventArgs e) { IPencilToolLayer lyr = new PencilToolLayer(); lyr.PencilType = enumPencilType.ControlFreeCurve; // _canvas.CurrentViewControl = lyr; _canvas.Refresh(enumRefreshType.All); }
private void TryResetPencilTool() { PencilToolLayer pencilTool = _canvas.CurrentViewControl as PencilToolLayer; if (pencilTool != null) { } _selectedAOILayer.Edit = false; _canvas.CurrentViewControl = new DefaultControlLayer(); _currentPencilToolText = null; }
private void ActiveToolLayer() { if (_toolLayer == null) { _toolLayer = CreateToolLayer(); } if (this.canvasHost1.Canvas.CurrentViewControl != _toolLayer) { this.canvasHost1.Canvas.CurrentViewControl = _toolLayer; } }
internal PencilToolLayer StartAOIDrawing(enumPencilType pencilType) { PencilToolLayer aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = pencilType; aoiLayer.PencilIsFinished = (result) => { _aoiContainer.AddAOI(result); //按住Control键可连续绘制 //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); }; _canvas.CurrentViewControl = aoiLayer; return(aoiLayer); }
private void btnAOI_Click(object sender, EventArgs e) { _aoiContainer.Reset(); PencilToolLayer drawTool = new PencilToolLayer(); drawTool.PencilType = enumPencilType.Rectangle; drawTool.PencilIsFinished = (x) => { _aoiContainer.AddAOI(x); UpdateDrawedAOI(); if (AOIIsChanged != null) { AOIIsChanged(this, null); } canvasHost1.Canvas.CurrentViewControl = _aoiContainer as IControlLayer; }; canvasHost1.Canvas.CurrentViewControl = drawTool; }
public void Free() { if (_maskLayer != null) { _maskLayer.Dispose(); _maskLayer = null; } if (_toolLayer != null) { _toolLayer.Dispose(); _toolLayer = null; } if (_geoGridLayer != null) { _geoGridLayer.Dispose(); _geoGridLayer = null; } }
private void button15_Click(object sender, EventArgs e) { if (_aoiLayer == null) { _aoiLayer = new AOIContainerLayer(); _aoiLayer.Color = Color.Red; _canvas.LayerContainer.Layers.Add(_aoiLayer as GeoDo.RSS.Core.DrawEngine.ILayer); } IPencilToolLayer layer = new PencilToolLayer(); layer.PencilType = enumPencilType.FreeCurve; layer.PencilIsFinished = (result) => { //ptfs = result.GeoPoints; //pts = result.RasterPoints; _result = result; _aoiLayer.AddAOI(_result); }; _canvas.CurrentViewControl = layer; }
private void btnSelect_Click(object sender, EventArgs e) { _aoiContainer.Reset(); PencilToolLayer drawTool = new PencilToolLayer(); drawTool.PencilType = enumPencilType.Rectangle; drawTool.PenColor = Color.Red; drawTool.PencilIsFinished = (result) => { //后的操作 //canvasHost1.Canvas.CurrentViewControl = new DefaultControlLayer(); //UpdateAllowPanMap(); if (MapSelectedIsChanged != null) { CoordEnvelope geoEnv = GetCoordEnvelope(result); MapSelectedIsChanged(this, geoEnv); } canvasHost1.Canvas.Refresh(enumRefreshType.All); }; canvasHost1.Canvas.CurrentViewControl = drawTool; }
internal void FloatToolItemClick(FloatToolItem item) { IPencilToolLayer aoiLayer = null; switch (item.Text) { case "绘制AOI": _toolbarManager.Close(); aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = enumPencilType.FreeCurve; aoiLayer.PencilIsFinished = (result) => { //if (!_ismultiAoi) // ClearAoi(); _aoiContainer.AddAOI(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); }; _canvas.CurrentViewControl = aoiLayer; CloseOtherLayerEdit(); break; case "绘制AOI(矩形)": _toolbarManager.Close(); aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = enumPencilType.Rectangle; aoiLayer.PencilIsFinished = (result) => { //if (!_ismultiAoi) // ClearAoi(); _aoiContainer.AddAOI(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) //_canvas.CurrentViewControl = new DefaultControlLayer(); }; _canvas.CurrentViewControl = aoiLayer; CloseOtherLayerEdit(); break; case "绘制AOI(多边形)": _toolbarManager.Close(); aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = enumPencilType.Polygon; aoiLayer.PencilIsFinished = (result) => { //if (!_ismultiAoi) // ClearAoi(); _aoiContainer.AddAOI(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); }; _canvas.CurrentViewControl = aoiLayer; CloseOtherLayerEdit(); break; case "绘制AOI(圆形)": _toolbarManager.Close(); aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = enumPencilType.Circle; aoiLayer.PencilIsFinished = (result) => { //if (!_ismultiAoi) // ClearAoi(); _aoiContainer.AddAOI(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); }; _canvas.CurrentViewControl = aoiLayer; CloseOtherLayerEdit(); break; case "导入AOI": _toolbarManager.Close(); _canvas.CurrentViewControl = new PencilToolLayer(); if (_contextMenuHandler.HandleImportAOI()) { _canvas.Refresh(enumRefreshType.All); } _canvas.CurrentViewControl = new DefaultControlLayer(); CloseOtherLayerEdit(); break; case "交互选择AOI": _toolbarManager.Close(); aoiLayer = new PencilToolLayer(); aoiLayer.PencilType = enumPencilType.Rectangle; _selectedAOILayer.AOIContaingerLayer = _aoiContainer; _selectedAOILayer.Edit = true; aoiLayer.PencilIsFinished = (result) => { if (_contextMenuHandler.HandleSelectAOIFromFeatures(result)) { _canvas.CurrentViewControl = new DefaultControlLayer(); _canvas.Refresh(enumRefreshType.All); } }; _canvas.CurrentViewControl = aoiLayer; break; case "删除AOI区域": _toolbarManager.Close(); ClearAoiAndResetCurrentViewControl(); break; case "魔术棒": _toolbarManager.Close(); IPencilToolLayer magicLayer = new PencilToolLayer(); _canvas.CurrentViewControl = magicLayer; magicLayer.PencilIsFinished = (result) => { _contextMenuHandler.HandleAdsorb(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); _canvas.Refresh(enumRefreshType.All); }; CloseOtherLayerEdit(); break; case "魔术棒判识": _toolbarManager.Close(); IContextMenuArgProvider argProvider = _toolbarManager.Show(_contextMenuHandler.GetArgProviderUI(enumCanvasViewerMenu.MagicWand)); if (argProvider == null) { return; } IPencilToolLayer magicWandLayer = new PencilToolLayer(); magicWandLayer.PencilType = enumPencilType.Point; _canvas.CurrentViewControl = magicWandLayer; ContextMenuToolbarManager barManager = (_toolbarManager as ContextMenuToolbarManager); if (barManager != null) { barManager.ucDispose = new ContextMenuToolbarManager.UCDisposeDeleg(UCDispose); } magicWandLayer.PencilIsFinished = (result) => { if (IsFitOtherToolItem(item)) { return; } Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("tolerance", argProvider.GetArg("tolerance")); args.Add("iscontinued", argProvider.GetArg("iscontinued")); //获取参数 _contextMenuHandler.HandleMagicWandExtracting(result, args); _currentPencilToolText = item.Text; //_canvas.CurrentViewControl = new DefaultControlLayer(); }; CloseOtherLayerEdit(); break; case "橡皮檫": _toolbarManager.Close(); IPencilToolLayer earseLayer = new PencilToolLayer(); _canvas.CurrentViewControl = earseLayer; earseLayer.PencilIsFinished = (result) => { _contextMenuHandler.HandleErase(result); _currentPencilToolText = item.Text; //if (Control.ModifierKeys != Keys.Control) // _canvas.CurrentViewControl = new DefaultControlLayer(); _canvas.Refresh(enumRefreshType.All); }; CloseOtherLayerEdit(); break; case "闪烁": _contextMenuHandler.HandleFlash(); CloseOtherLayerEdit(); break; case "撤销": _contextMenuHandler.HandleUnDo(); CloseOtherLayerEdit(); break; case "重做": _contextMenuHandler.HandleReDo(); CloseOtherLayerEdit(); break; case "清除判识结果": _contextMenuHandler.HandleRemoveAll(); CloseOtherLayerEdit(); break; case "多感兴趣区域": TryResetPencilTool(); _ismultiAoi = !_ismultiAoi; _aoiContainer.IsOnlyOneAOI = !_ismultiAoi; item.Image = GetMultiAoiImage(); try { _canvas.Refresh(enumRefreshType.All); } catch (Exception ex) { Console.WriteLine(ex.Message); } CloseOtherLayerEdit(); break; } }
public void TryFinishPencilTool() { PencilToolLayer pencilTool = Canvas.CurrentViewControl as PencilToolLayer; Canvas.CurrentViewControl = new DefaultControlLayer(); }
private void InitInfoLayer() { if (_infoLayer == null) { _infoLayer = new IceFreeCurveInfoLayer(); if (!_canvas.LayerContainer.Layers.Contains(_infoLayer)) { _canvas.LayerContainer.Layers.Add(_infoLayer); } } else { _infoLayer.InfoItems.Clear(); if (!_canvas.LayerContainer.Layers.Contains(_infoLayer)) { _canvas.LayerContainer.Layers.Add(_infoLayer); } } _iceFeatures.Clear(); IPencilToolLayer toolLayer = new PencilToolLayer(); toolLayer.PencilType = enumPencilType.ControlFreeCurve; _canvas.CurrentViewControl = toolLayer; toolLayer.PencilIsFinished = new Action <GeometryOfDrawed> ( (geo) => { //增加冰缘线 Feature feature = GetIceLineFeature(ref _iceLineFeatureOid, geo); //增加冰缘线拐点 List <IceFreeCurveInfoLayer.InfoItem> infoList = new List <IceFreeCurveInfoLayer.InfoItem>(); foreach (PointF rasterPoint in geo.ControlRasterPoints) { double geoX, geoY; double temp; _canvas.CoordTransform.Raster2Geo((int)rasterPoint.Y, (int)rasterPoint.X, out geoX, out geoY); temp = GetPixelTemperature(_canvas, rasterPoint.X, rasterPoint.Y); // IceFreeCurveInfoLayer.InfoItem info = new IceFreeCurveInfoLayer.InfoItem(); info.No = ++_iceControlPointNo; info.Longitude = geoX; info.Latitude = geoY; info.Temperature = temp; infoList.Add(info); } //if the last point is same to the one before it ,remove one int count = infoList.Count; if (count >= 2) { IceFreeCurveInfoLayer.InfoItem info = infoList.Last(); int firstNo = infoList[0].No; for (int i = count - 2; i >= 0; i--) { if ((infoList[i].Latitude == info.Latitude) && (infoList[i].Longitude == info.Longitude)) { infoList.RemoveAt(infoList.Count - 2); } else { break; } } for (int i = 0; i < infoList.Count; i++) { infoList[i].No = firstNo + i; } _iceControlPointNo = infoList.Last().No; } IceFreeCurveInfoLayer.InfoItem[] infos = infoList.ToArray(); _infoLayer.InfoItems.AddRange(infos); _iceFeatures.Add(feature, infos); UpdateLayer(feature); } ); }