public void StartGWire(int ExternalEnergy) { if (_gwireCommand != null) { return; } RasterImage image = _viewer.Image; try { if (_viewer.Floater != null) { _viewer.Floater.Dispose(); _viewer.Floater = null; } } catch (Exception ex) { Messager.ShowError(this, ex); } finally { _mainForm.UpdateControls(); } if (image.HasRegion) { image.SetRegion(null, null, RasterRegionCombineMode.Set); } if (image.ViewPerspective != RasterViewPerspective.TopLeft) { image.ChangeViewPerspective(RasterViewPerspective.TopLeft); } _gwireCommand = new GWireCommand(image, ExternalEnergy); _gwirePrevPath = new List <Point>(); _anchorPoints = new List <Point>(); _viewer.MouseDown += new MouseEventHandler(ActiveViewerForm_MouseDown); _viewer.MouseMove += new MouseEventHandler(ActiveViewerForm_MouseMove); _viewer.PostRender += new EventHandler <ImageViewerRenderEventArgs>(ActiveViewerForm_Paint); _gwireStarted = true; _gwireSeedSelected = _gwireNewSeed = false; }
public void FinishGWire() { if (_gwireCommand == null) { return; } if (_gwirePath != null && _gwirePrevPath != null) { int prevPathLength = _gwirePrevPath.Count; int curPathLength = _gwirePath.Length; List <LeadPoint> pts = new List <LeadPoint>(); for (int i = 0; i < prevPathLength; i++) { pts.Add(new LeadPoint(_gwirePrevPath[i].X, _gwirePrevPath[i].Y)); } for (int i = 0; i < curPathLength; i++) { pts.Add(new LeadPoint(_gwirePath[i].X, _gwirePath[i].Y)); } _viewer.Image.AddPolygonToRegion(null, pts.ToArray(), LeadFillMode.Alternate, RasterRegionCombineMode.Set); _viewer.ActiveItem.ImageRegionToFloater(); _viewer.Image.SetRegion(null, null, RasterRegionCombineMode.Set); _mainForm.DisableAllInteractiveModes(_viewer); _viewer.InteractiveModes.BeginUpdate(); _form.FloaterInteractiveMode.IsEnabled = true; _viewer.FloaterOpacity = 1.0; _viewer.InteractiveModes.EndUpdate(); } _viewer.MouseDown -= ActiveViewerForm_MouseDown; _viewer.MouseMove -= ActiveViewerForm_MouseMove; _viewer.PostRender -= ActiveViewerForm_Paint; _viewer.Cursor = Cursors.Default; _gwireCommand.Dispose(); _gwireCommand = null; _gwireSeedSelected = _gwireStarted = _gwireNewSeed = false; _gwirePrevPath = null; _gwirePath = null; _viewer.Invalidate(); }