Beispiel #1
0
        public static DrawableCellStates ToEto(this swf.DataGridViewElementStates state)
        {
            if (state.HasFlag(swf.DataGridViewElementStates.Selected))
            {
                return(DrawableCellStates.Selected);
            }

            return(DrawableCellStates.None);
        }
Beispiel #2
0
        public static DrawableCellState ToEto(this swf.DataGridViewElementStates state)
        {
            if ((state & swf.DataGridViewElementStates.Selected) == swf.DataGridViewElementStates.Selected)
            {
                return(DrawableCellState.Selected);
            }

            return(DrawableCellState.Normal);
        }
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                formattedValue = "";
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

                float?progressVal;

                if (!(progressVal = value as float?).HasValue)
                {
                    return;
                }

                float  percentage = (float)progressVal;
                string progress   = (int)(progressVal * 100f) + "%";

                sd.Rectangle paintRect = new sd.Rectangle(cellBounds.X + 1, cellBounds.Y + 2, cellBounds.Width - 2, cellBounds.Height - 4);

                PaintBorder(graphics, clipBounds, paintRect, cellStyle, advancedBorderStyle);

                sd.Color bkColor;
                if (elementState == swf.DataGridViewElementStates.Selected)
                {
                    bkColor = cellStyle.SelectionBackColor;
                }
                else
                {
                    bkColor = cellStyle.BackColor;
                }

                using (sd.SolidBrush backBrush = new sd.SolidBrush(bkColor))
                    graphics.FillRectangle(backBrush, paintRect);

                if (swf.ProgressBarRenderer.IsSupported)
                {
                    swf.ProgressBarRenderer.DrawHorizontalBar(graphics, paintRect);

                    sd.Rectangle barBounds = new sd.Rectangle(paintRect.X + 2, paintRect.Y + 2, paintRect.Width - 4, paintRect.Height - 4);
                    barBounds.Width = (int)Math.Round(barBounds.Width * percentage);
                    swf.ProgressBarRenderer.DrawHorizontalChunks(graphics, barBounds);
                }
                else
                {
                    sd.Rectangle barBounds = new sd.Rectangle(paintRect.X + 2, paintRect.Y + 2, paintRect.Width - 4, paintRect.Height - 3);
                    barBounds.Width = (int)Math.Round(barBounds.Width * percentage);

                    graphics.FillRectangle(sd.Brushes.LightGray, paintRect);
                    graphics.DrawRectangle(sd.Pens.Black, paintRect);
                    graphics.FillRectangle(new sd.SolidBrush(sd.Color.FromArgb(0, 216, 35)), barBounds);
                }

                swf.TextRenderer.DrawText(graphics, progress, cellStyle.Font, paintRect, cellStyle.ForeColor, swf.TextFormatFlags.HorizontalCenter | swf.TextFormatFlags.VerticalCenter);
            }
        //Paints the cell
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       paintParts);

            if (m_Chart == null | cellBounds.Width != m_Width | cellBounds.Height != m_Height)
            {
                this.Value = GetTickChart(cellBounds);
            }

            m_CellBounds.Width  = cellBounds.Width;
            m_CellBounds.Height = cellBounds.Height;
            m_CellBounds.X      = cellBounds.X;
            m_CellBounds.Y      = cellBounds.Y;
            m_Width             = cellBounds.Width;
            m_Height            = cellBounds.Height;
        }
Beispiel #5
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.SetClip(cellBounds);
#pragma warning disable 618
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);
                Handler.Callback.OnPaint(Handler.Widget, args);
#pragma warning restore 618
                graphics.ResetClip();
                graphics.Restore(state);
            }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            Single progressVal;

            try
            {
                progressVal = Conversions.ToSingle(value);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                progressVal = 0;
            }

            float percentage = (float)(progressVal / 100);
            Brush backBrush  = new SolidBrush(cellStyle.BackColor);
            Brush foreBrush  = new SolidBrush(cellStyle.ForeColor);

            // Call the base Class method to paint the default cell appearance.
            base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       paintParts);

            if (percentage > 0.0)
            {
                if (percentage > 1)
                {
                    percentage = 1;
                }
                // Draw the progress bar and the text
                Rectangle rect = new Rectangle(cellBounds.X + 1, cellBounds.Y + 1, Convert.ToInt32((percentage * cellBounds.Width - 3)), cellBounds.Height - 3);
                DrawingMethods.DrawGradient(g, rect, Color.FromArgb(205, 255, 205), Color.FromArgb(10, 209, 48), 90F, false, Color.White, 0);
                g.DrawRectangle(new Pen(Color.FromArgb(28, 220, 56)), rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
                //g.FillRectangle(New SolidBrush(Color.FromArgb(163, 189, 242)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4)
                g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreBrush, cellBounds.X + 6, cellBounds.Y + 4);
            }
            else
            {
                //draw the text
                if ((this.DataGridView.CurrentCell != null) && this.DataGridView.CurrentCell.RowIndex == rowIndex)
                {
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 4);
                }
                else
                {
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreBrush, cellBounds.X + 6, cellBounds.Y + 4);
                }
            }
        }
