Example #1
0
 public Block(int x, int y, int width, int height, GraphicTool graphicTool)
 {
     _graphicTool = graphicTool;
     X            = x;
     Y            = y;
     Width        = width;
     Height       = height;
 }
Example #2
0
        public void PointShouldBeNotAtPolygonBorder()
        {
            //arrange
            var point = new PointF {
                X = 1, Y = 1
            };

            //act
            var result = GraphicTool.IsPointInPolygon4(polygon, point);

            //assert
            Assert.IsFalse(result);
        }
Example #3
0
        public void PointShouldBeInPolygon()
        {
            //arrange
            var point = new PointF {
                X = 2, Y = 2
            };

            //act
            var result = GraphicTool.IsPointInPolygon4(polygon, point);

            //assert
            Assert.IsTrue(result);
        }
Example #4
0
        /// <summary>
        /// Draw G-code file with a path.
        /// </summary>
        public void GCodeDrawing(PointCollection pc)
        {
            GraphicTool graphicTool = new GraphicTool(pc);

            logger.Info("GraphicViewModel|GrblTest Geometry");

            GcodePaths.Add(new GraphicItems
            {
                GraphicPathGeometry    = graphicTool.Plotter(),
                GraphicFill            = Fill,
                GraphicStroke          = Brushes.Red,
                GraphicStrokeThickness = StrokeThickness,
            });
        }
Example #5
0
        public IActionResult IsPointInPolygone([FromBody] GraphicData data)
        {
            if (data == null)
            {
                new ArgumentNullException(nameof(data));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = GraphicTool.IsPointInPolygon4(data.Polygon, data.Point);

            return(Ok(result));
        }
Example #6
0
 private void dotToolStripButton_Click(object sender, EventArgs e)
 {
     selectedTool = GraphicTool.Dot;
     fillColorToolStripComboBox.Enabled = false;
     fillColorToolStripTextBox.Enabled = false;
 }
Example #7
0
 private void tsbRect_Click(object sender, EventArgs e)
 {
     selectedTool = GraphicTool.Rectangle;
     fillColorToolStripComboBox.Enabled = true;
     fillColorToolStripTextBox.Enabled = true;
 }
Example #8
0
 private void tsbPencil_Click(object sender, EventArgs e)
 {
     selectedTool = GraphicTool.Pencil;
     fillColorToolStripComboBox.Enabled = false;
     fillColorToolStripTextBox.Enabled = false;
 }
Example #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            selectedTool = GraphicTool.Pencil;

            brushSizeToolStripComboBox.SelectedIndex = 3;

            lineWidth = DEFAULT_LINE_WIDTH;

            //заполняем комбобоксы цветов
            string[] colorNames = Enum.GetNames(typeof(KnownColor));

            for (int i = 0; i < colorNames.Length; i++)
            {
                if (!Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorNames[i])).IsSystemColor)
                {
                    //цвета с понятными названиями
                    brushColorToolStripComboBox.Items.Add(colorNames[i]);
                    fillColorToolStripComboBox.Items.Add(colorNames[i]);
                }
                else
                {
                    // сюда попадут системные цвета с "непривычными" названиями. Для их отображения понадобиться переоформить способ отображения элементов.
                    // Секция показана для примера (лишние шаги).
                }
            }

            brushColorToolStripComboBox.SelectedIndex = 8; //value Black
            fillColorToolStripComboBox.SelectedIndex = 0;  //value Transparent

            //присваиваем дефолтные цвета кисти и заливки
            brushColor = Color.FromName(brushColorToolStripComboBox.Text);
            fillColor = Color.FromName(fillColorToolStripComboBox.Text);

            //При старте программы изначально выбран Pencil, поэтому настройку заливки отключаем
            fillColorToolStripComboBox.Enabled = false;
            fillColorToolStripTextBox.Enabled = false;
        }