public void RemoveFigure(IFigure figure)
        {
            ObjectValidator.CheckIfObjectIsNull(figure, GlobalErrorMessages.NullFigureErrorMessage);

            this.CheckIfFigureDoesNotExists(figure);
            this.figures.Remove(figure);
        }
 public ActionWithFigure(IFigure figure, ActionWithTwoParams action, double param1, double param2)
 {
     FigureToAction = figure;
     twoParamsAction = action;
     this.param1 = param1;
     this.param2 = param2;
 }
        private CollisionType ResolveMoveDown(IFigure figure)
        {
            var collision = CollisionType.None;

            figure.ForEachNonEmptyCell((i, j) =>
            {
                var absoluteX = figure.Placement.Left + i;
                var absoluteY = figure.Placement.Top + j;

                if (absoluteY > _gameField.Size.Height - 1)
                {
                    collision = CollisionType.Ground;
                    return false;
                }

                if (absoluteY < 0)
                    return true;

                if (_gameField.GroundView[absoluteX, absoluteY].IsEmptyCell())
                    return true;

                collision = CollisionType.Ground;
                if (figure.Placement.Top == 1) // a little bad assumpotion that figures always start at 0, and thatn moves down by 1
                    collision = CollisionType.Critical;

                return false;
            });
            return collision;
        }
Beispiel #4
0
        public static Brush ModifyFillBrushIfSelected(IFigure figure, Brush brush, FigureStyle style)
        {
            // Below is my suggestion for the fill appearance when a shape is selected. - David
            var brushAsSolidColor = brush as SolidColorBrush;
            if (figure != null && figure.Selected && !(style is PointStyle) && brushAsSolidColor != null)
            {
                // brush.Opacity = 0.2; // The previous method of showing a figure is selected.

                // The color of the stripes in the gradient is made by shifting the Fill color toward a gray value.
                var b = new LinearGradientBrush();
                var shapeWidth = 200;   // Arbitrary value.  Using the with of the figure would be better.
                b.StartPoint = new Point(0.0, 0.0);
                b.EndPoint = new Point(1.0, 0.0);
                double gap = 6;    // Actually half the gap between stripes in physical coordinates.
                double s = gap / shapeWidth;
                byte gray = 200;    // The gray value to shift the Fill color toward.
                double similarity = .65;    // How similar are the Fill color and the gray value (1 = similar, 0 = not).
                byte alpha = ((int)brushAsSolidColor.Color.A < 128) ? (byte)128 : brushAsSolidColor.Color.A;  // We need some opacity.
                for (double i = 0; i + s + s < 1; i += 2 * s)
                {
                    b.GradientStops.Add(new GradientStop() { Color = brushAsSolidColor.Color, Offset = i + .7 * s });
                    b.GradientStops.Add(new GradientStop()
                    {
                        Color = Color.FromArgb(alpha, (byte)(gray + (brushAsSolidColor.Color.R - gray) * similarity),
                                                      (byte)(gray + (brushAsSolidColor.Color.G - gray) * similarity),
                                                      (byte)(gray + (brushAsSolidColor.Color.B - gray) * similarity)),
                        Offset = i + s
                    });
                    b.GradientStops.Add(new GradientStop() { Color = brushAsSolidColor.Color, Offset = i + s + .3 * s });
                }
                brush = b;
            }
            // End of suggestion.
            return brush;
        }
