Exemple #1
0
        // 複製
        public object Clone()
        {
            Shape shape = new ShapeFactory().CreateShape(_shapeType);

            shape.SetStartPoint(_startPoint.Left, _startPoint.Top);
            shape.SetEndPoint(_endPoint.Left, _endPoint.Top);
            return(shape);
        }
        // 將 json 字串轉為 shapes
        public void ConvertToShapes(string text)
        {
            Debug.WriteLine(text);
            _shapes = new List <Shape>();
            List <ShapeFormat> shapeFormats = JsonSerializer.Deserialize <List <ShapeFormat> >(text);

            foreach (ShapeFormat shapeFormat in shapeFormats)
            {
                Shape shape = new ShapeFactory().CreateShape((ShapeType)shapeFormat.ShapeType);
                shape.SetStartPoint(shapeFormat.StartPointLeft, shapeFormat.StartPointTop);
                shape.SetEndPoint(shapeFormat.EndPointLeft, shapeFormat.EndPointTop);
                shape.IsReverse = shapeFormat.IsReverse;
                Debug.WriteLine(shape.IsReverse);
                _shapes.Add(shape);
            }
        }