public override void Terminate(bool IsNormalTermination = false, MouseEventArgs Parameter = null)
        {
            base.Terminate(IsNormalTermination, Parameter);
            PointingAssistant.Finish();

            ProductDirector.ContentTreeControl.Cursor = this.PreviousCursor;
        }
Beispiel #2
0
        public override void Terminate(bool IsNormalTermination = false, MouseEventArgs Parameter = null)
        {
            base.Terminate(IsNormalTermination, Parameter);
            PointingAssistant.Finish();

            Display.GetCurrentWindow().Cursor = Cursors.Arrow;

            ProductDirector.MarkerPaletteControl.ClearSelection();
        }
Beispiel #3
0
        public override void Initialize()
        {
            base.Initialize();

            var Loader = Display.GetResource <TextBlock>("CursorLoaderArrowMarker");   // Trick for assign custom cursors.

            Display.GetCurrentWindow().Cursor = Loader.Cursor;

            PointingAssistant.Start(this.ContextEngine.CurrentView, new ImageDrawing(this.MarkerDef.Pictogram, new Rect(MarkerDefinition.StandardMarkerIconSize)));
        }
        public override void Initialize()
        {
            base.Initialize();

            var Loader = Display.GetResource <TextBlock>("CursorLoaderArrowComplement");   // Trick for assign custom cursors.

            Display.GetCurrentWindow().Cursor = Loader.Cursor;

            PointingAssistant.Start(this.ContextEngine.CurrentView,
                                    new ImageDrawing(this.ComplementKind.Pictogram,
                                                     new Rect(0, 0, this.ComplementKind.Pictogram.GetWidth(), this.ComplementKind.Pictogram.GetHeight())));
        }
        public override void Initialize()
        {
            base.Initialize();

            var Loader = Display.GetResource <TextBlock>("CursorLoaderArrowShortcut");   // Trick for assign custom cursors.

            this.PreviousCursor = ProductDirector.ContentTreeControl.Cursor;
            ProductDirector.ContentTreeControl.Cursor = Loader.Cursor;

            var ImgSrc = Display.GetAppImage("shortcut_big.png");

            PointingAssistant.Start(this.ContextEngine.CurrentView,
                                    new ImageDrawing(ImgSrc, new Rect(0, 0, ImgSrc.GetWidth(), ImgSrc.GetHeight())));
        }
Beispiel #6
0
        public override void Terminate(bool IsNormalTermination = false, MouseEventArgs Parameter = null)
        {
            var WorkingRelationshipRep = this.OriginRepresentation as RelationshipVisualRepresentation;

            if (this.IsConnecting && this.RelationshipDef.IsSimple && this.RelationshipDef.HideCentralSymbolWhenSimple &&
                WorkingRelationshipRep != null && WorkingRelationshipRep.VisualConnectorsCount <= 1)
            {
                this.ContextEngine.DeleteObjects(this.OriginRepresentation.MainSymbol.IntoEnumerable());
            }

            base.Terminate(IsNormalTermination, Parameter);
            PointingAssistant.Finish();

            Display.GetCurrentWindow().Cursor = Cursors.Arrow;

            ProductDirector.RelationshipPaletteControl.ClearSelection();
        }
Beispiel #7
0
        public override void Initialize()
        {
            OriginRepresentation    = null;
            OriginLocation          = Display.NULL_POINT;
            TargetRepresentation    = null;
            TargetLocation          = Display.NULL_POINT;
            WasKeyShiftPressed      = false;
            WasKeyCtrlPressed       = false;
            IsConnecting            = false; // Very important to clear prior to restart
            PointingConnectorFormat = null;

            base.Initialize();

            var Loader = Display.GetResource <TextBlock>("CursorLoaderArrowIdea");   // Trick for assign custom cursors.

            Display.GetCurrentWindow().Cursor = Loader.Cursor;

            PointingAssistant.Start(this.ContextEngine.CurrentView, this.RelationshipDef.GetSampleDrawing(true), true, Cursors.Cross);
        }
