void VotesPanel_Paint(object sender, PaintEventArgs e) { var perLeft = Helpers.GetPercent(VotesCountLeft, VotesCountTotal); var perRight = Helpers.GetPercent(VotesCountRight, VotesCountTotal); if (perLeft == 0 && perRight == 0) { return; } Rectangle bounds = ((Control)sender).ClientRectangle; GraphicsCache cache = new GraphicsCache(e); if (perLeft > 0) { Rectangle dem = bounds; dem.Width = (int)(Math.Round(dem.Width * perLeft)); cache.FillRectangle(cache.GetSolidBrush(ColorLeft), dem); } if (perRight > 0) { Rectangle rep = bounds; rep.Width = (int)(Math.Round(rep.Width * perRight)); rep.X = bounds.Right - rep.Width; cache.FillRectangle(cache.GetSolidBrush(ColorRight), rep); } Rectangle divider = bounds; divider.X += (int)(bounds.Width * 0.5m) - 1; divider.Width = 3; cache.FillRectangle(cache.GetSolidBrush(Color.FromArgb(200, Color.White)), divider); }
private void WaitDialogPaint(object sender, PaintEventArgs e) { Rectangle clipRectangle = e.ClipRectangle; GraphicsCache graphicsCache = new GraphicsCache(e); using (StringFormat stringFormat = new StringFormat()) { Brush solidBrush = graphicsCache.GetSolidBrush(LookAndFeelHelper.GetSystemColor(base.LookAndFeel, SystemColors.WindowText)); stringFormat.Alignment = (stringFormat.LineAlignment = StringAlignment.Center); stringFormat.Trimming = StringTrimming.EllipsisCharacter; if (base.LookAndFeel.ActiveLookAndFeel.ActiveStyle == ActiveLookAndFeelStyle.Skin) { ObjectPainter.DrawObject(graphicsCache, new SkinTextBorderPainter(base.LookAndFeel), new BorderObjectInfoArgs(null, clipRectangle, null)); } else { ControlPaint.DrawBorder3D(e.Graphics, clipRectangle, Border3DStyle.RaisedInner); } clipRectangle.X += 30; clipRectangle.Width -= 30; clipRectangle.Height /= 3; clipRectangle.Y += clipRectangle.Height / 2; e.Graphics.DrawString(this.title, this.BoldFont, solidBrush, clipRectangle, stringFormat); clipRectangle.Y += clipRectangle.Height; e.Graphics.DrawString(this.caption, this.RegularFont, solidBrush, clipRectangle, stringFormat); graphicsCache.Dispose(); } }
public override void Draw(GraphicsCache cache, Font font, Color foreColor, StringFormat format) { if (IsBreak) { return; } if (LabelInfoHelper.IsActionElement(this.InfoText.Text)) { DrawButton(cache); return; } if (LabelInfoHelper.EditorItem(this)) { DrawTestEditor(cache, this.InfoText.Text); return; } Font activeFont = IsActive ? new Font(font, font.Style | FontStyle.Underline) : null; StringFormat sformat = format == null?CreateStringFormat() : format; for (int i = 0; i < Count; i++) { Rectangle bounds = this[i].Bounds; bounds.Y = bounds.Y - ScrollTop; cache.DrawString(this[i].Text, IsActive ? activeFont : font, cache.GetSolidBrush(foreColor), bounds, sformat); } if (format == null) { sformat.Dispose(); } if (activeFont != null) { activeFont.Dispose(); } }
void DrawLink(CustomDrawCellEventArgs e, GraphicsCache cache, string text) { e.DrawDefault(); e.Handled = true; var brush = cache.GetSolidBrush(Color.FromArgb(5, 111, 206)); var font = cache.GetFont(e.Font, FontStyle.Underline); SizeF size = cache.CalcTextSize(text, font, StringFormat.GenericDefault, 0); float height = (float)e.Bounds.Height - size.Height; RectangleF textBounds = new RectangleF(e.Bounds.Left + 8, e.Bounds.Top + height / 2, size.Width + 4, size.Height); cache.DrawString(text, font, brush, Rectangle.Round(textBounds), StringFormat.GenericDefault); }
protected override void DrawCore(OverlayWindowCustomDrawContext context) { GraphicsCache cache = context.DrawArgs.Cache; TextRenderingHint prev = cache.TextRenderingHint; cache.TextRenderingHint = TextRenderingHint.AntiAlias; try { cache.DrawString(Text, font, cache.GetSolidBrush(Color), textPos); } finally { cache.TextRenderingHint = prev; } }
public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context) { Font cellfont = _cellFont; Rectangle cellBound = Rectangle.Inflate(rect, -1, -1); Brush cellbrush = Brushes.Black ; StringFormat sformat = null; if (epd.HasLongAbsence) { string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId); if (String.IsNullOrEmpty(s)) return; sformat = new StringFormat (); sformat.Alignment = StringAlignment.Center; sformat.LineAlignment = StringAlignment.Center; cache.DrawString(s, cellfont, cellbrush, cellBound, sformat); } else { List<string> lstValues = new List<string>(); List<EmployeeTimeRange> lst = epd.TimeList; if (lst != null && lst.Count > 0) { sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap); //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces | // StringFormatFlags.NoWrap; //cellbrush = Brushes.Black ; Brush absenceBrush = null; string str = String.Empty; int heightCell = (int)(cellBound.Height);// / 2); foreach (EmployeeTimeRange range in lst) { str = range.ToString();//TextParser.EmployeeTimeToString(range); Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize (); if (range.Absence == null) { cache.DrawString(str, cellfont, cellbrush, cellBound, sformat); } else { absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color)); cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat); } cellBound.Y += sf.Height + 2; heightCell -= (sf.Height + 2); if ((heightCell < 0)) break;// - (sf.Height + 2)) < 0) break; //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break; } } } }
private void WaitDialogPaint(object sender, PaintEventArgs e) { Rectangle clipRectangle = e.ClipRectangle; clipRectangle.Inflate(-1, -1); GraphicsCache cache = new GraphicsCache(e); using (StringFormat format = new StringFormat()) { Brush solidBrush = cache.GetSolidBrush(DevExpress.LookAndFeel.LookAndFeelHelper.GetSystemColor(base.LookAndFeel, SystemColors.WindowText)); format.Alignment = format.LineAlignment = StringAlignment.Center; format.Trimming = StringTrimming.EllipsisCharacter; if (base.LookAndFeel.ActiveLookAndFeel.ActiveStyle == ActiveLookAndFeelStyle.Skin) { ObjectPainter.DrawObject(cache, new SkinTextBorderPainter(base.LookAndFeel), new BorderObjectInfoArgs(null, clipRectangle, null)); } else { ControlPaint.DrawBorder3D(e.Graphics, clipRectangle, Border3DStyle.RaisedInner); } clipRectangle.X += 30; clipRectangle.Width -= 30; clipRectangle.Height /= 3; clipRectangle.Y += clipRectangle.Height / 2; e.Graphics.DrawString(this.title, this.boldFont, solidBrush, clipRectangle, format); clipRectangle.Y += clipRectangle.Height; e.Graphics.DrawString(this.caption, this.font, solidBrush, clipRectangle, format); cache.Dispose(); } }
public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context) { Font cellfont = _cellFont; Rectangle cellBound = Rectangle.Inflate(rect, -1, -1); Brush cellbrush = Brushes.Black; StringFormat sformat = null; if (epd.HasLongAbsence) { string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId); if (String.IsNullOrEmpty(s)) { return; } sformat = new StringFormat(); sformat.Alignment = StringAlignment.Center; sformat.LineAlignment = StringAlignment.Center; cache.DrawString(s, cellfont, cellbrush, cellBound, sformat); } else { List <string> lstValues = new List <string>(); List <EmployeeTimeRange> lst = epd.TimeList; if (lst != null && lst.Count > 0) { sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap); //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces | // StringFormatFlags.NoWrap; //cellbrush = Brushes.Black ; Brush absenceBrush = null; string str = String.Empty; int heightCell = (int)(cellBound.Height);// / 2); foreach (EmployeeTimeRange range in lst) { str = range.ToString();//TextParser.EmployeeTimeToString(range); Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize(); if (range.Absence == null) { cache.DrawString(str, cellfont, cellbrush, cellBound, sformat); } else { absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color)); cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat); } cellBound.Y += sf.Height + 2; heightCell -= (sf.Height + 2); if ((heightCell < 0)) { break; // - (sf.Height + 2)) < 0) break; } //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break; } } } }
void DrawBackground(GraphicsCache graphicsCache) { graphicsCache.FillRectangle(graphicsCache.GetSolidBrush(transparentColor), ClientRectangle); //graphicsCache.DrawRectangle(graphicsCache.GetPen(Color.Black), ClientRectangle); }