/// <summary>
        /// Initialize a new instance of the PaletteDataGridViewContentStates class.
        /// </summary>
        /// <param name="inherit">Source for inheriting defaulted values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteDataGridViewContentStates(IPaletteContent inherit,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Default the initial values
            _draw = InheritBool.Inherit;
            _hint = PaletteTextHint.Inherit;
            _trim = PaletteTextTrim.Inherit;
            _color1 = Color.Empty;
            _color2 = Color.Empty;
            _colorStyle = PaletteColorStyle.Inherit;
            _colorAlign = PaletteRectangleAlign.Inherit;
            _colorAngle = -1;
            _imageStyle = PaletteImageStyle.Inherit;
            _imageAlign = PaletteRectangleAlign.Inherit;
            _multiLine = InheritBool.Inherit;
            _multiLineH = PaletteRelativeAlign.Inherit;
        }
Exemplo n.º 2
0
        private static Brush CreateColorBrush(Rectangle rect,
                                              Color color1,
                                              Color color2,
                                              PaletteColorStyle gradientStyle,
                                              float angle,
                                              VisualOrientation orientation)
        {
            // Should never provide the inherit value
            Debug.Assert(gradientStyle != PaletteColorStyle.Inherit);

            // If the gradient style is a solid colour
            if (gradientStyle == PaletteColorStyle.Solid)
                return new SolidBrush(color1);
            else
            {
                // Adjust angle for the orientation
                switch(orientation)
                {
                    case VisualOrientation.Left:
                        angle -= 90;
                        break;
                    case VisualOrientation.Right:
                        angle += 90;
                        break;
                    case VisualOrientation.Bottom:
                        angle += 180;
                        break;
                }

                // For OneNote we always use white as the first color
                if (gradientStyle == PaletteColorStyle.OneNote)
                    color1 = Color.White;

                // Otherwise we always create a linear brush using provided colors and angle
                LinearGradientBrush brush = new LinearGradientBrush(rect, color1, color2, angle);

                switch (gradientStyle)
                {
                    case PaletteColorStyle.Sigma:
                        brush.SetSigmaBellShape(0.5f);
                        break;
                    case PaletteColorStyle.Rounded:
                        brush.SetSigmaBellShape(1f, 1f);
                        break;
                    case PaletteColorStyle.Switch25:
                        brush.Blend = _switch25Blend;
                        break;
                    case PaletteColorStyle.Switch33:
                        brush.Blend = _switch33Blend;
                        break;
                    case PaletteColorStyle.Switch50:
                        brush.Blend = _switch50Blend;
                        break;
                    case PaletteColorStyle.Switch90:
                        brush.Blend = _switch90Blend;
                        break;
                    case PaletteColorStyle.Linear25:
                        brush.Blend = _linear25Blend;
                        break;
                    case PaletteColorStyle.Linear33:
                        brush.Blend = _linear33Blend;
                        break;
                    case PaletteColorStyle.Linear40:
                        brush.Blend = _linear40Blend;
                        break;
                    case PaletteColorStyle.Linear50:
                        brush.Blend = _linear50Blend;
                        break;
                    case PaletteColorStyle.HalfCut:
                        brush.Blend = _halfCutBlend;
                        break;
                    case PaletteColorStyle.QuarterPhase:
                        brush.Blend = _quarterPhaseBlend;
                        break;
                    case PaletteColorStyle.OneNote:
                        brush.Blend = _oneNoteBlend;
                        break;
                    case PaletteColorStyle.Rounding2:
                        brush.Blend = _rounding2Blend;
                        break;
                    case PaletteColorStyle.Rounding3:
                        brush.Blend = _rounding3Blend;
                        break;
                    case PaletteColorStyle.Rounding4:
                        brush.Blend = _rounding4Blend;
                        break;
                    case PaletteColorStyle.Rounding5:
                        brush.Blend = _rounding5Blend;
                        break;
                }

                return brush;
            }
        }
Exemplo n.º 3
0
        private void DrawBackSolidLine(RenderContext context,
                                       Rectangle rect,
                                       Color backColor1,
                                       Color backColor2,
                                       PaletteColorStyle style,
                                       GraphicsPath path)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Draw entire background in second color
                using (SolidBrush brushColor2 = new SolidBrush(backColor2))
                    context.Graphics.FillRectangle(brushColor2, rect);

                // Reduce area by edge(s) we want to leave alone
                switch (style)
                {
                    case PaletteColorStyle.SolidTopLine:
                        rect.Y++;
                        rect.Height--;
                        break;
                    case PaletteColorStyle.SolidBottomLine:
                        rect.Height--;
                        break;
                    case PaletteColorStyle.SolidLeftLine:
                        rect.X++;
                        rect.Width--;
                        break;
                    case PaletteColorStyle.SolidRightLine:
                        rect.Width--;
                        break;
                    case PaletteColorStyle.SolidAllLine:
                        rect.X++;
                        rect.Y++;
                        rect.Width -= 2;
                        rect.Height -= 2;
                        break;
                }

                // Draw the second color as a solid block
                using (SolidBrush brushColor2 = new SolidBrush(backColor1))
                    context.Graphics.FillRectangle(brushColor2, rect);
            }
        }
