public static GeometryCombineMode ToGeometryCombineMode(this SelectionCombineMode mode)
        {
            switch (mode)
            {
            case SelectionCombineMode.Union:
                return(GeometryCombineMode.Union);

            case SelectionCombineMode.Exclude:
                return(GeometryCombineMode.Exclude);

            case SelectionCombineMode.Intersect:
                return(GeometryCombineMode.Intersect);

            case SelectionCombineMode.Xor:
                return(GeometryCombineMode.Xor);
            }
            throw ExceptionUtil.InvalidEnumArgumentException <SelectionCombineMode>(mode, "mode");
        }
Ejemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgsF e)
        {
            base.OnMouseDown(e);
            base.Cursor = this.GetCursor();
            PointDouble point = e.Point;
            PointDouble item  = this.RoundMouseCanvasPoint(point);

            if (this.tracking)
            {
                this.moveOriginMode = true;
                this.lastXY         = item;
                this.OnMouseMove(e);
            }
            else if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right))
            {
                this.tracking    = true;
                this.hasMoved    = false;
                this.startTime   = DateTime.Now;
                this.tracePoints = new SegmentedList <PointDouble>();
                this.tracePoints.Add(item);
                this.undoAction  = new SelectionHistoryMemento("sentinel", base.Image, base.DocumentWorkspace);
                this.wasNotEmpty = !base.Selection.IsEmpty;
                if (((base.ModifierKeys & Keys.Control) != Keys.None) && (e.Button == MouseButtons.Left))
                {
                    this.combineMode = SelectionCombineMode.Union;
                }
                else if (((base.ModifierKeys & Keys.Alt) != Keys.None) && (e.Button == MouseButtons.Left))
                {
                    this.combineMode = SelectionCombineMode.Exclude;
                }
                else if (((base.ModifierKeys & Keys.Control) != Keys.None) && (e.Button == MouseButtons.Right))
                {
                    this.combineMode = SelectionCombineMode.Xor;
                }
                else if (((base.ModifierKeys & Keys.Alt) != Keys.None) && (e.Button == MouseButtons.Right))
                {
                    this.combineMode = SelectionCombineMode.Intersect;
                }
                else
                {
                    this.combineMode = base.ToolSettings.Selection.CombineMode.Value;
                }
                base.DocumentWorkspace.EnableSelectionOutline = false;
                Result <GeometryList> oldSelectionGeometryLazy0 = base.Selection.GetCachedLazyGeometryList();
                this.oldSelectionGeometryLazy = oldSelectionGeometryLazy0;
                Work.QueueWorkItem(delegate {
                    Result <GeometryList> oldSelectionGeometryLazy = this.oldSelectionGeometryLazy;
                    if (oldSelectionGeometryLazy0 == oldSelectionGeometryLazy)
                    {
                        oldSelectionGeometryLazy.EnsureEvaluated();
                    }
                });
                this.newSelection.Restore(base.Selection.Save());
                switch (this.combineMode)
                {
                case SelectionCombineMode.Replace:
                    this.append = false;
                    base.Selection.Reset();
                    break;

                case SelectionCombineMode.Union:
                case SelectionCombineMode.Exclude:
                case SelectionCombineMode.Intersect:
                case SelectionCombineMode.Xor:
                    this.append = true;
                    base.Selection.ResetContinuation();
                    break;

                default:
                    throw ExceptionUtil.InvalidEnumArgumentException <SelectionCombineMode>(this.combineMode, "this.combineMode");
                }
                this.newSelectionRenderer.IsVisible = true;
                if (this.tracePoints.Count >= this.MinPointsForRender)
                {
                    this.Render();
                }
            }
        }