Beispiel #7
0
 public virtual void Paint(GridColumnHandler column, System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
 {
 }
    /// <summary>
    /// Overrides Paint
    /// </summary>
    /// <param name="graphics"></param>
    /// <param name="clipBounds"></param>
    /// <param name="cellBounds"></param>
    /// <param name="rowIndex"></param>
    /// <param name="cellState"></param>
    /// <param name="value"></param>
    /// <param name="formattedValue"></param>
    /// <param name="errorText"></param>
    /// <param name="cellStyle"></param>
    /// <param name="advancedBorderStyle"></param>
    /// <param name="paintParts"></param>
    protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                  System.Windows.Forms.DataGridViewPaintParts paintParts)
    {
        //Draw the bar
        int barWidth;

        if ((double)value >= 1.0)
        {
            barWidth = (int)(cellBounds.Width - 10);
        }
        else
        {
            barWidth = (int)((cellBounds.Width - 10) * (double)value);
        }

        if ((double)value > 0 && barWidth > 0)
        {
            Rectangle r = new Rectangle(cellBounds.X + 3, cellBounds.Y + 3, barWidth, cellBounds.Height - 8);

            using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, KryptonManager.CurrentGlobalPalette.GetBackColor1(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), KryptonManager.CurrentGlobalPalette.GetBackColor2(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), LinearGradientMode.Vertical))
            {
                graphics.FillRectangle(linearBrush, r);
            }

            using (Pen pen = new Pen(KryptonManager.CurrentGlobalPalette.GetBorderColor1(PaletteBorderStyle.GridHeaderColumnList, PaletteState.Normal)))
            {
                graphics.DrawRectangle(pen, r);
            }

            //TODO : implement customization like conditional formatting
            //using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, Color.FromArgb(255, 140, 197, 66), Color.FromArgb(255, 247, 251, 242), LinearGradientMode.Horizontal))
            //{
            //    graphics.FillRectangle(linearBrush, r);
            //}

            //using (Pen pen = new Pen(Color.FromArgb(255, 140, 197, 66)))
            //{
            //    graphics.DrawRectangle(pen, r);

            //}
        }

        base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                   DataGridViewPaintParts.None | DataGridViewPaintParts.ContentForeground);
    }
