Esempio n. 1
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (_flex.Cols[e.Col].UserData != null && e.Row >= _flex.Rows.Fixed)
            {
                double value;
                if (double.TryParse(_flex.GetDataDisplay(e.Row, e.Col), NumberStyles.Any, CultureInfo.CurrentCulture, out value))
                {
                    // calculate bar extent
                    Rectangle rc  = e.Bounds;
                    double    max = (double)_flex.Cols[e.Col].UserData;
                    rc.Width = (int)(_flex.Cols[e.Col].WidthDisplay * value / max);

                    // draw background
                    e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Border);

                    // draw bar
                    rc.Inflate(-2, -2);
                    e.Graphics.FillRectangle(Brushes.Gold, rc);
                    rc.Inflate(-1, -1);
                    e.Graphics.FillRectangle(Brushes.LightGoldenrodYellow, rc);

                    // draw cell content
                    e.DrawCell(DrawCellFlags.Content);
                }
            }
        }
Esempio n. 2
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // check whether the cell contains RTF
            string rtfText = _flex.GetDataDisplay(e.Row, e.Col);

            if (rtfText.StartsWith(@"{\rtf"))
            {
                // it does, so draw background
                e.DrawCell(DrawCellFlags.Background);

                // draw the RTF text
                if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
                {
                    _rtf.Rtf       = rtfText;
                    _rtf.ForeColor = e.Style.ForeColor;
                    _rtf.BackColor = e.Style.BackColor;
                    _rtf.Render(e.Graphics, e.Bounds);
                }

                // and draw border last
                e.DrawCell(DrawCellFlags.Border);

                // we're done with this cell
                e.Handled = true;
            }
        }
Esempio n. 3
0
        public static void Paint_RTF_Cells(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            string rtfText = mod_global.MF.ObservationGrid.GetDataDisplay(e.Row, e.Col);

            if (rtfText.StartsWith(@"{\rtf"))
            {
                mod_rtf _rtf = new mod_rtf();
                // it does, so draw background
                e.DrawCell(DrawCellFlags.Background);

                // draw the RTF text
                if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
                {
                    _rtf.Rtf       = rtfText;
                    _rtf.ForeColor = e.Style.ForeColor;
                    _rtf.BackColor = e.Style.BackColor;
                    _rtf.Render(e.Graphics, e.Bounds);
                }

                // and draw border last
                e.DrawCell(DrawCellFlags.Border);

                // we're done with this cell
                e.Handled = true;
            }
        }
Esempio n. 4
0
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (_flex.Cols[e.Col].Name == "Status" && e.Row > 0)
            {
                // get song
                DataRowView drv = (DataRowView)_flex.Rows[e.Row].DataSource;
                if (drv == null)
                {
                    return;
                }
                DataRow dr = drv.Row;

                // see if we're copying the song
                if (!_songs.ContainsKey(dr))
                {
                    return;
                }

                // calculate how much is done
                DateTime start   = (DateTime)_songs[dr];
                TimeSpan elapsed = DateTime.Now - start;
                TimeSpan length  = (TimeSpan)dr["Length"];
                int      pct     = (length.TotalSeconds > 0)
                                        ? (int)(elapsed.TotalSeconds / length.TotalSeconds * 100f * 20f)
                                        : 100;

                // song is done? remove from list
                if (pct >= 100)
                {
                    _songs.Remove(dr);
                    dr["Status"] = "Copied";
                    return;
                }

                // draw background
                e.Style = _flex.Styles.Highlight;
                e.DrawCell(DrawCellFlags.Background);

                // progress bar outline
                Rectangle rc = e.Bounds;
                rc.Width--;
                rc.Height--;
                e.Graphics.DrawRectangle(_pen, rc);

                // fill progress bar
                rc = e.Bounds;
                rc.Inflate(-2, -2);
                rc.Width = rc.Width * pct / 100;
                e.Graphics.DrawImage(_bmp, rc);

                // draw text
                e.Text = string.Format("Copying ({0}% done)", pct);
                e.DrawCell(DrawCellFlags.Content);
                e.Handled = true;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Show Border Margins on the Cells
        /// covered by the Cross cursor.
        /// </summary>
        void fg_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (fg.IsCellHighlighted(e.Row, e.Col))
            {
                e.DrawCell();
                if (fg.Cursor == Cursors.Cross)
                {
                    // we only want cells with style set to "Border"
                    if (fg.GetUserData(e.Row, e.Col).ToString() != "Border")
                    {
                        return;
                    }

                    // draw cell content as usual
                    e.DrawCell();

                    // get custom border widths for this cell
                    // (depends on neighbor cells)
                    Margins m = GetBorderMargins(e.Row, e.Col);

                    // draw custom borders
                    Rectangle rc;
                    Graphics  g = e.Graphics;
                    if (m.Top > 0)
                    {
                        rc        = e.Bounds;
                        rc.Height = m.Top;
                        g.FillRectangle(_bdrBrush, rc);
                    }
                    if (m.Left > 0)
                    {
                        rc       = e.Bounds;
                        rc.Width = m.Left;
                        g.FillRectangle(_bdrBrush, rc);
                    }
                    if (m.Bottom > 0)
                    {
                        rc        = e.Bounds;
                        rc.Y      = rc.Bottom - m.Bottom;
                        rc.Height = m.Bottom;
                        g.FillRectangle(_bdrBrush, rc);
                    }
                    if (m.Right > 0)
                    {
                        rc       = e.Bounds;
                        rc.X     = rc.Right - m.Right;
                        rc.Width = m.Right;
                        g.FillRectangle(_bdrBrush, rc);
                    }
                    fg.Invalidate();
                }
            }
        }