Beispiel #8
0
        public override bool Continue(MouseEventArgs Parameter, bool IsDefinitive = true)
        {
            var Go = base.Continue(Parameter, IsDefinitive);

            if (!Go)
            {
                return(false);
            }

            if (this.WorkingView == null)
            {
                this.WorkingView = this.ContextEngine.CurrentView;
            }

            if (this.WorkingView != this.ContextEngine.CurrentView)
            {
                this.Terminate();
                return(false);
            }

            this.TargetLocation       = Parameter.GetPosition(this.WorkingView.PresenterControl);
            this.TargetRepresentation = this.ContextEngine.GetPointedRepresentation(this.TargetLocation, true);
            var TargetObject = this.ContextEngine.GetPointedVisualObject(this.TargetLocation, 2.0);

            // IMPORTANT: Get the snapped position AFTER obtain the pointed representation
            if (this.WorkingView.SnapToGrid)
            {
                this.TargetLocation = this.WorkingView.GetGridSnappedPosition(TargetLocation, false);
            }

            this.WasKeyShiftPressed = (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
            this.WasKeyCtrlPressed  = (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl));

            if (this.TargetRepresentation != null &&
                !(this.TargetRepresentation.RepresentedIdea.IdeaDefinitor.PreciseConnectByDefault ||
                  this.WasKeyCtrlPressed))
            {
                this.TargetLocation = this.TargetRepresentation.MainSymbol.BaseCenter;
            }

            if (IsDefinitive)   // If selecting a target representation...
            {
                //T Console.WriteLine("Pointed VisObj={0}", TargetObject.ToStringAlways("<NULL>"));

                PointingAssistant.ClearConnector();

                if (!this.IsConnecting)
                {
                    /* Better at definitive target (?)
                     * this.WasKeyCtrlPressed = (Keyboard.IsKeyDown(Key.LeftCtrl)  || Keyboard.IsKeyDown(Key.RightCtrl));
                     * this.WasKeyShiftPressed = (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)); */

                    this.OriginLocation       = Parameter.GetPosition(this.WorkingView.PresenterControl);
                    this.OriginRepresentation = this.ContextEngine.GetPointedRepresentation(this.OriginLocation, true);

                    // IMPORTANT: Get the snapped position AFTER obtain the pointed representation
                    if (this.WorkingView.SnapToGrid)
                    {
                        this.OriginLocation = this.WorkingView.GetGridSnappedPosition(this.OriginLocation, false);
                    }

                    if (this.OriginRepresentation == null)   // Exit if nothing pointed at the beginning
                    {
                        return(true);
                    }

                    if (!this.OriginRepresentation.RepresentedIdea.IdeaDefinitor.PreciseConnectByDefault &&
                        !this.WasKeyCtrlPressed)
                    {
                        this.OriginLocation = this.OriginRepresentation.MainSymbol.BaseCenter;
                    }

                    this.IsConnecting = true;
                    return(true);
                }

                if (this.OriginRepresentation == this.TargetRepresentation)
                {
                    return(true);
                }

                // Needed to discard cancellation from a previous mouse-right-button click.
                this.RestartAfterTermination = true;

                if (this.TargetRepresentation == null && TargetObject != null && TargetObject is VisualComplement)
                {
                    var Complement = (VisualComplement)TargetObject;

                    // NOTE: This don't work if pointing to a complement with null background (it is not seen).
                    if (Complement.CanGroup &&
                        (!Complement.Target.IsGlobal &&
                         Complement.Target.OwnerLocal.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.CanAutomaticallyCreateGroupedConcepts &&
                         Complement.Target.OwnerLocal.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.AutomaticGroupedConceptDef != null))
                    {
                        // PENDING: Create grouped Concept and use it as target-representation.
                        var ConceptDef = Complement.Target.OwnerLocal.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.AutomaticGroupedConceptDef;

                        var Position = this.TargetLocation;

                        if (Complement.IsComplementGroupLine)
                        {
                            var Direction = Complement.GetPropertyField <Orientation>(VisualComplement.PROP_FIELD_ORIENTATION);

                            if (Direction == Orientation.Vertical)
                            {
                                Position = new Point(Complement.BaseCenter.X,
                                                     this.TargetLocation.Y + ((ConceptDef.DefaultSymbolFormat.InitialHeight / 2.0) *
                                                                              (this.TargetLocation.Y >= Complement.Target.OwnerLocal.BaseCenter.Y
                                                                               ? 1.0 : -1.0)));
                            }
                            else
                            {
                                Position = new Point(this.TargetLocation.X + ((ConceptDef.DefaultSymbolFormat.InitialWidth / 2.0) *
                                                                              (this.TargetLocation.X >= Complement.Target.OwnerLocal.BaseCenter.X
                                                                               ? 1.0 : -1.0)),
                                                     Complement.BaseCenter.Y);
                            }
                        }

                        var Creation = ConceptCreationCommand.CreateConcept(this.WorkingView.VisualizedCompositeIdea, ConceptDef,
                                                                            this.WorkingView, Position);
                        if (Creation.WasSuccessful)
                        {
                            this.TargetRepresentation = Creation.Result.VisualRepresentators.First();
                        }
                    }
                }

                var OrigRep = this.OriginRepresentation;
                var TargRep = this.TargetRepresentation;
                var OrigLoc = this.OriginLocation;
                var TargLoc = this.TargetLocation;

                // Allows extend Relationship from alternate origin.
                // Notice that the target (later used as origin) must be not-null.
                if ((Keyboard.IsKeyDown(Key.LeftAlt)) &&
                    !this.WasKeyShiftPressed && TargRep != null)
                {
                    var TmpRep = OrigRep;
                    OrigRep = TargRep;
                    TargRep = TmpRep;

                    var TmpLoc = OrigLoc;
                    OrigLoc = TargLoc;
                    TargLoc = TmpLoc;
                }

                // NOTE: TargetRepresentation can be null, so the intermediate MainSymbol can be created with no targets yet.

                var CreationResult = CreateRelationship(this.WorkingView.VisualizedCompositeIdea,
                                                        this.RelationshipDef,
                                                        this.WorkingView,
                                                        OrigRep, OrigLoc,
                                                        TargRep, TargLoc,
                                                        !this.WasKeyShiftPressed,                                // Extend from origin.
                                                        !(Keyboard.IsKeyDown(Key.RightAlt) &&                    // IMPORTANT: This crashes if applied to a Simple-and-hiding-central-symbol Relationship
                                                          !(this.RelationshipDef.IsSimple &&
                                                            this.RelationshipDef.HideCentralSymbolWhenSimple))); // Extend Relationship, else create Rel. from Rel.

                this.WasKeyShiftPressed = false;
                this.WasKeyCtrlPressed  = false;

                if (CreationResult.WasSuccessful)
                {
                    bool CanSelect = !this.RelationshipDef.HideCentralSymbolWhenSimple;

                    // If a True boolean was passed, indicating to edit-in-place and can select...
                    bool CanEditInPlace = (CreationResult.Parameters.InterpretItem <bool>() && CanSelect);

                    this.OriginRepresentation = CreationResult.Result.VisualRepresentators[0];

                    // Re-start linking from Relationship Central/Main-Symbol center.
                    this.OriginLocation = this.OriginRepresentation.MainSymbol.BaseCenter;

                    this.WorkingView.Presenter
                    .PostCall(pres =>       // Post-called in order to be executed after the symbol heading-content area is established (on first draw).
                    {
                        var Symbol = CreationResult.Result.VisualRepresentators[0].MainSymbol;
                        if (CanSelect)
                        {
                            pres.OwnerView.Manipulator.ApplySelection(Symbol);
                        }

                        if (CanEditInPlace)
                        {
                            pres.OwnerView.EditInPlace(Symbol);
                        }
                    });

                    // PENDING: Also quit if role is non multi-connectable
                    if (this.RelationshipDef.IsSimple)
                    {
                        var RelationshipRep = CreationResult.Context as RelationshipVisualRepresentation;

                        if (RelationshipRep != null)
                        {
                            if (RelationshipRep.VisualConnectorsCount > 1)
                            {
                                return(false);
                            }
                            else
                            if (!RelationshipDef.HideCentralSymbolWhenSimple)
                            {
                                RelationshipRep.MainSymbol.IsAutoPositionable = false;
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    this.IsConnecting = false;
                    Console.WriteLine("Cannot create/change Relationship: " + CreationResult.Message.AbsentDefault("?"));
                    this.Terminate();

                    return(false);
                }
            }
            else    // Else, if just pointing...
            {
                if (this.IsConnecting && this.OriginRepresentation != null)
                {
                    if (this.PointingConnectorFormat == null)
                    {
                        this.PointingConnectorFormat = new VisualConnectorsFormat(this.RelationshipDef.OwnerDomain.LinkRoleVariants.First(), Plugs.None,
                                                                                  this.RelationshipDef.OwnerDomain.LinkRoleVariants.First(), Plugs.SimpleArrow,
                                                                                  DefaultPointingConnectorBrush);
                    }

                    var OrigPlug = Plugs.None;
                    var TargPlug = Plugs.SimpleArrow;

                    if ((Keyboard.IsKeyDown(Key.LeftAlt)) &&
                        !this.WasKeyShiftPressed)
                    {
                        var TmpPlug = OrigPlug;
                        OrigPlug = TargPlug;
                        TargPlug = TmpPlug;
                    }

                    var GraphicPointer = MasterDrawer.CreateDrawingConnector(OrigPlug, TargPlug,
                                                                             this.PointingConnectorFormat.LineBrush, this.PointingConnectorFormat.LineThickness,
                                                                             this.PointingConnectorFormat.LineDash, this.PointingConnectorFormat.LineJoin,
                                                                             this.PointingConnectorFormat.LineCap, this.PointingConnectorFormat.PathStyle,
                                                                             this.PointingConnectorFormat.PathCorner, this.PointingConnectorFormat.MainBackground,
                                                                             this.PointingConnectorFormat.Opacity,
                                                                             this.TargetLocation, this.OriginLocation);
                    PointingAssistant.PutConnector(GraphicPointer);

                    this.RestartAfterTermination = true;
                }
            }

            // Continue the command...
            return(true);
        }