internal static void DoPaint(IGraphics g, Panel control, int addx, int addy) { g.FillRectangle(new Brush2(GraphUtils.ToColor2(control.BackColor)), 0, 0, control.Width, control.Height); if (control.BorderStyle == BorderStyle.FixedSingle) { g.DrawRectangle(new Pen2(GraphUtils.ToColor2(control.ForeColor)), 0, 0, control.Width, control.Height); } if (control is TableLayoutPanel) { DoPaint(g, (Control)control, addx, addy); } else { foreach (Control c in control.Controls) { if (c is BasicControl) { Debug.WriteLine("- BasicControl"); g.SetClippingMask(c.Width, c.Height, control.Location.X + c.Location.X + addx, control.Location.Y + c.Location.Y + addy); ((BasicControl)c).view.Print(g, c.Width, c.Height); } else { DoPaint(g, c); } } } }
internal static void DoPaint(IGraphics g, DataGridView grid) { Pen2 p = new Pen2(GraphUtils.ToColor2(grid.GridColor)); float x = grid.Location.X; float y = grid.Location.Y; Brush2 text = new Brush2(GraphUtils.ToColor2(grid.ColumnHeadersDefaultCellStyle.ForeColor)); Font2 headerFont = GraphUtils.ToFont2(grid.ColumnHeadersDefaultCellStyle.Font); StringFormat2 headerformat = new StringFormat2 { Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Center }; for (int c = 0; c < grid.Columns.Count; c++) { Brush2 header = new Brush2(GraphUtils.ToColor2(grid.Columns[c].HeaderCell.Style.BackColor)); if (header.Color.IsEmpty || header.Color == Color2.Transparent || header.Color == Color2.Black || header.Color.Name == "0") { header.Color = GraphUtils.ToColor2(grid.ColumnHeadersDefaultCellStyle.BackColor); } g.FillRectangle(header, x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight); g.DrawRectangle(p, x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight); g.DrawString(grid.Columns[c].HeaderText, headerFont, text, new Rectangle2(x, y, grid.Columns[c].Width, grid.ColumnHeadersHeight), headerformat); x += grid.Columns[c].Width; } y += grid.ColumnHeadersHeight; for (int r = 0; r < grid.Rows.Count; r++) { x = grid.Location.X; for (int c = 0; c < grid.Columns.Count; c++) { Color2 backcolor = GetBackColor(grid, r, c); Color2 forecolor = GetForeColor(grid, r, c); if (!backcolor.IsEmpty) { g.FillRectangle(new Brush2(backcolor), x, y, grid.Columns[c].Width, grid.Rows[r].Height); } g.DrawRectangle(p, x, y, grid.Columns[c].Width, grid.Rows[r].Height); object value = grid.Rows[r].Cells[c].Value; if (value != null) { Font2 font = GraphUtils.ToFont2(grid.DefaultCellStyle.Font); StringFormat2 cellformat = GetStringFormat(grid.Columns[c].DefaultCellStyle.Alignment); string t = value.ToString(); if (!string.IsNullOrEmpty(grid.Columns[c].DefaultCellStyle.Format)) { string format = "{0:" + grid.Columns[c].DefaultCellStyle.Format.ToLower() + "}"; t = string.Format(format, value); } g.DrawString(t, font, new Brush2(forecolor), new Rectangle2(x, y, grid.Columns[c].Width, grid.Rows[r].Height), cellformat); } x += grid.Columns[c].Width; } y += grid.Rows[r].Height; } }
private static void DoPaint(IGraphics g, Label label) { Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(label.Location), GraphUtils.ToSizeF2(label.Size)); g.FillRectangle(new Brush2(GraphUtils.ToColor2(label.BackColor)), rect.X, rect.Y, label.Width - label.Margin.Left - label.Margin.Right, label.Height - label.Margin.Top - label.Margin.Bottom); StringFormat2 format = new StringFormat2 { Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near }; g.DrawString(label.Text, GraphUtils.ToFont2(label.Font), new Brush2(GraphUtils.ToColor2(label.ForeColor)), rect, format); }
private static void DoPaint(IGraphics g, TextBox textBox) { g.FillRectangle(new Brush2(GraphUtils.ToColor2(textBox.BackColor)), textBox.Location.X, textBox.Location.Y, textBox.Width - textBox.Margin.Left - textBox.Margin.Right, textBox.Height - textBox.Margin.Top - textBox.Margin.Bottom); Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(textBox.Location), GraphUtils.ToSize2(textBox.Size)); StringFormat2 format = new StringFormat2 { Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near }; g.DrawString(textBox.Text, GraphUtils.ToFont2(textBox.Font), new Brush2(GraphUtils.ToColor2(textBox.ForeColor)), rect, format); }
public static void DoPaintBackground(IGraphics g, Control control) { if (g is CGraphics && (!control.BackColor.IsEmpty && control.BackColor != Color.Transparent)) { g.FillRectangle(new Brush2(GraphUtils.ToColor2(control.BackColor)), control.Location.X, control.Location.Y, control.Width, control.Height); } (control as BasicControl)?.view.Print(g, control.Width, control.Height); if (control is Panel && ((Panel)control).BorderStyle == BorderStyle.FixedSingle) { g.DrawRectangle(new Pen2(GraphUtils.ToColor2(control.ForeColor)), control.Location.X, control.Location.Y, control.Width, control.Height); } }
private static void DoPaint(IGraphics g, RichTextBox textBox) { g.FillRectangle(new Brush2(GraphUtils.ToColor2(textBox.BackColor)), textBox.Location.X, textBox.Location.Y, textBox.Width - textBox.Margin.Left - textBox.Margin.Right, textBox.Height - textBox.Margin.Top - textBox.Margin.Bottom); string[] lines = textBox.Text.Split('\n'); float h = 0; foreach (string t in lines) { g.DrawString(t, GraphUtils.ToFont2(textBox.Font), new Brush2(GraphUtils.ToColor2(textBox.ForeColor)), textBox.Location.X, textBox.Location.Y + h); h += textBox.Font.Height * 0.8f; } }
private static Color2 GetForeColor(DataGridView grid, int r, int c) { if (grid.Rows[r].Cells[c].Selected) { return(GraphUtils.ToColor2(grid.Rows[r].Cells[c].InheritedStyle.SelectionForeColor)); } Color2 forecolor = Color2.Transparent; if (!grid.Rows[r].Cells[c].Style.ForeColor.IsEmpty) { forecolor = GraphUtils.ToColor2(grid.Rows[r].Cells[c].Style.ForeColor); } if (!grid.Columns[c].DefaultCellStyle.ForeColor.IsEmpty) { forecolor = GraphUtils.ToColor2(grid.Columns[c].DefaultCellStyle.ForeColor); } return(forecolor); }