protected override void OnPaint(PaintEventArgs e) { GraphicsPath gr = RoundedRectangle.Create(this.ClientRectangle, 10, RoundedRectangle.RectangleCorners.All); this.Region = new Region(gr); base.OnPaint(e); }
private void NotificationForm_Load(object sender, EventArgs e) { _innerPath = RoundedRectangle.Create(1, 1, this.Width - 3, this.Height - 3, 2); _outlinePath = RoundedRectangle.Create(0, 0, this.Width, this.Height, 2); Region = new Region(_outlinePath); _opening = true; _animationTimer.Interval = 50; _animationTimer.Start(); }
protected override void OnPaint(PaintEventArgs e) { //Responsiveness when window or container resizes label1.MaximumSize = new Size((this.Width - panel1.Width - 21) / 2, 0); label1.Width = this.Width - panel1.Width - 21; if (label1.Height < panel2.Height + 1) { this.MinimumSize = new Size(0, panel2.Height + 11 + 15); this.Height = panel2.Height + 11 + 15; } else { this.MinimumSize = new Size(0, label1.Height + 10 + 15); this.Height = label1.Height + 10 + 15; } if (!isAdded) { messageBottom.Size = new Size(0, 15); messageBottom.Dock = DockStyle.Bottom; messageBottom.Padding = new Padding(0, 0, 47, 0); messageBottom.BackColor = Color.Transparent; messageBottom.ForeColor = Color.White; time.Dock = DockStyle.Right; SetTimeWidth(); msgStatus.Dock = DockStyle.Right; msgStatus.SizeMode = PictureBoxSizeMode.StretchImage; msgStatus.Size = new Size(15, 15); msgStatus.Padding = new Padding(0); messageBottom.Controls.Add(time); messageBottom.Controls.Add(msgStatus); this.Controls.Add(messageBottom); SetMsgStatus(); isAdded = true; } GraphicsPath gr = RoundedRectangle.Create(panel2.ClientRectangle, 16, RoundedRectangle.RectangleCorners.All); panel2.Region = new Region(gr); GraphicsPath gr1 = RoundedRectangle.Create(pictureBox1.ClientRectangle, 16, RoundedRectangle.RectangleCorners.All); pictureBox1.Region = new Region(gr1); GraphicsPath path = RoundedRectangle.Create(label1.ClientRectangle, 5, RoundedRectangle.RectangleCorners.All); label1.Region = new Region(path); base.OnPaint(e); }
private void UpdatePaths() { if (_outerPath != null) { _outerPath.Dispose(); _innerPath.Dispose(); } _outerPath = RoundedRectangle.Create(new Rectangle(0, 0, Width - 1, Height - 1), 3, RoundedRectangle.RectangleCorners.All); _innerPath = RoundedRectangle.Create(new Rectangle(1, 1, Width - 3, Height - 3), 3, RoundedRectangle.RectangleCorners.All); }
/// <summary> /// Построение пути для прямоугольника со скругленными углами /// </summary> /// <param name="figure">Фигура для присвоения геометрии</param> /// <param name="radius">Радиус скругления (от 0 до 0.5)</param> public static void BuildRoundedRectangleGeometry(Figure figure, float radius) { var path = new SerializableGraphicsPath(); path.Path.AddPath(RoundedRectangle.Create(new RectangleF(-0.5f, -0.5f, 1, 1), radius <0 ? 0 : radius> 0.5f ? 0.5f : radius), false); figure.Geometry = new PrimitiveGeometry(path, AllowedOperations.All ^ AllowedOperations.Vertex) { Name = "RoundedRectangle" }; }
protected override void OnPaintBackground(PaintEventArgs e) { e.Graphics.Clear(Color.White); const int margin = 15; GraphicsPath overlay = RoundedRectangle.Create(margin, margin, Width - 2 * margin, Height - 2 * margin); e.Graphics.DrawPath(new Pen(Color.Red) { Width = Thickness }, overlay); }
protected override void OnPaint(PaintEventArgs e) { if (!isPainted) { GraphicsPath path = RoundedRectangle.Create(this.ClientRectangle, 5, RoundedRectangle.RectangleCorners.All); this.Region = new Region(path); isPainted = true; } base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { GraphicsPath gr = RoundedRectangle.Create(panel2.ClientRectangle, 19, RoundedRectangle.RectangleCorners.All); panel2.Region = new Region(gr); GraphicsPath gr1 = RoundedRectangle.Create(pictureBox1.ClientRectangle, 19, RoundedRectangle.RectangleCorners.All); pictureBox1.Region = new Region(gr1); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var borderPath = RoundedRectangle.Create(2, 2, this.Width - 5, this.Height - 5); using (var borderPen = new Pen(Brushes.White)) { borderPen.Width = 2; e.Graphics.DrawPath(borderPen, borderPath); } }
void draw_card(EncounterCard card, int count, bool topmost, RectangleF rect, Graphics g) { int alpha = (card != null) ? 255 : 100; GraphicsPath gp = RoundedRectangle.Create(rect, fRadius, RoundedRectangle.RectangleCorners.TopLeft | RoundedRectangle.RectangleCorners.TopRight); using (Brush b = new SolidBrush(Color.FromArgb(alpha, 54, 79, 39))) { g.FillPath(b, gp); } g.DrawPath(Pens.White, gp); float card_delta_y = Font.Height * 1.5f; RectangleF text_rect = new RectangleF(rect.X + fRadius, rect.Y, rect.Width - (2 * fRadius), card_delta_y); if (card != null) { string title = card.Title; if (count > 1) { title = "(" + count + "x) " + title; } Color text_colour = (card != fHoverCard) ? Color.White : Color.PaleGreen; using (Brush b = new SolidBrush(text_colour)) { using (Font f = new Font(Font, Font.Style | FontStyle.Bold)) { g.DrawString(title, f, b, text_rect, fTitle); } g.DrawString(card.Info, Font, b, text_rect, fInfo); } if (topmost) { float dx = fRadius * 0.2f; RectangleF content = new RectangleF(rect.X + dx, rect.Y + text_rect.Height, rect.Width - (2 * dx), rect.Height - text_rect.Height); using (Brush b = new SolidBrush(Color.FromArgb(225, 231, 197))) { g.FillRectangle(b, content); } string msg = "Click on a card to move it to the front of the deck."; g.DrawString(msg, Font, Brushes.Black, content, fCentred); } } else { int remaining = fCards.Count - fVisibleCards; g.DrawString("(" + remaining + " more cards)", Font, Brushes.White, text_rect, fCentred); } }
private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device) { // the render loop will call device.BeginScene() and device.EndScene() for us if (!device.IsDrawing) { _initializeGraphicObjects = true; return; } // clear the scene / fill it with our background device.ClearScene(_backgroundColor); // text // the background is dynamically adjusted to the text's size device.DrawTextWithBackground("FPS: " + device.FramesPerSecond, 10, 10, _font, _redBrush, _blackBrush); // primitives device.DrawCircle(100, 100, 50, 2.0f, _redBrush); device.DrawDashedCircle(250, 100, 50, 2.0f, _greenBrush); // Rectangle.Create offers a method to create rectangles with x, y, width, heigth device.DrawRectangle(Rectangle.Create(350, 50, 100, 100), 2.0f, _blueBrush); device.DrawRoundedRectangle(RoundedRectangle.Create(500, 50, 100, 100, 6.0f), 2.0f, _redBrush); device.DrawTriangle(650, 150, 750, 150, 700, 50, _greenBrush, 2.0f); // lines device.DrawLine(50, 175, 750, 175, 2.0f, _blueBrush); device.DrawDashedLine(50, 200, 750, 200, 2.0f, _redBrush); // outlines & filled device.OutlineCircle(100, 275, 50, 4.0f, _redBrush, _blackBrush); device.FillCircle(250, 275, 50, _greenBrush); device.OutlineRectangle(Rectangle.Create(350, 225, 100, 100), 4.0f, _blueBrush, _blackBrush); _gradient.SetRange(500, 225, 600, 325); device.FillRoundedRectangle(RoundedRectangle.Create(500, 225, 100, 100, 6.0f), _gradient); device.FillTriangle(650, 325, 750, 325, 700, 225, _greenBrush); // images device.DrawImage(_image, 310, 375); }
public Magnify2() { DoubleBuffered = true; BackColor = Color.FromArgb(255, 48, 48, 48); bmpSrc = new Bitmap(80, 80, PixelFormat.Format32bppArgb); gfxSrc = Graphics.FromImage(bmpSrc); gfxSrc.InterpolationMode = InterpolationMode.NearestNeighbor; Size = new Size(344, 400); Location = Point.Empty; Region = new Region(RoundedRectangle.Create(0, 0, Width, Height, 7)); cobine.ButtonType = ButtonType.Default; cobine.Size = new Size(100, 26); cobine.Location = new Point(Width - 14 - cobine.Width, Height - 36); cobine.Text = @"Capture"; cobine.MouseDown += combine_Click; var cobineToolTip = new ToolTip { ShowAlways = true }; cobineToolTip.SetToolTip(cobine, "Capture picture and put it to library."); Controls.Add(cobine); snap.ButtonType = ButtonType.Default; snap.Size = new Size(120, 26); snap.Location = new Point(Width - 14 - snap.Width - 10 - cobine.Width, Height - 36); snap.Text = @"Capture & Edit"; //snap.Click += new EventHandler(snap_Click); snap.MouseDown += snap_Click; var snapToolTip = new ToolTip { ShowAlways = true }; snapToolTip.SetToolTip(snap, "Capture picture and edit it."); Controls.Add(snap); closeButton.Location = new Point(Width - closeButton.Width - 10, 7); closeButton.Click += closeButton_Click; Controls.Add(closeButton); MouseDown += Form1_MouseDown; MouseUp += Form1_MouseUp; MouseMove += Form1_MouseMove; }
protected override void OnPaint(PaintEventArgs e) { var G = e.Graphics; float max = ValueMax ?? (Values.Count() > 0 ? Values.Max() : 0); float min = ValueMin ?? (Values.Count() > 0 ? Values.Min() : 0); float averagegeCount = (max - min) / ValueStripes; float currentCount = max; G.SmoothingMode = SmoothingMode.HighQuality; float startWidthPosition = ValueMax == null ? GraphicsHelper.GetTextWidthInPixels(Values.Select(a => a.ToString()).OrderByDescending(a => a.Length).FirstOrDefault(), FontText) : GraphicsHelper.GetTextWidthInPixels(ValueMax.ToString(), FontText); float chartHeight = Height - 17; float itemHeight = 10; G.FillPath(fillheaderColor, RoundedRectangle.Create(0, 0, Width - 1, Height - 1, 4)); for (int i = 0; i <= ValueStripes; i++) { G.DrawLine(new Pen(ColorStripes, SizeStripes), startWidthPosition, itemHeight, Width, itemHeight); G.DrawString((Math.Floor(currentCount)).ToString(), FontText, new SolidBrush(ColorText), 0, itemHeight - 7); itemHeight += chartHeight / ValueStripes; currentCount -= averagegeCount; } float lastItemHeight = (chartHeight - (chartHeight / (max - min) * (Values.FirstOrDefault() - min))) + 10; float lastItemWidth = startWidthPosition; float itemWidth = startWidthPosition; foreach (var value in Values) { var valueMin = value - min; var item = chartHeight - (chartHeight / (max - min) * valueMin); item = item == chartHeight ? chartHeight + 10 : item + 10; var currentBrush = FoxSettings.UpColor; G.DrawLine(new Pen(currentBrush.Color, SizeValues), lastItemWidth, lastItemHeight, itemWidth, item); G.FillEllipse(currentBrush, itemWidth - (SizeValues / 2), item - (SizeValues / 2), SizeValues, SizeValues); lastItemHeight = item; lastItemWidth = itemWidth; itemWidth += Width / Values.Count(); } }
private void draw_card(EncounterCard card, int count, bool topmost, RectangleF rect, Graphics g) { int num = (card != null ? 255 : 100); GraphicsPath graphicsPath = RoundedRectangle.Create(rect, this.fRadius, RoundedRectangle.RectangleCorners.TopLeft | RoundedRectangle.RectangleCorners.TopRight); using (Brush solidBrush = new SolidBrush(Color.FromArgb(num, 54, 79, 39))) { g.FillPath(solidBrush, graphicsPath); } g.DrawPath(Pens.White, graphicsPath); float height = (float)this.Font.Height * 1.5f; RectangleF rectangleF = new RectangleF(rect.X + this.fRadius, rect.Y, rect.Width - 2f * this.fRadius, height); if (card == null) { int num1 = this.fCards.Count - this.fVisibleCards; g.DrawString(string.Concat("(", num1, " more cards)"), this.Font, Brushes.White, rectangleF, this.fCentred); } else { string title = card.Title; if (count > 1) { object[] objArray = new object[] { "(", count, "x) ", title }; title = string.Concat(objArray); } using (Brush brush = new SolidBrush((card != this.fHoverCard ? Color.White : Color.PaleGreen))) { using (System.Drawing.Font font = new System.Drawing.Font(this.Font, this.Font.Style | FontStyle.Bold)) { g.DrawString(title, font, brush, rectangleF, this.fTitle); } g.DrawString(card.Info, this.Font, brush, rectangleF, this.fInfo); } if (topmost) { float single = this.fRadius * 0.2f; RectangleF rectangleF1 = new RectangleF(rect.X + single, rect.Y + rectangleF.Height, rect.Width - 2f * single, rect.Height - rectangleF.Height); using (Brush solidBrush1 = new SolidBrush(Color.FromArgb(225, 231, 197))) { g.FillRectangle(solidBrush1, rectangleF1); } string str = "Click on a card to move it to the front of the deck."; g.DrawString(str, this.Font, Brushes.Black, rectangleF1, this.fCentred); return; } } }
protected void DrawRect(Graphics gr, Rectangle rect, Color backColor) { int shadow = 2; SmoothingMode sm = gr.SmoothingMode; gr.SmoothingMode = SmoothingMode.HighQuality; GraphicsPath shadowPath = RoundedRectangle.Create(rect.Left + shadow, rect.Top + shadow, rect.Width, rect.Height); gr.FillPath(Brushes.Gray, shadowPath); GraphicsPath boxPath = RoundedRectangle.Create(rect.Left, rect.Top, rect.Width, rect.Height); gr.FillPath(new SolidBrush(backColor), boxPath); gr.DrawPath(Pens.Black, boxPath); gr.SmoothingMode = sm; }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); _bufferContext.MaximumBuffer = new Size(this.Width + 1, this.Height + 1); // Use handle here _bufGraphics = _bufferContext.Allocate(this.CreateGraphics(), this.ClientRectangle); _bufGraphics.Graphics.SmoothingMode = SmoothingMode.AntiAlias; _bufGraphics.Graphics.CompositingQuality = CompositingQuality.HighQuality; this.Region = new Region(this.ClientRectangle); using (GraphicsPath GP = RoundedRectangle.Create(this.ClientRectangle, _cornerRadius)) { this.Region = new Region(GP); } }
public override void Render(Graphics graphics, Rectangle rect) { if (Model.Children.Count > 0) { var ellipseRect = GetRect(rect); var path = RoundedRectangle.Create(ellipseRect, 8); using (var brush = new SolidBrush(GetBrushColor())) { graphics.FillPath(brush, path); RenderTextCenter(graphics, Brushes.Black, ellipseRect, this.Font, Model.Children.Count.ToString()); using (var pen = new Pen(GetPenColor(), 2)) { graphics.DrawPath(pen, path); } } } }
public override void Render(Graphics graphics, Rectangle rect) { var path = RoundedRectangle.Create(rect, 1); using (var brush = new SolidBrush(GetBrushColor())) { graphics.FillPath(brush, path); } using (var pen = new Pen(GetPenColor(), 2)) { graphics.DrawPath(pen, path); } using (var brush = new SolidBrush(GetTextBrushColor())) { RenderTextCenter(graphics, brush, rect, this.Font, Model.Text); } }
private void InitRules() { CreateNewRuleManager(); _format = (StringFormat.GenericDefault.Clone() as StringFormat); _format.Trimming = StringTrimming.EllipsisCharacter; _format.LineAlignment = StringAlignment.Center; _format.FormatFlags = _format.FormatFlags | StringFormatFlags.NoWrap; _backgroundBrush = new SolidBrush(lbRules.BackColor); _selectionBrush = new SolidBrush(Color.FromArgb(240, 245, 251)); _borderPen = new Pen(Color.FromArgb(150, 160, 180)); _openBorderPen = new Pen(_selectionBrush.Color); _panelBorder = RoundedRectangle.Create(panelDetails.ClientRectangle.Left, panelDetails.ClientRectangle.Top, panelDetails.ClientRectangle.Width - 1, panelDetails.ClientRectangle.Height - 1, 5); panelDetails.Visible = false; }
private void DrawSurface(IGraphics g, bool onScreen, Style style) { var backgroundRectangle = new Rectangle(Location.X, Location.Y, Size.Width, Size.Height); var backGroundPath = RoundedRectangle.Create(backgroundRectangle, 5); if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty) { shadowBrush.Color = style.ShadowColor; g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height); g.FillPath(shadowBrush, backGroundPath); g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height); } Brush backgroundBrush; switch (style.SystemBoundaryGradientStyle) { case GradientStyle.Vertical: backgroundBrush = new LinearGradientBrush(backgroundRectangle, style.SystemBoundaryGradientColor, style.SystemBoundaryBackColor, LinearGradientMode.Vertical); break; case GradientStyle.Diagonal: backgroundBrush = new LinearGradientBrush(backgroundRectangle, style.SystemBoundaryGradientColor, style.SystemBoundaryBackColor, LinearGradientMode.BackwardDiagonal); break; case GradientStyle.Horizontal: backgroundBrush = new LinearGradientBrush(backgroundRectangle, style.SystemBoundaryGradientColor, style.SystemBoundaryBackColor, LinearGradientMode.Horizontal); break; default: backgroundBrush = new SolidBrush(style.SystemBoundaryBackColor); break; } using (backGroundPath) using (backgroundBrush) using (var borderPen = new Pen(style.SystemBoundaryBorderColor, style.SystemBoundaryBorderWidth)) { g.FillPath(backgroundBrush, backGroundPath); g.DrawPath(borderPen, backGroundPath); } }
public override void Render(Graphics graphics, Rectangle rect) { using (var font = new Font("Verdana", 8)) { var ellipseRect = GetRect(rect); var path = RoundedRectangle.Create(ellipseRect, 5, RoundedRectangle.RectangleCorners.TopRight | RoundedRectangle.RectangleCorners.BottomRight); using (var brush = new SolidBrush(GetBrushColor())) { graphics.FillPath(brush, path); RenderTextCenter(graphics, Brushes.White, ellipseRect, font, this.Model.TraceNode.TimeTaken); using (var pen = new Pen(GetPenColor(), 1)) { graphics.DrawPath(pen, path); } } } }
private void NotificationForm_Load(object sender, EventArgs e) { _innerPath = RoundedRectangle.Create(1, 1, this.Width - 2, this.Height - 2, 2); _outlinePath = RoundedRectangle.Create(0, 0, this.Width, this.Height, 2); Region = new Region(_outlinePath); Rectangle workArea = Screen.GetWorkingArea(Point.Empty); _targetRectangle = new Rectangle(workArea.Width - this.Width, workArea.Height - this.Height, this.Width, this.Height); this.Opacity = 0.0; SetBounds(_targetRectangle.Left, _targetRectangle.Top, _targetRectangle.Width, _targetRectangle.Height); _openingTop = this.Top; _openingStep = (this.Top - _targetRectangle.Top) / 10.0; _opening = true; _animationTimer.Interval = 50; _animationTimer.Start(); _closeTimer.Interval = 5000; _closeTimer.Start(); }
private void DrawEntry(IHistoryEntry entry, DataGridViewCellPaintingEventArgs e, int i) { var color = DecisionStateColor.ConvertStateToColor(entry.State); var rectangle = new Rectangle( e.CellBounds.X + RectangleMargin, e.CellBounds.Y + (i * dataGridView1.RowTemplate.Height) + RectangleMargin, e.CellBounds.Width - (2 * RectangleMargin), dataGridView1.RowTemplate.Height - 2 * RectangleMargin); var path = RoundedRectangle.Create(rectangle); e.Graphics.FillPath(new SolidBrush(color), path); //e.Graphics.FillRectangle(new SolidBrush(color), rectangle); var text = entry.Decision.Name; var temp = text; var stringSize = e.Graphics.MeasureString(text, DefaultFont); while (stringSize.Width > rectangle.Width) { if (text.Length < 2) { break; } text = text.Substring(0, text.Length - 2); temp = text + ".."; stringSize = e.Graphics.MeasureString(temp, DefaultFont); } var horizontalMargin = (rectangle.Width - stringSize.Width) / 2; var verticalMargin = (rectangle.Height - stringSize.Height) / 2; var textRectangle = new RectangleF(rectangle.X + horizontalMargin, rectangle.Y + verticalMargin, stringSize.Width, stringSize.Height); e.Graphics.DrawString(temp, DefaultFont, Brushes.Black, textRectangle); }
public override void Draw(Graphics gr) { SmoothingMode sm = gr.SmoothingMode; gr.SmoothingMode = SmoothingMode.AntiAlias; StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; Font font = new Font(SwissPainterSettings.FontFamily, SwissPainterSettings.FontSize * 1.2f, FontStyle.Bold); GraphicsPath shadowPath = RoundedRectangle.Create(Left + SwissPainterSettings.ShadowStep, Top + SwissPainterSettings.ShadowStep, Size.Width, Size.Height); gr.FillPath(new SolidBrush(SwissPainterSettings.ShadowColor), shadowPath); GraphicsPath boxPath = RoundedRectangle.Create(Left, Top, Size.Width, Size.Height); gr.FillPath(new SolidBrush(SwissPainterSettings.RoundLabelColors.BackColor), boxPath); gr.DrawPath(new Pen(SwissPainterSettings.BorderColor), boxPath); gr.DrawString(Label, font, new SolidBrush(SwissPainterSettings.RoundLabelColors.ForeColor), ClientRect, sf); gr.SmoothingMode = sm; }
public void Run() { var gfx = _graphics; // little shortcut while (true) { gfx.BeginScene(); // call before you start any drawing gfx.ClearScene(_gray); // set the background of the scene (can be transparent) gfx.DrawTextWithBackground(_font, _red, _black, 10, 10, "FPS: " + gfx.FPS); gfx.DrawCircle(_red, 100, 100, 50, 2); gfx.DashedCircle(_green, 250, 100, 50, 2); // Rectangle.Create takes x, y, width, height instead of left top, right, bottom gfx.DrawRectangle(_blue, Rectangle.Create(350, 50, 100, 100), 2); gfx.DrawRoundedRectangle(_red, RoundedRectangle.Create(500, 50, 100, 100, 6), 2); gfx.DrawTriangle(_green, 650, 150, 750, 150, 700, 50, 2); gfx.DrawLine(_blue, 50, 175, 750, 175, 2); gfx.DashedLine(_red, 50, 200, 750, 200, 2); gfx.OutlineCircle(_black, _red, 100, 275, 50, 4); gfx.FillCircle(_green, 250, 275, 50); // parameters will always stay in this order: outline color, inner color, position, stroke gfx.OutlineRectangle(_black, _blue, Rectangle.Create(350, 225, 100, 100), 4); gfx.FillRoundedRectangle(_red, RoundedRectangle.Create(500, 225, 100, 100, 6)); gfx.FillTriangle(_green, 650, 325, 750, 325, 700, 225); // you could also scale the image on the fly gfx.DrawImage(_image, 310, 375); gfx.EndScene(); } }
protected override void OnDrawItem(DrawListViewItemEventArgs e) { var item = (CustomListViewItem)Items[e.ItemIndex]; if (item.ImageList == null) { return; } var img = item.ImageList.Images[item.ImageIndex]; e.Graphics.DrawImage(img, item.Bounds.X, item.Bounds.Y); e.Graphics.DrawRectangle(pBlack, item.Bounds.X, item.Bounds.Y, img.Width, img.Height); if (item.Selected && item.SelectionOpacity < 255) { item.SelectionOpacity += 5; } if (!item.Selected && item.SelectionOpacity > 0) { item.SelectionOpacity -= 5; } Pen pBlue = new Pen(Color.FromArgb(item.SelectionOpacity, Color.DodgerBlue)) { Width = 3 }; GraphicsPath rounded = RoundedRectangle.Create(item.Bounds.X - 1, item.Bounds.Y - 1, img.Width + 2, img.Height + 1, 5); e.Graphics.DrawPath(pBlue, rounded); base.OnDrawItem(e); if (item.SelectionOpacity > 0 && item.SelectionOpacity < 255) { Invalidate(); } }
protected override void OnPaint(PaintEventArgs e) { G = e.Graphics; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.HighQuality; SolidBrush currentBrush; if (isMouseDown) { currentBrush = downColor; } else { currentBrush = fillColor; } LinearGradientBrush linGrBrush = GraphicsHelper.CreateGradient(Width, Height, currentBrush); G.DrawPath(new Pen(currentBrush), RoundedRectangle.Create(0, 0, Width, Height, 4)); G.FillPath(linGrBrush, RoundedRectangle.Create(0, 0, Width, Height, 4)); G.DrawString(Text, textFont, textColor, new Point(Width / 2, Height / 2), stringformat); }
protected override void OnPaint(PaintEventArgs e) { GraphicsPath gr = RoundedRectangle.Create(panel2.ClientRectangle, 22, RoundedRectangle.RectangleCorners.All); panel2.Region = new Region(gr); GraphicsPath gr1 = RoundedRectangle.Create(pictureBox1.ClientRectangle, 22, RoundedRectangle.RectangleCorners.All); pictureBox1.Region = new Region(gr1); LeftIndicator.BackColor = Color.FromArgb(80, 80, 80); LeftIndicator.Dock = DockStyle.Left; LeftIndicator.Width = 2; if (!isPaddingSet) { panel3.Controls.Add(LeftIndicator); isPaddingSet = true; } base.OnPaint(e); }
protected override void DrawBar(Graphics graphics) { if (this.Width - KnobImage.Width > 1) { int barHeight = this.Height / 3; int x = KnobImage.Width / 2; int y = this.Height / 2 - barHeight / 2; // Draw bevel Rectangle rect = new Rectangle(x, y, this.Width - KnobImage.Width, barHeight); var path = RoundedRectangle.Create(rect, _CORNER_RADIUS); var brush = new LinearGradientBrush(rect, _upperBevelColor, _lowerBevelColor, 90f); graphics.FillPath(brush, path); // Draw full bar rect.Inflate(0, -1); path = RoundedRectangle.Create(rect, _CORNER_RADIUS); graphics.FillPath(_barPlainBrush, path); // Draw partial color path = RoundedRectangle.Create(rect.X, rect.Y, KnobX + KnobImage.Width / 2, rect.Height, _CORNER_RADIUS); graphics.FillPath(_progressBrush, path); } }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; e.Graphics.DrawString(Text, UI.SmallFont, Brushes.Black, new Rectangle(0, 0, Width - 60, Height), sf); if (!Focused) { return; } using (var border = RoundedRectangle.Create(1, 1, Width - 6 - clearButton.Width, Height - 4, 5)) { using (var white = new Pen(Brushes.Green)) { white.Width = 1; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.DrawPath(white, border); } } }