private Office2007CheckBoxStateColorTable GetCheckBoxStateColorTable(CheckBoxItemRenderEventArgs e)
 {
     CheckBoxItem item = e.CheckBoxItem;
     if (m_ColorTable != null && BarFunctions.IsOffice2007Style(e.CheckBoxItem.EffectiveStyle))
     {
         Office2007CheckBoxColorTable ct = GetColorTable(e.CheckBoxItem, e.ItemPaintArgs.ContainerControl); // m_ColorTable.CheckBoxItem;
         if (!item.GetEnabled())
             return ct.Disabled;
         else if (item.IsMouseDown)
             return ct.Pressed;
         else if (item.IsMouseOver)
             return ct.MouseOver;
         return ct.Default;
     }
     else
     {
         ColorScheme cs = e.ColorScheme;
         // Create color table based on the ColorScheme object...
         Office2007CheckBoxStateColorTable ct = new Office2007CheckBoxStateColorTable();
         if (!item.GetEnabled())
         {
             ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
             ct.CheckBorder = cs.ItemDisabledText;
             ct.CheckInnerBorder = cs.ItemDisabledText;
             ct.CheckInnerBackground = new LinearGradientColorTable();
             ct.CheckSign = new LinearGradientColorTable(cs.ItemDisabledText, Color.Empty);
             ct.Text = cs.ItemDisabledText;
         }
         else if (item.IsMouseDown)
         {
             ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
             ct.CheckBorder = cs.ItemPressedBorder;
             ct.CheckInnerBorder = cs.ItemPressedBorder;
             ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2);
             ct.CheckSign = new LinearGradientColorTable(cs.ItemPressedText, Color.Empty);
             ct.Text = cs.ItemPressedText;
         }
         else if (item.IsMouseOver)
         {
             ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
             ct.CheckBorder = cs.ItemHotBorder;
             ct.CheckInnerBorder = cs.ItemHotBorder;
             ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2);
             ct.CheckSign = new LinearGradientColorTable(cs.ItemHotText, Color.Empty);
             ct.Text = cs.ItemHotText;
         }
         else
         {
             ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
             ct.CheckBorder = cs.PanelBorder;
             ct.CheckInnerBorder = ColorBlendFactory.SoftLight(cs.PanelBorder, Color.White);
             ct.CheckInnerBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
             ct.CheckSign = new LinearGradientColorTable(cs.ItemText, Color.Empty);
             ct.Text = cs.ItemText;
         }
         return ct;
     }
 }
        public void PaintRadioButton(Graphics g, Rectangle checkBoxPosition, Office2007CheckBoxStateColorTable ct, bool isChecked)
        {
            Rectangle r = checkBoxPosition;
            r.Inflate(-1, -1);
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(r);
                DisplayHelp.FillPath(g, path, ct.CheckBackground);
            }
            using (Pen pen = new Pen(ct.CheckBorder, 1))
            {
                g.DrawEllipse(pen, checkBoxPosition);
            }
            // Draw inner border
            checkBoxPosition.Inflate(-3, -3);
            using (Pen pen = new Pen(ct.CheckInnerBorder, 1))
            {
                g.DrawEllipse(pen, checkBoxPosition);
            }

            if (!ct.CheckInnerBackground.IsEmpty)
            {
                if (ct.CheckInnerBackground.End.IsEmpty)
                {
                    r = checkBoxPosition;
                    r.Inflate(-1, -1);
                    using (SolidBrush brush = new SolidBrush(ct.CheckInnerBackground.Start))
                        g.FillEllipse(brush, r);
                }
                else
                {
                    // Draw gradient
                    Region old = g.Clip;
                    g.SetClip(checkBoxPosition, System.Drawing.Drawing2D.CombineMode.Replace);

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(checkBoxPosition);

                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor = ct.CheckInnerBackground.Start;
                            brush.SurroundColors = new Color[] { ct.CheckInnerBackground.End };
                            brush.CenterPoint = new PointF(checkBoxPosition.X, checkBoxPosition.Y);
                            g.FillEllipse(brush, checkBoxPosition);
                        }
                    }
                    g.Clip = old;
                }
            }

            if (isChecked && !ct.CheckSign.IsEmpty)
            {
                r = checkBoxPosition;
                //r.Inflate(-1, -1);
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(r);
                    DisplayHelp.FillPath(g, path, ct.CheckSign);
                }
            }
        }
        public void PaintCheckBox(Graphics g, Rectangle checkBoxPosition, Office2007CheckBoxStateColorTable ct, CheckState checkState)
        {
            Rectangle r = checkBoxPosition;
            r.Inflate(-1, -1);
            if(checkBoxPosition.Width<5 || checkBoxPosition.Height<5) return;

            DisplayHelp.FillRectangle(g, r, ct.CheckBackground);
            DisplayHelp.DrawRectangle(g, ct.CheckBorder, checkBoxPosition);

            // Inside rectangle
            checkBoxPosition.Inflate(-2, -2);

            if (!ct.CheckInnerBackground.IsEmpty)
            {
                if (ct.CheckInnerBackground.End.IsEmpty)
                {
                    r = checkBoxPosition;
                    r.Inflate(-1, -1);
                    DisplayHelp.FillRectangle(g, r, ct.CheckInnerBackground.Start);
                }
                else
                {
                    // Draw gradient
                    Region old = g.Clip;
                    g.SetClip(checkBoxPosition, System.Drawing.Drawing2D.CombineMode.Intersect);

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(checkBoxPosition);

                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor = ct.CheckInnerBackground.Start;
                            brush.SurroundColors = new Color[] { ct.CheckInnerBackground.End };
                            brush.CenterPoint = new PointF(checkBoxPosition.X, checkBoxPosition.Y);
                            g.FillRectangle(brush, checkBoxPosition);
                        }
                    }
                    g.Clip = old;
                }
            }

            DisplayHelp.DrawRectangle(g, ct.CheckInnerBorder, checkBoxPosition);

            if (checkState == CheckState.Indeterminate)
            {
                checkBoxPosition.Inflate(-2, -2);
                SmoothingMode sm = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.None;
                DisplayHelp.FillRectangle(g, checkBoxPosition, ct.CheckSign);
                g.SmoothingMode = sm;
            }
            else if (checkState == CheckState.Checked && !ct.CheckSign.IsEmpty)
            {
                using (GraphicsPath path = GetCheckSign(checkBoxPosition))
                    DisplayHelp.FillPath(g, path, ct.CheckSign);
            }
        }
