Example #1
0
 private void DeletePolygon()
 {
     paintSurface.Children.Clear();
     polygon       = new MyPolygon(paintSurface);
     secondPolygon = new MyPolygon(paintSurface);
     ReDrawAll();
 }
Example #2
0
        private void radPolygon_CheckedChanged(object sender, EventArgs e)
        {
            const double POLYSIZE = 200d;

            lblNotes.Text = "";

            MyPolygon poly = null;

            // Get the polygon
            if (radCube.Checked)
            {
                poly = MyPolygon.CreateCube(POLYSIZE, true);
            }
            else if (radTetrahedron.Checked)
            {
                poly          = MyPolygon.CreateTetrahedron(POLYSIZE, true);
                lblNotes.Text = "Lengths:\n0,1=" + MyVector.Subtract(poly.UniquePoints[1], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n0,2=" + MyVector.Subtract(poly.UniquePoints[2], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n0,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n1,2=" + MyVector.Subtract(poly.UniquePoints[2], poly.UniquePoints[1]).GetMagnitude().ToString() + "\n1,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[1]).GetMagnitude().ToString() + "\n2,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[2]).GetMagnitude().ToString();
            }
            else
            {
                _polygon = null;
                MessageBox.Show("Unknown Polygon", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Make a new solidball
            _polygon = new SolidBallPolygon(new MyVector(0, 0, 0), new DoubleVector(1, 0, 0, 0, 1, 0), poly, 10, 10);
        }
Example #3
0
        private List <MyShape> parseStringDataToListShapeObject(string data)
        {
            List <MyShape> myShapes  = new List <MyShape>();
            string         firstWord = null;

            string[] listShape = data.Split('\n');
            for (int i = 0; i < listShape.Length; i++)
            {
                if (listShape[i] != "")
                {
                    firstWord = listShape[i].Substring(0, listShape[i].IndexOf(" "));
                }
                switch (firstWord)
                {
                case "Line":
                    MyShape myLine = new MyLine();
                    myLine.Open(listShape[i]);
                    myShapes.Add(myLine);
                    break;

                case "Rectangle":
                    MyShape myRectangle = new MyRectangle();
                    myRectangle.Open(listShape[i]);
                    myShapes.Add(myRectangle);
                    break;

                case "Circle":
                    MyShape myCircle = new MyCircle();
                    myCircle.Open(listShape[i]);
                    myShapes.Add(myCircle);
                    break;

                case "Ellipse":
                    MyShape myEllipse = new MyEllipse();
                    myEllipse.Open(listShape[i]);
                    myShapes.Add(myEllipse);
                    break;

                case "Polygon":
                    MyShape myPolygon = new MyPolygon();
                    myPolygon.Open(listShape[i]);
                    myShapes.Add(myPolygon);
                    break;

                case "Bezier":
                    MyShape myBezier = new MyBezier();
                    myBezier.Open(listShape[i]);
                    myShapes.Add(myBezier);
                    break;

                case "Polyline":
                    MyShape myPolyline = new MyPolyline();
                    myPolyline.Open(listShape[i]);
                    myShapes.Add(myPolyline);
                    break;
                }
                firstWord = "";
            }
            return(myShapes);
        }
Example #4
0
        void UpdatePolygon(MyPolygon polygon)
        {
            SolidColorBrush border   = CreateColor(cbBorder);
            SolidColorBrush Fill     = CreateColor(cbFill);
            int             borderTh = Int32.Parse(tbBorderTh.Text);

            polygon.UpdateShape(Fill, border, borderTh);
        }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();

            polygon       = new MyPolygon(paintSurface);
            secondPolygon = new MyPolygon(paintSurface);

            clickInsidePolygonBoundingBox = false;
            secondPolygonAllowed          = false;
        }
Example #6
0
        public void MyPolygonTest()
        {
            //Arrange
            MyPolygon testPolygon = new MyPolygon(300);

            //Act
            int totalVertices = testPolygon.Vertices.Count;

            //Assert
            Assert.AreEqual(totalVertices, 300);
        }
Example #7
0
        public void CreatePentagon()
        {
            List <Point> points = getListPoints();

            if (points.Count == 5)
            {
                MyPolygon polygonShape = new MyPolygon(genereteName("Pentagon"), points);
                Shapes.Add(polygonShape);

                RemoveAllPoint();
            }
        }
Example #8
0
        Shape NewShapeForCancas(MyPolygon polygonShape)
        {
            Polygon polygon = new Polygon();

            foreach (var item in polygonShape.PointList)
            {
                polygon.Points.Add(item);
            }
            polygon.Stroke = Brushes.Black;
            polygon.Fill   = new SolidColorBrush(polygonShape.Color);
            polygon.Margin = new Thickness(polygonShape.Margin.X, polygonShape.Margin.Y, 0, 0);

            return(polygon);
        }
Example #9
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            string         result         = "";

            if (openFileDialog.ShowDialog() == true)
            {
                result = File.ReadAllText(openFileDialog.FileName);
                DeletePolygon();
                polygon = new MyPolygon(paintSurface);
                int lines = CountLines(result);
                polygon.Deserialize(result);
                ReDrawAll();
            }
        }
Example #10
0
 public override AbstractFigure GetFigure(double thickness, Color fill, Color border, Point prevPos, Point newPos, AbstractFigure figure)
 {
     try
     {
         if (figure == null || !(figure is MyPolygon))
         {
             var temp = new MyPolygon(thickness, fill, border, prevPos, newPos);
             return(temp);
         }
         else
         {
             (figure as MyPolygon).AddPoint(newPos);
             return(figure);
         }
     }
     catch
     {
         MessageBox.Show("PolygonFactory Error");
         return(null);
     }
 }