private void TuRysujemy_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Media.Color oColor = ((SolidColorBrush)Kolor.Background).Color; System.Drawing.Color nColor = System.Drawing.Color.FromArgb(oColor.A, oColor.R, oColor.G, oColor.B); System.Drawing.Pen p = new System.Drawing.Pen(nColor, float.Parse(Wielkosc.Text)); if (startPainting && !drawRectangle) { g.DrawLine(p, new System.Drawing.Point(initX ?? e.X, initY ?? e.Y), new System.Drawing.Point(e.X, e.Y)); initX = e.X; initY = e.Y; } if (startPainting && drawRectangle) { System.Drawing.Point tempP = e.Location; int x = Math.Min(wybPunkt.X, tempP.X); int y = Math.Min(wybPunkt.Y, tempP.Y); int w = Math.Abs(tempP.X - wybPunkt.X); int h = Math.Abs(tempP.Y - wybPunkt.Y); mProstokat = new System.Drawing.Rectangle(x, y, w, h); g.DrawRectangle(p, mProstokat); TuRysujemy.Invalidate(); } }
public MainWindow() { InitializeComponent(); g = TuRysujemy.CreateGraphics(); }