Example #1
0
        public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
        {
            DGVScrollBar vsb = GetVScrollBar();
            if (vsb != null && vsb.Visible) vsb.Invalidate();

            DGHScrollBar hsb = GetHScrollBar();
            if (hsb != null && hsb.Visible) hsb.Invalidate();

            // Update Style
            Office2007ColorTable ct = null;
            if (GlobalManager.Renderer is Office2007Renderer)
            {
                ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
                m_ColorTable = ct.DataGridView;
                m_ButtonStateColorTable = ct.ButtonItemColors[0].Checked;
            }
            try // Don't like to do this but bug in GridColor setter requires it
            {
                if (!_UseCustomBackgroundColor)
                    this.BackgroundColor = m_ColorTable.BackgroundColor;
                this.ColumnHeadersDefaultCellStyle.ForeColor = m_ColorTable.ColumnHeaderNormalText;
                this.ColumnHeadersDefaultCellStyle.SelectionForeColor = m_ColorTable.ColumnHeaderSelectedText;
                this.DefaultCellStyle.BackColor = m_ColorTable.DefaultCellBackground;
                this.DefaultCellStyle.ForeColor = m_ColorTable.DefaultCellText;
                if (this.PaintEnhancedSelection)
                    this.DefaultCellStyle.SelectionForeColor = m_ButtonStateColorTable.Text;
                this.GridColor = m_ColorTable.GridColor;
                this.RowHeadersDefaultCellStyle.ForeColor = m_ColorTable.ColumnHeaderNormalText;
                this.RowHeadersDefaultCellStyle.SelectionForeColor = m_ColorTable.ColumnHeaderSelectedText;
                this.EnableHeadersVisualStyles = false;
            }
            catch { }
        }
Example #2
0
 protected virtual void PaintButtonBackground(PaintInfo p, Office2007ButtonItemStateColorTable ct)
 {
     Graphics g = p.Graphics;
     Rectangle r = this.RenderBounds;
     if (RenderBackground(p))
         Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RectangleShape);
 }
Example #3
0
        protected override void PaintStateBackground(ButtonItem button, Graphics g, Office2007ButtonItemStateColorTable stateColors, Rectangle r, IShapeDescriptor shape, bool isDefault, bool paintBorder)
        {
            if (stateColors == null || stateColors.Background == null || stateColors.Background.IsEmpty)
                return;

            Rectangle shadowRect = r;
            ShadowPaintInfo spi = new ShadowPaintInfo();
            spi.Graphics = g;
            spi.Rectangle = shadowRect;
            ShadowPainter.Paint3(spi);

            r.Width -= 4;
            r.Height -= 4;
            r.Offset(1, 1);

            DisplayHelp.FillRectangle(g, r, stateColors.Background);
            if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty)
            {
                Rectangle ellipse = new Rectangle(r.X, r.Y + r.Height / 2 - 2, r.Width, r.Height + 4);
                GraphicsPath path = new GraphicsPath();
                path.AddEllipse(ellipse);
                PathGradientBrush brush = new PathGradientBrush(path);
                brush.CenterColor = stateColors.BottomBackgroundHighlight.Start;
                brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End };
                brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, r.Bottom);
                Blend blend = new Blend();
                blend.Factors = new float[] { 0f, .5f, .6f };
                blend.Positions = new float[] { .0f, .4f, 1f };
                brush.Blend = blend;

                g.FillRectangle(brush, r);
                brush.Dispose();
                path.Dispose();
            }

            DisplayHelp.DrawGradientRectangle(g, r, stateColors.OuterBorder, 1);
            r.Inflate(-1, -1);
            DisplayHelp.DrawGradientRectangle(g, r, stateColors.InnerBorder, 1);
        }