Beispiel #5
0
 /// <summary>
 /// Add the specific figure at the specific position on the board
 /// </summary>
 /// <param name="figure">Figure to be added</param>
 /// <param name="position">The position on which the figure should be added</param>
 public void AddFigure(IFigure figure, IPosition position)
 {
     Validator.CheckIfObjectIsNull(figure);
     Validator.CheckIfPositionValid(position);
     this.board[position.Row, position.Col] = figure;
     this.figurePositionsOnBoard[figure.DisplaySign] = position;
 }
        public CollisionType EvaluateNextMove(MoveType move, IFigure figure)
        {
            var collision = CollisionType.None;
            IFigure movedFigure;
            switch (move)
            {
                case MoveType.RowAdded:
                    collision = ResolveRowAdded();
                    break;
                case MoveType.MoveRight:
                    movedFigure = figure.MoveRight();
                    collision = ResolveMoveRight(movedFigure);
                    break;
                case MoveType.MoveLeft:
                    movedFigure = figure.MoveLeft();
                    collision = ResolveMoveLeft(movedFigure);
                    break;
                case MoveType.MoveDown:
                    movedFigure = figure.MoveDown();
                    collision = ResolveMoveDown(movedFigure);
                    break;
                case MoveType.TossDown:
                    // for now do nothing
                    break;
                case MoveType.Rotate:
                    var rotatedFigure = figure.RotateClockwise();
                    collision = ResolveRotate(rotatedFigure);
                    break;
                default:
                    throw new NotImplementedException("unknown movement type: " + move);
            }

            return collision;
        }
Beispiel #7
0
 public void AddFigure(IFigure figure, IPosition position)
 {
     Validator.CheckIfObjectIsNull(figure, GlobalErrorMessages.NullFigureErrorMessage);
     Validator.CheckIfPositionValid(position, GlobalErrorMessages.PositionNotValidMessage);
     this.board[position.Row, position.Col] = figure;
     this.figurePositionsOnBoard[figure.DisplayName] = position;
 }
        public void VlidateMove(IFigure figure, IBoard board, Move move)
        {
            Position from = move.From;
            Position to = move.To;

            if (from.Row != to.Row && from.Col != to.Col)
            {
                throw new InvalidOperationException("Rook cannot move this way!");
            }

            if (to.Col > from.Col)
            {
                this.RightChecker(board, from, to);
                return;
            }
            else if (to.Col < from.Col)
            {
                this.LeftChecker(board, from, to);
                return;
            }
            else if (to.Row > from.Row)
            {
                this.TopChecker(board, from, to);
                return;
            }
            else if (to.Row < from.Row)
            {
                this.DownChecker(board, from, to);
                return;
            }
            else
            {
                throw new InvalidOperationException("Rook cannot move this way!");
            }
        }
