Пример #1
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Creates and returns a new draw implementing this visual connector for an optional presentation context.
        /// </summary>
        public override DrawingGroup CreateDraw(UIElement PresentationContext, bool ShowManipulationAdorners)
        {
            // Calculate the Edge Positions
            if (this.OriginSymbol.Graphic == null)
            {
                this.OriginSymbol.GenerateGraphic(PresentationContext, ShowManipulationAdorners);
            }

            if (this.TargetSymbol.Graphic == null)
            {
                this.TargetSymbol.GenerateGraphic(PresentationContext, ShowManipulationAdorners);
            }

            // IMPORTANT: This validation allows to calculate edge-positions ONLY when not present.
            //            The last calculated edge-positions are used for when presentation-context is not supplied,
            //            which is used for generating the graphics of a composite-content view inside a symbol's details poster.
            if (PresentationContext == null &&
                (this.OriginEdgePosition == Display.NULL_POINT || this.TargetEdgePosition == Display.NULL_POINT))
            {
                PresentationContext = this.OwnerRepresentation.DisplayingView.Presenter;
            }

            DrawingGroup Result = null;

            if (this.IntermediatePosition == Display.NULL_POINT)
            {
                if (PresentationContext != null)
                {
                    /*T Console.WriteLine("OriSym={0}=>{1}, TarSym={2}=>{3}.",
                     *                this.OriginSymbol, this.OriginSymbol.Graphic.GetHashCode(),
                     *                this.TargetSymbol, this.TargetSymbol.Graphic.GetHashCode()); */

                    if (this.OriginSymbol.IsRelatedVisible)
                    {
                        this.OriginEdgePosition = (this.OriginSymbol.IsHidden ? this.OriginPosition :
                                                   this.OriginPosition.DetermineNearestIntersectingPoint(this.TargetPosition, PresentationContext,
                                                                                                         this.OriginSymbol.Graphic, this.OwnerRepresentation.DisplayingView.VisualHitTestFilter));
                    }

                    if (this.TargetSymbol.IsRelatedVisible)
                    {
                        this.TargetEdgePosition = (this.TargetSymbol.IsHidden ? this.TargetPosition :
                                                   this.TargetPosition.DetermineNearestIntersectingPoint(this.OriginPosition, PresentationContext,
                                                                                                         this.TargetSymbol.Graphic, this.OwnerRepresentation.DisplayingView.VisualHitTestFilter));
                    }

                    // Nasty trick to compensate miscalculation of border position (or after undoing a relationship-central-symbol move)
                    if (this.OriginEdgePosition == this.TargetSymbol.BaseCenter)
                    {
                        this.OriginPosition = this.OriginSymbol.BaseCenter.FindBoundary(this.OriginPosition, PresentationContext, this.OriginSymbol.Graphic, true)
                                              .SubstituteFor(default(Point), this.OriginSymbol.BaseCenter);
                        this.OriginEdgePosition = this.OriginPosition;
                    }

                    if (this.TargetEdgePosition == this.OriginSymbol.BaseCenter)
                    {
                        this.TargetPosition = this.TargetSymbol.BaseCenter.FindBoundary(this.TargetPosition, PresentationContext, this.TargetSymbol.Graphic, true)
                                              .SubstituteFor(default(Point), this.TargetSymbol.BaseCenter);
                        this.TargetEdgePosition = this.TargetPosition;
                    }
                }

                /*T Console.WriteLine("OriginEdgePoint X={0}, Y={1}. TargetEdgePoint X={2}, Y={3}",
                 *                Math.Truncate(this.OriginEdgePosition.X), Math.Truncate(this.OriginEdgePosition.Y),
                 *                Math.Truncate(this.TargetEdgePosition.X), Math.Truncate(this.TargetEdgePosition.Y)); */

                // Draw the Connector line
                Result = MasterDrawer.CreateDrawingConnector(this.OriginPlug, this.TargetPlug,
                                                             VisualConnectorsFormat.GetLineBrush(this),
                                                             VisualConnectorsFormat.GetLineThickness(this),
                                                             VisualConnectorsFormat.GetLineDash(this),
                                                             VisualConnectorsFormat.GetLineJoin(this),
                                                             VisualConnectorsFormat.GetLineCap(this),
                                                             VisualConnectorsFormat.GetPathStyle(this),
                                                             VisualConnectorsFormat.GetPathCorner(this),
                                                             VisualConnectorsFormat.GetMainBackground(this),
                                                             VisualConnectorsFormat.GetOpacity(this),
                                                             this.TargetEdgePosition, this.OriginEdgePosition,
                                                             null, VISUAL_MAGNITUDE_ADJUSTMENT);

                /*T visual cue for detecting miscalculations...
                 * Result.Children.Add(new GeometryDrawing(Brushes.Green, new Pen(Brushes.Red, 1.0),
                 *                  new EllipseGeometry(new Point(this.OriginEdgePosition.X + 100, this.OriginEdgePosition.Y), 3, 3)));
                 * Result.Children.Add(new GeometryDrawing(Brushes.Blue, new Pen(Brushes.Red, 1.0),
                 *                  new EllipseGeometry(new Point(this.TargetEdgePosition.X + 100, this.TargetEdgePosition.Y), 3, 3))); */
            }
            else
            {
                if (PresentationContext != null)
                {
                    var EdgePos = (this.OriginSymbol.IsHidden ? this.OriginPosition :
                                   this.OriginPosition.DetermineNearestIntersectingPoint(this.IntermediatePosition, PresentationContext,
                                                                                         this.OriginSymbol.Graphic, this.OwnerRepresentation.DisplayingView.VisualHitTestFilter));
                    if (EdgePos != this.IntermediatePosition)
                    {
                        this.OriginEdgePosition = EdgePos;
                    }

                    EdgePos = (this.TargetSymbol.IsHidden ? this.TargetPosition :
                               this.TargetPosition.DetermineNearestIntersectingPoint(this.IntermediatePosition, PresentationContext,
                                                                                     this.TargetSymbol.Graphic, this.OwnerRepresentation.DisplayingView.VisualHitTestFilter));
                    if (EdgePos != this.IntermediatePosition)
                    {
                        this.TargetEdgePosition = EdgePos;
                    }
                }

                //T Console.WriteLine("OriginEdgePoint X={0}, Y={1}. TargetEdgePoint X={2}, Y={3}. IP={4}", OriginEdgePoint.X, OriginEdgePoint.Y, TargetEdgePoint.X, TargetEdgePoint.Y, this.IntermediatePosition);

                // Draw the Connector origin line
                Result = MasterDrawer.CreateDrawingConnector(this.OriginPlug, Plugs.None,
                                                             VisualConnectorsFormat.GetLineBrush(this),
                                                             VisualConnectorsFormat.GetLineThickness(this),
                                                             VisualConnectorsFormat.GetLineDash(this),
                                                             VisualConnectorsFormat.GetLineJoin(this),
                                                             VisualConnectorsFormat.GetLineCap(this),
                                                             VisualConnectorsFormat.GetPathStyle(this),
                                                             VisualConnectorsFormat.GetPathCorner(this),
                                                             VisualConnectorsFormat.GetMainBackground(this),
                                                             VisualConnectorsFormat.GetOpacity(this),
                                                             this.IntermediatePosition, this.OriginEdgePosition,
                                                             null, VISUAL_MAGNITUDE_ADJUSTMENT);
                // Draw the Connector target line
                Result.Children.Add(
                    MasterDrawer.CreateDrawingConnector(Plugs.None, this.TargetPlug,
                                                        VisualConnectorsFormat.GetLineBrush(this),
                                                        VisualConnectorsFormat.GetLineThickness(this),
                                                        VisualConnectorsFormat.GetLineDash(this),
                                                        VisualConnectorsFormat.GetLineJoin(this),
                                                        VisualConnectorsFormat.GetLineCap(this),
                                                        VisualConnectorsFormat.GetPathStyle(this),
                                                        VisualConnectorsFormat.GetPathCorner(this),
                                                        VisualConnectorsFormat.GetMainBackground(this),
                                                        VisualConnectorsFormat.GetOpacity(this),
                                                        this.TargetEdgePosition, this.IntermediatePosition,
                                                        null, VISUAL_MAGNITUDE_ADJUSTMENT));
            }

            /*T Console.WriteLine("OriginEdgePosition X={0}, Y={1}. TargetEdgePosition X={2}, Y={3}. IP={4}",
             *                OriginEdgePosition.X, OriginEdgePosition.Y, TargetEdgePosition.X, TargetEdgePosition.Y, this.IntermediatePosition); */

            // PENDING: Register periferic decorators for drawing (such as callouts, notes, etc. Not to be confused with Text decorations)

            // Show main-symbol name if required
            var RelDef = this.RepresentedLink.OwnerRelationship.RelationshipDefinitor.Value;

            /* ?
             * if (RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple && RelDef.ShowNameIfHidingCentralSymbol)
             * {
             *  var LabelingBrushes = this.OwnerRelationshipRepresentation.MainSymbol.PutNameOnTop(Result);
             *  this.OwnerRelationshipRepresentation.MainSymbol.PutDefinitionOnTop(Result, LabelingBrushes.Item2, LabelingBrushes.Item1, 4);
             * }
             * else
             *  if (this.OwnerRelationshipRepresentation.MainSymbol.IsHidden)
             *  {
             *      var LabelingBrushes = this.OwnerRelationshipRepresentation.MainSymbol.GetDefaultLabelBrushes();
             *      this.OwnerRelationshipRepresentation.MainSymbol.PutDefinitionOnTop(Result, LabelingBrushes.Item2, LabelingBrushes.Item1);
             *  } */

            this.LabelArea = null;

            // Show link-role name decorator if required
            if (RelDef.DefaultConnectorsFormat.LabelLinkVariant ||
                RelDef.DefaultConnectorsFormat.LabelLinkDefinitor ||
                RelDef.DefaultConnectorsFormat.LabelLinkDescriptor ||
                this.OwnerRepresentation.DisplayingView.ShowLinkRoleVariantLabels ||
                this.OwnerRepresentation.DisplayingView.ShowLinkRoleDefNameLabels ||
                this.OwnerRepresentation.DisplayingView.ShowLinkRoleDescNameLabels)
            {
                using (var Context = Result.Append())
                {
                    var DecoratorCenter = this.IntermediatePosition;

                    if (DecoratorCenter == Display.NULL_POINT)
                    {
                        DecoratorCenter = new Point((this.OriginEdgePosition.X + this.TargetEdgePosition.X) / 2.0,
                                                    (this.OriginEdgePosition.Y + this.TargetEdgePosition.Y) / 2.0);
                    }

                    /*T else
                     *      Console.WriteLine("DecoratorCenter = IntermediatePoint"); */

                    //T Console.WriteLine("DecoratorCenter: X={0}, Y={1}", DecoratorCenter.X, DecoratorCenter.Y);

                    var LinkDescriptorLabel = (((RelDef.DefaultConnectorsFormat.LabelLinkDescriptor ||
                                                 this.OwnerRepresentation.DisplayingView.ShowLinkRoleDescNameLabels) &&
                                                this.RepresentedLink.Descriptor != null)
                                               ? this.RepresentedLink.Descriptor.Name : null);

                    var LinkDefinitorLabel = (RelDef.DefaultConnectorsFormat.LabelLinkDefinitor ||
                                              this.OwnerRepresentation.DisplayingView.ShowLinkRoleDefNameLabels
                                              ? this.RepresentedLink.RoleDefinitor.Name : null);

                    var LinkRoleVariantLabel = (RelDef.DefaultConnectorsFormat.LabelLinkVariant ||
                                                this.OwnerRepresentation.DisplayingView.ShowLinkRoleVariantLabels
                                                ? this.RepresentedLink.RoleVariant.ToString() : null);

                    this.LabelArea = MasterDrawer.PutConnectorLabeling(Context, RelDef, DecoratorCenter,
                                                                       VisualSymbolFormat.GetTextFormat(this.OwnerRelationshipRepresentation.MainSymbol,
                                                                                                        ETextPurpose.Extra),
                                                                       VisualConnectorsFormat.GetMainBackground(this),
                                                                       VisualConnectorsFormat.GetLineBrush(this),
                                                                       LinkDescriptorLabel, LinkDefinitorLabel, LinkRoleVariantLabel);
                }
            }

            // Register Selection Indicators for drawing
            // NOTE: (selection indicators at the symbol's center interfere with in-place editing)
            if (ShowManipulationAdorners)
            {
                if (this.OwnerRepresentation.IsSelected)
                {
                    var SizeFactor = (this.GetDisplayingView().SelectedObjects.Contains(this)
                                      ? 1.5 : 0.5);
                    this.OwnerRepresentation.DisplayingView.AttachAdorner(this, GenerateSelectionIndicators(INDICATOR_SIZE * SizeFactor,
                                                                                                            SelectionIndicatorBackground,
                                                                                                            SelectionIndicatorForeground).Select(tup => tup.Item1));
                }
                else
                {
                    this.OwnerRepresentation.DisplayingView.DetachAdorner(this);
                }
            }

            if (this.OwnerRepresentation.IsVanished)
            {
                Result.Opacity = VisualRepresentation.SELECTION_VANISHING_OPACITY;
            }

            return(Result);
        }
 // ---------------------------------------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Gets a sample format (e.g.: for palettes) based on the visualization formats established.
 /// </summary>
 public override Drawing GetSampleDrawing(bool IsForCursor = false, bool ShowUpperLeftPointer = false)
 {
     return(MasterDrawer.CreateDrawingSample(this, IsForCursor, ShowUpperLeftPointer));
 }