Example #4
0
        internal static Office2007ButtonItemColorTable GetFallBackAppButtonColorTable()
        {
            if (FallBackAppButtonColorTable != null) return FallBackAppButtonColorTable;

            // Blue default
            Office2007ButtonItemColorTable table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.Blue);

            Office2007ButtonItemStateColorTable ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(0x3E7DDB, 0x265FB2);
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(DevComponents.DotNetBar.ColorScheme.GetColor(64, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(0x1E48A0, 0x244FA6);
            ct.InnerBorder = new LinearGradientColorTable(32, 0xFFFFFF);
            ct.Text = DevComponents.DotNetBar.ColorScheme.GetColor(0xFFFFFF);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(0x4786E5, 0x2D65BC);
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(DevComponents.DotNetBar.ColorScheme.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(0x1F48A1, 0x2954A9);
            ct.InnerBorder = new LinearGradientColorTable(DevComponents.DotNetBar.ColorScheme.GetColor(72, 0xFFFFFF), DevComponents.DotNetBar.ColorScheme.GetColor(48, 0xFFFFFF));
            ct.Text = DevComponents.DotNetBar.ColorScheme.GetColor(0xFFFFFF);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(0x2861B6, 0x1D5AB2);
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(DevComponents.DotNetBar.ColorScheme.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(0x1F48A1, 0x224EA6);
            ct.InnerBorder = new LinearGradientColorTable(DevComponents.DotNetBar.ColorScheme.GetColor(72, 0xFFFFFF), DevComponents.DotNetBar.ColorScheme.GetColor(48, 0xFFFFFF));
            ct.Text = DevComponents.DotNetBar.ColorScheme.GetColor(0xFFFFFF);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            FallBackAppButtonColorTable = table;
            return table;
        }
Example #5
0
        private void PaintButton(Graphics g, MDISystemItem mdi , SystemButton button, Rectangle r, Office2007ButtonItemStateColorTable ct, ColorScheme colorScheme)
        {
            Region oldClip = g.Clip;
            g.SetClip(r);

            Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RoundCorner2);
            r.Inflate(-1, -1);
            r.Offset(1, 0);
            using (Bitmap bmp = mdi.GetButtonBitmap(g, button, r, colorScheme))
            {
                if (button == SystemButton.Minimize && !mdi.MinimizeEnabled ||
                    button == SystemButton.Restore && !mdi.RestoreEnabled ||
                    button == SystemButton.Close && !mdi.CloseEnabled)
                {
                    float[][] array = new float[5][];
                    array[0] = new float[5] { 0, 0, 0, 0, 0 };
                    array[1] = new float[5] { 0, 0, 0, 0, 0 };
                    array[2] = new float[5] { 0, 0, 0, 0, 0 };
                    array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 };
                    array[4] = new float[5] { 0, 0, 0, 0, 0 };
                    System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
                    System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
                    disabledImageAttr.ClearColorKey();
                    disabledImageAttr.SetColorMatrix(grayMatrix);
                    g.DrawImage(bmp, r, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr);
                }
                else
                {
                    if (button == mdi.MouseDownButton)
                        r.Offset(1, 1);
                    g.DrawImageUnscaled(bmp, r);
                }
            }

            g.Clip = oldClip;
        }
Example #6
0
        internal static void InitAppButtonColors(Office2007ColorTable colorTable, ColorFactory factory, MetroPartColors metroColors)
        {
            Office2007ButtonItemColorTableCollection colors = colorTable.ApplicationButtonColors;
            colors.Clear();

            // Blue default
            Office2007ButtonItemColorTable table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.Orange);

            Office2007ButtonItemStateColorTable ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(metroColors.BaseColor));
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(32, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = LinearGradientColorTable.Empty; //new LinearGradientColorTable(factory.GetColor(metroColors.BaseColor));
            ct.InnerBorder = LinearGradientColorTable.Empty; //new LinearGradientColorTable(factory.GetColor(16, 0xFFFFFF));
            ct.Text = factory.GetColor(metroColors.BaseTextColor);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(metroColors.BaseColorLight1));
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(metroColors.BaseColorDark));
            ct.InnerBorder = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(72, 0xFFFFFF), factory.GetColor(48, 0xFFFFFF)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(metroColors.BaseTextColor);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(metroColors.BaseColorDark));
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(metroColors.BaseColorDarker));
            ct.InnerBorder = LinearGradientColorTable.Empty; // new LinearGradientColorTable(factory.GetColor(72, 0xFFFFFF), factory.GetColor(48, 0xFFFFFF)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(metroColors.BaseTextColor);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            colors.Add(table);

            // Magenta
            table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.Magenta);

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xCC256B), factory.GetColor(0xB10851));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(64, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x8F013C), factory.GetColor(0x940741));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(32, 0xFFFFFF));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xD63272), factory.GetColor(0xB10B52));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x8F013C), factory.GetColor(0x950942));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(72, 0xFFFFFF), factory.GetColor(48, 0xFFFFFF)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xB50C53), factory.GetColor(0xB00B52));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(82, 0xFFFFFF), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x8F013D), factory.GetColor(0x950741));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(72, 0xFFFFFF), factory.GetColor(48, 0xFFFFFF)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            colors.Add(table);

            // Orange
            table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.Blue);

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xF27350), factory.GetColor(0xE5552F));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0xF89E42), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0xCC2B12), factory.GetColor(0xCF3415));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0xF68954), factory.GetColor(0xF78B3E));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xF87E4D), factory.GetColor(0xE6552E));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0xFBBD5E), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0xCA2810), factory.GetColor(0xCD3217));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0xFBAA5A), factory.GetColor(0xFCB857)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0xE3531D), factory.GetColor(0xE04E19));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0xFDAF4C), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0xCA2810), factory.GetColor(0xCD3013));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0xE86229), factory.GetColor(0xFB8D44)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            colors.Add(table);

            // Green
            table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.BlueWithBackground);

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x459731), factory.GetColor(0x2B7F2C));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x6BCA45), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x186337), factory.GetColor(0x1E6A39));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x4CA231), factory.GetColor(0x53B331));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x469734), factory.GetColor(0x267C2B));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x89D668), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x196437), factory.GetColor(0x216B3C));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x65B943), factory.GetColor(0x70CC4A));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x2F822A), factory.GetColor(0x2A7E2C));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x68CB38), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x186437), factory.GetColor(0x1D6A38));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x368F2B), factory.GetColor(0x59BD2D)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            colors.Add(table);

            // Teal
            table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.MagentaWithBackground);

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x159795), factory.GetColor(0x018281));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x20B7B4), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x055E5E), factory.GetColor(0x076464));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x1BA29D), factory.GetColor(0x1FB1A9));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x1F9C99), factory.GetColor(0x038584));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x36CDCA), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x055E5E), factory.GetColor(0x096767));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x30B8B3), factory.GetColor(0x34C2BE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(factory.GetColor(0x028482), factory.GetColor(0x028081));
            ct.BottomBackgroundHighlight = new LinearGradientColorTable(factory.GetColor(0x2CC2BE), Color.Transparent);
            ct.OuterBorder = new LinearGradientColorTable(factory.GetColor(0x055E5E), factory.GetColor(0x086565));
            ct.InnerBorder = new LinearGradientColorTable(factory.GetColor(0x028F8D), factory.GetColor(0x1DB4AD)); //new LinearGradientColorTable(factory.GetColor(0x55A1F3), factory.GetColor(0x4F9EEE));
            ct.Text = factory.GetColor(0xFFFFFF);
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            colors.Add(table);
        }