Beispiel #9
0
        private static bool CanTearOff(IFigure figure)
        {
            if (figure is ParallelLine)
            {
                return true;
            }

            foreach (var dependency in figure.Dependencies)
            {
                var dependencyPoint = dependency as IPoint;
                if (dependencyPoint == null)
                {
                    // for now, can't tear off a figure
                    // that has a non-point dependency (such as a ParallelLine)
                    return false;
                }

                if (dependencyPoint is FreePoint)
                {
                    // no need to tear-off from an already free point
                    // since no one else uses this point
                    if (dependencyPoint.Dependents.Count == 1) continue;
                    if (dependencyPoint.Dependents.Count == 2 && dependencyPoint.Dependents.OfType<LabelBase>().Count() > 0) continue;
                }

                return true;
            }

            return false;
        }
        // TODO: Castling checking
        public void VlidateMove(IFigure figure, IBoard board, Move move)
        {
            Position from = move.From;
            Position to = move.To;

            bool condition = (
                ((from.Col + 1) == to.Col) ||
                ((from.Col - 1) == to.Col) ||
                ((from.Row + 1) == to.Row) ||
                ((from.Row - 1) == to.Row) ||
                (((from.Row + 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
                (((from.Row - 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
                (((from.Row - 1) == to.Row) && ((from.Col - 1) == to.Col)) ||
                (((from.Row + 1) == to.Row) && ((from.Col - 1) == to.Col))
                );

            if (condition)
            {
                return;
            }
            else
            {
                throw new InvalidOperationException("King cannot move this way!");
            }
        }
Beispiel #11
0
 protected override void AddFoundDependency(IFigure figure)
 {
     if (figure != null)
     {
         FoundDependencies.Add(figure);
     }
 }
 public ButtonHandle(IFigure owner, ILocator locator, kindButton type)
     : base(owner)
 {
     _locator = locator;
     _clicked = false;
     typeButton = type;
 }
Beispiel #13
0
 protected virtual void AddFoundDependency(IFigure figure)
 {
     if (ExpectedDependency.IsAssignableFrom(figure.GetType()))
     {
         FoundDependencies.Add(figure);
     }
 }
Beispiel #14
0
 public virtual void ValidateMove(IFigure figure, IBoard board, Move move)
 {
     if (figure.IsFirstMove)
        {
        figure.IsFirstMove = false;
        }
 }
Beispiel #15
0
 private void CheckIfFigureExists(IFigure figure)
 {
     if (this.figures.Contains(figure))
     {
         throw new InvalidOperationException("This player already owns this figure!");
     }
 }
Beispiel #16
0
        public void DelFigure(IFigure f)
        {
            ACommand command = new DelFigureCommand(figures, f);
            command.Execute();

            HandleAddCommand(command);
        }
Beispiel #17
0
 void WriteInput(IFigure input, XmlWriter writer)
 {
     writer.WriteStartElement("Input");
     writer.WriteAttributeString("Name", input.Name);
     writer.WriteAttributeString("Type", GetInputType(input));
     writer.WriteEndElement();
 }
Beispiel #18
0
 private void CheckIfFigureDoesNotExists(IFigure figure)
 {
     if (!this.figures.Contains(figure))
     {
         throw new InvalidOperationException("This player does not own this figure!");
     }
 }
Beispiel #19
0
        /// <summary>
        /// Determines if figure directly or indirectly depends 
        /// on <paramref name="possibleDependency"/>
        /// </summary>
        /// <param name="figure">figure to check</param>
        /// <param name="possibleDependency"></param>
        /// <returns></returns>
        public static bool DependsOn(this IFigure figure, IFigure possibleDependency)
        {
            // we consider that a figure depends on itself
            if (figure == possibleDependency)
            {
                return true;
            }

            // quick rejection - if it doesn't depend on anything,
            // it certainly doesn't depend on possibleDependency
            if (figure.Dependencies.IsEmpty())
            {
                return false;
            }

            // first do the cheap pre-test without going deep
            if (figure.DirectlyDependsOn(possibleDependency))
            {
                return true;
            }

            // if that failed, go deeper using recursion
            foreach (var directDependency in figure.Dependencies)
            {
                if (directDependency.DependsOn(possibleDependency))
                {
                    return true;
                }
            }

            // depth-first search didn't find anything
            return false;
        }
		public void VisitFigure (IFigure hostFigure) {
			if (_addedFigures.Contains (hostFigure) == false 
				&& Drawing.Includes (hostFigure) == false) {
				Drawing.Add (hostFigure);
				_addedFigures.Add (hostFigure);
			}
		}
Beispiel #21
0
        public void ValidateMove(IFigure figure, IBoard board, Move move)
        {
            var rowDistance = Math.Abs(move.From.Row - move.To.Row);
            var colDistance = Math.Abs(move.From.Col - move.To.Col);

            if (rowDistance != colDistance)
            {
                throw new InvalidOperationException(string.Format(GlobalConstants.ExceptionMessege, figure.Type));
            }

            int rowDirection = move.From.Row > move.To.Row ? -1 : 1;
            int colDirection = move.From.Col > move.To.Col ? -1 : 1;

            var row = move.From.Row;
            var col = move.From.Col;

            var endRow = move.To.Row + (rowDirection * (-1));
            var endCol = move.To.Col + (colDirection * (-1));

            while (row != endRow && col != endCol)
            {
                row += rowDirection;
                col += colDirection;

                if (board.SeeFigureOnPosition(row, col) != null)
                {
                    throw new InvalidOperationException(string.Format(GlobalConstants.ExceptionMessege, figure.Type));
                }
            }

            base.ValidateMove(figure, board, move);
        }
			public ResizeHandleUndoActivity(IDrawingView view, IFigure owner): base (view) {
				Undoable = true;
				Redoable = true;
				Owner = owner;
				OldDisplayBox = Owner.DisplayBox;
				NewDisplayBox = Owner.DisplayBox;
			}
Beispiel #23
0
 public ToggleButtonHandle(IFigure owner, ILocator locator)
     : base(owner, locator)
 {
     FillColor = new Color(1, 1, 0.0, 0.3);
     Width = 15.0;
     Height = 15.0;
 }
		public void VisitFigure (IFigure hostFigure) {
			if (_deletedFigures.Contains (hostFigure) == false 
				&& Drawing.Includes (hostFigure)) {
				Drawing.Remove (hostFigure);
				_deletedFigures.Add (hostFigure);
			}
		}
Beispiel #25
0
 public PointD Locate(IFigure owner)
 {
     PointD topleft = owner.DisplayBox.TopLeft;
     return new PointD {
         X = topleft.X + x,
         Y = topleft.Y + y,
     };
 }
		public PointD Locate (IFigure owner) {
			if (owner != null) {
				RectangleD r = owner.DisplayBox;
				return new PointD (r.X + r.Width * _relativeX, r.Y + r.Height * _relativeY);
			}
			
			return new PointD (0, 0);
		}
Beispiel #27
0
 protected override bool CanSelectFigure(IFigure figure)
 {
     if (DependencyAlgorithms.FigureCompletelyDependsOnFigures(figure, GetSelection().Without(figure)))
     {
         return false;
     }
     return true;
 }
 public GameField(Size size, IInputQueue queue)
 {
     _size = size;
     _queue = queue;
     _sprite = new ModifyableSprite(size);
     _currentFigure = new FigureI(3, 0);
     _peak = _size.Height;
 }
 public PointD Locate (IFigure owner) {
     if (owner != null) {
         PolyLineFigure figure = (PolyLineFigure) owner; 
         return GetPosition(figure.Points);
     }
     
     return new PointD ();
 }
Beispiel #30
0
 public bool IsFigureAllowed(IFigure candidate)
 {
     if (FigureAllowed == null)
     {
         return true;
     }
     return FigureAllowed(candidate);
 }
 // событие доставания фигуры в рюкзак
 private void RemoveFigure(IFigure figure)
 {
     StartCoroutine(SendToServer("remove", figure));
 }
Beispiel #32
0
        //END HERZUM SPRINT 5.5 TLAB-253

        /// <summary>
        /// Initializes a new instance of the <see cref="MonoHotDraw.Handles.PixButtonHandle"/> class.
        /// Takes action to be invoked when button is clicked
        /// </summary>
        /// <param name="owner">Owner.</param>
        /// <param name="locator">Locator.</param>
        /// <param name="pixbuf">Pixbuf.</param>
        /// <param name="action">Action.</param>

        public PixButtonHandle(IFigure owner, ILocator locator, Gdk.Pixbuf pixbuf, Action action)
            : base(owner, locator, pixbuf)
        {
            m_action = action;
        }
Beispiel #33
0
        /// <summary>
        /// Assumes coordinates are logical already
        /// </summary>
        /// <param name="coordinates">Logical coordinates of the click point</param>
        protected override 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();

                        Drawing.Figures.UpdateVisual();
                    }
                }
                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();
        }
Beispiel #34
0
        public static void Add(Drawing drawing, IFigure newFigure)
        {
            var action = new AddFigureAction(drawing, newFigure);

            drawing.ActionManager.RecordAction(action);
        }
Beispiel #35
0
 public override void DisposeFeedback(IRequest request, IFigure feedback)
 {
 }
Beispiel #36
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            _mouseDown = true;

            switch (mode)
            {
            case "PAINT":
                if (_figure.Reaction is FreeLineIRightClickReaction || _figure.Reaction is FreeFigureIRightClickReaction)
                {
                    //если фигура начинается то записать первую стартПоинт
                    if (_figure.started == false)
                    {
                        startPoint      = e.Location;
                        tmpPoint        = e.Location;
                        _figure.started = true;
                    }
                    else
                    {
                        tmpPoint   = e.Location;
                        startPoint = _figure.secondPoint;
                    }
                }
                else
                {
                    startPoint = e.Location;
                    _figure    = fabrica.CreateFigure(_pen);
                }


                break;

            case "MOVE":
                _figure = null;

                foreach (IFigure checkFigure in figuresList)
                {
                    if (checkFigure.IsEdge(e.Location) || checkFigure.IsArea(e.Location))
                    {
                        _figure      = checkFigure;
                        movingFigure = checkFigure;
                        figuresList.Remove(_figure);
                        pictureBox1.Image = canvas.Clear();
                        DrawAll();
                        startPoint = checkFigure.touchPoint;
                        break;
                    }
                }
                break;

            case "ROTATE":
                _figure = null;

                foreach (IFigure checkFigure in figuresList)
                {
                    if (checkFigure.IsEdge(e.Location) || checkFigure.IsArea(e.Location))
                    {
                        _figure = checkFigure;
                        figuresList.Remove(_figure);
                        pictureBox1.Image = canvas.Clear();
                        DrawAll();
                        movingFigure = checkFigure;
                        startPoint   = checkFigure.touchPoint;
                        break;
                    }
                }
                break;

            case "ZOOM":
                _figure = null;

                foreach (IFigure checkFigure in figuresList)
                {
                    if (checkFigure.IsEdge(e.Location))
                    {
                        _figure = checkFigure;
                        figuresList.Remove(_figure);
                        pictureBox1.Image = canvas.Clear();
                        movingFigure      = checkFigure;
                        DrawAll();
                        startPoint = checkFigure.touchPoint;
                        break;
                    }
                }
                break;

            case "FILL":
                _figure = null;
                foreach (IFigure checkFigure in figuresList)
                {
                    if (checkFigure.IsEdge(e.Location) || checkFigure.IsArea(e.Location))
                    {
                        _figure          = checkFigure;
                        _figure.IsFilled = true;
                        figuresList.Remove(_figure);
                        pictureBox1.Image = canvas.Clear();
                        movingFigure      = checkFigure;
                        DrawAll();



                        canvas.DrawIt(_figure, _pen);
                        startPoint = checkFigure.touchPoint;
                        break;
                    }
                }
                break;

            case "COLOR_PICK":
                if (pictureBox1.Image != null)
                {
                    pickedColor = canvas._mainBitmap.GetPixel(e.X, e.Y);
                    if (pickedColor.A == 0)
                    {
                        _pen.Color            = pictureBox1.BackColor;
                        colorPalete.BackColor = pictureBox1.BackColor;
                    }
                    else
                    {
                        colorPalete.BackColor = pickedColor;
                        _pen.Color            = pickedColor;
                    }
                }
                else
                {
                    _pen.Color            = pictureBox1.BackColor;
                    colorPalete.BackColor = pictureBox1.BackColor;
                }
                break;

            default:
                break;
            }
        }
Beispiel #37
0
 private void NanglesFigure_Click(object sender, EventArgs e)
 {
     // _figure = new NanglesFigure((int)_anglesNumber.Value);
     fabrica = new NanglesIFabric((int)_anglesNumber.Value);
     _figure = fabrica.CreateFigure(_pen);
 }
 public void AddFigure(IFigure figure)
 {
     OBjectValidator.CheckIfOBjectIsNull(figure, GlobalErrorMessages.NULLFIGUREMESAGE);
     CheckIfFigureExist(figure);
     this.figures.Add(figure);
 }
 public DelFigureCommand(CompositeFigure figures, IFigure f)
 {
     this.figures = figures;
     this.f       = f;
 }
Beispiel #40
0
 public override void Remove(IFigure figure)
 {
     base.Remove(figure);
     figure.FigureChanged -= FigureChangedHandler;
     CalculateDimensions();
 }
Beispiel #41
0
 public override void Add(IFigure figure)
 {
     base.Add(figure);
     figure.FigureChanged += FigureChangedHandler;
     CalculateDimensions();
 }
Beispiel #42
0
        private void openGLControlView_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isMouseDown = false;

                switch (selectedFigure)
                {
                case Figures.Line:

                    //containerFigures.addNewFigure(
                    //    Factory.Create(
                    //    "Line",
                    //    new Dictionary<string, object>()
                    //    {
                    //        { "Point1", last3Points[1] },
                    //        { "Point2", last3Points[2] }
                    //    })
                    //);
                    break;

                case Figures.Quadrangle:

                    IFigure figure =
                        Factory.Create(
                            "Rectangle",
                            new Dictionary <string, object>()
                    {
                        { "DownLeft", new Interfaces.Point(last3Points[1].X, last3Points[2].Y) },
                        { "UpRight", new Interfaces.Point(last3Points[2].X, last3Points[1].Y) },
                        { "BorderColor", borderColor },
                        { "FillColor", fillColor }
                    });
                    addCommand.Execute(figure);
                    break;

                case Figures.Circle:

                    //containerFigures.addNewFigure(
                    //    Factory.Create(
                    //    "Circle",
                    //    new Dictionary<string, object>()
                    //    {
                    //        { "Point1", last3Points[1] },
                    //        { "Point2", last3Points[2] }
                    //    })
                    //);
                    break;

                case Figures.Ellipse:

                    //containerFigures.addNewFigure(
                    //    Factory.Create(
                    //    "Ellipse",
                    //    new Dictionary<string, object>()
                    //    {
                    //        { "Point1", last3Points[1] },
                    //        { "Point2", last3Points[2] }
                    //    })
                    //);
                    break;
                }
                isStartDrag = false;
            }
            if (e.Button == MouseButtons.Middle)
            {
                isMiddleButton = false;
            }
        }