Пример #3
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);
        }
Пример #4
0
        public App()
        {
            InitializeComponent();

            MainPage = new MasterDrawer();
        }
Пример #5
0
        public void ShowPreview(object Sender = null, EventArgs Args = null)
        {
            if (this.SourceIdeaDef == null)
            {
                return;
            }

            try
            {
                if (this.SourceRelationshipDef != null && this.SourceRelationshipDef.IsDirectional)
                {
                    this.TxbOrigin.Text = "Origin";
                    this.TxbTarget.Text = "Target";
                }
                else
                {
                    this.TxbOrigin.Text = "Participant";
                    this.TxbTarget.Text = "Participant";
                }

                var Result = new DrawingGroup();

                if (this.SourceRelationshipDef == null)
                {
                    Result.Children.Add(DrawCentralSymbol());
                }
                else
                {
                    var CentralSymbolCenter = this.GetSymbolCenter();
                    // Discarded: From right to left, as the palette and drop-into-view samples
                    // From left to right, as the tabs in the Idea-Definition editing window.
                    var PreviewOrigin = new Point(this.BrdPreviewContainer.Padding.Left, CentralSymbolCenter.Y);
                    var PreviewTarget = new Point(this.BrdPreviewContainer.ActualWidth - (this.BrdPreviewContainer.Padding.Left +
                                                                                          this.BrdPreviewContainer.Padding.Right),
                                                  CentralSymbolCenter.Y);

                    var OriginRoleLink = this.SourceRelationshipDef.GetLinkForRole(ERoleType.Origin);
                    var TargetRoleLink = this.SourceRelationshipDef.GetLinkForRole(ERoleType.Target);

                    var LineBrush     = this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush;
                    var LineThickness = this.SourceRelationshipDef.DefaultConnectorsFormat.LineThickness;
                    var LineDash      = this.SourceRelationshipDef.DefaultConnectorsFormat.LineDash;
                    var LineJoin      = this.SourceRelationshipDef.DefaultConnectorsFormat.LineJoin;

                    var OriginVariant = this.SourceRelationshipDef.OriginOrParticipantLinkRoleDef.AllowedVariants.FirstOrDefault();
                    var TailPlug      = this.SourceRelationshipDef.DefaultConnectorsFormat.TailPlugs.GetMatchingOrFirst((key, value) => key.TechName == OriginVariant.TechName);
                    var TargetVariant = this.SourceRelationshipDef.TargetLinkRoleDef.NullDefault(this.SourceRelationshipDef.OriginOrParticipantLinkRoleDef).AllowedVariants.FirstOrDefault();
                    var HeadPlug      = this.SourceRelationshipDef.DefaultConnectorsFormat.HeadPlugs.GetMatchingOrFirst((key, value) => key.TechName == TargetVariant.TechName);

                    var LabelOriginPos = new Point((PreviewOrigin.X + CentralSymbolCenter.X) / 2.0,
                                                   (PreviewOrigin.Y + CentralSymbolCenter.Y) / 2.0);

                    var LabelTargetPos = new Point((CentralSymbolCenter.X + PreviewTarget.X) / 2.0,
                                                   (CentralSymbolCenter.Y + PreviewTarget.Y) / 2.0);

                    if (this.SourceRelationshipDef.IsSimple &&
                        this.SourceRelationshipDef.HideCentralSymbolWhenSimple)
                    {
                        var UniqueConnector = MasterDrawer.CreateDrawingConnector(TailPlug,
                                                                                  (this.SourceRelationshipDef.IsDirectional ? HeadPlug : TailPlug),
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineThickness,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineDash,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineJoin,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineCap,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathStyle,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathCorner,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.MainBackground,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.Opacity,
                                                                                  PreviewTarget, PreviewOrigin, null,
                                                                                  VisualConnector.VISUAL_MAGNITUDE_ADJUSTMENT);

                        Result.Children.Add(UniqueConnector);
                    }
                    else
                    {
                        Result.Children.Add(DrawCentralSymbol());

                        var CentralSymbolTarget = new Point(CentralSymbolCenter.X - SymbolWidth / 2.0, CentralSymbolCenter.Y);
                        var CentralSymbolOrigin = new Point(CentralSymbolCenter.X + SymbolWidth / 2.0, CentralSymbolCenter.Y);

                        LabelOriginPos = new Point((PreviewOrigin.X + CentralSymbolTarget.X) / 2.0,
                                                   (PreviewOrigin.Y + CentralSymbolTarget.Y) / 2.0);
                        LabelTargetPos = new Point((CentralSymbolOrigin.X + PreviewTarget.X) / 2.0,
                                                   (CentralSymbolOrigin.Y + PreviewTarget.Y) / 2.0);

                        var OriginConnector = MasterDrawer.CreateDrawingConnector(TailPlug, Plugs.None,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineThickness,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineDash,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineJoin,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineCap,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathStyle,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathCorner,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.MainBackground,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.Opacity,
                                                                                  CentralSymbolTarget, PreviewOrigin, null,
                                                                                  VisualConnector.VISUAL_MAGNITUDE_ADJUSTMENT);

                        var TargetConnector = MasterDrawer.CreateDrawingConnector(Plugs.None,
                                                                                  (this.SourceRelationshipDef.IsDirectional ? HeadPlug : TailPlug),
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineThickness,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineDash,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineJoin,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.LineCap,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathStyle,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.PathCorner,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.MainBackground,
                                                                                  this.SourceRelationshipDef.DefaultConnectorsFormat.Opacity,
                                                                                  PreviewTarget, CentralSymbolOrigin, null,
                                                                                  VisualConnector.VISUAL_MAGNITUDE_ADJUSTMENT);

                        Result.Children.Insert(0, OriginConnector);
                        Result.Children.Insert(0, TargetConnector);
                    }

                    using (var Context = Result.Append())
                    {
                        var LinkDescriptorLabel = (this.SourceRelationshipDef.DefaultConnectorsFormat.LabelLinkDescriptor
                                             ? "Descriptor" : null);

                        var LinkDefinitorLabel = (this.SourceRelationshipDef.DefaultConnectorsFormat.LabelLinkDefinitor
                                            ? "Definitor" : null);

                        var LinkRoleVariantLabel = (this.SourceRelationshipDef.DefaultConnectorsFormat.LabelLinkVariant
                                              ? "Variant" : null);

                        MasterDrawer.PutConnectorLabeling(Context, this.SourceRelationshipDef, LabelOriginPos,
                                                          this.SourceRelationshipDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Extra),
                                                          this.SourceRelationshipDef.DefaultConnectorsFormat.MainBackground,
                                                          this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush,
                                                          (LinkDescriptorLabel == null ? null : this.TxbOrigin.Text + "-" + LinkDescriptorLabel),
                                                          LinkDefinitorLabel, LinkRoleVariantLabel);

                        MasterDrawer.PutConnectorLabeling(Context, this.SourceRelationshipDef, LabelTargetPos,
                                                          this.SourceRelationshipDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Extra),
                                                          this.SourceRelationshipDef.DefaultConnectorsFormat.MainBackground,
                                                          this.SourceRelationshipDef.DefaultConnectorsFormat.LineBrush,
                                                          (LinkDescriptorLabel == null ? null : this.TxbTarget.Text + "-" + LinkDescriptorLabel),
                                                          LinkDefinitorLabel, LinkRoleVariantLabel);
                    }
                }

                this.ImgPreview.Source = Result.ToDrawingImage();
            }
            //catch (Exception Problem)
            catch
            {
                // Console.WriteLine("Cannot show preview.");
            }
        }