Example #7
0
        internal static Office2007ButtonItemColorTable GetAppFallBackColorTable()
        {
            if (FallBackAppButtonColorTable != null) return FallBackAppButtonColorTable;

            MetroPartColors metroColors = MetroColorTableInitializer.CreateMetroPartColors(MetroColorGeneratorParameters.Default.CanvasColor, MetroColorGeneratorParameters.Default.BaseColor);
            // Blue default
            Office2007ButtonItemColorTable table = new Office2007ButtonItemColorTable();
            table.Name = Enum.GetName(typeof(eButtonColor), eButtonColor.Orange);

            Office2007ButtonItemStateColorTable ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(metroColors.BaseColor);
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty; 
            ct.OuterBorder = LinearGradientColorTable.Empty;
            ct.InnerBorder = LinearGradientColorTable.Empty;
            ct.Text = metroColors.BaseTextColor;
            table.Default = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(metroColors.BaseColorLight1);
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty;
            ct.OuterBorder = LinearGradientColorTable.Empty;
            ct.InnerBorder = LinearGradientColorTable.Empty; 
            ct.Text = metroColors.BaseTextColor;
            table.MouseOver = ct;

            ct = new Office2007ButtonItemStateColorTable();
            ct.Background = new LinearGradientColorTable(metroColors.BaseColorDark);
            ct.BottomBackgroundHighlight = LinearGradientColorTable.Empty;
            ct.OuterBorder = LinearGradientColorTable.Empty;
            ct.InnerBorder = LinearGradientColorTable.Empty;
            ct.Text = metroColors.BaseTextColor;
            table.Pressed = ct;

            table.Expanded = table.Pressed;
            table.Checked = table.Pressed;

            FallBackAppButtonColorTable = table;

            return table;
        }