Exemplo n.º 4
0
        private void DrawBackRounding5(RenderContext context,
                                       Rectangle rect,
                                       Rectangle gradientRect,
                                       Color backColor1,
                                       Color backColor2,
                                       PaletteColorStyle backColorStyle,
                                       float backColorAngle,
                                       VisualOrientation orientation,
                                       GraphicsPath path)
        {
            // We want to ignore the ourside pixel edge, so inflate inwards
            rect.Inflate(-1, -1);

            // Prevent drawing over that ourside edge
            using (Clipping clip = new Clipping(context.Graphics, rect))
            {
                // Use standard helper routine to create appropriate color brush
                using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2,
                                                          PaletteColorStyle.Rounding5, backColorAngle,
                                                          orientation))
                {
                    context.Graphics.FillPath(backBrush, path);
                }
            }
        }
Exemplo n.º 5
0
        private void DrawBackRoundedTopLight(RenderContext context,
                                             Rectangle rect,
                                             Rectangle gradientRect,
                                             Color backColor1,
                                             Color backColor2,
                                             PaletteColorStyle backColorStyle,
                                             float backColorAngle,
                                             VisualOrientation orientation,
                                             GraphicsPath path)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Draw entire background in white
                using(SolidBrush lightBrush = new SolidBrush(ControlPaint.LightLight(backColor1)))
                    context.Graphics.FillRectangle(lightBrush, rect);

                // Offset the drawing rectangle depending on the orientation
                switch (orientation)
                {
                    case VisualOrientation.Top:
                        rect.Y++;
                        rect.Height--;
                        break;
                    case VisualOrientation.Bottom:
                        rect.Height--;
                        break;
                    case VisualOrientation.Left:
                        rect.X++;
                        rect.Width--;
                        break;
                    case VisualOrientation.Right:
                        rect.Width--;
                        break;
                }

                // Draw the second color as the offset background
                using (Brush backBrush = CreateColorBrush(gradientRect,
                                                          backColor1,
                                                          backColor2,
                                                          PaletteColorStyle.Rounded,
                                                          backColorAngle,
                                                          orientation))
                {
                    context.Graphics.FillRectangle(backBrush, rect);
                }
            }
        }
Exemplo n.º 6
0
        private void DrawBackRoundedTopLeftWhite(RenderContext context,
                                                 Rectangle rect,
                                                 Rectangle gradientRect,
                                                 Color backColor1,
                                                 Color backColor2,
                                                 PaletteColorStyle backColorStyle,
                                                 float backColorAngle,
                                                 VisualOrientation orientation,
                                                 GraphicsPath path)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Draw entire background in white
                context.Graphics.FillRectangle(Brushes.White, rect);

                // Offset the drawing rectangle for the top and left
                rect.X++;
                rect.Y++;

                // Size is smaller in both directions because of offseting
                rect.Width--;
                rect.Height--;

                // Draw the second color as the offset background
                using (Brush backBrush = CreateColorBrush(gradientRect,
                                                          backColor1,
                                                          backColor2,
                                                          PaletteColorStyle.Rounded,
                                                          backColorAngle,
                                                          orientation))
                {
                    context.Graphics.FillRectangle(backBrush, rect);
                }
            }
        }
