public override void Draw(Graphic g) { var pos = (_c.Position + _c.Margin.TopLeft) * _c.Scale; g.DrawRectangle(pos, _c.Size * _c.Scale, true, Style.Background); g.DrawRectangle(pos, _c.Size * _c.Scale, false, ForegroundColor); g.DrawRectangle(pos, _c.Size.Width * _c.Current * _c.Scale, _c.Size.Height * _c.Scale, true, ForegroundColor); }
public override void Draw(Graphic g) { g.DrawRectangle((_c.Position + _c.Margin.TopLeft) * _c.Scale, _c.Size * _c.Scale, false, ForegroundColor); if (!_c.Value) return; var size = _c.Size * .5f; var position = _c.Position + ((_c.Size - size).ToVector2() / 2) + _c.Margin.TopLeft; g.DrawRectangle(position * _c.Scale, size * _c.Scale, true, ForegroundColor); }
public override void Draw(Graphic g) { var position = _c.Position * _c.Scale; var size = _c.Size * _c.Scale; g.DrawRectangle(position, size, true, Style.Background); }
public void Draw() { // Деревянные границы graphic.SetColor(0.5f, 0.27f, 0.1f); graphic.DrawRectangle( room.top + border, room.bottom - border, room.left - border, room.right + border ); // Тёмно зелёное поле graphic.SetColor(0f, 0.5f, 0.3f); graphic.DrawRectangle( room.top, room.bottom, room.left, room.right ); }
public override void Draw(Graphic g) { g.DrawRectangle(_control.Bounds, true, ForegroundColor); }
private void pictureBox_MouseDown(object sender, MouseEventArgs e) // нажать клавишу { var wfactor = (double)MyImage.Width / pictureBox.ClientSize.Width; var hfactor = (double)MyImage.Height / pictureBox.ClientSize.Height; var resizeFactor = Math.Max(wfactor, hfactor); ResizeImage = resizeFactor; if (e.Button == MouseButtons.Left) // Проверить какая кнопка нажата { X1Painting = Convert.ToInt32(e.X * ResizeImage); Y1Painting = Convert.ToInt32(e.Y * ResizeImage); } if (e.Button == MouseButtons.Right && X1Painting != -1 && Y1Painting != -1) // проверить была ли нажата левая кнопка изначально { X2Painting = Convert.ToInt32(e.X * ResizeImage); Y2Painting = Convert.ToInt32(e.Y * ResizeImage); } if (X1Painting > -1 && Y1Painting > -1 && X2Painting > -1 && Y2Painting > -1) // если кнопки нажаты координаты >= 0 { if (MenuItemLine.Checked) // рисуем { if (Graphic != null) { Graphic.Dispose(); } Pen BackPen = new Pen(Color.Red, (float)(2 * ResizeImage)); Graphic = Graphics.FromImage(this.pictureBox.Image); Graphic.DrawLine(BackPen, X1Painting, Y1Painting, X2Painting, Y2Painting); X1Painting = Y1Painting = X2Painting = Y2Painting = -1; countChangePainting++; } if (MenuItemEllipse.Checked) { if (Graphic != null) { Graphic.Dispose(); } Pen BackPen = new Pen(Color.Blue, (float)(2 * ResizeImage)); Graphic = Graphics.FromImage(this.pictureBox.Image); Graphic.DrawEllipse(BackPen, X1Painting, Y1Painting, X2Painting - X1Painting, Y2Painting - Y1Painting); X1Painting = Y1Painting = X2Painting = Y2Painting = -1; countChangePainting++; } if (MenuItemRectangle.Checked) { if (Graphic != null) { Graphic.Dispose(); } Pen BackPen = new Pen(Color.Lime, (float)(2 * ResizeImage)); Graphic = Graphics.FromImage(this.pictureBox.Image); Graphic.DrawRectangle(BackPen, X1Painting, Y1Painting, X2Painting - X1Painting, Y2Painting - Y1Painting); X1Painting = Y1Painting = X2Painting = Y2Painting = -1; countChangePainting++; } } if (e.Button == MouseButtons.Left && groupBoxPixelValue.Visible) // Проверить какая кнопка нажата { CoordX1GetPixel = e.X; CoordY1GetPixel = e.Y; DistancePixel = true; } pictureBox.Invalidate(); }