Beispiel #9
0
        protected void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, ref sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
        {
            if (CellConfig != null)
            {
                CellConfig.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var offset = CellConfig.GetRowOffset(rowIndex);
                cellBounds.X     += offset;
                cellBounds.Width -= offset;
            }
        }
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            //Paint inactive cells
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, "", "", errorText, cellStyle, advancedBorderStyle, paintParts);

            try {
                if (rowIndex < 0)
                {
                    return;
                }

                foreach (GoogleOgcs.EventColour.Palette ci in Forms.ColourMap.GoogleComboBox.Items)
                {
                    if (ci.Name == this.Value.ToString())
                    {
                        Brush boxBrush  = new SolidBrush(ci.RgbValue);
                        Brush textBrush = SystemBrushes.WindowText;
                        Extensions.ColourCombobox.DrawComboboxItemColour(true, boxBrush, textBrush, this.Value.ToString(), graphics, cellBounds);
                        break;
                    }
                }
            } catch (System.Exception ex) {
                OGCSexception.Analyse("GoogleColourComboboxCell.Paint()", ex);
            }
        }
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            try
            {
                object o;
                o = value;

                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, "", "", errorText, cellStyle, advancedBorderStyle,
                           paintParts);

                //load Icons from resources
                //arrows
                ImageList GridIcons = new ImageList();
                //System.IO.Stream strm;
                string iconName;
                Icon   icon;

                //UP
                iconName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Up.ico";
                icon     = new Icon(this.GetType().Assembly.GetManifestResourceStream(iconName));
                GridIcons.Images.Add(icon.ToBitmap());
                //Down
                iconName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Down.ico";
                icon     = new Icon(this.GetType().Assembly.GetManifestResourceStream(iconName));
                GridIcons.Images.Add(icon.ToBitmap());
                //Equal
                iconName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Eq.ico";
                icon     = new Icon(this.GetType().Assembly.GetManifestResourceStream(iconName));
                GridIcons.Images.Add(icon.ToBitmap());
                //Na
                //iconName = "AC.Utils.Na.ico"
                iconName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Na2.ico";
                icon     = new Icon(this.GetType().Assembly.GetManifestResourceStream(iconName));
                GridIcons.Images.Add(icon.ToBitmap());

                int ngXlocation = (cellBounds.Width - 16);
                int ngYlocation = (cellBounds.Height - 16);
                if (ngXlocation < 0)
                {
                    ngXlocation = 0;
                }
                if (ngYlocation < 0)
                {
                    ngYlocation = 0;
                }
                ngXlocation = ngXlocation / 2;
                ngYlocation = ngYlocation / 2;

                Rectangle ng = new Rectangle(cellBounds.X + ngXlocation, cellBounds.Y + ngYlocation, 16, 16);

                if ((((o) != null)))
                {
                    Single c;
                    c = Conversions.ToSingle(o);
                    //Debug
                    //MessageBox.Show(c)

                    Brush backBrush = new SolidBrush(cellStyle.BackColor);

                    if (elementState == DataGridViewElementStates.Selected)
                    {
                        backBrush = new SolidBrush(Color.Gold);
                    }

                    //erase background
                    if (c == 1)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        graphics.DrawImage(GridIcons.Images[0], ng);
                    }
                    else if (c == -1)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        graphics.DrawImage(GridIcons.Images[1], ng);
                    }
                    else if (c == 0)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        graphics.DrawImage(GridIcons.Images[2], ng);
                    }
                    else if (c == 2)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        graphics.DrawImage(GridIcons.Images[3], ng);
                    }
                    else
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                    }
                }

                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
            catch
            {
                // empty catch
                //MessageBox.Show(ex.Message)
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                           paintParts);
                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
        }
    /// <summary>
    /// Overrides Paint
    /// </summary>
    /// <param name="graphics"></param>
    /// <param name="clipBounds"></param>
    /// <param name="cellBounds"></param>
    /// <param name="rowIndex"></param>
    /// <param name="cellState"></param>
    /// <param name="value"></param>
    /// <param name="formattedValue"></param>
    /// <param name="errorText"></param>
    /// <param name="cellStyle"></param>
    /// <param name="advancedBorderStyle"></param>
    /// <param name="paintParts"></param>
    protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                  System.Windows.Forms.DataGridViewPaintParts paintParts)
    {
        //Double p = 0;
        //Single percentage = 0f;
        //if (value != null && Double.TryParse((string)value, out p))
        //{
        //p = Convert.ToDouble(value);
        //percentage = (Convert.ToSingle(value) / 100f);
        //formattedValue = value + "%";
        //}

        //Draw the bar
        int barWidth = (int)((cellBounds.Width - 10) * (double)value);

        if ((double)value > 0 && barWidth > 0)
        {
            Rectangle r = new Rectangle(cellBounds.X + 5, cellBounds.Y + 3, barWidth, cellBounds.Height - 8);

            using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, KryptonManager.CurrentGlobalPalette.GetBackColor1(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), KryptonManager.CurrentGlobalPalette.GetBackColor2(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal), LinearGradientMode.Vertical))
            {
                graphics.FillRectangle(linearBrush, r);
            }

            using (Pen pen = new Pen(KryptonManager.CurrentGlobalPalette.GetBackColor2(PaletteBackStyle.GridHeaderColumnList, PaletteState.Normal)))
            {
                graphics.DrawRectangle(pen, r);
                // graphics.DrawRectangle(Pens.DimGray, r);
            }
        }

        base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                   DataGridViewPaintParts.None | DataGridViewPaintParts.ContentForeground);
    }