Esempio n. 4
0
        private static Office2007CheckBoxStateColorTable GetCheckBoxStateColorTable(NodeCellRendererEventArgs e)
        {
            Cell cell = e.Cell;

            if (ColorTable != null && BarFunctions.IsOffice2007Style(e.ColorScheme.Style))
            {
                Office2007CheckBoxColorTable ct = ColorTable;
                if (!cell.GetEnabled())
                    return ct.Disabled;
                //else if (cell.IsMouseDown)
                //    return ct.Pressed;
                //else if (cell.IsMouseOver)
                //    return ct.MouseOver;
                return ct.Default;
            }
            else
            {
                ColorScheme cs = e.ColorScheme;
                // Create color table based on the ColorScheme object...
                Office2007CheckBoxStateColorTable ct = new Office2007CheckBoxStateColorTable();
                if (!cell.GetEnabled())
                {
                    ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
                    ct.CheckBorder = cs.ItemDisabledText;
                    ct.CheckInnerBorder = cs.ItemDisabledText;
                    ct.CheckInnerBackground = new LinearGradientColorTable();
                    ct.CheckSign = new LinearGradientColorTable(cs.ItemDisabledText, Color.Empty);
                    ct.Text = cs.ItemDisabledText;
                }
                //else if (cell.IsMouseDown)
                //{
                //    ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
                //    ct.CheckBorder = cs.ItemPressedBorder;
                //    ct.CheckInnerBorder = cs.ItemPressedBorder;
                //    ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2);
                //    ct.CheckSign = new LinearGradientColorTable(cs.ItemPressedText, Color.Empty);
                //    ct.Text = cs.ItemPressedText;
                //}
                //else if (cell.IsMouseOver)
                //{
                //    ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
                //    ct.CheckBorder = cs.ItemHotBorder;
                //    ct.CheckInnerBorder = cs.ItemHotBorder;
                //    ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2);
                //    ct.CheckSign = new LinearGradientColorTable(cs.ItemHotText, Color.Empty);
                //    ct.Text = cs.ItemHotText;
                //}
                else
                {
                    ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
                    ct.CheckBorder = cs.PanelBorder;
                    ct.CheckInnerBorder = ColorBlendFactory.SoftLight(cs.PanelBorder, Color.White);
                    ct.CheckInnerBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
                    ct.CheckSign = new LinearGradientColorTable(cs.ItemText, Color.Empty);
                    ct.Text = cs.ItemText;
                }
                return ct;
            }
        }