private void buttonchangesizeposition_Click(object sender, EventArgs e) { if (!painter.shape_was_select) { MessageBox.Show("No selected shape"); return; } IRepositable shape = painter.selected_shape as IRepositable; if (shape == null) { MessageBox.Show("This shape cant be moved"); return; } painter.CurrentShapeToPaintID = Serializator.getInstance().GetStringType(painter.selected_shape.GetType()); changeflag = true; editflag = false; painter.prevpoint = new PointF(shape.getpospoint().X, shape.getpospoint().Y); painter.pen.Color = painter.selected_shape.color; painter.pen.Width = painter.selected_shape.outline_width; buff = shape_list.IndexOf(painter.selected_shape); shape_list.Remove(painter.selected_shape); }
public MainForm() { InitializeComponent(); colorDialog.Color = Color.Black; shapestates = new LinkedList <List <Shape> >(); shape_list = new List <Shape>(); NullShape nullshape = new NullShape(); painter = new Painter(); painter.SetWidth(3); painter.currentpoint = new Point(0, 0); picture = new Bitmap(680, 400); buffpicture = new Bitmap(680, 400); nullmap = new Bitmap(100, 100); states = new LinkedList <Bitmap>(); prevmap = new Bitmap(680, 400); Graphics.FromImage(prevmap).DrawImage(picture, 0, 0); states.AddFirst(nullmap); states.AddFirst(prevmap); changeflag = false; posflag = false; prevmaps = new Bitmap[20]; nextmaps = new Bitmap[20]; redoind = 50; LoadDlls(); Serializator.getInstance().Serialize(shape_list, "BUFF/" + Convert.ToString(redoind) + ".json"); redoind++; Serializator s = Serializator.getInstance(); graphics = Graphics.FromImage(picture); buffgraphics = Graphics.FromImage(buffpicture); }
public static Serializator getInstance() { if (instance == null) { instance = new Serializator(MainForm.types); } return(instance); }
private void Serredo() { Serializator.getInstance().Serialize(shape_list, "BUFF/" + Convert.ToString(redoind) + ".json"); shape_list = Serializator.getInstance().Desirialize_err("BUFF/" + Convert.ToString(redoind + 1) + ".json"); redoind++; painter.DrawShapeList(shape_list); PaintShapeList(); Refresh(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); shape_list = Serializator.getInstance().Desirialize_err(openFileDialog1.FileName); painter.DrawShapeList(shape_list); pictureBox.Image = picture; states.AddLast(nullmap); SaveNextGraphicsState(); PaintShapeList(); painter.shape_was_select = false; }
private void buttondeleteshape_Click(object sender, EventArgs e) { if (!painter.shape_was_select) { MessageBox.Show("No selected shape"); return; } Serializator.getInstance().Serialize(shape_list, "BUFF/" + Convert.ToString(redoind) + ".json"); redoind++; shape_list.Remove(painter.selected_shape); painter.selected_shape = null; painter.shape_was_select = false; painter.DrawShapeList(shape_list); PaintShapeList(); Refresh(); }
public Shape Create(List <IShapeDll> dlls, List <Type> types) { Serializator.getInstance().Serialize(MainForm.shape_list, "BUFF/" + Convert.ToString(MainForm.redoind) + ".json"); MainForm.redoind++; String id = CurrentShapeToPaintID; if (id == "Circuit") { id = "Ellipse"; } if (id == "Square") { id = "Rectangle"; } String[] args = new String[6]; for (int i = 0; i < types.Count; i++) { if (types.ElementAt(i).Name.Contains(id)) { LastShape = dlls[i].GetShape(); var buff = LastShape as IShapeDll; if (buff == null) { return(new NullShape()); } else { buff.SetColor(pen.Color); buff.SetWidth(pen.Width); } var shapebuff = LastShape as ITwoPointsToPaint; if (shapebuff == null) { var shapebuff3p = LastShape as IThreePointsToPaint; if (shapebuff3p == null) { return(new NullShape()); } else { points[2].X = points[1].X + ShapeWidth * 2; points[2].Y = points[1].Y; args[0] = Convert.ToString(points[0].X); args[1] = Convert.ToString(points[0].Y); args[2] = Convert.ToString(points[1].X); args[3] = Convert.ToString(points[1].Y); args[4] = Convert.ToString(points[2].X); args[5] = Convert.ToString(points[2].Y); shapebuff3p.SetPaintArgs(args); } } else { int x = (int)points[0].X; int y = (int)points[0].Y; args[0] = Convert.ToString(x); args[1] = Convert.ToString(y); args[2] = Convert.ToString(ShapeWidth); args[3] = Convert.ToString(ShapeHeight); shapebuff.SetPaintArgs(args); } break; } } if (LastShape != null) { LastShape.Paint(MainForm.graphics); } return(LastShape); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); Serializator.getInstance().Serialize(shape_list, saveFileDialog1.FileName); }