Beispiel #43
0
 public NorthWestHandle(IFigure owner) : base(owner, RelativeLocator.NorthWest)
 {
 }
Beispiel #44
0
 private void FigureND_Click(object sender, EventArgs e)
 {
     fabrica = new FigureNDIFabric();
     _figure = fabrica.CreateFigure(_pen);
     radioButtonPaintMode.Checked = true;
 }
Beispiel #45
0
 private void Ellipse_Click(object sender, EventArgs e)
 {
     fabrica = new EllipseIFabric();
     _figure = new EllipseFigure(_pen);
     radioButtonPaintMode.Checked = true;
 }
 public void RemoveFigure(IFigure figure)
 {
     OBjectValidator.CheckIfOBjectIsNull(figure, GlobalErrorMessages.NULLFIGUREMESAGE);
     CheckIFFigureDoesNotExist(figure);
     this.figures.Remove(figure);
 }
Beispiel #47
0
 private void IsoscelesTriangle_Click(object sender, EventArgs e)
 {
     fabrica = new IsoscelesIFabric();
     _figure = new IsoscelesTriangle(_pen);
     radioButtonPaintMode.Checked = true;
 }
Beispiel #48
0
 public int[] Turn(IFigure[,] board, int numberOfRecursions, out IFigure killedFigure)
 {
 }
