Exemple #1
0
        public void AddPointTest()
        {
            Quadrilateral quadrilateral = new Quadrilateral();

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(true, quadrilateral.AddPoint(new Point(0, i)));
            }
            Assert.IsFalse(quadrilateral.IsCompleted());
            Assert.AreEqual(false, quadrilateral.AddPoint(new Point(0, 1234)));
            Assert.IsTrue(quadrilateral.IsCompleted());
        }
        public void AddPointTest()
        {
            var quadrilateral = new Quadrilateral();

            for (var i = 0; i < 3; i++)
            {
                Assert.Equal(true, quadrilateral.AddPoint(new Point(0, i)));
            }
            Assert.False(quadrilateral.IsCompleted());
            Assert.Equal(false, quadrilateral.AddPoint(new Point(0, 1234)));
            Assert.True(quadrilateral.IsCompleted());
        }
        private void PanelMain_DoubleClick(object sender, EventArgs e)
        {
            MouseEventArgs mouseEvent = e as MouseEventArgs;

            if (mouseEvent.Button == MouseButtons.Left)
            {
                Point point = new Point(mouseEvent.Location.X, mouseEvent.Location.Y);
                if (quadrilateralToDraw.AddPoint(point) == false && doubleClickCounter == 3)
                {
                    quadrilaterals.Add(quadrilateralToDraw);
                    quadrilateralToDraw = new Quadrilateral();
                    Graphic.Redraw(panelMain, graphics, quadrilaterals);
                    doubleClickCounter = 0;
                }
                else
                {
                    doubleClickCounter++;
                }

                UI.SetTextToLabel(labelCounter, string.Format("Додайте ще {0} точки щоб утворити {1}-кутник ", Quadrilateral.SIZE - quadrilateralToDraw.Count(), Quadrilateral.SIZE));
            }
        }
Exemple #4
0
        private void PanelMain_DoubleClick(object sender, EventArgs e)
        {
            var mouseEvent = e as MouseEventArgs;

            if (mouseEvent != null && mouseEvent.Button == MouseButtons.Left)
            {
                var point = new Point(mouseEvent.Location.X, mouseEvent.Location.Y);
                if (_quadrilateralToDraw.AddPoint(point) == false && _doubleClickCounter == 3)
                {
                    _quadrilaterals.Add(_quadrilateralToDraw);
                    _quadrilateralToDraw = new Quadrilateral();
                    Graphic.Redraw(panelMain, _graphics, _quadrilaterals);
                    _doubleClickCounter = 0;
                }
                else
                {
                    _doubleClickCounter++;
                }

                Utils.UI.SetTextToLabel(labelCounter,
                                        $"Додайте ще {Quadrilateral.SIZE - _quadrilateralToDraw.Count()} точки щоб утворити {Quadrilateral.SIZE}-кутник ");
            }
        }