예제 #1
0
        public static IEnumerable<Shape> RestoreState(int ext, string format)
        {
            var shapesMemento = FormatFactory.SelectSerializationFormat(ext).Load(format);
            var shapes = new List<Shape>();

            foreach (var shapeMemento in shapesMemento)
            {
                var data = new XData();
                data.SetData(shapeMemento.X, shapeMemento.Y, shapeMemento.Width, shapeMemento.Height,
                    shapeMemento.Color, shapeMemento.LineWidth, shapeMemento.Type, shapeMemento.TabIndex);

                var shape = new Shape(data, data.Type);
                shapes.Add(shape);
            }

            return shapes;
        }
예제 #2
0
 public void SetData(Shape shape)
 {
     _data = shape.Data;
     _currentShape = shape;
     SetValue();
 }
예제 #3
0
        private void pctbx_canvas_MouseClick(object sender, MouseEventArgs e)
        {
            var pctbx = (PictureBox)sender;

            _data.SetData(e.X, e.Y, 40, 40, _data.Color, _data.LineWidth, _data.Type, tbcntrl_canvas.SelectedIndex);

            var shape = new Shape(_data, _data.Type) { Location = new Point(_data.X, _data.Y) };
            pctbx.Controls.Add(shape);
        }