Example #1
0
        void _viewer_MouseDown(object sender, MouseEventArgs e)
        {
            if (command != null && e.Button == MouseButtons.Left)
            {
                if (_viewer.ViewBounds.Contains(LeadPoint.Create(e.X, e.Y)))
                {
                    double xFactor = _viewer.XScaleFactor;
                    double yFactor = _viewer.YScaleFactor;

                    int xOffset = _viewer.ClientRectangle.Left;
                    int yOffset = _viewer.ClientRectangle.Top;

                    LeadPoint pnt = new LeadPoint((int)((e.X - xOffset) * 1.0 / xFactor + 0.5), (int)((e.Y - yOffset) * 1.0 / yFactor + 0.5));

                    _drawing         = true;
                    _mousedown       = true;
                    _center          = pnt;
                    _curntMousePoint = _center;
                    _viewer.Invalidate();

                    if (_viewer.InteractiveModes.FindById(_form.FloaterInteractiveMode.Id).IsEnabled)
                    {
                        _form.DisableInteractiveModes(_viewer);
                        _viewer.InteractiveModes.EnableById(_form.NoneInteractiveMode.Id);
                        try
                        {
                            if (_viewer.Floater != null)
                            {
                                RasterRegionXForm xForm = new RasterRegionXForm();
                                xForm.ViewPerspective              = RasterViewPerspective.TopLeft;
                                xForm.XOffset                      = (int)_viewer.FloaterTransform.OffsetX;
                                xForm.YOffset                      = (int)_viewer.FloaterTransform.OffsetY;
                                xForm.YScalarDenominator           =
                                    xForm.XScalarDenominator       =
                                        xForm.XScalarNumerator     =
                                            xForm.YScalarNumerator = 1;

                                _viewer.Image.SetRegion(xForm, _viewer.Floater.GetRegion(null), RasterRegionCombineMode.Set);

                                _viewer.Floater.Dispose();
                                _viewer.Floater = null;
                            }
                        }
                        catch (Exception ex)
                        {
                            Messager.ShowError(this, ex);
                        }
                    }
                }
            }
        }
Example #2
0
 public PerspectiveDialog(MainForm form, ViewerForm viewer)
 {
     _mainForm = form;
     _form     = viewer;
     _viewer   = viewer.Viewer;
     InitializeComponent();
     _form.DisableInteractiveModes(_form.Viewer);
     _form.Viewer.InteractiveModes.EnableById(_form.NoneInteractiveMode.Id);
 }
Example #3
0
        public GWireDialog(ViewerForm viewer, MainForm mainForm)
        {
            _form              = viewer;
            _viewer            = viewer.Viewer;
            _mainForm          = mainForm;
            _form.FormClosing += new FormClosingEventHandler(_form_FormClosing);
            _form.DisableInteractiveModes(_form.Viewer);
            _form.Viewer.InteractiveModes.EnableById(_form.NoneInteractiveMode.Id);

            InitializeComponent();
        }
Example #4
0
        public ShrinkWrapDialog(MainForm form, ViewerForm viewer)
        {
            InitializeComponent();
            _mainForm                = form;
            _form                    = viewer;
            _viewer                  = viewer.Viewer;
            _cbType.SelectedIndex    = 0;
            _cbCombine.SelectedIndex = 1;
            _form.DisableInteractiveModes(_form.Viewer);
            _form.Viewer.InteractiveModes.EnableById(_form.NoneInteractiveMode.Id);

            _isCircle = true;
        }
Example #5
0
        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);
                _form.DisableInteractiveModes(_viewer);
                _viewer.InteractiveModes.EnableById(_form.FloaterInteractiveMode.Id);
                _viewer.FloaterOpacity = 1;
            }

            _viewer.MouseDown  -= ActiveViewerForm_MouseDown;
            _viewer.MouseMove  -= ActiveViewerForm_MouseMove;
            _viewer.PostRender -= new EventHandler <ImageViewerRenderEventArgs>(_viewer_PostRender);
            _viewer.Cursor      = Cursors.Default;
            _gwireCommand       = null;
            _gwireSeedSelected  = _gwireStarted = _gwireNewSeed = false;
            _gwirePrevPath      = null;
            _gwirePath          = null;

            _viewer.Invalidate();
        }