Beispiel #13
0
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            string spaces = new string(' ', 2);

            l = new Point(cellBounds.Width - 18, 5);
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, spaces + value.ToString().Trim(), spaces + formattedValue.ToString().Trim(), errorText, cellStyle, advancedBorderStyle,
                       paintParts);
            CheckBoxRenderer.DrawCheckBox(graphics, new Point(cellBounds.X + l.X, l.Y), isChecked ? System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal : System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
        }
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            try
            {
                object o;
                o = value;

                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, "", "", errorText, cellStyle, advancedBorderStyle,
                           paintParts);

                //load Icons from resources
                //arrows
                ImageList GridIcons = new ImageList();
                GridIcons.ColorDepth = ColorDepth.Depth32Bit;

                string iconOkName;
                string iconFailName;
                string iconNoneName;
                //Icon icon;
                //Bitmap icon;

                //Ok
                iconOkName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Up.png";

                //Fail
                iconFailName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Down.png";

                //None
                iconNoneName = "AC.ExtendedRenderer.Toolkit.StdControls.Images.Question.png";


                int ngXlocation = (cellBounds.Width - 16);
                int ngYlocation = (cellBounds.Height - 16);
                if (ngXlocation < 0)
                {
                    ngXlocation = 0;
                }
                if (ngYlocation < 0)
                {
                    ngYlocation = 0;
                }
                ngXlocation = ngXlocation / 2;
                ngYlocation = ngYlocation / 2;

                Rectangle ng = new Rectangle(cellBounds.X + ngXlocation, cellBounds.Y + ngYlocation, 16, 16);

                if ((((o) != null)))
                {
                    Single c;
                    c = Conversions.ToSingle(o);
                    //Debug
                    //MessageBox.Show(c)

                    Brush backBrush = new SolidBrush(cellStyle.BackColor);

                    if (elementState == DataGridViewElementStates.Selected)
                    {
                        backBrush = new SolidBrush(Color.Gold);
                    }

                    //erase background
                    if (c == 1)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        using (Bitmap tmpBitmap = new Bitmap(this.GetType().Assembly.GetManifestResourceStream(iconOkName)))
                        {
                            tmpBitmap.MakeTransparent();
                            graphics.DrawImage(tmpBitmap, ng);
                        }
                    }
                    else if (c == 0)
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        using (Bitmap tmpBitmap = new Bitmap(this.GetType().Assembly.GetManifestResourceStream(iconFailName)))
                        {
                            tmpBitmap.MakeTransparent();
                            graphics.DrawImage(tmpBitmap, ng);
                        }
                    }
                    else
                    {
                        //graphics.FillRectangle(backBrush, cellBounds.X, cellBounds.Y, cellBounds.Width, cellBounds.Height)
                        using (Bitmap tmpBitmap = new Bitmap(this.GetType().Assembly.GetManifestResourceStream(iconNoneName)))
                        {
                            tmpBitmap.MakeTransparent();
                            graphics.DrawImage(tmpBitmap, ng);
                        }
                    }
                }

                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
            catch
            {
                // empty catch
                //MessageBox.Show(ex.Message)
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                           paintParts);
                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
        }
Beispiel #15
0
 protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
 {
     graphics.InterpolationMode = InterpolationMode;
     Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
     base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
 }
Beispiel #16
0
        /// <summary>
        /// Paints the specified graphics.
        /// </summary>
        /// <param name="graphics">The graphics.</param>
        /// <param name="clipBounds">The clip bounds.</param>
        /// <param name="cellBounds">The cell bounds.</param>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="cellState">State of the cell.</param>
        /// <param name="value">The value.</param>
        /// <param name="formattedValue">The formatted value.</param>
        /// <param name="errorText">The error text.</param>
        /// <param name="cellStyle">The cell style.</param>
        /// <param name="advancedBorderStyle">The advanced border style.</param>
        /// <param name="paintParts">The paint parts.</param>
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            if (FormatParams != null)  // null can happen when cell set to Formatting but no condition has been set !
            {
                switch (FormatType)
                {
                case EnumConditionalFormatType.Bar:
                    int       barWidth;
                    BarParams par = (BarParams)FormatParams;
                    barWidth        = (int)((cellBounds.Width - 10) * par.ProportionValue);
                    Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor;
                    Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor;

                    if (barWidth > 0)     //(double)value > 0 &&
                    {
                        Rectangle r = new Rectangle(cellBounds.X + 3, cellBounds.Y + 3, barWidth, cellBounds.Height - 8);
                        if (par.GradientFill)
                        {
                            using (LinearGradientBrush linearBrush = new LinearGradientBrush(r, par.BarColor, Color.White, LinearGradientMode.Horizontal))     //Color.FromArgb(255, 247, 251, 242)
                            {
                                graphics.FillRectangle(linearBrush, r);
                            }
                        }
                        else
                        {
                            using (SolidBrush solidBrush = new SolidBrush(par.BarColor))     //Color.FromArgb(255, 247, 251, 242)
                            {
                                graphics.FillRectangle(solidBrush, r);
                            }
                        }

                        using (Pen pen = new Pen(par.BarColor))     //Color.FromArgb(255, 140, 197, 66)))
                        {
                            graphics.DrawRectangle(pen, r);
                        }
                    }

                    break;

                case EnumConditionalFormatType.TwoColorsRange:
                    TwoColorsParams TWCpar = (TwoColorsParams)FormatParams;
                    Style.BackColor = TWCpar.ValueColor;
                    //  if (ContrastTextColor)
                    Style.ForeColor = ContrastColor(TWCpar.ValueColor);
                    break;

                case EnumConditionalFormatType.ThreeColorsRange:
                    ThreeColorsParams THCpar = (ThreeColorsParams)FormatParams;
                    Style.BackColor = THCpar.ValueColor;
                    Style.ForeColor = ContrastColor(THCpar.ValueColor);
                    break;

                default:
                    Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor;
                    Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor;
                    break;
                }
            }
            else
            {
                Style.BackColor = this.DataGridView.DefaultCellStyle.BackColor;
                Style.ForeColor = this.DataGridView.DefaultCellStyle.ForeColor;
            }

            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       DataGridViewPaintParts.None | DataGridViewPaintParts.ContentForeground);
        }