Example #8
0
        public static void PaintBackground(Graphics g, Office2007ButtonItemStateColorTable stateColors, Rectangle r, IShapeDescriptor shape, bool isDefault, bool paintBorder)
        {
            float topSplit = .35f;
            float bottomSplit = .65f;
            if (!shape.CanDrawShape(r)) return;

            if (stateColors != null)
            {
                Rectangle fillRectangle = r;
                
                Rectangle backRect = new Rectangle(fillRectangle.X, fillRectangle.Y, fillRectangle.Width, (int)(fillRectangle.Height * topSplit));
                if (!stateColors.OuterBorder.IsEmpty && paintBorder)
                    fillRectangle.Width--;
                GraphicsPath backPath = shape.GetShape(fillRectangle);
                if (stateColors.Background != null)
                {
                    if (backPath != null)
                    {
                        if (stateColors.Background.End.IsEmpty)
                        {
                            using (SolidBrush brush = new SolidBrush(stateColors.Background.Start))
                                g.FillPath(brush, backPath);
                        }
                        else
                        {
                            using (LinearGradientBrush lb = new LinearGradientBrush(fillRectangle, stateColors.Background.Start, stateColors.Background.End, stateColors.Background.GradientAngle))
                            {
                                g.FillPath(lb, backPath);
                            }
                        }
                        backPath.Dispose();
                    }
                }
                else
                {
                    if (backPath != null && stateColors.TopBackground!= null && stateColors.BottomBackground!=null)
                    {
                        if (stateColors.TopBackground.End.IsEmpty && stateColors.BottomBackground.End.IsEmpty)
                        {
                            if (stateColors.TopBackground.Start == stateColors.BottomBackground.Start)
                                using (SolidBrush lb = new SolidBrush(stateColors.TopBackground.Start))
                                    g.FillPath(lb, backPath);
                            else
                            {
                                using (LinearGradientBrush lb = new LinearGradientBrush(fillRectangle, stateColors.TopBackground.Start, stateColors.BottomBackground.Start, stateColors.TopBackground.GradientAngle))
                                {
                                    g.FillPath(lb, backPath);
                                }
                            }
                        }
                        else
                        {
                            using (LinearGradientBrush lb = new LinearGradientBrush(fillRectangle, stateColors.TopBackground.Start, stateColors.BottomBackground.End, stateColors.TopBackground.GradientAngle))
                            {
                                ColorBlend cb = new ColorBlend(4);
                                cb.Colors = new Color[] { stateColors.TopBackground.Start, stateColors.TopBackground.End, stateColors.BottomBackground.Start, stateColors.BottomBackground.End };
                                cb.Positions = new float[] { 0, topSplit, topSplit, 1f };
                                lb.InterpolationColors = cb;
                                g.FillPath(lb, backPath);
                            }
                        }
                        backPath.Dispose();
                    }

                    if (stateColors.TopBackgroundHighlight!=null && !stateColors.TopBackgroundHighlight.IsEmpty)
                    {
                        Rectangle ellipse = new Rectangle(fillRectangle.X, fillRectangle.Y, fillRectangle.Width, fillRectangle.Height);
                        GraphicsPath path = new GraphicsPath();
                        path.AddEllipse(ellipse);
                        PathGradientBrush brush = new PathGradientBrush(path);
                        brush.CenterColor = stateColors.TopBackgroundHighlight.Start;
                        brush.SurroundColors = new Color[] { stateColors.TopBackgroundHighlight.End };
                        brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, fillRectangle.Bottom);
                        Blend blend = new Blend();
                        blend.Factors = new float[] { 0f, .5f, 1f };
                        blend.Positions = new float[] { .0f, .4f, 1f };
                        brush.Blend = blend;

                        g.FillRectangle(brush, backRect);
                        brush.Dispose();
                        path.Dispose();
                    }

                    // Draw Bottom part
                    int bottomHeight = (int)(fillRectangle.Height * bottomSplit);
                    backRect = new Rectangle(fillRectangle.X, fillRectangle.Y + backRect.Height, fillRectangle.Width, fillRectangle.Height - backRect.Height);

                    if (stateColors.BottomBackgroundHighlight!=null && !stateColors.BottomBackgroundHighlight.IsEmpty)
                    {
                        Rectangle ellipse = new Rectangle(fillRectangle.X, fillRectangle.Y + bottomHeight - 2, fillRectangle.Width, fillRectangle.Height + 4);
                        GraphicsPath path = new GraphicsPath();
                        path.AddEllipse(ellipse);
                        PathGradientBrush brush = new PathGradientBrush(path);
                        brush.CenterColor = stateColors.BottomBackgroundHighlight.Start;
                        brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End };
                        brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, fillRectangle.Bottom);
                        Blend blend = new Blend();
                        blend.Factors = new float[] { 0f, .5f, .6f };
                        blend.Positions = new float[] { .0f, .4f, 1f };
                        brush.Blend = blend;

                        g.FillRectangle(brush, backRect);
                        brush.Dispose();
                        path.Dispose();
                    }
                }

                if (paintBorder)
                {
                    SmoothingMode sm = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    // Draw Border
                    if (!stateColors.OuterBorder.IsEmpty && stateColors.OuterBorderWidth>0)
                    {
                        Rectangle br = r;
                        br.Width--;
                        br.Height--;

                        if (shape is EllipticalShapeDescriptor && stateColors.OuterBorder.End.IsEmpty)
                        {
                            br.Width -= (stateColors.OuterBorderWidth / 2);
                            br.Height -= (stateColors.OuterBorderWidth / 2);
                            using (Pen pen = new Pen(stateColors.OuterBorder.Start, stateColors.OuterBorderWidth))
                                g.DrawEllipse(pen, br);
                        }
                        else
                        {
                            GraphicsPath path = shape.GetShape(br);
                            if (path != null)
                            {
                                DisplayHelp.DrawGradientPath(g, path, r, stateColors.OuterBorder, stateColors.OuterBorderWidth);
                                path.Dispose();
                            }
                        }
                        //if (cornerSize > 1)
                        //    DisplayHelp.DrawRoundGradientRectangle(g, r, stateColors.OuterBorder, 1, cornerSize);
                        //else
                        //    DisplayHelp.DrawGradientRectangle(g, r, stateColors.OuterBorder, 1);

                        if (isDefault)
                        {
                            Color clr = Color.FromArgb(128, stateColors.OuterBorder.Start);
                            r.Inflate(-1, -1);
                            DisplayHelp.DrawRectangle(g, clr, r);
                            r.Inflate(-1, -1);
                            DisplayHelp.DrawRectangle(g, clr, r);
                        }
                    }
                    if (!isDefault && !stateColors.InnerBorder.IsEmpty)
                    {
                        Rectangle innerRect = r;
                        innerRect.Inflate(-1, -1);
                        innerRect.Width--;
                        innerRect.Height--;
                        using (GraphicsPath path = shape.GetInnerShape(innerRect, 1))
                            DisplayHelp.DrawGradientPath(g, path, innerRect, stateColors.InnerBorder, 1);
                        //cornerSize--;
                        //if (cornerSize > 1)
                        //    DisplayHelp.DrawRoundGradientRectangle(g, innerRect, stateColors.InnerBorder, 1, cornerSize);
                        //else
                        //    DisplayHelp.DrawGradientRectangle(g, innerRect, stateColors.InnerBorder, 1);
                    }

                    g.SmoothingMode = sm;
                }
            }
        }
