private void panel4_MouseMove(object sender, MouseEventArgs e) { int w = panel4.Width / 2; int h = panel4.Height / 2; toolStripStatusLabel1.Text ="X: "+ (e.X - w).ToString(); if(e.Y<h) toolStripStatusLabel2.Text = "Y: -0"; else toolStripStatusLabel2.Text = "Y: 0"; toolStripStatusLabel7.Text = "Z: " + (h - e.Y).ToString(); if (toolStripButton1.Checked) this.Cursor = Cursors.Default; else this.Cursor = Cursors.Cross; switch (state) { case States.NONE: { Graphics g = panel2.CreateGraphics(); if (pen) { switch (fd) { case FigureGraw.Line: { g1.Clear(panel2.BackColor); g2.Clear(panel2.BackColor); g3.Clear(panel2.BackColor); if (setka) Setka(true, true, true); g2.DrawLine(new Pen(cur.color), x1, y1, e.X, e.Y); drawfigures(cur); toolStripButton2.Enabled = true; отменитьToolStripMenuItem.Enabled = true; вернутьToolStripMenuItem.Enabled = false; toolStripButton3.Enabled = false; if (buffer.Count != 0) { buffer.Clear(); } gg1.DrawImage(bmp1, 0, 0); gg2.DrawImage(bmp2, 0, 0); gg3.DrawImage(bmp3, 0, 0); } break; case FigureGraw.Sphere: { g1.Clear(panel2.BackColor); g2.Clear(panel2.BackColor); g3.Clear(panel2.BackColor); Drawmode = 2; if (setka) Setka(true, true, true); cur = new Sphere(x1, y1, Math.Abs(e.X - x1), Math.Abs(e.X - x1), panel2.Height, panel2.Width, Drawmode); func(); drawfigures(cur); toolStripButton2.Enabled = true; отменитьToolStripMenuItem.Enabled = true; вернутьToolStripMenuItem.Enabled = false; toolStripButton3.Enabled = false; if (buffer.Count != 0) { buffer.Clear(); } } break; case FigureGraw.Pyramide: { g1.Clear(panel2.BackColor); g2.Clear(panel2.BackColor); g3.Clear(panel2.BackColor); Drawmode = 2; if (setka) Setka(true, true, true); cur = new Pyramide(x1, y1, Math.Abs(e.X - x1), Math.Abs(e.Y - y1), panel4.Height, panel4.Width, Drawmode, (int)numericUpDown1.Value); func(); drawfigures(cur); toolStripButton2.Enabled = true; отменитьToolStripMenuItem.Enabled = true; вернутьToolStripMenuItem.Enabled = false; toolStripButton3.Enabled = false; if (buffer.Count != 0) { buffer.Clear(); } } break; default: break; } } } break; case States.MOVE: { for (int i = 0; i < count; i++) select[i].move(e.X - x1, e.Y - y1); g1.Clear(panel2.BackColor); g2.Clear(panel2.BackColor); g3.Clear(panel2.BackColor); if (setka) Setka(true, true, true); drawfigures(); for (int i = 0; i < count; i++) select[i].move(-(e.X - x1), -(e.Y - y1)); } break; } }
private void drawfigures(MainFigure[] ge, int size) { figures.draw1(g1, zoom); figures.draw2(g2, zoom); figures.draw3(g3, zoom); if (ge != null) { for (int i = 0; i < size; i++) { ge[i].drawXY(g1, zoom); ge[i].drawYZ(g2, zoom); ge[i].drawXZ(g3, zoom); } } gg1.DrawImage(bmp1, 0, 0); gg2.DrawImage(bmp2, 0, 0); gg3.DrawImage(bmp3, 0, 0); System.GC.Collect(); }
private void panel4_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Middle) { if (fd == FigureGraw.Line) { if (!lom) { x1 = e.X; y1 = e.Y; Drawmode = 2; cur = new Line(new Point(e.X, e.Y), panel2.Height / 2, panel2.Width / 2, Drawmode); func(); lom = true; drawfigures(cur); figures.add(cur); } else { x1 = e.X; y1 = e.Y; (cur as Line).Add(new Point(e.X, e.Y)); drawfigures(cur); } } } if (e.Button == MouseButtons.Middle) { lom = false; g1.Clear(panel2.BackColor); g2.Clear(panel2.BackColor); g3.Clear(panel2.BackColor); pen = false; state = States.NONE; panel4.ContextMenuStrip = contextMenuStrip1; for (int i = 0; i < count; i++) { select[i].width = select[i].width - 2; } count = 0; if (setka) Setka(true, true, true); drawfigures(); return; } if (e.Button != MouseButtons.Left) return; if (state == States.SELECT) { for (int i = 0; i < count; i++) { select[i].width = select[i].width - 2; } drawfigures(); panel4.ContextMenuStrip = contextMenuStrip1; state = States.NONE; return; } if (state != States.NONE) return; if (!toolStripButton1.Checked) return; select = new MainFigure[figures.count]; count = 0; foreach (MainFigure fg in figures) { MainFigure geom; if (fg.contain(new PointF(e.X, e.Y)) == 1) { select[count] = fg; geom = select[count]; toolStripLabel1.Enabled = true; toolStripLabel2.Enabled = true; numericUpDown2.Enabled = true; numericUpDown3.Enabled = true; numericUpDown2.Value = (int)fg.fwidth; numericUpDown3.Value = (int)fg.fheight; if ((select[count] is Pyramide) || (select[count] is Sphere)) { panel4.ContextMenuStrip = contextMenuStrip2; } else panel4.ContextMenuStrip = contextMenuStrip3; fg.width = fg.width + 2; count++; if (count > 1) { toolStripLabel1.Enabled = false; toolStripLabel2.Enabled = false; numericUpDown2.Enabled = false; numericUpDown3.Enabled = false; } } } if (count != 0) { state = States.SELECT; if (setka) Setka(true, true, true); drawfigures(); } }
private void drawfigures(MainFigure gr) { figures.draw1(g1, zoom); figures.draw2(g2, zoom); figures.draw3(g3, zoom); if (gr != null) { gr.drawYZ(g2, zoom); gr.drawXZ(g3, zoom); gr.drawXY(g1, zoom); } gg1.DrawImage(bmp1, 0, 0); gg2.DrawImage(bmp2, 0, 0); gg3.DrawImage(bmp3, 0, 0); System.GC.Collect(); }