Beispiel #17
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) ||
                    cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(Handler.Generator, new GraphicsHandler(graphics, shouldDisposeGraphics: false));
                }

                if (Handler.Widget.PaintHandler != null)
                {
                    var b = graphics.ClipBounds;
                    graphics.SetClip(clipBounds);
                    Handler.Widget.PaintHandler(new DrawableCellPaintArgs
                    {
                        Graphics   = cachedGraphics,
                        CellBounds = new RectangleF(cellBounds.ToEto()),
                        Item       = value,
                        CellState  = cellState.ToEto(),
                    });
                    graphics.SetClip(b);                     // restore
                }
            }
Beispiel #18
0
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      System.Windows.Forms.DataGridViewPaintParts paintParts)
        {
            try
            {
                object o;
                o = value;

                if ((((o) != null)))
                {
                    double c;
                    c = Conversions.ToDouble(o);
                    //Debug
                    //MessageBox.Show(c)


                    //erase background
                    if (c < 0)
                    {
                        cellStyle.BackColor = Color.FromArgb(255, 200, 200);
                    }
                    else if (c == 0)
                    {
                        cellStyle.BackColor = Color.FromArgb(200, 200, 255);
                    }
                    else if (c > 0)
                    {
                        cellStyle.BackColor = Color.FromArgb(200, 255, 200);
                    }
                }

                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                           paintParts);

                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
            catch
            {
                // empty catch
                //MessageBox.Show(ex.Message)
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                           paintParts);
                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
        }
