Example #1
0
        //------------------------------------------------------------------------------------------------------------------------
        public override Visual DeterminePointedVisual(Point Position)
        {
            PreviousPosition = CurrentPosition;
            CurrentPosition  = Position;

            if (CurrentPosition == PreviousPosition || IsManipulating)
            {
                return(CurrentPointedVisual);
            }

            var NewPointed = GetPointedVisual(Position);

            IsManipulatingHeading = !NewPointed.IsOneOf(FrmPointingDetailsPanel, IndDetailsBottom, IndDetailsBottomLeft, IndDetailsBottomRight, IndDetailsLeft, IndDetailsRight);

            if (NewPointed != CurrentPointedVisual)
            {
                CurrentPointedVisual = NewPointed;

                bool IsPointingToIndicator = true;

                if (NewPointed.IsOneOf(IndHeadingTop, IndHeadingBottom, IndDetailsBottom))
                {
                    ResizingDirection = (NewPointed == IndHeadingTop ? EManipulationDirection.Top : EManipulationDirection.Bottom);
                    TentativeAction   = ESymbolManipulationAction.Resize;
                    Cursor            = Cursors.SizeNS;
                }
                else if (NewPointed.IsOneOf(IndHeadingLeft, IndHeadingRight, IndDetailsLeft, IndDetailsRight))
                {
                    ResizingDirection = (NewPointed.IsOneOf(IndHeadingLeft, IndDetailsLeft) ? EManipulationDirection.Left : EManipulationDirection.Right);
                    TentativeAction   = ESymbolManipulationAction.Resize;
                    Cursor            = Cursors.SizeWE;
                }
                else if (NewPointed.IsOneOf(IndHeadingTopLeft, IndHeadingBottomRight, IndDetailsBottomRight))
                {
                    ResizingDirection = (NewPointed == IndHeadingTopLeft ? EManipulationDirection.TopLeft : EManipulationDirection.BottomRight);
                    TentativeAction   = ESymbolManipulationAction.Resize;
                    Cursor            = Cursors.SizeNWSE;
                }
                else if (NewPointed.IsOneOf(IndHeadingBottomLeft, IndHeadingTopRight, IndDetailsBottomLeft))
                {
                    ResizingDirection = (NewPointed == IndHeadingTopRight ? EManipulationDirection.TopRight : EManipulationDirection.BottomLeft);
                    TentativeAction   = ESymbolManipulationAction.Resize;
                    Cursor            = Cursors.SizeNESW;
                }
                else if (NewPointed.IsOneOf(FrmPointingHeadingPanel, FrmPointingDetailsPanel))
                {
                    TentativeAction = ESymbolManipulationAction.Move;
                    Cursor          = Cursors.ScrollAll;
                }
                else if (NewPointed == FrmEditZone || NewPointed == null)
                {
                    if (ManipulatedSymbol.OwnerRepresentation.IsShortcut)
                    {
                        TentativeAction = ESymbolManipulationAction.GoToShortcutTarget;
                        Cursor          = Cursors.UpArrow;
                    }
                    else
                    {
                        // Do not Edit In-Place if multiselecting...
                        if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl) ||
                            Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                        {
                            TentativeAction = ESymbolManipulationAction.Move;
                            Cursor          = Cursors.ScrollAll;
                        }
                        else
                        {
                            TentativeAction = ESymbolManipulationAction.EditInPlace;
                            Cursor          = Cursors.Pen;
                        }
                    }
                }
                else if (NewPointed.IsIn(FrmMarkingZones.Keys))
                {
                    LastPointedMarkerAssignment = FrmMarkingZones[NewPointed];
                    TentativeAction             = ESymbolManipulationAction.MarkerEdit;
                    Cursor = Cursors.Pen;
                }
                else if (NewPointed.IsIn(FrmDetailContentAssignZones.Keys))
                {
                    LastPointedDetailDesignator = FrmDetailContentAssignZones[NewPointed];
                    TentativeAction             = ESymbolManipulationAction.IndividualDetailChange;
                    Cursor = Cursors.Hand;
                }
                else if (NewPointed.IsIn(FrmDetailContentEditZones.Keys))
                {
                    LastPointedDetailDesignator = FrmDetailContentEditZones[NewPointed];
                    TentativeAction             = ESymbolManipulationAction.IndividualDetailAccess;
                    Cursor = Cursors.Pen;
                }
                else if (NewPointed.IsIn(FrmDetailTitleExpandZones.Keys))
                {
                    LastPointedDetailDesignator = FrmDetailTitleExpandZones[NewPointed];
                    TentativeAction             = ESymbolManipulationAction.SwitchIndividualDetail;
                    Cursor = Cursors.UpArrow;
                }
                else if (NewPointed.IsIn(FrmDetailTitleDesignateZones.Keys))
                {
                    LastPointedDetailDesignator = FrmDetailTitleDesignateZones[NewPointed];
                    TentativeAction             = ESymbolManipulationAction.IndividualDetailDesignation;
                    Cursor = Cursors.Arrow;
                }
                else
                {
                    Cursor = Cursors.Hand;

                    if (NewPointed == ActSwitchDetails)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionSwitchDetails;
                    }
                    else if (NewPointed == ActSwitchRelated)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionSwitchRelated;
                    }
                    else if (NewPointed == ActShowComposite)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionShowCompositeAsView;
                    }
                    else if (NewPointed == DefaultActionIndicator)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionEditProperties;
                    }
                    else if (NewPointed == ActSwitchCompositeView)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionShowCompositeAsDetail;
                    }
                    else if (NewPointed == ActAddDetail)
                    {
                        TentativeAction = ESymbolManipulationAction.ActionAddDetail;
                    }
                    else
                    {
                        IsPointingToIndicator = false;
                    }
                }

                if (IsPointingToIndicator)
                {
                    var IndDescription = TentativeAction.GetDescription();

                    if (TentativeAction == ESymbolManipulationAction.EditInPlace &&
                        ManipulatedSymbol.OwnerRepresentation is RelationshipVisualRepresentation representation)
                    {
                        var RepRel = representation.RepresentedRelationship;

                        if (!RepRel.RelationshipDefinitor.Value.IsSimple || RepRel.Links.Count <= 1)
                        {
                            IndDescription += " Drag to extend the pointed Relationship with a new Link/Connector.";
                        }
                    }

                    ProductDirector.ShowAssistance(IndDescription);

                    /* Problem: This tooltip stops the adorner working
                     * var Tip = this.ToolTip as ToolTip;
                     *
                     * if (Tip == null || (Tip.Content as string).IsAbsent())
                     * {
                     *  Tip = (Tip == null ? new ToolTip() : Tip);
                     *  this.ToolTip = Tip;
                     *
                     *  Tip.Content = IndDescription;
                     *  Tip.IsOpen = true;
                     *  Tip.StaysOpen = false;
                     * } */
                }
                else
                {
                    ProductDirector.ShowAssistance();
                }

                ProductDirector.ShowPointingTo(ManipulatedSymbol);
            }

            return(NewPointed);
        }
        //------------------------------------------------------------------------------------------------------------------------
        public override Visual DeterminePointedVisual(Point Position)
        {
            this.PreviousPosition = this.CurrentPosition;
            this.CurrentPosition  = Position;

            if (this.CurrentPosition == this.PreviousPosition || this.IsManipulating)
            {
                return(this.CurrentPointedVisual);
            }

            var NewPointed = GetPointedVisual(Position);

            if (NewPointed != this.CurrentPointedVisual)
            {
                this.CurrentPointedVisual = NewPointed;

                /* POSTPONED: Displace connecting points
                 * if (NewPointed.IsOneOf(IndOriginPoint, IndTargetPoint))
                 * {
                 *  this.TentativeAction = EConnectorManipulationAction.Displace;
                 *  this.Cursor = Cursors.Cross;
                 * } */

                if (NewPointed != null /* && !NewPointed.IsOneOf(IndOriginPoint, IndTargetPoint)*/)
                {
                    if (NewPointed == this.DefaultActionIndicator || NewPointed.IsIn(AlternateActions))
                    {
                        this.TentativeAction = this.CurrentManipulationAction;
                    }
                    else
                    if (NewPointed == this.RelinkActionTargetIndicator || NewPointed == this.RelinkActionOriginIndicator)
                    {
                        this.TentativeAction = EConnectorManipulationAction.ReLink;
                    }

                    if (this.TentativeAction == EConnectorManipulationAction.Displace)
                    {
                        this.Cursor = Cursors.ScrollAll;
                    }
                    else
                    if (this.TentativeAction == EConnectorManipulationAction.ReLink)
                    {
                        this.Cursor = Cursors.Cross;
                    }
                    else
                    {
                        this.Cursor = Cursors.Hand;
                    }
                }

                var IndDescription = this.TentativeAction.GetDescription();

                if (this.TentativeAction == EConnectorManipulationAction.Displace)
                {
                    IndDescription = IndDescription + " Double-click for Edit. " +
                                     "Action icons: [Ctrl]=Straighten line, [Shift]=Delete connector, [Alt]=Cycle variant plugs.";
                }

                ProductDirector.ShowAssistance(IndDescription);

                /* DANGER: This tooltip stops the adorner working
                 * var Tip = this.ToolTip as ToolTip;
                 *
                 * if (Tip == null || (Tip.Content as string).IsAbsent())
                 * {
                 *  Tip = (Tip == null ? new ToolTip() : Tip);
                 *  Tip.Content = IndDescription;
                 *  Tip.IsOpen = true;
                 *  Tip.StaysOpen = false;
                 *  this.ToolTip = Tip;
                 * } */
                //- }

                ProductDirector.ShowPointingTo(this.ManipulatedConnector);
            }

            return(NewPointed);
        }