Пример #6
0
        private Drawing DrawCentralSymbol()
        {
            var MaxDetPosterHeight = (this.BrdPreviewContainer.ActualHeight
                                      - (this.BrdPreviewContainer.Padding.Top +
                                         this.BrdPreviewContainer.Padding.Bottom)) - this.SymbolHeight;

            var LocalSymbolWidth = SymbolWidth;

            // Adjust of the WPF-Bug which incorrectly draws non-solid dash-styles of non-filled geometries.
            // 2020-07-25 -- Added StraightMidHorizLine to the list.
            if (this.SourceIdeaDef.DefaultSymbolFormat.LineDash != DashStyles.Solid &&
                this.SourceIdeaDef.RepresentativeShape.IsOneOf(Shapes.XMark, Shapes.StraightParallelLines, Shapes.StraightUnderLine,
                                                               Shapes.StraightMidHorizLine,
                                                               Shapes.BracketsCurly, Shapes.BracketsCurved, Shapes.BracketsSquare))
            {
                LocalSymbolWidth = LocalSymbolWidth * 1.5;
            }

            var SymDraw = MasterDrawer.CreateDrawingSymbol(this.SourceIdeaDef.RepresentativeShape,
                                                           this.SourceIdeaDef.DefaultPictogram,
                                                           this.SourceIdeaDef.DefaultPictogram,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.LineBrush,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.LineThickness,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.LineDash,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.LineJoin,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.LineCap,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.UsePictogramAsSymbol,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.MainBackground,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.DetailsPosterIsHanging,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.Opacity,
                                                           this.GetSymbolCenter(), LocalSymbolWidth, SymbolHeight,
                                                           (this.CbxDetailsPoster.IsChecked.IsTrue() &&
                                                            (LocalSymbolWidth >= VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Width &&
                                                             MaxDetPosterHeight >= VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height)
                                                         ? VisualSymbol.INITIAL_DETAILS_POSTER_HEIGHT
                                                            .EnforceMaximum(MaxDetPosterHeight)
                                                            .EnforceMinimum(VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height * 2.0)
                                                            .SubstituteFor(VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height * 2.0, 0.0)
                                                         : 0.0),
                                                           this.SourceIdeaDef.DefaultSymbolFormat.AsMultiple,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.InitiallyFlippedHorizontally,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.InitiallyFlippedVertically,
                                                           this.SourceIdeaDef.DefaultSymbolFormat.InitiallyTilted);

            var WorkingPictogram = (this.SourceIdeaDef.DefaultSymbolFormat.UseDefinitorPictogramAsNullDefault
                                 ? this.SourceIdeaDef.Pictogram
                                 : Display.GetAppImage("page_white.png"));

            var TitleFormat = this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Title);

            MasterDrawer.GenerateHeadingContent(SymDraw.Item1, SymDraw.Item2,
                                                WorkingPictogram, this.SourceIdeaDef.DefaultSymbolFormat.UsePictogramAsSymbol, this.SourceIdeaDef.DefaultSymbolFormat.PictogramVisualDisposition,
                                                this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Title), this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Subtitle),
                                                this.SourceIdeaDef.DefaultSymbolFormat.SubtitleVisualDisposition, this.SourceIdeaDef.DefaultSymbolFormat.UseNameAsMainTitle,
                                                this.SourceIdeaDef.Name, this.SourceIdeaDef.TechName);

            if (SymDraw.Item3 != Rect.Empty)
            {
                using (var Context = SymDraw.Item1.Append())
                {
                    var TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + VisualSymbol.DETS_MARGIN_SIZE,
                                              SymDraw.Item3.Width, (SymDraw.Item3.Height - VisualSymbol.DETS_MARGIN_SIZE));

                    if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0)
                    {
                        var TitleDesignateArea = VisualSymbol.DrawDetailTitle(Context, "Detail Heading", true,
                                                                              this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailHeading),
                                                                              TargetArea, VisualSymbol.DETS_PADDING_SIZE,
                                                                              this.SourceIdeaDef.DefaultSymbolFormat.DetailHeadingBackground,
                                                                              this.SourceIdeaDef.DefaultSymbolFormat.DetailHeadingForeground);

                        TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE,
                                              SymDraw.Item3.Width, SymDraw.Item3.Height - (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE));

                        if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0)
                        {
                            var LabelArea = MasterDrawer.DrawTextLabel(Context, "Detail Caption",
                                                                       this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailCaption),
                                                                       TargetArea, this.SourceIdeaDef.DefaultSymbolFormat.DetailCaptionBackground,
                                                                       new Pen(this.SourceIdeaDef.DefaultSymbolFormat.DetailCaptionForeground, 1.0),
                                                                       Padding.Top, Padding.Left, Padding.Right);

                            TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE + LabelArea.Height),
                                                  SymDraw.Item3.Width, SymDraw.Item3.Height - (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE + LabelArea.Height));

                            if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0)
                            {
                                MasterDrawer.DrawTextLabel(Context, "Detail Content",
                                                           this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailContent),
                                                           TargetArea, this.SourceIdeaDef.DefaultSymbolFormat.DetailContentBackground,
                                                           new Pen(this.SourceIdeaDef.DefaultSymbolFormat.DetailContentForeground, 1.0),
                                                           Padding.Top, Padding.Left, Padding.Right, false);
                            }
                        }
                    }
                }
            }

            var Result = SymDraw.Item1;

            // Compensates adjust of the WPF-Bug which incorrectly draws non-solid dash-styles of non-filled geometries.
            if (LocalSymbolWidth != SymbolWidth)
            {
                var CompensatedResult = new DrawingGroup();
                CompensatedResult.Children.Add(Result);
                CompensatedResult.Transform = new TranslateTransform(-(LocalSymbolWidth / 1.5), 0);
                Result = CompensatedResult;
            }

            return(Result);
        }
        //------------------------------------------------------------------------------------------------------------------------
        public override void Visualize(bool Show = true, bool OnlyAdornAsSelected = false)
        {
            this.AlternateActions.Clear();
            this.ClearAllIndicators();
            //T Console.WriteLine("Visualizing 111 ..." + DateTime.Now.Ticks);

            // Validate that the Adorner still points something.
            // Else, maybe an "Undo" was performed, so the Represented-Idea may not exist anymore.
            if (this.ManipulatedConnector == null || this.ManipulatedConnector.OwnerRepresentation == null)
            {
                if (this.ManipulatedConnector != null)
                {
                    this.OwnerManager.RemoveAdorners();
                }

                this.OwnerManager.OwnerView.UnselectAllObjects();

                return;
            }

            if (!Show)
            {
                return;
            }

            //T Console.WriteLine("Visualizing 222 ..." + DateTime.Now.Ticks);
            //T Console.WriteLine("Showing connector manipulation adorner.");

            var PaintBrush = FrmStroke;

            PaintBrush.Opacity = 0.5;

            var RelDef = this.ManipulatedConnector.OwnerRelationshipRepresentation.RepresentedRelationship.RelationshipDefinitor.Value;

            if (this.IntendedAction == EConnectorManipulationAction.ReLink)
            {
                var ConnFormat = RelDef.DefaultConnectorsFormat;

                Point PosTarget, PosOrigin;

                var ViewPosition = this.MousePositionCurrent = Mouse.GetPosition(this.OwnerManager.OwnerView.Presenter);

                if (!this.WorkingOnOrigin)
                {
                    PosTarget = this.ManipulConnRelinkingPos;
                    PosOrigin = this.ManipulatedConnector.FinalOriginPoint;
                }
                else
                {
                    PosTarget = this.ManipulatedConnector.FinalTargetPoint;
                    PosOrigin = this.ManipulConnRelinkingPos;
                }

                var RelinkingConnector = MasterDrawer.CreateDrawingConnector(Plugs.None, Plugs.SimpleArrow,
                                                                             ConnFormat.LineBrush, ConnFormat.LineThickness,
                                                                             ConnFormat.LineDash, ConnFormat.LineJoin,
                                                                             ConnFormat.LineCap, ConnFormat.PathStyle,
                                                                             ConnFormat.PathCorner, ConnFormat.MainBackground,
                                                                             ConnFormat.Opacity,
                                                                             PosTarget,
                                                                             PosOrigin).RenderToDrawingVisual();

                this.Indicators.Insert(0, RelinkingConnector);
                //T Console.WriteLine("Visualizing 333 ..." + DateTime.Now.Ticks);
                this.RefreshAdorner();
                return;
            }

            //T Console.WriteLine("Visualizing 444 ..." + DateTime.Now.Ticks);
            if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
            {
                this.CurrentManipulationAction = EConnectorManipulationAction.Remove;
            }
            else
            if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) &&
                (this.ManipulatedConnector.IntermediatePosition != Display.NULL_POINT ||
                 (RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple)))
            {
                this.CurrentManipulationAction = EConnectorManipulationAction.StraightenLine;
            }
            else
            if ((Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                /*? && this.ManipulatedConnector.RepresentedLink.RoleDefinitor.AllowedVariants.Count > 1 */)
            {
                this.CurrentManipulationAction = EConnectorManipulationAction.CycleThroughVariants;
            }
            else
            {
                this.CurrentManipulationAction = EConnectorManipulationAction.Displace;
            }

            /* Remove: problematic in autoref? */
            var PosX = this.ManipulatedConnector.OriginPosition.X - INDICATOR_SIZE / 2.0;
            var PosY = this.ManipulatedConnector.OriginPosition.Y - INDICATOR_SIZE / 2.0;

            this.IndOriginPoint = (new GeometryDrawing(IndStroke, IndPencil, new RectangleGeometry(new Rect(PosX, PosY, INDICATOR_SIZE, INDICATOR_SIZE)))).RenderToDrawingVisual();
            Indicators.Add(this.IndOriginPoint);    // Origin must be first

            PosX = this.ManipulatedConnector.TargetPosition.X - INDICATOR_SIZE / 2.0;
            PosY = this.ManipulatedConnector.TargetPosition.Y - INDICATOR_SIZE / 2.0;
            this.IndTargetPoint = (new GeometryDrawing(IndStroke, IndPencil, new RectangleGeometry(new Rect(PosX, PosY, INDICATOR_SIZE, INDICATOR_SIZE)))).RenderToDrawingVisual();
            Indicators.Add(this.IndTargetPoint);    // Origin must be last

            // Determine whether exposition of adorner for a hidden relationship's Central/Main-Symbol (which may be reccently deleted) is needed
            if (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol != null &&
                this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol.IsHidden)
            {
                PosX = this.ManipulationAlternatePosition.X - ACTIONER_SIZE / 2.0;
                PosY = this.ManipulationAlternatePosition.Y - ACTIONER_SIZE / 2.0;
                var AltActionIndicator = CreateActioner(PosX, PosY, this.CurrentManipulationAction, false, Brushes.Red);
                this.AlternateActions.Add(AltActionIndicator);
                this.ManipulatedAlternateObject = this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol;

                this.Indicators.Add(AltActionIndicator);
                this.ExclusivePointingIndicators.Add(AltActionIndicator);
            }

            // Draw lines before other visuals
            var PencilYellow = new Pen(PaintBrush, MANIPULATING_CONNECTOR_WIDTH);

            PencilYellow.DashCap      = PenLineCap.Round;
            PencilYellow.StartLineCap = PenLineCap.Round;
            PencilYellow.EndLineCap   = PenLineCap.Round;

            // NOTE: Yellow and Red are always from origin to target, over the side where the mouse pointer is working on.
            var PencilRed   = PencilYellow; // new Pen(Brushes.Red, MANIPULATING_CONNECTOR_WIDTH);
            var PencilGreen = PencilYellow; // new Pen(Brushes.Green, MANIPULATING_CONNECTOR_WIDTH);
            var PencilBlue  = PencilYellow; // new Pen(Brushes.Blue, MANIPULATING_CONNECTOR_WIDTH);

            var StartPoint = (this.ManipulatedConnector.OriginSymbol == this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol
                              ? this.ManipulationAlternatePosition
                              : this.ManipulatedConnector.OriginPosition);

            var EndPoint = (this.ManipulatedConnector.OriginSymbol == this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol
                            ? this.ManipulatedConnector.TargetPosition
                            : this.ManipulationAlternatePosition);

            DrawingVisual IndConnectCurrentLine = null;

            var CommonPoint = this.ManipulConnDisplacingPos;

            // PENDING: Solve ungly misplaced indicator at the previous intermediate-position
            if (RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple &&
                this.ManipulatedConnector.IntermediatePosition == Display.NULL_POINT &&
                this.IsWorkingOnAlternateTarget)
            {
                CommonPoint = new Point((StartPoint.X + EndPoint.X) / 2.0,
                                        (StartPoint.Y + EndPoint.Y) / 2.0);
            }

            //T Console.WriteLine("Visualizing Compoint=" + CommonPoint.ToString() + ". NEW  At " + DateTime.Now.Ticks);

            this.DefaultActionIndicator = CreateActioner(CommonPoint.X - ACTIONER_SIZE / 2.0, CommonPoint.Y - ACTIONER_SIZE / 2.0,
                                                         this.CurrentManipulationAction, true, Brushes.Blue);
            this.Indicators.Add(this.DefaultActionIndicator);
            this.ExclusivePointingIndicators.Add(this.DefaultActionIndicator);

            /*T if (StartPoint == EndPoint)
             *      Console.WriteLine("EqualPoints"); */

            IndConnectCurrentLine = (new GeometryDrawing(PaintBrush, PencilYellow, new LineGeometry(StartPoint, CommonPoint))).RenderToDrawingVisual();
            this.Indicators.Insert(0, IndConnectCurrentLine);

            IndConnectCurrentLine = (new GeometryDrawing(PaintBrush, PencilRed, new LineGeometry(CommonPoint, EndPoint))).RenderToDrawingVisual();
            this.Indicators.Insert(0, IndConnectCurrentLine);

            var Connectors = this.ManipulatedConnector.OwnerRelationshipRepresentation.VisualConnectors;

            // Indicators for re-linking
            if (this.CurrentManipulationAction != EConnectorManipulationAction.CycleThroughVariants &&
                ((!(RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple) &&
                  (RelDef.PreciseConnectByDefault || (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))) ||
                 this.ManipulatedConnector.TargetSymbol != this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol))
            {
                this.RelinkActionTargetIndicator = CreateActioner(this.ManipulatedConnector.TargetEdgePosition.X - ACTIONER_SIZE / 2.0,
                                                                  this.ManipulatedConnector.TargetEdgePosition.Y - ACTIONER_SIZE / 2.0,
                                                                  EConnectorManipulationAction.ReLink,
                                                                  this.ManipulatedConnector.TargetSymbol == this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol,
                                                                  Brushes.Orange);
                this.Indicators.Add(this.RelinkActionTargetIndicator);
            }

            if (this.CurrentManipulationAction != EConnectorManipulationAction.CycleThroughVariants &&
                ((!(RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple) &&
                  (RelDef.PreciseConnectByDefault || (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))) ||
                 this.ManipulatedConnector.OriginSymbol != this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol))
            {
                this.RelinkActionOriginIndicator = CreateActioner(this.ManipulatedConnector.OriginEdgePosition.X - ACTIONER_SIZE / 2.0,
                                                                  this.ManipulatedConnector.OriginEdgePosition.Y - ACTIONER_SIZE / 2.0,
                                                                  EConnectorManipulationAction.ReLink,
                                                                  this.ManipulatedConnector.OriginSymbol == this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol,
                                                                  Brushes.Green);
                this.Indicators.Add(this.RelinkActionOriginIndicator);
            }

            if (RelDef.IsSimple && RelDef.HideCentralSymbolWhenSimple &&
                Connectors.Count() > 1)
            {
                var OppositeConnector = (this.ManipulatedConnector == Connectors.First() ? Connectors.Skip(1).First() : Connectors.First());

                StartPoint = (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol == OppositeConnector.TargetSymbol
                                ? OppositeConnector.OriginIntermediateOrFinalPosition
                                : this.ManipulationAlternatePosition);

                EndPoint = (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol == OppositeConnector.TargetSymbol
                            ? this.ManipulationAlternatePosition
                            : OppositeConnector.TargetIntermediateOrFinalPosition);

                var IndConnectOppositeLine = (new GeometryDrawing(PaintBrush, PencilGreen, new LineGeometry(StartPoint, EndPoint))).RenderToDrawingVisual();
                this.Indicators.Insert(0, IndConnectOppositeLine);
                this.AlternateActions.Add(IndConnectOppositeLine);

                Point OppositeCenter = OppositeConnector.IntermediatePosition;

                if (OppositeCenter == Display.NULL_POINT)
                {
                    StartPoint = (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol == OppositeConnector.TargetSymbol
                                    ? OppositeConnector.OriginIntermediateOrFinalPosition
                                  .DetermineNearestIntersectingPoint(EndPoint, this.OwnerManager.OwnerView.Presenter,
                                                                     OppositeConnector.OriginSymbol.Graphic, this.OwnerManager.OwnerView.VisualHitTestFilter)
                                    : this.ManipulationAlternatePosition);

                    EndPoint = (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol == OppositeConnector.TargetSymbol
                                ? this.ManipulationAlternatePosition
                                : OppositeConnector.TargetIntermediateOrFinalPosition
                                .DetermineNearestIntersectingPoint(StartPoint, this.OwnerManager.OwnerView.Presenter,
                                                                   OppositeConnector.TargetSymbol.Graphic, this.OwnerManager.OwnerView.VisualHitTestFilter));

                    OppositeCenter = StartPoint.DetermineCenterRespect(EndPoint);
                }

                if (OppositeConnector.IntermediatePosition != Display.NULL_POINT)
                {
                    StartPoint = OppositeConnector.IntermediatePosition;
                    EndPoint   = (this.ManipulatedConnector.OwnerRelationshipRepresentation.MainSymbol == OppositeConnector.TargetSymbol
                                ? OppositeConnector.OriginPosition : OppositeConnector.TargetPosition);

                    var IndConnectOppositeFarthestLine = (new GeometryDrawing(PaintBrush, PencilBlue, new LineGeometry(StartPoint, EndPoint))).RenderToDrawingVisual();
                    this.Indicators.Insert(0, IndConnectOppositeFarthestLine);
                    this.AlternateActions.Add(IndConnectOppositeFarthestLine);
                }

                OppositeCenter.X -= ACTIONER_SIZE / 2.0;
                OppositeCenter.Y -= ACTIONER_SIZE / 2.0;
                var OppositeActionIndicator = CreateActioner(OppositeCenter.X, OppositeCenter.Y, this.CurrentManipulationAction, true, Brushes.Violet);
                this.Indicators.Add(OppositeActionIndicator);
                this.ExclusivePointingIndicators.Add(OppositeActionIndicator);
            }

            //T Console.WriteLine("Visualizing 555 ..." + DateTime.Now.Ticks);

            // Needed in order to show this adorner's indicators on top of a potentially selected visual element
            this.RefreshAdorner();
        }