Example #1
0
        void _flex_OwnerDrawCell(object sender, 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.Turquoise, rc);
                    rc.Inflate(-1, -1);
                    e.Graphics.FillRectangle(Brushes.Teal, rc);
                    e.Text = (value * 100).ToString() + "%";

                    // draw cell content
                    e.DrawCell(DrawCellFlags.Content);
                }
            }
        }
Example #2
0
        //------------------------------------------------
        #region ** Overrides
        protected override void OnOwnerDrawCell(OwnerDrawCellEventArgs e)
        {
            // highlight appointment busy status and label
            if (e.Col == 1)
            {
                Appointment app = Rows[e.Row].UserData as Appointment;
                if (app != null && app.BusyStatus != null)
                {
                    // Draw the background.
                    e.Graphics.FillRectangle(app.BusyStatus.Brush.Brush, e.Bounds);
                    // Let the grid draw the border.
                    e.DrawCell(DrawCellFlags.Border);
                    // We' re done drawing this cell.
                    e.Handled = true;
                }
            }
            if (e.Col == 2)
            {
                Appointment app = Rows[e.Row].UserData as Appointment;
                if (app != null && app.Label != null)
                {
                    // Draw the background.
                    e.Graphics.FillRectangle(app.Label.Brush.Brush, e.Bounds);

                    e.Style.ForeColor = System.Drawing.Color.Black;
                    // Let the grid draw the content and border.
                    e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);

                    // We' re done drawing this cell.
                    e.Handled = true;
                }
            }
            base.OnOwnerDrawCell(e);
        }
Example #3
0
 private void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
 {
     if (e.Row > 0 && e.Col > 0)
     {
         e.DrawCell(DrawCellFlags.Background);
         e.Graphics.DrawImage(_bmp, e.Bounds);
         e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);
         e.Handled = true;
     }
 }
Example #4
0
        private void fg_OwnerDrawCell_1(object sender, OwnerDrawCellEventArgs e)
        {
            fg.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
            e.DrawCell();
            var rc = e.Bounds;

            //e.Graphics.DrawLine(Pens.Black, rc.Right - 1, rc.Top, rc.Right - 1, rc.Bottom);
            e.Graphics.DrawLine(Pens.Black, rc.Right - 1, rc.Top - 1, rc.Right - 1, rc.Bottom - 1);
        }
Example #5
0
        /// <summary>
        /// セルのオーナードロー
        /// </summary>
        /// <param name="e"></param>
        protected override void OnOwnerDrawCell(OwnerDrawCellEventArgs e)
        {
            base.OnOwnerDrawCell(e);

            if (_barList == null)
            {
                return;
            }

            if (FixedRowIdx <= e.Row && e.Row < this.Rows.Count && e.Col == FrozenColumnIdx + 1)
            {
                e.DrawCell(C1.Win.C1FlexGrid.DrawCellFlags.Background | C1.Win.C1FlexGrid.DrawCellFlags.Border);
                //ストライプ描画
                DrawHourStripe(this.ScrollPosition.X, e.Bounds, e.Graphics);
                //バー描画
                DrawBar(this.ScrollPosition.X, e.Bounds, e.Graphics, _barList[e.Row - FixedRowIdx].BarList);
            }
        }
Example #6
0
        public override void OnDrawCell(C1FlexGridBase flex, OwnerDrawCellEventArgs e, C1FlexGridRenderer.CellType cellType)
        {
            if (cellType == CellType.ColumnHeader)
            {
                using (var brush = GetHeaderBrush(e.Bounds))
                {
                    // paint the cell background
                    e.Graphics.FillRectangle(brush, e.Bounds);

                    // paint the border and content
                    e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);
                }
            }
            else
            {
                base.OnDrawCell(flex, e, cellType);
            }
        }
