Example #1
0
 private void RemoveTempPoint()
 {
     if (TempPoint != null)
     {
         Drawing.Figures.Remove(TempPoint);
         FoundDependencies.Remove(TempPoint);
     }
 }
Example #2
0
 protected void RemoveTempPointIfNecessary()
 {
     if (TempPoint != null)
     {
         FoundDependencies.Remove(TempPoint);
         Drawing.ActionManager.ExecuteImmediatelyWithoutRecording = true;
         Actions.Remove(TempPoint);
         Drawing.ActionManager.ExecuteImmediatelyWithoutRecording = false;
         TempPoint = null;
     }
 }
Example #3
0
        /// <summary>
        /// Assumes coordinates are logical already
        /// </summary>
        /// <param name="coordinates">Logical coordinates of the click point</param>
        protected virtual void Click(System.Windows.Point coordinates)
        {
            IFigure underMouse   = null;
            Type    expectedType = ExpectedDependency;

            if (TempPoint != null)
            {
                underMouse = Drawing.Figures.HitTest(
                    coordinates,
                    typeof(IPoint));
            }
            else if (expectedType != null)
            {
                underMouse = Drawing.Figures.HitTest(coordinates, expectedType);
            }
            else
            {
                underMouse = Drawing.Figures.HitTest(coordinates);
            }

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

            if (ExpectingAPoint())
            {
                if (underMouse == null)
                {
                    underMouse = CreatePointAtCurrentPosition(coordinates, true);
                }
            }

            RemoveIntermediateFigureIfNecessary();

            if (TempPoint != null)
            {
                if (underMouse == TempPoint || underMouse == TempResult || underMouse == null)
                {
                    underMouse = CreatePointAtCurrentPosition(coordinates, true);
                }
                TempPoint.SubstituteWith(underMouse);
                FoundDependencies.Remove(TempPoint);
                Drawing.Figures.Remove(TempPoint);
                TempPoint = null;
            }

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

            if (ExpectedDependency != null)
            {
                if (ExpectingAPoint())
                {
                    TempPoint = CreateTempPoint(coordinates);
                    AddFoundDependency(TempPoint);
                    if (ExpectedDependency == null)
                    {
                        CreateAndAddFigure();
                    }
                }
                AddIntermediateFigureIfNecessary();
                AdvertiseNextDependency();
            }
            else
            {
                Finish();
            }

            Drawing.Figures.CheckConsistency();
        }
Example #4
0
        /// <summary>
        /// Assumes coordinates are logical already
        /// </summary>
        /// <param name="coordinates">Logical coordinates of the click point</param>
        protected virtual void Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            System.Windows.Point coordinates = Coordinates(e);

            IFigure underMouse   = null;
            Type    expectedType = ExpectedDependency;

            if (TempPoint != null)
            {
                underMouse = Drawing.Figures.HitTest(
                    coordinates,
                    typeof(IPoint));
            }
            else if (expectedType != null)
            {
                underMouse = Drawing.Figures.HitTest(coordinates, expectedType);
            }
            else
            {
                underMouse = Drawing.Figures.HitTest(coordinates);
            }

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

            if (ExpectingAPoint())
            {
                if (underMouse == null)
                {
                    //underMouse = CreatePointAtCurrentPosition(coordinates, true);
                    return;
                }
                else
                {
                    // one branch only
                    if (underMouse is Webb.Playbook.Geometry.Game.PBPlayer && underMouse.Dependents.Count > 0)
                    {
                        return;
                    }
                    // at most two branch
                    if (underMouse is IPoint && underMouse.Dependents.Count > 1)
                    {
                        return;
                    }
                }
            }

            RemoveIntermediateFigureIfNecessary();

            if (TempPoint != null)
            {
                //if (underMouse == TempPoint || underMouse == TempResult || underMouse == null)
                //{
                underMouse = CreatePointAtCurrentPosition(coordinates, true);
                //}
                TempPoint.SubstituteWith(underMouse);
                FoundDependencies.Remove(TempPoint);
                Drawing.Figures.Remove(TempPoint);
                TempPoint = null;
            }

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

            if (ExpectedDependency != null)
            {
                if (ExpectingAPoint())
                {
                    TempPoint = CreateTempPoint(coordinates);
                    AddFoundDependency(TempPoint);
                    if (ExpectedDependency == null)
                    {
                        CreateAndAddFigure();
                    }
                }
                AddIntermediateFigureIfNecessary();
                AdvertiseNextDependency();
            }
            else
            {
                Finish();

                //07-22-2009 scott
                if (IsMouseButtonDown)
                {// click mode
                    IFigure endFigure = Drawing.Figures.HitTest(coordinates, typeof(Webb.Playbook.Geometry.Game.PBPlayer));
                    if (endFigure is Webb.Playbook.Geometry.Game.PBPlayer)
                    {
                        Drawing.ActionManager.Undo();
                    }
                    else
                    {
                        MouseLeftButtonDown(sender, e as System.Windows.Input.MouseButtonEventArgs);
                    }
                }
                else
                {// drag mode
                }
            }

            Drawing.Figures.CheckConsistency();
        }