public FigureTool(IFigure figure, AbstractCanvas canvas) { this.figure = figure; figureTmp = (IFigure)this.figure.Clone(); this.canvas = canvas; cursorActive = false; }
// ================================================== Методы установки значений по умолчанию ================================================== private void startProgram() // Набор стартовых значений { labelX.Text = Convert.ToString(pictureBoxSheet.Width); labelY.Text = Convert.ToString(pictureBoxSheet.Height); if (canvas == Canvas.GetCanvas) { Canvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height); setDefaultToolRaster(); } if (canvas == VectorCanvas.GetCanvas) { VectorCanvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height); setDefaultToolVector(); } if (canvas == null) { Canvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height); VectorCanvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height); canvas = Canvas.GetCanvas; brush = new CircleBrush(brushSize, paintColor1); brush.BrushColor = palette1.BackColor; fill = new NoFill(paintColor2); tool = new PenTool(); } pictureBoxSheet.DrawToBitmap(Canvas.GetCanvas.Bmp.Bmp, pictureBoxSheet.ClientRectangle); }
// ================================================== Методы переключения режимов ================================================== private void растроваяГрафикаToolStripMenuItem_Click(object sender, EventArgs e) // Подготовка режима растровой графики { canvas = Canvas.GetCanvas; canvas.WriteToPictureBox(pictureBoxSheet); labelTool.Text = " Кисть"; tool = new PenTool(); showModeMenu(); }
private void векторнаяГрафикаToolStripMenuItem_Click(object sender, EventArgs e) // Подготовка режима векторной графики { canvas = VectorCanvas.GetCanvas; canvas.WriteToPictureBox(pictureBoxSheet); labelTool.Text = " Линия"; tool = null; showModeMenu(); }
public void Draw(AbstractCanvas canvas) { canvas.Bmp.Lock(); brush.DrawLine(canvas.Bmp, begin.X, begin.Y, end.X, end.Y, drawFirstDot); canvas.Bmp.Unlock(); }
public void Draw(AbstractCanvas canvas) { //случай линии if (figure.dotlist.Count == 2) { Drawline drawer = new Drawline(figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, brush, true); drawer.Draw(canvas); return; } BitmapWrap tmp = new BitmapWrap(canvas.Width, canvas.Height); tmp.Lock(); IBrush tmpBrush = new SquareBrush(1, fill.FillColor); tmpBrush.DrawLine(tmp, figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, true); for (int i = 1; i < figure.dotlist.Count - 1; i++) { tmpBrush.DrawLine(tmp, figure.dotlist[i].X, figure.dotlist[i].Y, figure.dotlist[i + 1].X, figure.dotlist[i + 1].Y); } tmpBrush.DrawLine(tmp, figure.dotlist[figure.dotlist.Count - 1].X, figure.dotlist[figure.dotlist.Count - 1].Y, figure.dotlist[0].X, figure.dotlist[0].Y); if (figure.IsInside(figure.center)) { fill.Fill(tmp, figure.center); } if (!(fill is OnlyFill)) { brush.DrawLine(tmp, figure.dotlist[0].X, figure.dotlist[0].Y, figure.dotlist[1].X, figure.dotlist[1].Y, true); for (int i = 1; i < figure.dotlist.Count - 1; i++) { brush.DrawLine(tmp, figure.dotlist[i].X, figure.dotlist[i].Y, figure.dotlist[i + 1].X, figure.dotlist[i + 1].Y); } brush.DrawLine(tmp, figure.dotlist[figure.dotlist.Count - 1].X, figure.dotlist[figure.dotlist.Count - 1].Y, figure.dotlist[0].X, figure.dotlist[0].Y); } tmp.Unlock(); Graphics g = Graphics.FromImage(canvas.Bmp.Bmp); g.DrawImage(tmp.Bmp, new System.Drawing.Rectangle(0, 0, canvas.Width, canvas.Height)); }
public FillTool(AbstractCanvas canvas) { this.canvas = canvas; }