Example #9
0
 public static void PaintBackground(Graphics g, Office2007ButtonItemStateColorTable stateColors, Rectangle r, IShapeDescriptor shape, bool isDefault)
 {
     PaintBackground(g, stateColors, r, shape, isDefault, true);
 }
Example #10
0
 public static void PaintBackground(Graphics g, Office2007ButtonItemStateColorTable stateColors, Rectangle r, IShapeDescriptor shape)
 {
     PaintBackground(g, stateColors, r, shape, false);
 }
Example #11
0
 protected virtual void PaintStateBackground(ButtonItem button, Graphics g, Office2007ButtonItemStateColorTable stateColors, Rectangle r, IShapeDescriptor shape, bool isDefault, bool paintBorder)
 {
     PaintBackground(g, stateColors, r, shape, isDefault, paintBorder);
 }
Example #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Office2007ColorTable ct = null;
            if (GlobalManager.Renderer is Office2007Renderer)
            {
                ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
                m_ColorTable = ct.DataGridView;
                m_ButtonStateColorTable = ct.ButtonItemColors[0].Checked;
            }

            if (this.CurrentCell != null)
                m_SelectedRowIndex = this.CurrentCell.RowIndex;
            else
                m_SelectedRowIndex = -1;

            base.OnPaint(e);

            if (this.VerticalScrollBar.Visible && this.HorizontalScrollBar.Visible)
            {
                Rectangle r = new Rectangle(this.VerticalScrollBar.Left, this.VerticalScrollBar.Bottom, this.VerticalScrollBar.Width, this.HorizontalScrollBar.Height);
                Color c = ct.AppScrollBar.Default.Background.End;
                if (c.IsEmpty) c = ct.AppScrollBar.Default.Background.Start;
                DisplayHelp.FillRectangle(e.Graphics, r, c);
                //e.Graphics.FillRectangle(Brushes.BlueViolet, r);
            }

            m_ColorTable = null;
            m_ButtonStateColorTable = null;
        }