Beispiel #1
0
        protected override void AddDependency(Point coordinates)
        {
            IFigure underMouse = null;

            if (GetExpectedDependencyType() != null)
            {
                underMouse = LookForExpectedDependencyUnderCursor(coordinates);
                if (underMouse != null && FoundDependencies.Contains(underMouse) && !CanReuseDependency)
                {
                    return;
                }
            }

            Drawing.RaiseConstructionStepStarted();

            if (GetExpectedDependencyType() != null)
            {
                AddFoundDependency(underMouse);
            }

            if (GetExpectedDependencyType() != null)
            {
                AdvertiseNextDependency();
            }
            else
            {
                AddFiguresAndRestart();
            }

            Drawing.Figures.CheckConsistency();
        }
Beispiel #2
0
        protected virtual void AddDependency(Point coordinates)
        {
            IFigure underMouse = null;

            if (GetExpectedDependencyType() != null)
            {
                // MouseDownUnconstrainedCoordinates used here to properly find the figure under the mouse.
                underMouse = LookForExpectedDependencyUnderCursor(ClickedUnconstrainedCoordinates);

                if (underMouse != null && FoundDependencies.Contains(underMouse) && !CanReuseDependency)
                {
                    return;
                }

                if (underMouse == null && ExpectingAPoint())
                {
                    underMouse = CreatePointAtCurrentPosition(coordinates);
                }
                else if (ExpectingAPoint() && !usePointsUnderMouse)
                {
                    var pointUnderMouse = underMouse as IPoint;
                    var freePoint       = CreatePointAtCurrentPosition(coordinates);
                    if (pointUnderMouse != null)
                    {
                        freePoint.Coordinates = pointUnderMouse.Coordinates;
                    }
                    underMouse = freePoint;
                }
            }

            Drawing.RaiseConstructionStepStarted();
            RemoveIntermediateFigureIfNecessary();
            RemoveTempResultsIfNecessary();

            if (TempPoint != null)
            {
                if (underMouse == null)
                {
                    throw new NullReferenceException("How come underMouse is null at this point?");
                }
                TempPoint.SubstituteWith(underMouse);
                RemoveTempPointIfNecessary();
            }

            if (GetExpectedDependencyType() != null)
            {
                AddFoundDependency(underMouse);
            }

            if (GetExpectedDependencyType() != null)
            {
                if (ExpectingAPoint())
                {
                    CreateTempPoint(coordinates);
                    if (CanCreateTempResults())
                    {
                        CreateTempResults();
                    }
                    else
                    {
                        AddIntermediateFigureIfNecessary();
                    }
                }

                AdvertiseNextDependency();
            }
            else
            {
                AddFiguresAndRestart();
            }

            Drawing.Figures.CheckConsistency();
        }