Example #3
0
        //------------------------------------------------------------------------------------------------------------------------
        public override Visual DeterminePointedVisual(Point Position)
        {
            this.PreviousPosition = this.CurrentPosition;
            this.CurrentPosition  = Position;

            if (this.CurrentPosition == this.PreviousPosition || this.IsManipulating)
            {
                return(this.CurrentPointedVisual);
            }

            var NewPointed = GetPointedVisual(Position);

            if (NewPointed != this.CurrentPointedVisual)
            {
                this.CurrentPointedVisual = NewPointed;
                bool IsPointingToIndicator = true;

                if (NewPointed.IsOneOf(IndHeadingTop, IndHeadingBottom))
                {
                    this.ResizingDirection = (NewPointed == IndHeadingTop ? EManipulationDirection.Top : EManipulationDirection.Bottom);
                    this.TentativeAction   = EComplementManipulationAction.Resize;
                    this.Cursor            = Cursors.SizeNS;
                }
                else
                if (NewPointed.IsOneOf(IndHeadingLeft, IndHeadingRight))
                {
                    this.ResizingDirection = (NewPointed == IndHeadingLeft ? EManipulationDirection.Left : EManipulationDirection.Right);
                    this.TentativeAction   = EComplementManipulationAction.Resize;
                    this.Cursor            = Cursors.SizeWE;
                }
                else
                if (NewPointed.IsOneOf(IndHeadingTopLeft, IndHeadingBottomRight))
                {
                    this.ResizingDirection = (NewPointed == IndHeadingTopLeft ? EManipulationDirection.TopLeft : EManipulationDirection.BottomRight);
                    this.TentativeAction   = EComplementManipulationAction.Resize;
                    this.Cursor            = Cursors.SizeNWSE;
                }
                else
                if (NewPointed.IsOneOf(IndHeadingBottomLeft, IndHeadingTopRight))
                {
                    this.ResizingDirection = (NewPointed == IndHeadingTopRight ? EManipulationDirection.TopRight : EManipulationDirection.BottomLeft);
                    this.TentativeAction   = EComplementManipulationAction.Resize;
                    this.Cursor            = Cursors.SizeNESW;
                }
                else
                if (NewPointed == FrmPointingHeadingPanel)
                {
                    this.TentativeAction = EComplementManipulationAction.Move;
                    this.Cursor          = Cursors.ScrollAll;
                }
                else
                if (NewPointed == FrmEditZone || NewPointed == null)
                {
                    this.TentativeAction = EComplementManipulationAction.Edit;
                    this.Cursor          = Cursors.Pen;
                }
                else
                {
                    this.Cursor = Cursors.Hand;

                    if (NewPointed == DefaultActionIndicator)
                    {
                        this.TentativeAction = EComplementManipulationAction.Edit;
                    }
                    else
                    {
                        IsPointingToIndicator = false;
                    }
                }

                if (IsPointingToIndicator)
                {
                    var IndDescription = this.TentativeAction.GetDescription();
                    ProductDirector.ShowAssistance(IndDescription);
                }
                else
                {
                    ProductDirector.ShowAssistance();
                }

                ProductDirector.ShowPointingTo(this.ManipulatedComplement);
            }

            return(NewPointed);
        }
        public void PresenterControl_MouseMove(object sender, MouseEventArgs e)
        {
            CurrentMousePosition = e.GetPosition(CurrentView.PresenterControl);
            //T Console.WriteLine("At: " + e.GetPosition(null));

            var VisObject = GetPointedVisualObject(CurrentMousePosition);

            if ((Mouse.LeftButton == MouseButtonState.Pressed || Mouse.RightButton != MouseButtonState.Pressed) &&
                this.RunningMouseCommand == this.PanCommand && this.PanCommand != null)
            {
                this.DoCancelOperation(true, null);
            }

            if (this.RunningMouseCommand == null)
            {
                var Manipulator = CurrentView.Manipulator;

                if (this.MouseLeftButtonDownOutsideControl != null && this.MouseLeftButtonDownOutsideControl.Value)
                {
                    if (Manipulator.WorkingAdorner != null)
                    {
                        Manipulator.WorkingAdorner.CancelledByMouseLeftButtonDownOutsideControl = true;
                    }

                    Manipulator.IsManipulating = false;
                    Manipulator.UnpointObject();
                    Manipulator.Finish();
                    this.MouseLeftButtonDownOutsideControl = null;
                    return;
                }
                else
                if (Manipulator.IsManipulating)
                {
                    Manipulator.Continue();
                }
                else
                if (!Manipulator.PointObject(VisObject))
                {
                    ProductDirector.ShowPointingTo();
                    ProductDirector.ShowAssistance();
                    // Cancelled: Too much to explain... ProductDirector.ShowAssistance("To Select: Move pressing [Mouse-Button]. To Pan: Move pressing [Mouse-Alternate-Button]. To Zoom in/out: Roll [Mouse-Wheel]+[Ctrl].");
                }
            }
            else
            {
                if (!this.RunningMouseCommand.Continue(e, false))
                {
                    this.RunningMouseCommand = null;
                }

                PreviousMousePosition = CurrentMousePosition;
                return;
            }

            if (!VisObject.IsEqual(PointedObject))
            {
                PointedObject = VisObject;

                /*T Console.WriteLine("Pointing Representator of Idea: [{0}] at [{1}]. Element is at [{2}].",
                 *                (Element == null ? "<NONE>" : Element.OwnerRepresentation.RepresentedIdea.Name),
                 *                CurrentMousePosition,
                 *                (Element == null ? Rect.Empty : Element.Graphic.ContentBounds )); */
            }

            // When [Dragging] and Selecting-by-Rectangle
            if (IsSelectingByRectangle && Mouse.LeftButton == MouseButtonState.Pressed)
            {
                if (this.SelectByRectangleCommand == null)
                {
                    this.SelectByRectangleCommand = new WorkCommandInteractive <MouseEventArgs>("SelectByRectangle",
                                                                                                (mevargs, definitive) =>
                    {
                        var MousePos = mevargs.GetPosition(this.CurrentView.Presenter);

                        if (mevargs.LeftButton == MouseButtonState.Pressed &&
                            !this.CurrentView.Manipulator.IsManipulating)
                        {
                            //T Console.WriteLine("FinishedSelByRect ONE. Breaked.");
                            this.CurrentView.SelectByRectangle(MousePos);
                            return(true);
                        }

                        /*T Console.WriteLine("FinishedSelByRect ONE. IsMan={0}, MALB={1}",
                         *                this.CurrentView.Manipulator.IsManipulating, mevargs.LeftButton); */
                        if (!this.CurrentView.Manipulator.IsManipulating)
                        {
                            this.CurrentView.FinishSelectByRectangle(true, MousePos);
                        }

                        return(false);
                    },
                                                                                                (normal, mevargs) =>
                    {
                        //T Console.WriteLine("FinishedSelByRect TWO. ");
                        this.CurrentView.FinishSelectByRectangle(false);
                    });
                }

                this.RunningMouseCommand = this.SelectByRectangleCommand;  // To avoid Pointing of elements
            }
            else
            if (this.RunningMouseCommand == this.SelectByRectangleCommand && this.SelectByRectangleCommand != null)
            {
                this.DoCancelOperation(true, null);
            }

            // When [Dragging]
            // then Update cursor depending on pointed target

            // When ([Dragging] and [Going out of view scope]) or [Mouse Right-Button down]
            // then [Pan]
            if (Mouse.RightButton == MouseButtonState.Pressed)
            {
                if (this.RunningMouseCommand == null)
                {
                    if (this.PanCommand == null)
                    {
                        this.PanCommand = new WorkCommandInteractive <MouseEventArgs>("Pan",
                                                                                      (mevargs, definitive) => { this.CurrentView.Pan(); return(true); },
                                                                                      (normal, mevargs) => { this.CurrentView.PreviousPanPosition = default(Point); });
                    }

                    this.RunningMouseCommand = this.PanCommand;  // To avoid Pointing of elements
                }
            }
            else
            if (this.RunningMouseCommand == this.PanCommand && this.PanCommand != null)
            {
                this.DoCancelOperation(true, null);
            }

            PreviousMousePosition = CurrentMousePosition;
        }