Example #7
0
        private void fg_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
        {
            if (cbToggleView.Checked)
            {
                if (e.Row >= fg.Rows.Fixed)
                {
                    //fg.SetCellStyle(e.Row, e.Col, csCellBorder);
                    decimal value;
                    if (fg.Cols[e.Col].Name == "PhanTramHoanThanh")
                    {
                        if (decimal.TryParse((fg[e.Row, e.Col] ?? "").ToString(), out value))
                        {
                            e.Text = e.Text + " %";
                            Rectangle rc  = e.Bounds;
                            decimal   max = 100;
                            rc.Width = (int)(fg.Cols["PhanTramHoanThanh"].WidthDisplay * value / max);

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

                            // draw bar
                            if (value < 25)
                            {
                                rc.Inflate(-3, -3);
                                e.Graphics.FillRectangle(Brushes.Firebrick, rc);
                                rc.Inflate(-2, -2);
                                e.Graphics.FillRectangle(Brushes.Crimson, rc);
                            }
                            else if (value >= 25 && value < 50)
                            {
                                rc.Inflate(-3, -3);
                                e.Graphics.FillRectangle(Brushes.MediumTurquoise, rc);
                                rc.Inflate(-2, -2);
                                e.Graphics.FillRectangle(Brushes.DarkTurquoise, rc);
                            }
                            else if (value >= 50 && value < 75)
                            {
                                rc.Inflate(-3, -3);
                                e.Graphics.FillRectangle(Brushes.SandyBrown, rc);
                                rc.Inflate(-2, -2);
                                e.Graphics.FillRectangle(Brushes.Orange, rc);
                            }
                            else if (value >= 75)
                            {
                                rc.Inflate(-3, -3);
                                e.Graphics.FillRectangle(Brushes.LightGreen, rc);
                                rc.Inflate(-2, -2);
                                e.Graphics.FillRectangle(Brushes.LightGreen, rc);
                            }

                            // draw cell content
                            e.DrawCell(DrawCellFlags.Content);
                        }
                    }
                    if (fg.Cols[e.Col].Name == "MoTa" || fg.Cols[e.Col].Name == "DS_Ten_NhanVien")
                    {
                        if (e.Text.Length > 100)
                        {
                            e.Text = HelperMethods.TruncateString(e.Text, 100) + " ...";
                        }
                    }
                    if (fg.Cols[e.Col].Name == "Ten_TrangThai")
                    {
                        if (e.Text.Trim() == "Chưa thực hiện")
                        {
                            e.Style = csChuaThucHien;
                        }
                        if (e.Text.Trim() == "Đang thực hiện")
                        {
                            e.Style = csDangThucHien;
                        }
                        else if (e.Text.Trim() == "Hủy")
                        {
                            e.Style = csHuy;
                        }
                        else if (e.Text.Trim() == "Đã xong")
                        {
                            e.Style = csDaXong;
                        }
                    }
                    if (fg.Cols[e.Col].Name == "Ten_MucDo")
                    {
                        if (e.Text.Trim() == "Thấp")
                        {
                            e.Style = csMucDoThap;
                        }
                        else if (e.Text.Trim() == "Trung bình")
                        {
                            e.Style = csMucDoTB;
                        }
                        else if (e.Text.Trim() == "Cao")
                        {
                            e.Style = csMucDoCao;
                        }
                    }
                }
            } //end if
            else
            {
                if (e.Row >= fg.Rows.Fixed)
                {
                    //fg.SetCellStyle(e.Row, e.Col, csCellBorder);
                    decimal value;
                    if (fg.Cols[e.Col].Name == "PhanTramHoanThanh")
                    {
                        if (decimal.TryParse((fg[e.Row, e.Col] ?? "").ToString(), out value))
                        {
                            e.Text = e.Text + " %";
                        }
                    }
                    if (fg.Cols[e.Col].Name == "MoTa" || fg.Cols[e.Col].Name == "DS_Ten_NhanVien")
                    {
                        if (e.Text.Length > 100)
                        {
                            e.Text = HelperMethods.TruncateString(e.Text, 100) + " ...";
                        }
                    }
                    if (fg.Cols[e.Col].Name == "Ten_MucDo")
                    {
                        if (e.Text.Trim() == "Thấp")
                        {
                            e.Style = csMucDoThap;
                        }
                        else if (e.Text.Trim() == "Trung bình")
                        {
                            e.Style = csMucDoTB;
                        }
                        else if (e.Text.Trim() == "Cao")
                        {
                            e.Style = csMucDoCao;
                        }
                    }
                }
            } //end else
        }
