コード例 #1
0
 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);
             }
         }
     }
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     // TODO reduce the resolution to fit (?)
     try {
         Image img = Image.GetInstance(GraphUtils.ToBitmap(image), System.Drawing.Imaging.ImageFormat.Tiff);
         img.SetAbsolutePosition(x, currentHeight - img.ScaledHeight - y);
         template.AddImage(img);
     } catch { }
 }
コード例 #4
0
 private static PointF[] ToPointsF(Point2[] p)
 {
     PointF[] result = new PointF[p.Length];
     for (int i = 0; i < result.Length; i++)
     {
         result[i] = GraphUtils.ToPointF(p[i]);
     }
     return(result);
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
        public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
        {
            Image img = null;

            try {
                img = Image.GetInstance(GraphUtils.ToBitmap(image), System.Drawing.Imaging.ImageFormat.Tiff);
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
            }
            if (img != null)
            {
                img.ScaleAbsolute(width, height);
                img.SetAbsolutePosition(x, currentHeight - img.ScaledHeight - y);
                template.AddImage(img);
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: SvgGraphics.cs プロジェクト: jdrudolph/compbio-base
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="font"></param>
        /// <param name="width"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public SizeF MeasureString(string text, Font2 font, int width, StringFormat2 format)
        {
            TextFormatFlags flags = new TextFormatFlags();

            if (format != null)
            {
                switch (format.Alignment)
                {
                case StringAlignment2.Center:
                    flags = TextFormatFlags.HorizontalCenter;
                    break;

                case StringAlignment2.Near:
                    flags = TextFormatFlags.Left | TextFormatFlags.Top;
                    break;

                case StringAlignment2.Far:
                    flags = TextFormatFlags.Right | TextFormatFlags.Bottom;
                    break;
                }
            }
            return(TextRenderer.MeasureText(text, GraphUtils.ToFont(font), new Size(width, font.Height), flags));
        }
コード例 #12
0
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 location)
 {
     gc.DrawString(s, GraphUtils.ToFont(font), GetBrush(brush), GraphUtils.ToPointF(location));
 }
コード例 #13
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     gc.DrawString(s, GraphUtils.ToFont(font), GetBrush(brush), ToRectangleF(rectangleF));
 }
コード例 #14
0
 public void DrawString(string s, Font2 font, Brush2 brush, Point2 point, StringFormat2 format)
 {
     gc.DrawString(s, GraphUtils.ToFont(font), GetBrush(brush), GraphUtils.ToPointF(point),
                   GraphUtils.ToStringFormat(format));
 }
コード例 #15
0
 public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
 {
     gc.DrawImage(GraphUtils.ToBitmap(image), x, y, width, height);
 }
コード例 #16
0
 public void DrawString(string s, Font2 font, Brush2 brush, float x, float y)
 {
     gc.DrawString(s, GraphUtils.ToFont(font), GetBrush(brush), x, y);
 }
コード例 #17
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     gc.DrawImageUnscaled(GraphUtils.ToBitmap(image), (int)x, (int)y);
 }
コード例 #18
0
 public Size2 MeasureString(string text, Font2 font, float width)
 {
     return(GraphUtils.ToSizeF2(gc.MeasureString(text, GraphUtils.ToFont(font), (int)width)));
 }
コード例 #19
0
ファイル: SvgGraphics.cs プロジェクト: jdrudolph/compbio-base
 public Size2 MeasureString(string text, Font2 font, float width)
 {
     return(GraphUtils.ToSizeF2(TextRenderer.MeasureText(text, GraphUtils.ToFont(font))));
 }
コード例 #20
0
 public Size2 MeasureString(string text, Font2 font)
 {
     return(GraphUtils.ToSizeF2(gc.MeasureString(text, GraphUtils.ToFont(font))));
 }