Example #1
0
 private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (IsCellSelected(e.Row, e.Col))
     {
         e.Style = _flex.Styles.Highlight;
     }
 }
Example #2
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);
                }
            }
        }
Example #3
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;
            }
        }
Example #4
0
 void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (_flex[e.Row, e.Col] is Image)
     {
         e.Image = _flex[e.Row, e.Col] as Image;
     }
 }
Example #5
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);
                }
            }
        }
Example #6
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;
            }
        }
Example #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);
     }
 }
Example #8
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;
            }
        }
Example #9
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);
            }
        }
Example #10
0
 // use custom style for hyperlinks
 private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (e.Style.BackColor == _flex.Styles.Normal.BackColor)
     {
         Hyperlink link = _flex[e.Row, e.Col] as Hyperlink;
         if (link != null)
         {
             e.Style = _flex.Styles[link.Visited? "OldLink": "NewLink"];
         }
     }
 }
Example #11
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);
         }
     }
 }
Example #12
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();
                }
            }
        }
        // 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);
            }
        }
Example #14
0
        //-------------------------------------------------------------------------------------------------

        public static void Paint_Id_Codes_Cells(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (e.Row > 0)
            {
                if (mod_global.MF.XmlIdCodeGrid.Cols[e.Col].Name == "nbitem")
                {
                    if (e.Text != String.Empty)
                    {
                        if (int.Parse(e.Text) > 0)
                        {
                            e.Style = mod_global.MF.XmlIdCodeGrid.Styles["ItemExistStyle"];
                        }
                    }
                }
            }
        }
Example #15
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);
            }
        }
Example #16
0
 /*
  *
  * Colorer la colonne Nb Codes LiƩs si > 0 */
 public static void Paint_Obs_Codelie_Cells(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (e.Row > 0)
     {
         if (mod_global.MF.XmlObsCodesGrid.Cols[e.Col].Name == "codelie")
         {
             if (e.Text != String.Empty)
             {
                 if (int.Parse(e.Text) > 0)
                 {
                     e.Style = mod_global.MF.XmlObsCodesGrid.Styles["CodeExistStyle"];
                 }
             }
         }
     }
 }
Example #17
0
 // draw row and column headers
 protected override void OnOwnerDrawCell(C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (e.Col == 0 && e.Row >= Rows.Fixed)
     {
         var row = e.Row - Rows.Fixed + 1;
         e.Text  = row.ToString();
         e.Style = _csHeader;
     }
     else if (e.Row == 0 && e.Col >= Cols.Fixed)
     {
         var col = e.Col - Cols.Fixed;
         e.Text  = GetAlphaColumnHeader(col);
         e.Style = _csHeader;
     }
     base.OnOwnerDrawCell(e);
 }
Example #18
0
 private void vs_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
 {
     if (vs.Cols[e.Col].Name == "COL_NO" && e.Row > 0 && vs.Rows[e.Row][e.Col] + "" != "")
     {
         System.Drawing.RectangleF r = new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
         string st    = vs.Rows[e.Row][e.Col] + "";
         int    index = st.IndexOf(".", 0, st.Length);
         Byte   R     = System.Byte.Parse(st.Remove(index, st.Length - index));
         st    = st.Remove(0, index + 1);
         index = st.IndexOf(".", 0, st.Length);
         Byte  G     = System.Byte.Parse(st.Remove(index, st.Length - index));
         Byte  B     = System.Byte.Parse(st.Remove(0, index + 1));
         Color color = System.Drawing.Color.FromArgb(R, G, B);
         Brush b     = new HatchBrush(HatchStyle.Max, color, color);
         e.Graphics.FillRectangle(b, r);
         e.Handled = true;                 // we're done drawing this cell
     }
 }
Example #19
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);
             }
         }
     }
 }
Example #20
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)
                            });
                        }
                    }
                }
            }
        }
Example #21
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);
            }
        }
Example #22
0
        // select style based on row state
        private void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // only apply styles to scrollable cells
            if (e.Row < _flex.Rows.Fixed || e.Col < _flex.Cols.Fixed)
            {
                return;
            }

            // get underlying DataRow
            int index = _flex.Rows[e.Row].DataIndex;

            if (index < 0)
            {
                return;
            }
            CurrencyManager cm  = (CurrencyManager)BindingContext[_flex.DataSource, _flex.DataMember];
            DataRowView     drv = cm.List[index] as DataRowView;

            // select style based on row state
            switch (drv.Row.RowState)
            {
            case DataRowState.Added:
                e.Style = _flex.Styles["Added"];
                break;

            case DataRowState.Modified:
                e.Style = _flex.Styles["Modified"];
                break;

            case DataRowState.Detached:
                e.Style = _flex.Styles["Detached"];
                break;

            case DataRowState.Unchanged:
                break;

            default:
                break;
            }
        }
Example #23
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;
            }
        }