Beispiel #1
0
        /// <summary>
        /// Добавя примитив - Елипса на произволно място върху клиентската област.
        /// </summary>
        public void AddRandomCircleWithLines(Color fillColor, Color borderColor)
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            CirlceWithLines elipse = new CirlceWithLines(new Rectangle(x, y, 100, 100));

            {
                elipse.FillColor   = fillColor;
                elipse.BorderColor = borderColor;
            }

            ShapeList.Add(elipse);
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var shapeListJson    = File.ReadAllText("save.json");
            var shapeListObjects = JsonConvert.DeserializeObject <List <string> >(shapeListJson);

            var shapeList = new List <Shape>();

            foreach (var shapeObject in shapeListObjects)
            {
                var parts = shapeObject.Split('|');

                var shapeType       = parts[0];
                var shapeProperties = parts[1];

                Shape currentShape = JsonConvert.DeserializeObject <Shape>(shapeProperties);
                Shape typizedShape = null;

                if (shapeType == "rectangle")
                {
                    typizedShape = new RectangleShape(currentShape.Rectangle);
                }
                else if (shapeType == "line")
                {
                    typizedShape = new LineShape(currentShape.Rectangle);
                }
                else if (shapeType == "elipse")
                {
                    typizedShape = new ElipseShape(currentShape.Rectangle);
                }

                else if (shapeType == "circle")
                {
                    typizedShape = new CirlceWithLines(currentShape.Rectangle);
                }

                // ToDo serialize Color
                typizedShape.FillColor   = this.lastSelectedFillColor;
                typizedShape.BorderColor = this.lastSelectedBorderColor;

                shapeList.Add(typizedShape);
            }

            this.dialogProcessor.ShapeList = shapeList;

            this.viewPort.Invalidate();
        }
Beispiel #3
0
 public CirlceWithLines(CirlceWithLines elipse) : base(elipse)
 {
 }