Exemplo n.º 1
0
        /// <summary>
        /// Gets the first border color.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetBorderColor1(PaletteState state)
        {
            if (Apply)
            {
                Color ret = _primary.GetBorderColor1(Override ? OverrideState : state);

                if (ret == Color.Empty)
                {
                    ret = _backup.GetBorderColor1(state);
                }

                return(ret);
            }
            else
            {
                return(_backup.GetBorderColor1(state));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the actual first border color.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>Color value.</returns>
 public Color GetBorderColor1(PaletteState state)
 {
     if (Color1 != Color.Empty)
     {
         return(Color1);
     }
     else
     {
         return(_inherit.GetBorderColor1(state));
     }
 }
        /// <summary>
        /// Gets the first border color.
        /// </summary>
        /// <param name="style">Border style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetBorderColor1(PaletteBorderStyle style, PaletteState state)
        {
            IPaletteBorder inherit = GetInherit(state);

            if (inherit != null)
            {
                return(inherit.GetBorderColor1(state));
            }
            else
            {
                return(Target.GetBorderColor1(style, state));
            }
        }
 /// <summary>
 /// Gets the first background color.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>Color value.</returns>
 public Color GetBackColor1(PaletteState state)
 {
     return(_parent.GetBorderColor1(state));
 }
 /// <summary>
 /// Gets the actual first border color.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>Color value.</returns>
 public Color GetBorderColor1(PaletteState state)
 {
     return(_inherit.GetBorderColor1(state));
 }
        /// <summary>
        /// Gets the first border color.
        /// </summary>
        /// <param name="style">Border style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetBorderColor1(PaletteBorderStyle style, PaletteState state)
        {
            IPaletteBorder inherit = GetInherit(state);

            return(inherit?.GetBorderColor1(state) ?? Target.GetBorderColor1(style, state));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the first border color.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>Color value.</returns>
 public override Color GetBorderColor1(PaletteState state) => _inherit.GetBorderColor1(state);
Exemplo n.º 8
0
        /// <summary>
        /// Draw border on the inside edge of the specified rectangle.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="palette">Palette used for drawing.</param>
        /// <param name="orientation">Visual orientation of the border.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawBorder(RenderContext context,
									    Rectangle rect,
									    IPaletteBorder palette,
										VisualOrientation orientation,
										PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            PaletteDrawBorders borders = palette.GetBorderDrawBorders(state);

            // Is there anything to actually draw?
            if ((rect.Width > 0) && (rect.Height > 0) && CommonHelper.HasABorder(borders))
            {
                // Only use anti aliasing if the border is rounded
                SmoothingMode smoothMode = (palette.GetBorderRounding(state) > 0 ? SmoothingMode.AntiAlias : SmoothingMode.Default);

                // We want to draw using anti aliasing for a nice smooth effect
                using (GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)))
                {
                    // Cache commonly used values
                    int borderWidth = palette.GetBorderWidth(state);

                    // Get the orientation correct borders value
                    borders = CommonHelper.OrientateDrawBorders(borders, orientation);

                    // Is there any border to actually draw?
                    if (borderWidth > 0)
                    {
                        using (Clipping clip = new Clipping(context.Graphics, rect))
                        {
                            // We always create the first border path variant
                            GraphicsPath borderPath0 = CreateBorderBackPath(true, true, rect, borders, borderWidth,
                                                                            palette.GetBorderRounding(state),
                                                                            (smoothMode == SmoothingMode.AntiAlias), 0);

                            GraphicsPath borderPath1 = null;

                            // We only need the second border path if the two borders used are opposite each other
                            if ((borders == PaletteDrawBorders.TopBottom) ||
                                (borders == PaletteDrawBorders.LeftRight))
                            {
                                borderPath1 = CreateBorderBackPath(true, true, rect, borders, borderWidth,
                                                                   palette.GetBorderRounding(state),
                                                                   (smoothMode == SmoothingMode.AntiAlias), 1);
                            }

                            // Get the rectangle to use when dealing with gradients
                            Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBorderColorAlign(state), rect);

                            // Use standard helper routine to create appropriate color brush
                            PaletteColorStyle colorStyle = palette.GetBorderColorStyle(state);
                            using (Pen borderPen = new Pen(CreateColorBrush(gradientRect,
                                                                            palette.GetBorderColor1(state),
                                                                            palette.GetBorderColor2(state),
                                                                            colorStyle,
                                                                            palette.GetBorderColorAngle(state),
                                                                            orientation), borderWidth))
                            {
                                if (colorStyle == PaletteColorStyle.Dashed)
                                    borderPen.DashPattern = new float[] { 2, 2 };

                                context.Graphics.DrawPath(borderPen, borderPath0);

                                // Optionally also draw the second path
                                if (borderPath1 != null)
                                    context.Graphics.DrawPath(borderPen, borderPath1);
                            }

                            Image borderImage = palette.GetBorderImage(state);
                            PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state);

                            // Do we need to draw the image?
                            if (ShouldDrawImage(borderImage))
                            {
                                // Get the rectangle to use when dealing with gradients
                                Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect);

                                // Use standard helper routine to create appropriate image brush
                                using (Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth))
                                {
                                    context.Graphics.DrawPath(borderPen, borderPath0);

                                    // Optionally also draw the second path
                                    if (borderPath1 != null)
                                        context.Graphics.DrawPath(borderPen, borderPath1);
                                }
                            }

                            // Remember to dispose of resources
                            borderPath0.Dispose();

                            if (borderPath1 != null)
                                borderPath1.Dispose();
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Evaluate if transparent painting is needed for background or border palettes.
        /// </summary>
        /// <param name="paletteBack">Background palette to test.</param>
        /// <param name="paletteBorder">Background palette to test.</param>
        /// <param name="state">Element state associated with palette.</param>
        /// <returns>True if transparent painting required.</returns>
        public override bool EvalTransparentPaint(IPaletteBack paletteBack,
                                                  IPaletteBorder paletteBorder,
                                                  PaletteState state)
        {
            int rounding = paletteBorder.GetBorderRounding(state);

            // If the border takes up some visual space
            if (paletteBorder.GetBorderWidth(state) > 0)
            {
                // If the border is not being painted then it must be transparent
                if (paletteBorder.GetBorderDraw(state) == InheritBool.False)
                    return true;
                else
                {
                    // If there is rounding causing transparent corners
                    if (paletteBorder.GetBorderRounding(state) > 0)
                        return true;
                    else
                    {
                        // If the first color has alpha channel then has transparency
                        if (paletteBorder.GetBorderColor1(state).A < 255)
                            return true;
                        else
                        {
                            // Does the draw style require use of the second color?
                            if (paletteBorder.GetBorderColorStyle(state) != PaletteColorStyle.Solid)
                            {
                                // If the second color has alpha channel then has transparency
                                if (paletteBorder.GetBorderColor2(state).A < 255)
                                    return true;
                            }
                        }
                    }
                }
            }

            // The border does not cause transparency, check the background
            return EvalTransparentPaint(paletteBack, state);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Draw border on the inside edge of the specified rectangle.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="palette">Palette used for drawing.</param>
        /// <param name="orientation">Visual orientation of the border.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="tabBorderStyle">Style of tab border.</param>
        public override void DrawTabBorder(RenderContext context,
                                           Rectangle rect,
                                           IPaletteBorder palette,
                                           VisualOrientation orientation,
                                           PaletteState state,
                                           TabBorderStyle tabBorderStyle)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Is there anything to actually draw?
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Decide if we need to use anti aliasing for a smoother looking visual
                using (GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)))
                {
                    // Cache commonly used values
                    int borderWidth = palette.GetBorderWidth(state);

                    // Is there any border to actually draw?
                    if (borderWidth > 0)
                    {
                        // Create the path that represents the entire tab border
                        using (GraphicsPath borderPath = CreateTabBorderBackPath(context.Control.RightToLeft, state, true, rect,
                                                                                 borderWidth, tabBorderStyle, orientation,
                                                                                 (palette.GetBorderGraphicsHint(state) == PaletteGraphicsHint.AntiAlias)))
                        {
                            // Get the rectangle to use when dealing with gradients
                            Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBorderColorAlign(state), rect);

                            // Use standard helper routine to create appropriate color brush
                            using(Brush borderBrush = CreateColorBrush(gradientRect,
                                                                       palette.GetBorderColor1(state),
                                                                       palette.GetBorderColor2(state),
                                                                       palette.GetBorderColorStyle(state),
                                                                       palette.GetBorderColorAngle(state),
                                                                       orientation))
                            {
                                using (Pen borderPen = new Pen(borderBrush, borderWidth))
                                    context.Graphics.DrawPath(borderPen, borderPath);
                            }

                            Image borderImage = palette.GetBorderImage(state);

                            // Do we need to draw the image?
                            if (ShouldDrawImage(borderImage))
                            {
                                // Get the rectangle to use when dealing with gradients
                                Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect);

                                // Get the image style to use for the image brush
                                PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state);

                                // Use standard helper routine to create appropriate image brush
                                using (Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth))
                                {
                                    context.Graphics.DrawPath(borderPen, borderPath);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// the main difference with a Group row and a regular row is the way it is painted on the control.
        /// the Paint method is therefore overridden and specifies how the Group row is painted.
        /// Note: this method is not implemented optimally. It is merely used for demonstration purposes
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="rowBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="rowState"></param>
        /// <param name="isFirstDisplayedRow"></param>
        /// <param name="isLastVisibleRow"></param>
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow)
        {
            if (isGroupRow)
            {
                KryptonOutlookGrid grid   = (KryptonOutlookGrid)DataGridView;
                int rowHeadersWidth       = grid.RowHeadersVisible ? grid.RowHeadersWidth : 0;
                int groupLevelIndentation = group.Level * StaticValues._groupLevelMultiplier;

                int       gridwidth   = grid.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);
                Rectangle myRowBounds = rowBounds;
                myRowBounds.Width = gridwidth;

                IPaletteBack   paletteBack   = grid.StateNormal.DataCell.Back;
                IPaletteBorder paletteBorder = grid.StateNormal.DataCell.Border;

                PaletteState state = PaletteState.Normal;
                if (grid.PreviousSelectedGroupRow == rowIndex && (KryptonManager.CurrentGlobalPalette.GetRenderer() != KryptonManager.RenderOffice2013))
                {
                    state = PaletteState.CheckedNormal;
                }

                using (RenderContext renderContext = new RenderContext(grid, graphics, myRowBounds, grid.Renderer))
                {
                    using (GraphicsPath path = grid.Renderer.RenderStandardBorder.GetBackPath(renderContext, myRowBounds, paletteBorder, VisualOrientation.Top, PaletteState.Normal))
                    {
                        //Back
                        IDisposable unused = grid.Renderer.RenderStandardBack.DrawBack(renderContext,
                                                                                       myRowBounds,
                                                                                       path,
                                                                                       paletteBack,
                                                                                       VisualOrientation.Top,
                                                                                       state,
                                                                                       null);

                        // We never save the memento for reuse later
                        if (unused != null)
                        {
                            unused.Dispose();
                            unused = null;
                        }
                    }
                }

                // Draw the botton : solid line for 2007 palettes or dot line for 2010 palettes, full background for 2013
                if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010)
                {
                    using (Pen focusPen = new Pen(Color.Gray))
                    {
                        focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                        graphics.DrawLine(focusPen, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 1, gridwidth + 1, rowBounds.Bottom - 1);
                    }
                }
                else if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                {
                    using (SolidBrush br = new SolidBrush(Color.FromArgb(225, 225, 225)))
                    {
                        graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - StaticValues._2013GroupRowHeight, gridwidth + 1, StaticValues._2013GroupRowHeight - 1);
                    }
                }
                else
                {
                    using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state)))
                    {
                        graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset, rowBounds.Bottom - 2, gridwidth + 1, 2);
                    }
                }

                //Draw right vertical bar
                if (grid.CellBorderStyle == DataGridViewCellBorderStyle.SingleVertical || grid.CellBorderStyle == DataGridViewCellBorderStyle.Single)
                {
                    using (SolidBrush br = new SolidBrush(paletteBorder.GetBorderColor1(state)))
                    {
                        graphics.FillRectangle(br, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + gridwidth, rowBounds.Top, 1, rowBounds.Height);
                    }
                }

                //Set the icon and lines according to the renderer
                if (group.Collapsed)
                {
                    if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                    {
                        graphics.DrawImage(Properties.Resources.CollapseIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11);
                    }
                    else
                    {
                        graphics.DrawImage(Properties.Resources.ExpandIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11);
                    }
                }
                else
                {
                    if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                    {
                        graphics.DrawImage(Properties.Resources.ExpandIcon2010, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11);
                    }
                    else
                    {
                        graphics.DrawImage(Properties.Resources.CollapseIcon, rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + groupLevelIndentation, rowBounds.Bottom - 18, 11, 11);
                    }
                }

                //Draw image group
                int imageoffset = 0;
                if (group.GroupImage != null)
                {
                    if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2010 || KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                    {
                        graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide);
                        imageoffset = StaticValues._ImageOffsetwidth;
                    }
                    else
                    {
                        graphics.DrawImage(group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide);
                        imageoffset = StaticValues._ImageOffsetwidth;
                    }
                }

                //Draw text, using the current grid font
                int offsetText = rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + imageoffset + groupLevelIndentation;
                if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                {
                    TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._2013OffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state),
                                          TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                }
                else
                {
                    TextRenderer.DrawText(graphics, group.Text, grid.GridPalette.GetContentShortTextFont(PaletteContentStyle.LabelBoldControl, state), new Rectangle(offsetText, rowBounds.Bottom - StaticValues._defaultOffsetHeight, rowBounds.Width - offsetText, rowBounds.Height), grid.GridPalette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalControl, state),
                                          TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                }

                ////Debug Hits
                ////ExpandCollaspe icon
                //graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + 4 + group.Level * 15, rowBounds.Bottom - 18, 11, 11));
                ////Image
                //if (KryptonManager.CurrentGlobalPalette.GetRenderer() == KryptonManager.RenderOffice2013)
                //    graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._2013OffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide));
                //else
                //    graphics.DrawRectangle(new Pen(Color.Blue), new Rectangle(rowBounds.Left + rowHeadersWidth - grid.HorizontalScrollingOffset + StaticValues._ImageOffsetwidth + groupLevelIndentation, rowBounds.Bottom - StaticValues._defaultOffsetHeight, StaticValues._groupImageSide, StaticValues._groupImageSide));
            }
            else
            {
                base.Paint(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow);
            }
        }
 /// <summary>
 /// Gets the first background color.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>Color value.</returns>
 public Color GetBackColor1(PaletteState state) => _parent.GetBorderColor1(state);