Esempio n. 6
0
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (e.Row <= 1)
            {
                // select border color and thickness
                Brush br    = Brushes.Green;
                int   thick = 2;

                // default painting
                e.DrawCell();

                // draw line below cell
                if ((e.Row == 1 && e.Col > 0) || (e.Row == 0 && e.Col == 1))
                {
                    Rectangle rc = e.Bounds;
                    rc.Y      = rc.Bottom - thick;
                    rc.Height = thick;
                    e.Graphics.FillRectangle(br, rc);
                }

                // draw line to the right of the cell
                if ((e.Row == 0 && e.Col == 0) || (e.Row == 0 && e.Col == 1) ||
                    (e.Row == 0 && e.Col == 2) || (e.Row == 1 && e.Col == 5))
                {
                    Rectangle rc = e.Bounds;
                    rc.X     = rc.Right - thick;
                    rc.Width = thick;
                    e.Graphics.FillRectangle(br, rc);
                }
            }
        }
Esempio n. 7
0
 // make normal and scrollable areas look different
 // (when painting and when editing)
 private void _frz_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (e.Style.BackColor == _frz.Styles.Normal.BackColor)
     {
         e.Graphics.FillRectangle(Brushes.Beige, e.Bounds);
         e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);
     }
 }
Esempio n. 8
0
        // draw accelerators
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (e.Row < _flex.Rows.Fixed && e.Text.IndexOf("&") > -1)
            {
                e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Border);

                StringFormat fmt = new StringFormat();
                fmt.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
                e.Graphics.DrawString(e.Text, e.Style.Font, Brushes.Black, e.Bounds, fmt);
            }
        }
Esempio n. 9
0
 // method 1: use OwnerDraw cells to paint one column yellow when another is checked
 private void _flex1_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     // paint a yellow background depending on the value of another column
     if (_flex1.Cols[e.Col].Name == "Length" && _flex1[e.Row, "UserDef"] is bool)
     {
         if ((bool)_flex1[e.Row, "UserDef"])
         {
             e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
             e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);
         }
     }
 }
Esempio n. 10
0
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            object value = _flex[e.Row, e.Col];

            if (value is Point)
            {
                Point pt = (Point)value;
                e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Border);
                _flex.Styles["Left"].Render(e.Graphics, e.Bounds, pt.X.ToString(), null, DrawCellFlags.Content);
                _flex.Styles["Right"].Render(e.Graphics, e.Bounds, pt.Y.ToString(), null, DrawCellFlags.Content);
            }
            if (value is Rectangle)
            {
                Rectangle rc = (Rectangle)value;
                e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Border);
                _flex.Styles["Left"].Render(e.Graphics, e.Bounds, rc.X.ToString(), null, DrawCellFlags.Content);
                _flex.Styles["Right"].Render(e.Graphics, e.Bounds, rc.Y.ToString(), null, DrawCellFlags.Content);
                _flex.Styles["Top"].Render(e.Graphics, e.Bounds, rc.Width.ToString(), null, DrawCellFlags.Content);
                _flex.Styles["Bottom"].Render(e.Graphics, e.Bounds, rc.Height.ToString(), null, DrawCellFlags.Content);
            }
        }