Example #8
0
        // draw cells to make them look like Outlook
        private void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
        {
            // do not paint while measuring
            if (e.Graphics == null)
            {
                return;
            }

            // custom draw only scrollable rows on tree column
            if (_groups.Count == 0)
            {
                return;
            }
            if (e.Col != _flex.Tree.Column)
            {
                return;
            }
            if (e.Row < _flex.Rows.Fixed)
            {
                return;
            }

            // get parameters we'll need
            Row row = _flex.Rows[e.Row];

            if (row.Node == null)
            {
                return;
            }
            int       idt = _flex.Tree.Indent;
            int       x   = _flex.ScrollPosition.X;
            int       lvl = row.Node.Level;
            Rectangle rc;

            // custom draw nodes
            UpdateObjects();
            if (row.IsNode)
            {
                // draw background and content
                e.Style = _styleGroup;
                e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Content);

                // draw line above
                if (lvl == 0 || !_flex.Rows[e.Row - 1].IsNode)
                {
                    rc = e.Bounds;
                    OffsetLeft(ref rc, lvl * idt + x);
                    rc.Height = 1;
                    e.Graphics.FillRectangle(_brBdr, rc);
                }

                // if the node is expanded, draw line below
                if (row.Node.Expanded)
                {
                    rc = e.Bounds;
                    OffsetLeft(ref rc, (lvl + 1) * idt + x);
                    rc.Y      = rc.Bottom - 1;
                    rc.Height = 1;
                    e.Graphics.FillRectangle(_brBdr, rc);
                }

                // draw vertical lines to the left of the symbol
                rc       = e.Bounds;
                rc.X    += x;
                rc.Width = 1;
                for (int i = 0; i <= lvl; i++)
                {
                    e.Graphics.FillRectangle(_brBdr, rc);
                    rc.Offset(idt, 0);
                }

                // done
                return;
            }

            // custom draw data
            {
                // base painting
                e.DrawCell();

                // fill area on the left
                rc       = e.Bounds;
                rc.Width = (lvl + 1) * idt;
                e.Graphics.FillRectangle(_brGrp, rc);

                // draw vertical lines over filled area
                rc       = e.Bounds;
                rc.Width = 1;
                for (int i = 0; i <= lvl + 1; i++)
                {
                    e.Graphics.FillRectangle(_brBdr, rc);
                    rc.Offset(idt, 0);
                }
            }
        }
Example #9
0
        private void c1FlexGrid1_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
        {
            if (e.Row <= 0)
            {
                return;
            }

            //Handle Hyperlinks
            if (e.Col == _hyperlinkCol)
            {
                FlexHyperlink link = c1FlexGrid1[e.Row, e.Col] as FlexHyperlink;
                if (link != null)
                {
                    e.Style = c1FlexGrid1.Styles[link.Visited ? "OldLink" : "NewLink"];
                }
            }

            //Handle Progress Bars
            else if (e.Col == _progressBarCol && e.Row > 0 && e.Row < c1FlexGrid1.Rows.Count - 1)
            {
                //Get underlying value
                int value = 0;
                if (c1FlexGrid1[e.Row, e.Col] == null)
                {
                    c1FlexGrid1[e.Row, e.Col] = value;
                }
                else
                {
                    value = (int)c1FlexGrid1[e.Row, e.Col];
                }
                if (value < 0)
                {
                    value = 0;
                }
                if (value > 100)
                {
                    value = 100;
                }

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

                // draw progress bar background from actual ProgressBar control
                Rectangle rc = e.Bounds;
                rc.Inflate(-2, -2);
                _bmp    = new Bitmap(e.Bounds.Size.Width, e.Bounds.Size.Height);
                pb.Size = e.Bounds.Size;
                pb.DrawToBitmap(_bmp, new Rectangle(new Point(0, 0), e.Bounds.Size));
                e.Graphics.DrawImage(_bmp, rc);

                //Draw Green Progress image over top of background
                rc.Width = rc.Width * value / 100;
                rc.Inflate(-1, -1);
                e.Graphics.DrawImage(imageList1.Images["progress.png"], rc);

                // draw text
                e.Text = value.ToString() + "%";
                e.DrawCell(DrawCellFlags.Content);
                e.Handled = true;
            }
        }