Exemplo n.º 7
0
        private void DrawBackRounded4(RenderContext context,
                                      Rectangle rect,
                                      Rectangle gradientRect,
                                      Color backColor1,
                                      Color backColor2,
                                      PaletteColorStyle backColorStyle,
                                      float backColorAngle,
                                      VisualOrientation orientation,
                                      GraphicsPath path)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Use standard helper routine to create appropriate color brush
                using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2,
                                                          backColorStyle, backColorAngle, orientation))
                {
                    context.Graphics.FillPath(backBrush, path);
                }

                using (Pen linePen = new Pen(backColor1))
                {
                    // Adjust angle for the orientation
                    switch (orientation)
                    {
                        case VisualOrientation.Left:
                            context.Graphics.DrawLine(linePen, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
                            break;
                        case VisualOrientation.Right:
                            context.Graphics.DrawLine(linePen, rect.Left, rect.Top, rect.Left, rect.Bottom - 1);
                            break;
                        case VisualOrientation.Bottom:
                            context.Graphics.DrawLine(linePen, rect.Left, rect.Top, rect.Right - 1, rect.Top);
                            break;
                        case VisualOrientation.Top:
                            context.Graphics.DrawLine(linePen, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                            break;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void DrawBackOneNote(RenderContext context,
                                     Rectangle gradientRect,
                                     Color backColor1,
                                     Color backColor2,
                                     PaletteColorStyle backColorStyle,
                                     float backColorAngle,
                                     VisualOrientation orientation,
                                     GraphicsPath path)
        {
            // Draw entire background in first color
            using (Brush backBrush = CreateColorBrush(gradientRect,
                                                      backColor1,
                                                      backColor1,
                                                      backColorStyle,
                                                      backColorAngle,
                                                      orientation))
            {
                context.Graphics.FillPath(backBrush, path);
            }

            // Make a copy of the original path, so we can change it
            GraphicsPath insetPath = (GraphicsPath)path.Clone();

            // Offset by 1.5 pixels so the background shows around two of
            // the edges of the background we are about to draw
            switch (orientation)
            {
                case VisualOrientation.Top:
                    insetPath.Transform(new Matrix(1, 0, 0, 1, 1.5f, 1.5f));
                    break;
                case VisualOrientation.Bottom:
                case VisualOrientation.Left:
                    insetPath.Transform(new Matrix(1, 0, 0, 1, 1.5f, -1.5f));
                    break;
                case VisualOrientation.Right:
                    insetPath.Transform(new Matrix(1, 0, 0, 1, -1.5f, 1.5f));
                    break;
            }

            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Draw the second color as the offset background
                using (Brush backBrush = CreateColorBrush(gradientRect,
                                                          backColor2,
                                                          backColor2,
                                                          backColorStyle,
                                                          backColorAngle,
                                                          orientation))
                {
                    context.Graphics.FillPath(backBrush, insetPath);
                }
            }

            // Dispose of created resources
            insetPath.Dispose();
        }
Exemplo n.º 9
0
        private void DrawBackLinearShadow(RenderContext context,
                                          Rectangle rect,
                                          Rectangle gradientRect,
                                          Color backColor1,
                                          Color backColor2,
                                          PaletteColorStyle backColorStyle,
                                          float backColorAngle,
                                          VisualOrientation orientation,
                                          GraphicsPath path)
        {
            // Prevent drawing over that ourside edge
            using (Clipping clip = new Clipping(context.Graphics, rect))
            {
                // Use standard helper routine to create appropriate color brush
                using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2,
                                                          PaletteColorStyle.Linear, backColorAngle,
                                                          orientation))
                {
                    context.Graphics.FillPath(backBrush, path);
                }

                // Use path gradient to give the outside of the area a shadow effect
                using (PathGradientBrush borderBrush = new PathGradientBrush(path))
                {
                    borderBrush.Blend = _linearShadowBlend;
                    borderBrush.CenterColor = backColor1;
                    borderBrush.SurroundColors = new Color[] { backColor2 };
                    context.Graphics.FillPath(borderBrush, path);
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Initialize a new instance of the InternalStorage structure.
 /// </summary>
 public InternalStorage()
 {
     // Set to default values
     ContentTextHint = PaletteTextHint.Inherit;
     ContentTextTrim = PaletteTextTrim.Inherit;
     ContentTextPrefix = PaletteTextHotkeyPrefix.Inherit;
     ContentTextH = PaletteRelativeAlign.Inherit;
     ContentTextV = PaletteRelativeAlign.Inherit;
     ContentTextMultiLineH = PaletteRelativeAlign.Inherit;
     ContentTextMultiLine = InheritBool.Inherit;
     ContentTextColor1 = Color.Empty;
     ContentTextColor2 = Color.Empty;
     ContentTextColorStyle = PaletteColorStyle.Inherit;
     ContentTextColorAlign = PaletteRectangleAlign.Inherit;
     ContentTextColorAngle = -1;
     ContentTextImageStyle = PaletteImageStyle.Inherit;
     ContentTextImageAlign = PaletteRectangleAlign.Inherit;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initialize a new instance of the InternalStorage structure.
 /// </summary>
 public InternalStorage()
 {
     // Set to default values
     BorderDraw = InheritBool.Inherit;
     BorderDrawBorders = PaletteDrawBorders.All;
     BorderGraphicsHint = PaletteGraphicsHint.Inherit;
     BorderColor1 = Color.Empty;
     BorderColor2 = Color.Empty;
     BorderColorStyle = PaletteColorStyle.Inherit;
     BorderColorAlign = PaletteRectangleAlign.Inherit;
     BorderColorAngle = -1;
     BorderWidth = -1;
     BorderRounding = -1;
     BorderImageStyle = PaletteImageStyle.Inherit;
     BorderImageAlign = PaletteRectangleAlign.Inherit;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initialize a new instance of the InternalStorage structure.
 /// </summary>
 public InternalStorage()
 {
     // Set to default values
     BackDraw = InheritBool.Inherit;
     BackGraphicsHint = PaletteGraphicsHint.Inherit;
     BackColor1 = Color.Empty;
     BackColor2 = Color.Empty;
     BackColorStyle = PaletteColorStyle.Inherit;
     BackColorAlign = PaletteRectangleAlign.Inherit;
     BackColorAngle = -1;
     BackImageStyle = PaletteImageStyle.Inherit;
     BackImageAlign = PaletteRectangleAlign.Inherit;
 }