Esempio n. 11
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (_flex.Cols[e.Col].Name == "HTML")
            {
                // draw background
                e.DrawCell(DrawCellFlags.Background);

                // use the C1SuperLabel to draw the html text
                if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
                {
                    _html.Text      = _flex.GetDataDisplay(e.Row, e.Col);
                    _html.BackColor = Color.Transparent;
                    _html.DrawToGraphics(e.Graphics, e.Bounds);
                }

                // and draw border last
                e.DrawCell(DrawCellFlags.Border);

                // we're done with this cell
                e.Handled = true;
            }
        }
        // custom drawing for cells with custom borders
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // we only want cells with style set to "Border"
            CellStyle s = _flex.GetCellStyle(e.Row, e.Col);

            if (s == null || s.Name != "Border")
            {
                return;
            }

            // draw cell content as usual
            e.DrawCell();

            // get custom border widths for this cell
            // (depends on neighbor cells)
            Margins m = GetBorderMargins(e.Row, e.Col);

            // draw custom borders
            Rectangle rc;
            Graphics  g = e.Graphics;

            if (m.Top > 0)
            {
                rc        = e.Bounds;
                rc.Height = m.Top;
                g.FillRectangle(_bdrBrush, rc);
            }
            if (m.Left > 0)
            {
                rc       = e.Bounds;
                rc.Width = m.Left;
                g.FillRectangle(_bdrBrush, rc);
            }
            if (m.Bottom > 0)
            {
                rc        = e.Bounds;
                rc.Y      = rc.Bottom - m.Bottom;
                rc.Height = m.Bottom;
                g.FillRectangle(_bdrBrush, rc);
            }
            if (m.Right > 0)
            {
                rc       = e.Bounds;
                rc.X     = rc.Right - m.Right;
                rc.Width = m.Right;
                g.FillRectangle(_bdrBrush, rc);
            }
        }
Esempio n. 13
0
        // draw cell note indicator on the cell
        // (a little red triangle on the upper-right corner)
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // check if the cell has a note
            CellRange rg = _flex.GetCellRange(e.Row, e.Col);

            if (rg.UserData is CellNote)
            {
                // default drawing
                e.DrawCell();

                // add the little red rectangle that indicaates there's a note on this cell
                Point   pt     = new Point(e.Bounds.Right, e.Bounds.Y);
                Point[] points = { new Point(pt.X - 4, pt.Y), pt, new Point(pt.X, pt.Y + 4) };
                e.Graphics.FillPolygon(Brushes.Red, points);
            }
        }
Esempio n. 14
0
 void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (_flex[e.Row, e.Col] is Color)
     {
         var clr = (Color)_flex[e.Row, e.Col];
         if (clr != null)
         {
             e.DrawCell(C1.Win.C1FlexGrid.DrawCellFlags.Background | C1.Win.C1FlexGrid.DrawCellFlags.Border);
             var rc = e.Bounds;
             rc.Inflate(-4, -2);
             using (var br = new SolidBrush(clr))
             {
                 e.Graphics.FillRectangle(br, rc);
                 e.Graphics.DrawRectangle(Pens.Black, rc);
             }
         }
     }
 }
Esempio n. 15
0
        private void c1FlexGrid1_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // draw cell as usual
            e.DrawCell();

            // spell check unless (we're just measuring)
            if (!e.Measuring)
            {
                var fg     = sender as C1FlexGrid;
                var text   = fg.GetDataDisplay(e.Row, e.Col);
                var errors = c1SpellChecker1.CheckText(text);

                // underline errors
                if (errors.Count > 0)
                {
                    var ranges = new CharacterRange[errors.Count];
                    for (int i = 0; i < errors.Count; i++)
                    {
                        ranges[i] = new CharacterRange(errors[i].Start, errors[i].Length);
                    }

                    var sf = new StringFormat(e.Style.StringFormat);
                    sf.SetMeasurableCharacterRanges(ranges);
                    var rc   = e.Style.GetTextRectangle(e.Bounds, null);
                    var rgns = e.Graphics.MeasureCharacterRanges(text, e.Style.Font, rc, sf);

                    foreach (var rgn in rgns)
                    {
                        rc = Rectangle.Truncate(rgn.GetBounds(e.Graphics));
                        for (Point pt = new Point(rc.X, rc.Bottom); pt.X + 2 < rc.Right; pt.X += 4)
                        {
                            e.Graphics.DrawLines(Pens.Red, new Point[]
                            {
                                new Point(pt.X, pt.Y),
                                new Point(pt.X + 2, pt.Y - 2),
                                new Point(pt.X + 4, pt.Y)
                            });
                        }
                    }
                }
            }
        }