Beispiel #49
0
 public override void UpdateFeedback(IRequest request, IFigure feedback)
 {
 }
Beispiel #50
0
        private void openGLControlView_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (isModeSelectFigures)
                {
                    pickCommand.Execute(Tuple.Create(new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY), true));
                }
                else
                {
                    // тут к координатам точки прибавляю смещение полотна
                    AddNewLastPoint(new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY));

                    switch (selectedFigure)
                    {
                    case Figures.Triangle:
                        if (iPointTriangle > 2)
                        {
                            iPointTriangle = 1;
                        }
                        else if (iPointTriangle == 2)
                        {
                            iPointTriangle++;

                            IFigure figure = Factory.Create(
                                "Triangle",
                                new Dictionary <string, object>()
                            {
                                { "Point1", last3Points[0] },
                                { "Point2", last3Points[1] },
                                { "Point3", last3Points[2] },
                                { "BorderColor", borderColor },
                                { "FillColor", fillColor }
                            });

                            addCommand.Execute(figure);
                        }
                        else
                        {
                            iPointTriangle++;
                        }
                        break;

                    case Figures.Mutant:
                        pointsMutant.Add(new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY));
                        break;

                    default:
                        last3Points[0] = new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY);
                        last3Points[1] = new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY);
                        last3Points[2] = new Interfaces.Point(e.X - canvasPositionX, e.Y - canvasPositionY);
                        break;
                    }



                    isMouseDown         = true;
                    isStartDrag         = true;
                    isChangedOpenGLView = true;
                }
            }
            if (e.Button == MouseButtons.Middle)
            {//Тут будем зажимать колёсико
                isMiddleButton = true;
                prevLocationX  = e.X;
                prevLocationY  = e.Y;
            }
        }
 public abstract void RefreshEditor(RefreshContext context, IFigure figure, object model);