Beispiel #19
0
 public void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
 {
     if (GridHandler != null)
     {
         GridHandler.Paint(this, graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
     }
 }
Beispiel #20
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var val = value as object[];
                var img = val[0] as sd.Image;

                if (img != null)
                {
                    if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                    {
                        using (var b = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor))
                        {
                            graphics.FillRectangle(b, new sd.Rectangle(cellBounds.X, cellBounds.Y, IconSize + IconPadding * 2, cellBounds.Height));
                        }
                    }

                    var container = graphics.BeginContainer();
                    graphics.SetClip(cellBounds);
                    if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                    {
                        using (var background = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor))
                            graphics.FillRectangle(background, cellBounds);
                    }
                    graphics.InterpolationMode = InterpolationMode;
                    graphics.DrawImage(img, new sd.Rectangle(cellBounds.X + IconPadding, cellBounds.Y + (cellBounds.Height - Math.Min(img.Height, cellBounds.Height)) / 2, IconSize, IconSize));
                    graphics.EndContainer(container);
                    cellBounds.X     += IconSize + IconPadding * 2;
                    cellBounds.Width -= IconSize + IconPadding * 2;
                }
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
Beispiel #21
0
            protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var val = value as object[];
                var img = val[0] as sd.Image;

                if (img != null)
                {
                    var container = graphics.BeginContainer();
                    graphics.SetClip(cellBounds);
                    graphics.InterpolationMode = InterpolationMode;
                    graphics.DrawImage(img, new sd.Rectangle(cellBounds.X + IconPadding, cellBounds.Y + (cellBounds.Height - Math.Min(img.Height, cellBounds.Height)) / 2, IconSize, IconSize));
                    graphics.EndContainer(container);
                    cellBounds.X     += IconSize + IconPadding * 2;
                    cellBounds.Width -= IconSize + IconPadding * 2;
                }
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
Beispiel #22
0
        public override void Paint(GridColumnHandler column, sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
        {
            if (object.ReferenceEquals(column.Widget, this.Widget.Columns[0]))
            {
                // paint the background
                if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                {
                    sd.Brush brush;
                    if (cellState.HasFlag(swf.DataGridViewElementStates.Selected))
                    {
                        brush = new sd.SolidBrush(cellStyle.SelectionBackColor);
                    }
                    else
                    {
                        brush = new sd.SolidBrush(cellStyle.BackColor);
                    }
                    graphics.FillRectangle(brush, cellBounds);
                    paintParts &= ~swf.DataGridViewPaintParts.Background;
                }

                var node     = controller.GetNodeAtRow(rowIndex);
                var treeRect = cellBounds;
                treeRect.X    += node.Level * INDENT_WIDTH;
                treeRect.Width = 16;

                if (ClassicStyle && ClassicGridLines)
                {
                    // Draw grid lines - for classic style
                    using (var linePen = new sd.Pen(sd.SystemBrushes.ControlDark, 1.0f))
                    {
                        var lineRect = treeRect;
                        lineRect.X       += 7;
                        lineRect.Width    = 10;
                        linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                        var isFirstSibling = node.IsFirstNode;
                        var isLastSibling  = node.IsLastNode;
                        if (node.Level == 0)
                        {
                            // the Root nodes display their lines differently
                            if (isFirstSibling && isLastSibling)
                            {
                                // only node, both first and last. Just draw horizontal line
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else if (isLastSibling)
                            {
                                // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else if (isFirstSibling)
                            {
                                // first sibling doesn't draw the line extended above. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.X, cellBounds.Bottom);
                            }
                            else
                            {
                                // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom);
                            }
                        }
                        else
                        {
                            if (isLastSibling)
                            {
                                // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else
                            {
                                // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom);
                            }

                            // paint lines of previous levels to the root
                            int horizontalStop = lineRect.X - INDENT_WIDTH;
                            var previousNode   = node.Parent;

                            while (previousNode != null)
                            {
                                if (!previousNode.IsLastNode)
                                {
                                    // paint vertical line
                                    graphics.DrawLine(linePen, horizontalStop, lineRect.Top, horizontalStop, lineRect.Bottom);
                                }
                                previousNode   = previousNode.Parent;
                                horizontalStop = horizontalStop - INDENT_WIDTH;
                            }
                        }
                    }
                }

                if (node.Item.Expandable)
                {
                    // draw open/close glyphs
                    if (swf.Application.RenderWithVisualStyles)
                    {
                        EnsureGlyphRenderers();
                        if (controller.IsExpanded(rowIndex))
                        {
                            openRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16));
                        }
                        else
                        {
                            closedRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16));
                        }
                    }
                    else
                    {
                        // todo: draw +/- manually
                        var glyphRect = treeRect;
                        glyphRect.Width = glyphRect.Height = 8;
                        glyphRect.X    += 3;
                        glyphRect.Y    += (treeRect.Height - glyphRect.Height) / 2;
                        graphics.FillRectangle(sd.SystemBrushes.Window, glyphRect);
                        graphics.DrawRectangle(sd.SystemPens.ControlDark, glyphRect);
                        glyphRect.Inflate(-2, -2);
                        if (!controller.IsExpanded(rowIndex))
                        {
                            var midx = glyphRect.X + glyphRect.Width / 2;
                            graphics.DrawLine(sd.SystemPens.ControlDarkDark, midx, glyphRect.Top, midx, glyphRect.Bottom);
                        }

                        var midy = glyphRect.Y + glyphRect.Height / 2;
                        graphics.DrawLine(sd.SystemPens.ControlDarkDark, glyphRect.Left, midy, glyphRect.Right, midy);
                    }
                }
            }
        }
Beispiel #23
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) ||
                    cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, shouldDisposeGraphics: false));
                }

                graphics.SetClip(cellBounds);
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
            }
Beispiel #24
0
 protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
 {
     Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
     base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
 }
Beispiel #25
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half;
                graphics.SetClip(cellBounds);
                var color = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor);

                graphics.FillRectangle(color, cellBounds);
                var args = new CellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
                graphics.Restore(state);
            }