Beispiel #52
0
 /// <summary>
 /// Возвращает площадь уже созданной фигуры
 /// </summary>
 /// <param name="figure">Объект класса наследника IFigure</param>
 /// <returns>Площадь фигуры</returns>
 public static double CalculateSquare(IFigure figure)
 {
     return(figure.GetSquare());
 }
Beispiel #53
0
 public DragCreationTool(IDrawingEditor editor, IFigure ptype) : base(editor, ptype)
 {
 }
Beispiel #54
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            _mouseDown = false;
            mouseMove  = false;

            if (_figure != null && _figure.Reaction is NoReactionIReaction)
            {
                figuresList.Add(_figure);
            }
            else
            {
            }
            switch (mode)
            {
            case "PAINT":
                if (e.Button == MouseButtons.Right)
                {
                    if (_figure.Reaction is FreeLineIRightClickReaction || _figure.Reaction is FreeFigureIRightClickReaction)
                    {
                        _figure.Reaction.Do();
                        figuresList.Add(_figure);
                        pictureBox1.Image = canvas.DrawIt(_figure, _pen);
                        _figure           = fabrica.CreateFigure(_pen);
                    }
                    else
                    {
                        _figure.Reaction.Do();
                    }
                }
                break;

            case "MOVE":
                if (_figure != null)
                {
                    if ((e.Button != MouseButtons.Right) && (_figure.Reaction is FreeLineIRightClickReaction || _figure.Reaction is FreeFigureIRightClickReaction))
                    {
                        figuresList.Add(_figure);
                        pictureBox1.Image = canvas.Clear();
                        DrawAll();
                    }
                    else
                    {
                        pictureBox1.Image = canvas.Clear();
                        DrawAll();
                    }
                }
                break;

            case "ROTATE":
                pictureBox1.Image = canvas.Clear();
                DrawAll();
                break;

            case "ZOOM":
                pictureBox1.Image = canvas.Clear();
                DrawAll();
                break;

            case "PEAK":
                pictureBox1.Image = canvas.Clear();
                DrawAll();
                break;

            case "FILL":
                pictureBox1.Image = canvas.Clear();
                DrawAll();
                break;

            case "COLOR_PICK":
                //mode = "PAINT";
                radioButtonPaintMode.Checked = true;
                colorPicker.Checked          = false;
                break;

            default:
                break;
            }
            canvas.Save();
        }
 public static double GetFigureTotalArea(IFigure figure) => figure.GetTotalArea();
Beispiel #56
0
 private void Rectangle_2d_Click(object sender, EventArgs e)
 {
     fabrica = new RectangleIFabric();
     _figure = new RectangleFigure(_pen);
     radioButtonPaintMode.Checked = true;
 }
Beispiel #57
0
 // ========================================
 // constructor
 // ========================================
 protected AbstractTool(IFigure customFeedback)
 {
     _customFeedback = customFeedback;
 }
 // событие складываения фигуры в рюкзак
 private void AddFigure(IFigure figure)
 {
     StartCoroutine(SendToServer("add", figure));
 }
Beispiel #59
0
 static public double Area(IFigure figure)
 {
     return(figure.GetArea());
 }
Beispiel #60
0
 void Queen_FocusFigureEvent(IFigure focusFigure)
 {
     FormulatedAvailableActions();
 }