SetSigmaBellShape() public method

public SetSigmaBellShape ( float focus ) : void
focus float
return void
Ejemplo n.º 1
0
 public void CreateGreyscale()
 {
     using (Bitmap b = new Bitmap(100, 100))
     {
         using (Graphics g = b.GetGraphics())
         {
             using (LinearGradientBrush brush = new LinearGradientBrush(
               new Rectangle(0, 0, 100, 100),
               Color.Blue,
               Color.Red,
               LinearGradientMode.Vertical))
             {
                 brush.SetSigmaBellShape(0.5f);
                 g.FillRectangle(brush, new Rectangle(0, 0, 100, 100));
                 using (Bitmap b2 = (Bitmap)b.CreateGreyscale())
                 {
                     if (ShowTestForm(b2) != DialogResult.OK)
                     {
                         Assert.Fail();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void AboutForm_Paint(object sender, PaintEventArgs e)
 {
     Graphics g = e.Graphics;
     Rectangle rect = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height);
     using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Black, Color.FromArgb(50, 50, 50), LinearGradientMode.Vertical))
     {
         brush.SetSigmaBellShape(0.25f);
         g.FillRectangle(brush, rect);
     }
 }
Ejemplo n.º 3
0
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds)
        {
            float length = (float)this.manager.Progress / 100.0f;

			using (LinearGradientBrush complete = new LinearGradientBrush(bounds, Color.LightBlue, Color.Blue, LinearGradientMode.Horizontal))
            using (SolidBrush incomplete = new SolidBrush(Color.White))
            using(StringFormat format = new StringFormat())
            using(SolidBrush text = new SolidBrush(Color.Black))
            {
				complete.SetSigmaBellShape(1.0f, 0.25f);
                format.Alignment = StringAlignment.Center;
				graphics.FillRectangle(complete, bounds.X, bounds.Y + borderHeight, bounds.Width * length, bounds.Height - 2 * borderHeight);
				graphics.FillRectangle(incomplete, bounds.X + (bounds.Width * length), bounds.Y + borderHeight, bounds.Width - bounds.Width * length, bounds.Height - 2 * borderHeight);
                graphics.DrawString(string.Format("{0:0.00} %",this.manager.Progress), new Font(FontFamily.GenericSansSerif, 7), text, bounds, format); 
            }
        }
Ejemplo n.º 4
0
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds)
        {
            float width = (float)bounds.Width / args.Piece.BlockCount;
            RectangleF brushDimensions = new RectangleF(0, 0, width, bounds.Height);
            using (LinearGradientBrush requestedBrush = new LinearGradientBrush(brushDimensions, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical))
            using (LinearGradientBrush receivedBrush = new LinearGradientBrush(brushDimensions, Color.LightGoldenrodYellow, Color.Goldenrod, LinearGradientMode.Vertical))
            using (LinearGradientBrush writtenBrush = new LinearGradientBrush(brushDimensions, Color.LightGreen, Color.LimeGreen, LinearGradientMode.Vertical))
            using (LinearGradientBrush notRequestedBrush = new LinearGradientBrush(brushDimensions, Color.LightSalmon, Color.Red, LinearGradientMode.Vertical))
            using (LinearGradientBrush pendingHashCheck = new LinearGradientBrush(brushDimensions, Color.BurlyWood, Color.Brown, LinearGradientMode.Vertical))
            {
                requestedBrush.SetSigmaBellShape(0.25f);
                receivedBrush.SetSigmaBellShape(0.25f);
                writtenBrush.SetSigmaBellShape(0.25f);
                notRequestedBrush.SetSigmaBellShape(0.25f);
                pendingHashCheck.SetSigmaBellShape(0.25f);

                Rectangle rect = bounds;
                
                for (int i = 0; i < this.args.Piece.BlockCount; i++)
                {
                    RectangleF newArea = new RectangleF(rect.X + (width * i), rect.Y + borderHeight, width, rect.Height - 2 * borderHeight);
                    if (this.args.Piece.AllBlocksReceived)
                        graphics.FillRectangle(pendingHashCheck, newArea);

                    else if (args.Piece[i].Written)
                        graphics.FillRectangle(writtenBrush, newArea);

                    else if (args.Piece[i].Received)
                        graphics.FillRectangle(receivedBrush, newArea);

                    else if (args.Piece[i].Requested)
                        graphics.FillRectangle(requestedBrush, newArea);

                    else
                        graphics.FillRectangle(notRequestedBrush, newArea);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws a gradient around the specified polygon. Fades from 'inner' to 'outer' over a distance of 'width' pixels. 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="poly"></param>
        /// <param name="inner"></param>
        /// <param name="outer"></param>
        /// <param name="width"></param>
        public static void DrawOuterGradient(Graphics g, PointF[] poly, Color inner, Color outer, float width)
        {
            PointF[,] corners = PolygonMath.GetCorners(poly, width);
            PointF[,] sides = PolygonMath.GetSides(poly, width);
            //Overlapping these causes darker areas... Dont use InflatePoly

            //Paint corners
            for (int i = 0; i <= corners.GetUpperBound(0); i++) {
                PointF[] pts = PolygonMath.GetSubArray(corners, i);
                using (Brush b = PolygonMath.GenerateRadialBrush(inner, outer, pts[0], width + 1)) {
                    g.FillPolygon(b, pts);
                }
            }
            //Paint sides
            for (int i = 0; i <= sides.GetUpperBound(0); i++) {
                PointF[] pts = PolygonMath.GetSubArray(sides, i);
                using (LinearGradientBrush b = new LinearGradientBrush(pts[3], pts[0], inner, outer)) {
                    b.SetSigmaBellShape(1);
                    b.WrapMode = WrapMode.TileFlipXY;
                    g.FillPolygon(b, pts);
                }
            }
        }
 void PaintView13(Graphics g)
 {
     // Create a rectangle
     Rectangle rect = new Rectangle(0, 0, 40, 20);
     // Create a linear gradient brush
     LinearGradientBrush rgBrush =
         new LinearGradientBrush(
             rect, Color.Black, Color.Blue,
             0.0f, true);
     // Fill rectangle
     g.FillRectangle(rgBrush,
                     new Rectangle(10, 10, 300, 100));
     // Set sigma bell shape
     rgBrush.SetSigmaBellShape(0.8f, 1.0f);
     // Fill rectangle again
     g.FillRectangle(rgBrush,
                     new Rectangle(10, 120, 300, 100));
     // Set blend triangular shape
     rgBrush.SetBlendTriangularShape(0.2f, 1.0f);
     // Fill rectangle again
     g.FillRectangle(rgBrush,
                     new Rectangle(10, 240, 300, 100));
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Perform drawing of a ribbon group separator.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonGroupSeparator(PaletteRibbonShape shape,
                                                      RenderContext context,
                                                      Rectangle displayRect,
                                                      IPaletteRibbonGeneral paletteGeneral,
                                                      PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

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

            int x = displayRect.X + (displayRect.Width - 2) / 2;
            Color darkColor = paletteGeneral.GetRibbonGroupSeparatorDark(state);
            Color lightColor = paletteGeneral.GetRibbonGroupSeparatorLight(state);

            switch (shape)
            {
                default:
                case PaletteRibbonShape.Office2007:
                    using (Pen darkPen = new Pen(darkColor),
                               lightPen = new Pen(lightColor))
                    {
                        context.Graphics.DrawLine(lightPen, x, displayRect.Top + 2, x, displayRect.Bottom - 3);
                        context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top + 2, x + 1, displayRect.Bottom - 3);
                    }
                    break;
                case PaletteRibbonShape.Office2010:
                    using (LinearGradientBrush darkBrush = new LinearGradientBrush(new RectangleF(displayRect.X, displayRect.Y - 1, displayRect.Width, displayRect.Height + 2), Color.FromArgb(72, darkColor), darkColor, 90f),
                                               lightBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), Color.FromArgb(128, lightColor), lightColor, 90f))
                    {
                        darkBrush.SetSigmaBellShape(0.5f);
                        lightBrush.SetSigmaBellShape(0.5f);

                        using (Pen darkPen = new Pen(darkBrush))
                        {
                            context.Graphics.FillRectangle(lightBrush, x, displayRect.Top, 3, displayRect.Height);
                            context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top, x + 1, displayRect.Bottom - 1);
                        }
                    }
                    break;
            }
        }
Ejemplo n.º 8
0
        private void DrawGradientToolSplitItem(Graphics g,
                                               ToolStripSplitButton splitButton,
                                               GradientItemColors colorsButton,
                                               GradientItemColors colorsDrop,
                                               GradientItemColors colorsSplit)
        {
            // Create entire area and just the drop button area rectangles
            Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size);
            Rectangle backRectDrop = splitButton.DropDownButtonBounds;

            // Cannot paint zero sized areas
            if ((backRect.Width > 0) && (backRectDrop.Width > 0) &&
                (backRect.Height > 0) && (backRectDrop.Height > 0))
            {
                // Area that is the normal button starts as everything
                Rectangle backRectButton = backRect;

                // The X offset to draw the split line
                int splitOffset;

                // Is the drop button on the right hand side of entire area?
                if (backRectDrop.X > 0)
                {
                    backRectButton.Width = backRectDrop.Left;
                    backRectDrop.X -= 1;
                    backRectDrop.Width++;
                    splitOffset = backRectDrop.X;
                }
                else
                {
                    backRectButton.Width -= backRectDrop.Width - 2;
                    backRectButton.X = backRectDrop.Right - 1;
                    backRectDrop.Width++;
                    splitOffset = backRectDrop.Right - 1;
                }

                // Create border path around the item
                using (GraphicsPath borderPath = this.CreateBorderPath(backRect, _cutMenuItemBack))
                {
                    // Draw the normal button area background
                    this.DrawGradientBack(g, backRectButton, colorsButton);

                    // Draw the drop button area background
                    this.DrawGradientBack(g, backRectDrop, colorsDrop);

                    // Draw the split line between the areas
                    using (
                        LinearGradientBrush splitBrush =
                            new LinearGradientBrush(
                                new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1),
                                colorsSplit.Border1, colorsSplit.Border2, 90f))
                    {
                        // Sigma curve, so go from color1 to color2 and back to color1 again
                        splitBrush.SetSigmaBellShape(0.5f);

                        // Convert the brush to a pen for DrawPath call
                        using (Pen splitPen = new Pen(splitBrush))
                            g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset,
                                       backRect.Bottom - 1);
                    }

                    // Draw the border of the entire item
                    this.DrawGradientBorder(g, backRect, colorsButton);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a LinearGradientBrush object.
 /// </summary>
 /// <param name="path">The graphics path used to construct the brush.</param>
 /// <param name="angle">The gradient angle.</param>
 /// <param name="focus">The focus for the SigmaBellShape.</param>
 /// <param name="scale">The scale for the SigmaBellShape.</param>
 public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle, float focus, float scale)
 {
     LinearGradientBrush brush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
     brush.SetSigmaBellShape(focus, scale);
     return brush;
 }
Ejemplo n.º 10
0
 private void drawLinearGradient(Rectangle rDmn, IntPtr hdc, LinearGradientMode m)
 {
     Graphics g = Graphics.FromHdc(hdc);
     float o = _fOpacity * 255;
     Color c1 = Color.FromArgb((int)o, _oGradientStartColor);
     Color c2 = Color.FromArgb((int)o, _oGradientEndColor);
     LinearGradientBrush hB = new LinearGradientBrush(
         rDmn,
         c1,
         c2,
         m);
     switch (_eGradientStyle)
     {
         case GradientStyle.VerticalTube:
             hB.SetBlendTriangularShape(.5f, 1.0f);
             g.FillRectangle(hB, rDmn);
             break;
         case GradientStyle.HorizontalTube:
             hB.SetBlendTriangularShape(.5f, 1.0f);
             g.FillRectangle(hB, rDmn);
             break;
         case GradientStyle.SigmaBellShape:
             hB.SetSigmaBellShape(.5f, 1.0f);
             g.FillRectangle(hB, rDmn);
             break;
         default:
             g.FillRectangle(hB, rDmn);
             break;
     }
     hB.Dispose();
     g.Dispose();
 }
Ejemplo n.º 11
0
    protected override void OnDrawItem(DrawItemEventArgs e)
    {
      Graphics grfx = e.Graphics;
      Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);
      rectColor.Inflate(-1, -1);

      Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
        e.Bounds.Top,
        e.Bounds.Width - 2 * e.Bounds.Height,
        e.Bounds.Height);

      if (this.Enabled)
        e.DrawBackground();

      LinearGradientShape item = e.Index >= 0 ? (LinearGradientShape)Items[e.Index] : LinearGradientShape.Linear;

      Rectangle rectShape = new Rectangle(rectColor.X + rectColor.Width / 4, rectColor.Y, rectColor.Width / 2, rectColor.Height);
      using (LinearGradientBrush br = new LinearGradientBrush(rectShape, e.ForeColor, e.BackColor, LinearGradientMode.Horizontal))
      {
        if (item == LinearGradientShape.Triangular)
          br.SetBlendTriangularShape(0.5f);
        else if (item == LinearGradientShape.SigmaBell)
          br.SetSigmaBellShape(0.5f);

        grfx.FillRectangle(br, rectColor);
      }
      SolidBrush foreColorBrush = new SolidBrush(e.ForeColor);
      grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
    }
Ejemplo n.º 12
0
            public override void DrawBack(Graphics g, Rectangle rect)
            {
                Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
                Rectangle insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
                Rectangle insetC = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4);

                using (LinearGradientBrush insideBrush1 = new LinearGradientBrush(rect, Back1B, Back1, 90f),
                                           insideBrush2 = new LinearGradientBrush(insetB, Back2B, Back2, 90f))
                {
                    insideBrush1.SetSigmaBellShape(0.5f);
                    insideBrush2.SetSigmaBellShape(0.5f);

                    g.FillRectangle(insideBrush1, inset);
                    using (GraphicsPath borderPath = CreateBorderPath(insetC, _cutInnerItemMenu),
                                        clipPath = CreateBorderPath(insetB, _cutInnerItemMenu))
                    {
                        using (Pen insidePen = new Pen(insideBrush2))
                            g.DrawPath(insidePen, borderPath);

                        g.FillPath(insideBrush2, borderPath);

                        using (Clipping clipping = new Clipping(g, clipPath))
                        {
                            using (GraphicsPath ellipsePath = new GraphicsPath())
                            {
                                RectangleF ellipseRect = new RectangleF(-(rect.Width / 2), rect.Bottom - 9, rect.Width * 2, 18);
                                PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2));
                                ellipsePath.AddEllipse(ellipseRect);

                                using (PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath))
                                {
                                    insideLighten.CenterPoint = ellipseCenter;
                                    insideLighten.CenterColor = Color.White;
                                    insideLighten.SurroundColors = new Color[] { Color.Transparent };
                                    g.FillPath(insideLighten, ellipsePath);
                                }
                            }
                        }
                    }
                }
            }
Ejemplo n.º 13
0
        private void createMacStyleButton(Color clrStartUp, Color clrEndUp, Color clrBorder, Graphics g)
        {
            GraphicsPath btn = new GraphicsPath();

            //Rectangle rcBtn = new Rectangle(m_lLeft, m_lTop, m_lButtonWidth, m_lButtonHeight);

            int l = m_lLeft + m_lButtonWidth / 4;
            int t = m_lTop + m_lButtonHeight / 4;
            int w = m_lButtonWidth / 2;
            int h = m_lButtonHeight / 2;
            Rectangle rcBtn = new Rectangle(l, t, w, h);
            btn.AddEllipse(rcBtn);

            // fill button:
            using (LinearGradientBrush aquaUp = new LinearGradientBrush(rcBtn, clrStartUp, clrEndUp, LinearGradientMode.Vertical))
            {
                aquaUp.SetSigmaBellShape(1.0f);
                g.FillPath(aquaUp, btn);
                using (Pen border = new Pen(clrBorder))
                {
                    g.DrawPath(border, btn);
                }

                #region Outer border

                // This will give very cool shadow drop effect to the button:
                Rectangle rcOuterBorder = rcBtn;
                rcOuterBorder.Inflate(1, 1);
                using (GraphicsPath ob = new GraphicsPath())
                {
                    ob.AddEllipse(rcOuterBorder);
                    using (Pen po = new Pen(Color.FromArgb(205, 205, 205)))
                    {
                        g.DrawPath(po, ob);
                    }
                }

                #endregion
            }
            // draw upper glow:
            Rectangle rcGlow = new Rectangle(rcBtn.Left + rcBtn.Width / 2 - 1, rcBtn.Top + 1, 3, 2);
            using (SolidBrush sb = new SolidBrush(Color.FromArgb(200, Color.White)))
            {
                g.FillRectangle(sb, rcGlow);
            }
            // draw button symbol:
            if (m_bHovering)
            {
                switch (m_eButtonType)
                {
                    case ECtrlType.Close:
                        using (Pen pClose = new Pen(Color.FromArgb(146, 57, 46)))
                        {
                            pClose.Width = 1.55f;
                            g.DrawLine(pClose, rcBtn.Left + 4, rcBtn.Top + 4, rcBtn.Right - 4, rcBtn.Bottom - 4);
                            g.DrawLine(pClose, rcBtn.Right - 4, rcBtn.Top + 4, rcBtn.Left + 4, rcBtn.Bottom - 4);
                        }
                        break;

                    case ECtrlType.Maximize:
                        using (Pen pMaximize = new Pen(Color.FromArgb(162, 95, 59)))
                        {
                            pMaximize.Width = 1.55f;
                            Rectangle rcMax = rcBtn;
                            rcMax.Inflate(-4, -4);
                            g.DrawRectangle(pMaximize, rcMax);
                        }
                        break;

                    case ECtrlType.Minimize:
                        using (Pen pMinimize = new Pen(Color.FromArgb(81, 120, 47)))
                        {
                            pMinimize.Width = 1.55f;
                            g.DrawLine(pMinimize, rcBtn.Left + 4, rcBtn.Bottom - 4, rcBtn.Right - 4, rcBtn.Bottom - 4);
                        }
                        break;
                }
                // fill lower glow:
                using (GraphicsPath shn = new GraphicsPath())
                {
                    shn.AddEllipse(rcBtn.Left, rcBtn.Top + rcBtn.Height / 2, rcBtn.Width, rcBtn.Height);
                    using (PathGradientBrush pgb = new PathGradientBrush(shn))
                    {
                        g.SetClip(btn);
                        pgb.CenterColor = Color.FromArgb(210, Color.White);
                        pgb.SurroundColors = new Color[] { Color.FromArgb(0, clrEndUp) };
                        if (m_bHovering)
                        {
                            g.FillPath(pgb, shn);
                        }
                        g.ResetClip();
                    }
                }
            }
            btn.Dispose();
        }
Ejemplo n.º 14
0
		public static void DrawTab(Graphics g, Rectangle r, Corners corner, GradientType gradient, Color darkColor, Color lightColor, Color edgeColor, bool closed )
		{
			//dims
			Point[] points;
			GraphicsPath path;
			Region region;
			LinearGradientBrush linearBrush;
			
			Brush brush = null;
			Pen pen;
			//set brushes
			switch(gradient)
			{
				case GradientType.Flat:
					brush = new SolidBrush(darkColor);
					break;
				case GradientType.Linear:
					brush = new LinearGradientBrush(r,darkColor,lightColor,LinearGradientMode.Vertical);
					break;
				case GradientType.Bell:
					linearBrush = new LinearGradientBrush(r,darkColor,lightColor,LinearGradientMode.Vertical);
					linearBrush.SetSigmaBellShape(0.17F,0.67F);
					brush = linearBrush;
					break;
			}
			pen = new Pen(edgeColor,1);
			//generic points
			points = new Point[12]
								{
									new Point(r.Left,r.Bottom), //0
									new Point(r.Left, r.Bottom-bshift), //1
									new Point(r.Left,r.Top+bshift), //2
									new Point(r.Left,r.Top), //3
									new Point(r.Left+bshift,r.Top), //4
									new Point(r.Right-bshift,r.Top), //5
									new Point(r.Right,r.Top), //6
									new Point(r.Right,r.Top+bshift), //7
									new Point(r.Right,r.Bottom-bshift), //8
									new Point(r.Right,r.Bottom), //9
									new Point(r.Right-bshift,r.Bottom), //10									  
									new Point(r.Left+bshift,r.Bottom) //10
								};
			path = new GraphicsPath();
			switch(corner)
			{
				case Corners.LB:

					path.AddLine(points[3],points[1]);
					path.AddBezier(points[1],points[0],points[0],points[11]);	
					path.AddLine(points[11],points[9]);					
					path.AddLine(points[9],points[6]);
					path.AddLine(points[6],points[3]);
					region = new Region(path);
					g.FillRegion(brush,region);

					g.DrawLine(pen,points[3],points[1]);
					g.DrawBezier(pen,points[1],points[0],points[0],points[11]);	
					g.DrawLine(pen,points[11],points[9]);					
					g.DrawLine(pen,points[9],points[6]);
					if(closed)
						g.DrawLine(pen,points[6],points[3]);
					break;
				case Corners.LT:
					path.AddLine(points[0],points[2]);
					path.AddBezier(points[2],points[3],points[3],points[4]);
					path.AddLine(points[4],points[6]);						
					path.AddLine(points[6],points[9]);
					path.AddLine(points[9],points[0]);
					region = new Region(path);
					g.FillRegion(brush,region);

					g.DrawLine(pen,points[0],points[2]);
					g.DrawBezier(pen,points[2],points[3],points[3],points[4]);	
					g.DrawLine(pen,points[4],points[6]);					
					g.DrawLine(pen,points[6],points[9]);
					if(closed)
						g.DrawLine(pen,points[9],points[0]);
					break;
				case Corners.RB:
					path.AddLine(points[3],points[0]);
					path.AddLine(points[0],points[10]);
					path.AddBezier(points[10],points[9],points[9],points[8]);	
					path.AddLine(points[8],points[6]);
					path.AddLine(points[6],points[3]);
					region = new Region(path);
					g.FillRegion(brush,region);

					g.DrawLine(pen,points[3],points[0]);
					g.DrawLine(pen,points[0],points[10]);
					g.DrawBezier(pen,points[10],points[9],points[9],points[8]);	
					g.DrawLine(pen,points[8],points[6]);
					if(closed)
						g.DrawLine(pen,points[6],points[3]);
					break;
				case Corners.RT:
					path.AddLine(points[0],points[3]);
					path.AddLine(points[3],points[5]);
					path.AddBezier(points[5],points[6],points[6],points[7]);	
					path.AddLine(points[7],points[9]);
					path.AddLine(points[9],points[0]);
					region = new Region(path);
					g.FillRegion(brush,region);

					g.DrawLine(pen,points[0],points[3]);
					g.DrawLine(pen,points[3],points[5]);
					g.DrawBezier(pen,points[5],points[6],points[6],points[7]);	
					g.DrawLine(pen,points[7],points[9]);
					if(closed)
						g.DrawLine(pen,points[9],points[0]);
					break;
			}
		}
Ejemplo n.º 15
0
            public override void DrawBack(Graphics g, Rectangle rect)
            {
                Rectangle inset = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
                Rectangle insetB = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);

                using (LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Back2, Back1, 90f))
                {
                    insideBrush.SetSigmaBellShape(0.5f);
                    g.FillRectangle(insideBrush, inset);

                    using (GraphicsPath borderPath = CreateBorderPath(inset, _cutInnerItemMenu))
                    {
                        using (GraphicsPath ellipsePath = new GraphicsPath())
                        {
                            RectangleF ellipseRect = new RectangleF(rect.Left, rect.Bottom - 8, rect.Width, 8);
                            PointF ellipseCenter = new PointF(ellipseRect.Left + (ellipseRect.Width / 2), ellipseRect.Top + (ellipseRect.Height / 2));
                            ellipsePath.AddEllipse(ellipseRect);

                            using (PathGradientBrush insideLighten = new PathGradientBrush(ellipsePath))
                            {
                                insideLighten.CenterPoint = ellipseCenter;
                                insideLighten.CenterColor = Color.FromArgb(96, Color.White);
                                insideLighten.SurroundColors = new Color[] { Color.Transparent };
                                g.FillPath(insideLighten, ellipsePath);
                            }
                        }
                    }
                }
            }
        private static void DrawGradientBorder(Graphics g,
                                               Rectangle backRect,
                                               GradientItemColors colors)
        {
            var backRectI = backRect;
            backRectI.Inflate(1, 1);

            // Finally draw the border around the menu item
            using (var borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2, 90f))
            {
                // Sigma curve, so go from color1 to color2 and back to color1 again
                borderBrush.SetSigmaBellShape(0.5f);

                // Convert the brush to a pen for DrawPath call
                using (var borderPen = new Pen(borderBrush))
                {
                    // Create border path around the entire item
                    using (var borderPath = CreateBorderPath(backRect, _cutMenuItemBack))
                        g.DrawPath(borderPen, borderPath);
                }
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 ///     传入文字,生成图片(图片宽高1280x720(是固定的))
 /// </summary>
 /// <param name="content">文字内容</param>
 /// <returns></returns>
 private static Bitmap DrawLineString(string content) {
     //将内容进行处理
     content = ToSBC(content.Trim());
     //2.绘制背景
     var b_bru = new LinearGradientBrush(
         new Rectangle(0, 0, 1280, 720), Color.FromArgb(20, 20, 20),
         Color.FromArgb(60, 60, 60), LinearGradientMode.Horizontal);
     //设置渐变位置
     b_bru.SetSigmaBellShape(0.5f);
     var backgroundimg = new Bitmap(1280, 720); //图片大小转化
     var g = Graphics.FromImage(backgroundimg);
     g.FillRectangle(b_bru, new Rectangle(0, 0, 1280, 720));
     //两层渐变效果
     var b_bru2 = new LinearGradientBrush(
         new Rectangle(0, 0, 1280, 720), Color.FromArgb(100, 20, 20, 20),
         Color.FromArgb(100, 60, 60, 60), LinearGradientMode.Vertical);
     b_bru2.SetSigmaBellShape(0.5f);
     g.FillRectangle(b_bru2, new Rectangle(0, 0, 1280, 720));
     g.SmoothingMode = SmoothingMode.HighSpeed;
     //画刷
     var bru = Brushes.White;
     //居中的方法
     var sf = new StringFormat();
     sf.Alignment = StringAlignment.Center;
     sf.LineAlignment = StringAlignment.Center;
     switch (content.Length) {
         case 1:
             DrawLines(1, content, ref g, bru, sf, 400, 0);
             break;
         case 2:
             DrawLines(1, content, ref g, bru, sf, 350, 0);
             break;
         case 3:
             DrawLines(1, content, ref g, bru, sf, 250, 0);
             break;
         case 4:
             DrawLines(1, content, ref g, bru, sf, 200, 0);
             break;
         case 5:
         case 6:
             DrawLines(2, content, ref g, bru, sf, 200, 300);
             break;
         case 7:
         case 8:
             DrawLines(2, content, ref g, bru, sf, 180, 300);
             break;
         case 9:
         case 10:
             DrawLines(2, content, ref g, bru, sf, 160, 300);
             break;
         case 11:
         case 12:
             DrawLines(2, content, ref g, bru, sf, 140, 270);
             break;
         case 13:
         case 14:
             DrawLines(2, content, ref g, bru, sf, 120, 250);
             break;
         case 15:
         case 16:
             DrawLines(2, content, ref g, bru, sf, 110, 240);
             break;
         case 17:
         case 18:
             DrawLines(3, content, ref g, bru, sf, 120, 200);
             break;
         case 19:
         case 20:
         case 21:
             DrawLines(3, content, ref g, bru, sf, 115, 200);
             break;
         case 22:
         case 23:
         case 24:
             DrawLines(3, content, ref g, bru, sf, 105, 200);
             break;
         case 25:
         case 26:
         case 27:
             DrawLines(3, content, ref g, bru, sf, 95, 200);
             break;
         case 28:
         case 29:
         case 30:
             DrawLines(3, content, ref g, bru, sf, 88, 200);
             break;
         case 31:
         case 32:
         case 33:
             DrawLines(3, content, ref g, bru, sf, 80, 200);
             break;
         case 34:
         case 35:
             DrawLines(4, content, ref g, bru, sf, 90, 160);
             break;
         case 36:
         case 37:
         case 38:
         case 39:
         case 40:
             DrawLines(4, content, ref g, bru, sf, 82, 150);
             break;
         case 41:
         case 42:
         case 43:
         case 44:
             DrawLines(4, content, ref g, bru, sf, 75, 150);
             break;
         case 45:
         case 46:
         case 47:
         case 48:
             DrawLines(4, content, ref g, bru, sf, 70, 150);
             break;
         case 49:
         case 50:
             DrawLines(5, content, ref g, bru, sf, 80, 125);
             break;
         case 51:
         case 52:
         case 53:
         case 54:
         case 55:
             DrawLines(5, content, ref g, bru, sf, 75, 125);
             break;
         case 56:
         case 57:
         case 58:
         case 59:
         case 60:
             DrawLines(5, content, ref g, bru, sf, 70, 125);
             break;
         case 61:
         case 62:
         case 63:
         case 64:
         case 65:
             DrawLines(5, content, ref g, bru, sf, 65, 125);
             break;
         case 66:
         case 67:
         case 68:
         case 69:
         case 70:
             DrawLines(5, content, ref g, bru, sf, 60, 125);
             break;
         case 71:
         case 72:
             DrawLines(6, content, ref g, bru, sf, 66, 110);
             break;
         case 73:
         case 74:
         case 75:
         case 76:
         case 77:
         case 78:
             DrawLines(6, content, ref g, bru, sf, 60, 110);
             break;
         case 79:
         case 80:
         case 81:
         case 82:
         case 83:
         case 84:
             DrawLines(6, content, ref g, bru, sf, 58, 110);
             break;
         case 85:
         case 86:
         case 87:
         case 88:
         case 89:
         case 90:
             DrawLines(6, content, ref g, bru, sf, 55, 110);
             break;
         case 91:
         case 92:
         case 93:
         case 94:
         case 95:
         case 96:
             DrawLines(6, content, ref g, bru, sf, 52, 110);
             break;
         case 97:
         case 98:
             DrawLines(7, content, ref g, bru, sf, 58, 95);
             break;
         case 99:
         case 100:
         case 101:
         case 102:
         case 103:
         case 104:
         case 105:
             DrawLines(7, content, ref g, bru, sf, 55, 95);
             break;
         case 106:
         case 107:
         case 108:
         case 109:
         case 110:
         case 111:
         case 112:
             DrawLines(7, content, ref g, bru, sf, 52, 95);
             break;
         case 113:
         case 114:
         case 115:
         case 116:
         case 117:
         case 118:
         case 119:
             DrawLines(7, content, ref g, bru, sf, 49, 95);
             break;
         case 120:
             DrawLines(8, content, ref g, bru, sf, 55, 85);
             break;
         case 121:
         case 122:
         case 123:
         case 124:
         case 125:
         case 126:
         case 127:
         case 128:
             DrawLines(8, content, ref g, bru, sf, 50, 85);
             break;
         case 129:
         case 130:
         case 131:
         case 132:
         case 133:
         case 134:
         case 135:
         case 136:
             DrawLines(8, content, ref g, bru, sf, 48, 85);
             break;
         case 137:
         case 138:
         case 139:
         case 140:
             DrawLines(8, content, ref g, bru, sf, 48, 85);
             break;
     }
     return backgroundimg;
 }
        void PaintView7(Graphics g)
        {
            // Create a LinearGradientBrush.
            Rectangle myRect = new Rectangle(20, 20, 200, 100);
            LinearGradientBrush myLGBrush = new LinearGradientBrush(
                myRect, Color.Blue, Color.Red, 0.0f, true);

            LinearGradientBrush myLGBrush2 = new LinearGradientBrush(
                myRect, Color.Blue, Color.Red, 0.0f, true);

            // Draw an ellipse to the screen using the LinearGradientBrush.
            g.FillEllipse(myLGBrush, myRect);

            // Create a bell-shaped brush with the peak at the
            // center of the drawing area.
            myLGBrush.SetSigmaBellShape(.5f, 1.0f);

            // Use the bell- shaped brush to draw a second
            // ellipse.
            myRect.Y = 150;
            g.FillEllipse(myLGBrush, myRect);
        }
Ejemplo n.º 19
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;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Paints the background.
        /// </summary>
        /// <param name="pevent">The paint event arguments.</param>
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            Graphics grfx = pevent.Graphics;

            grfx.Clear(this.BackColor);

            Color blendColor;
            switch (this.index)
            {
                case 0:
                    blendColor = Color.Red;
                    break;
                case 1:
                    blendColor = Color.Orange;
                    break;
                default:
                    throw new ApplicationException();
            }

            if (this.ClientRectangle.Width > 0 && this.ClientRectangle.Height > 0)
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, blendColor, this.BackColor, 90f, true))
                {
                    brush.SetSigmaBellShape(1.0f, 1.0f);
                    grfx.FillRectangle(brush, this.ClientRectangle);
                }
            }
        }
        public void DrawSeparator(Graphics g, RibbonSeparator separator, Ribbon ribbon)
        {
            #region Office_2007_2013

            if (ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || ribbon.OrbStyle == RibbonOrbStyle.Office_2013)
            {
                if (separator.SizeMode == RibbonElementSizeMode.DropDown)
                {
                    // A horizontal separator on a dropdown menu
                    if (!string.IsNullOrEmpty(separator.Text))
                    {
                        using (SolidBrush b = new SolidBrush(ColorTable.SeparatorBg))
                        {
                            g.FillRectangle(b, separator.Bounds);
                        }

                        using (Pen p = new Pen(ColorTable.SeparatorLine))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left, separator.Bounds.Bottom),
                                 new Point(separator.Bounds.Right, separator.Bounds.Bottom));
                        }
                    }
                    else
                    {
                        using (Pen p = new Pen(ColorTable.DropDownImageSeparator))
                        {
                            g.DrawLine(p,
                                new Point(separator.Bounds.Left + ((separator.DropDownWidth == RibbonSeparatorDropDownWidth.Full) ? 0 : 40), separator.Bounds.Top),
                                 new Point(separator.Bounds.Right, separator.Bounds.Top));
                        }
                    }
                }
                else
                {
                    // A vertical separator on  panel or QAT
                    if (separator.OwnerPanel == null)
                    {
                        // A vertical separator on the QAT
                        using (Pen p = new Pen(ColorTable.QATSeparatorDark))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Top + 5),
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Bottom - 1));
                        }

                        using (Pen p = new Pen(ColorTable.QATSeparatorLight))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Top + 5),
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Bottom - 1));
                        }
                    }
                    else
                    {
                        // A vertical separator on a Panel
                        using (Pen p = new Pen(ColorTable.SeparatorDark))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Top),
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Bottom));
                        }

                        using (Pen p = new Pen(ColorTable.SeparatorLight))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Top),
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Bottom));
                        }
                    }
                }
            }

            #endregion

            #region Office_2010

            if (ribbon.OrbStyle == RibbonOrbStyle.Office_2010)
            {
                if (separator.SizeMode == RibbonElementSizeMode.DropDown)
                {
                    // A horizontal separator on a dropdown menu
                    if (!string.IsNullOrEmpty(separator.Text))
                    {
                        using (SolidBrush b = new SolidBrush(ColorTable.SeparatorBg))
                        {
                            g.FillRectangle(b, separator.Bounds);
                        }

                        using (Pen p = new Pen(ColorTable.SeparatorLine))
                        {
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left, separator.Bounds.Bottom),
                                 new Point(separator.Bounds.Right, separator.Bounds.Bottom));
                        }
                    }
                    else
                    {
                        using (Pen p = new Pen(ColorTable.DropDownImageSeparator))
                        {
                            if (separator.DropDownWidth == RibbonSeparatorDropDownWidth.Partial)
                                p.DashStyle = DashStyle.Dash;
                            
                            g.DrawLine(p,
                                new Point(separator.Bounds.Left + ((separator.DropDownWidth == RibbonSeparatorDropDownWidth.Full) ? 0 : 40), separator.Bounds.Top),
                                 new Point(separator.Bounds.Right, separator.Bounds.Top));
                        }
                    }
                }
                else
                {
                    // A vertical separator on  panel or QAT
                    if (separator.OwnerPanel == null)
                    {
                        // A vertical separator on the QAT
                        using (Pen p = new Pen(ColorTable.QATSeparatorDark))
                        {
                            SmoothingMode smbuff = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.None;
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Top + 5),
                                 new Point(separator.Bounds.Left + 1, separator.Bounds.Bottom - 1));
                            g.SmoothingMode = smbuff;

                        }

                        using (Pen p = new Pen(ColorTable.QATSeparatorLight))
                        {
                            SmoothingMode smbuff = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.None;
                            g.DrawLine(p,
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Top + 5),
                                 new Point(separator.Bounds.Left + 2, separator.Bounds.Bottom - 1));
                            g.SmoothingMode = smbuff;
                        }
                    }
                    else
                    {
                        // A vertical separator on a Panel
                        using (LinearGradientBrush blendBrush = new LinearGradientBrush(
                            new Point(separator.Bounds.Left, separator.Bounds.Top),
                            new Point(separator.Bounds.Left, separator.Bounds.Bottom),
                            Color.FromArgb(50, ColorTable.SeparatorDark),
                            ColorTable.SeparatorDark))
                        {
                            blendBrush.SetSigmaBellShape(0.5f);
                            using (Pen p = new Pen(blendBrush))
                            {
                                SmoothingMode sm = g.SmoothingMode;
                                g.SmoothingMode = SmoothingMode.None;
                                g.DrawLine(p, separator.Bounds.Left + 2, separator.Bounds.Top + 3, separator.Bounds.Left + 2, separator.Bounds.Bottom - 7);
                                g.SmoothingMode = sm;
                            }
                        }

                        using (LinearGradientBrush blendBrush = new LinearGradientBrush(
                            new Point(separator.Bounds.Left, separator.Bounds.Top),
                            new Point(separator.Bounds.Left, separator.Bounds.Bottom),
                            Color.FromArgb(50, ColorTable.SeparatorLight),
                            ColorTable.SeparatorLight))
                        {
                            blendBrush.SetSigmaBellShape(0.5f);
                            using (Pen p = new Pen(blendBrush))
                            {
                                SmoothingMode sm = g.SmoothingMode;
                                g.SmoothingMode = SmoothingMode.None;
                                g.DrawLine(p, separator.Bounds.Left + 1, separator.Bounds.Top + 3, separator.Bounds.Left + 1, separator.Bounds.Bottom - 7);
                                g.DrawLine(p, separator.Bounds.Left + 3, separator.Bounds.Top + 3, separator.Bounds.Left + 3, separator.Bounds.Bottom - 7);
                                g.SmoothingMode = sm;
                            }
                        }
                    }
                }
            }

            #endregion

        }
Ejemplo n.º 22
0
        private void Repaint(Graphics graphics)
        {
            if (IsHeading && this.ClientRectangle.Width > 0 && this.ClientRectangle.Height > 0)
            {
                LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, Slyce.Common.Colors.FadingTitleLightColor, Slyce.Common.Colors.FadingTitleDarkColor, LinearGradientMode.Vertical);
                brush.SetSigmaBellShape(0.5f, 1.0f);
                graphics.FillRectangle(brush, this.ClientRectangle);
                Brush textBrush = new SolidBrush(this.ForeColor);
                SizeF textSize = graphics.MeasureString(this.Text, this.Font);
                graphics.DrawString(Text, this.Font, textBrush, 5, (this.Height / 2) - (System.Convert.ToInt32(textSize.Height) / 2));
                Pen pen = new Pen(textBrush, 2.0f);

                if (ChildrenAreHidden)
                {
                    graphics.DrawLine(pen, new Point(10, this.Height / 2 + 4), new Point(10, this.Height / 2 - 4));
                }
                graphics.DrawLine(pen, new Point(10 - 4, this.Height / 2), new Point(10 + 4, this.Height / 2));
                brush.Dispose();
                textBrush.Dispose();
            }
        }
Ejemplo n.º 23
0
 private void drawGlass(Rectangle rDmn, IntPtr hdc, string caption, string title, IntPtr parent)
 {
     RECT tR = new RECT();
     GetWindowRect(_hTipWnd, ref tR);
     // blit the capture, simulating transparency 
     if (_fOpacity < 1.0f)
         BitBlt(hdc, 0, 0, rDmn.Width, rDmn.Height, _cBgDc.Hdc, 0, 0, 0xCC0020);
     Graphics g = Graphics.FromHdc(hdc);
     // draw the frame -CDEBEB 7EABD4 BCD9EB 6D90B0
     Color c1 = Color.FromArgb(255, 0xCD, 0xEB, 0xEB);
     Color c2 = Color.FromArgb(255, 0x7E, 0xAB, 0xD4);
     Pen p1 = new Pen(c1, .9f);
     Pen p2 = new Pen(c2, .9f);
     g.DrawLines(p1, new Point[] {
             new Point (0, rDmn.Height - 1), 
             new Point (0, 0), 
             new Point (rDmn.Width - 1, 0)
         });
     p1 = new Pen(c2, .1f);
     g.DrawLines(p2, new Point[] {
             new Point (0, rDmn.Height - 1), 
             new Point (rDmn.Width - 1, rDmn.Height - 1), 
             new Point (rDmn.Width - 1, 0)
         });
     p1.Dispose();
     p2.Dispose();
     // draw 'sheen'
     rDmn.Inflate(-2, -2);
     float o = _fOpacity * 255;
     c1 = Color.FromArgb((int)o, Color.Snow);
     c2 = Color.FromArgb((int)o, 0x6D, 0x90, 0xB0);
     LinearGradientBrush hb = new LinearGradientBrush(
         rDmn,
         c1,
         c2,
         LinearGradientMode.ForwardDiagonal);
     hb.SetSigmaBellShape(1f, .5f);
     g.FillRectangle(hb, rDmn);
     hb.Dispose();
     g.Dispose();
 }
Ejemplo n.º 24
0
 /// <summary>Creates a <see cref="T:Brush"/> that can be used to draw a sigma bell gradient.</summary>
 /// <param name="bounds">The bounds of the gradient.</param>
 /// <param name="edgeColor">The color of the gradient edges.</param>
 /// <param name="centerColor">The color of the gradient center.</param>
 /// <param name="mode">The gradient mode.</param>
 /// <returns>The created <see cref="T:Brush"/>.</returns>
 public static Brush CreateSigmaBellGradientBrush(
     Rectangle bounds,
     Color edgeColor,
     Color centerColor,
     LinearGradientMode mode)
 {
     LinearGradientBrush brush = new LinearGradientBrush(bounds, edgeColor, centerColor, mode);
     brush.WrapMode = WrapMode.TileFlipXY;
     brush.SetSigmaBellShape(0.5F, 1F);
     return brush;
 }
Ejemplo n.º 25
0
        private void drawMirror(ref Rectangle rDmn, IntPtr hdc, string caption, string title, IntPtr parent)
        {
            RECT tR = new RECT();
            GetWindowRect(_hTipWnd, ref tR);
            // blit the capture, simulating transparency
            if (_fOpacity < 1.0f)
                BitBlt(hdc, 0, 0, rDmn.Width, rDmn.Height, _cBgDc.Hdc, 0, 0, 0xCC0020);
            Graphics g = Graphics.FromHdc(hdc);
            // draw the frame
            Color c1 = Color.Silver;
            Color c2 = Color.SteelBlue;
            Pen p1 = new Pen(c1, .9f);
            Pen p2 = new Pen(c2, .9f);
            g.DrawLines(p1, new Point[] {
                    new Point (0, rDmn.Height - 1), 
                    new Point (0, 0), 
                    new Point (rDmn.Width - 1, 0)
                });
            p1 = new Pen(c2, .1f);
            g.DrawLines(p2, new Point[] {
                    new Point (0, rDmn.Height - 1), 
                    new Point (rDmn.Width - 1, rDmn.Height - 1), 
                    new Point (rDmn.Width - 1, 0)
                });
            p1.Dispose();
            p2.Dispose();

            // draw bevel
            rDmn.Inflate(-2, -2);
            rDmn.Offset(1, 1);
            float fO = _fOpacity * 255;
            c1 = Color.FromArgb((int)fO, Color.Snow);
            c2 = Color.FromArgb((int)fO, Color.Silver);
            // left
            Rectangle rBv = new Rectangle(1, 1, 4, rDmn.Height);
            Brush hS1 = new SolidBrush(c1);
            Brush hS2 = new SolidBrush(c2);
            g.FillRectangle(hS2, rBv);
            // bottom
            rBv = new Rectangle(1, rDmn.Height - 1, rDmn.Width, 4);
            g.FillRectangle(hS1, rBv);
            // right
            rBv = new Rectangle(rDmn.Width, 2, 4, rDmn.Height + 1);
            g.FillRectangle(hS1, rBv);
            // top
            rBv = new Rectangle(1, 1, rDmn.Width, 4);
            g.FillRectangle(hS2, rBv);
            hS1.Dispose();
            hS2.Dispose();
            // fill
            LinearGradientBrush hB = new LinearGradientBrush(
                rDmn,
                c1,
                c2,
                LinearGradientMode.ForwardDiagonal);
            rDmn.Inflate(1, 1);
            rDmn.Offset(-1, -1);
            hB.SetSigmaBellShape(1f, .5f);
            g.FillRectangle(hB, rDmn);

            hB.Dispose();
            g.Dispose();
        }
Ejemplo n.º 26
0
		public void Rectangle ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			CheckDefaultRectangle ("Original", lgb.Rectangle);
			lgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
			CheckDefaultRectangle ("Multiply", lgb.Rectangle);
			lgb.ResetTransform ();
			CheckDefaultRectangle ("Reset", lgb.Rectangle);
			lgb.RotateTransform (90);
			CheckDefaultRectangle ("Rotate", lgb.Rectangle);
			lgb.ScaleTransform (4, 0.25f);
			CheckDefaultRectangle ("Scale", lgb.Rectangle);
			lgb.TranslateTransform (-10, -20);
			CheckDefaultRectangle ("Translate", lgb.Rectangle);

			lgb.SetBlendTriangularShape (0.5f);
			CheckDefaultRectangle ("SetBlendTriangularShape", lgb.Rectangle);
			lgb.SetSigmaBellShape (0.5f);
			CheckDefaultRectangle ("SetSigmaBellShape", lgb.Rectangle);
		}
Ejemplo n.º 27
0
        private void DrawGradientBorder(Graphics g,
                                        Rectangle backRect,
                                        GradientItemColors colors)
        {
            // Drawing with anti aliasing to create smoother appearance
            using (UseAntiAlias uaa = new UseAntiAlias(g))
            {
                Rectangle backRectI = backRect;
                backRectI.Inflate(1, 1);

                // Finally draw the border around the menu item
                using (
                    LinearGradientBrush borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2,
                                                                              90f))
                {
                    // Sigma curve, so go from color1 to color2 and back to color1 again
                    borderBrush.SetSigmaBellShape(0.5f);

                    // Convert the brush to a pen for DrawPath call
                    using (Pen borderPen = new Pen(borderBrush))
                    {
                        // Create border path around the entire item
                        using (GraphicsPath borderPath = this.CreateBorderPath(backRect, _cutMenuItemBack))
                            g.DrawPath(borderPen, borderPath);
                    }
                }
            }
        }
Ejemplo n.º 28
0
		public void SetSigmaBellShape_Scale ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			// max valid
			lgb.SetSigmaBellShape (0, 1);
			Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-1");
			// min valid
			lgb.SetSigmaBellShape (1, 0);
			Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-2");
			// middle
			lgb.SetSigmaBellShape (0.5f, 0.5f);
			Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity-3");
			// no impact on matrix
		}
Ejemplo n.º 29
0
        private String ReflectImage(HttpContext context, String sourcePhysPath, String destDirPhysPath)
        {
            String fileExtension = Path.GetExtension(sourcePhysPath);
            String fileName = Path.GetFileNameWithoutExtension(sourcePhysPath) + "_reflected.png";
            String procPhysicalPath = Path.Combine(destDirPhysPath, fileName);

            if (!File.Exists(procPhysicalPath))
            {
                if (!Directory.Exists(destDirPhysPath))
                    Directory.CreateDirectory(destDirPhysPath);

                using (Image img = Image.FromFile(sourcePhysPath))
                {
                    Int32 height = img.Height > 3 ? img.Height / 3 - 1 : 1;

                    using (Bitmap bitmap = new Bitmap(img.Width, height))
                    {
                        using (Graphics graphics = Graphics.FromImage(bitmap))
                        {
                            using (Matrix matrix = new Matrix(1, 0, 0, -1, 0, img.Height - 1))
                            {
                                graphics.Transform = matrix;

                                using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, img.Height - bitmap.Height, bitmap.Width, bitmap.Height + 1), Color.White, Color.Transparent, LinearGradientMode.Vertical))
                                {
                                    brush.SetSigmaBellShape(1.0f, 0.45f);

                                    graphics.DrawImage(img, new Point(0, 0));
                                    graphics.FillRectangle(brush, new Rectangle(0, img.Height - bitmap.Height - 1, img.Width, img.Height));

                                    bitmap.Save(procPhysicalPath, System.Drawing.Imaging.ImageFormat.Png);
                                }
                            }
                        }
                    }
                }
            }

            return procPhysicalPath;
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates a brush of the type specified by BrushType.
 /// </summary>
 /// <param name="path">The graphics path used to construct the brush.</param>
 /// <param name="center">The center point of the gradient as a percentage value typically ranging from 0.0 to 1.0.</param>
 /// <param name="angle">The angle used for the gradients, allowing an override of BrushAngle</param>
 public Brush GetBrush(GraphicsPath path, PointF center, float angle)
 {
     RectangleF rect;
     switch (_BrushType)
     {
         case eBrushTypes.Solid:
             return new SolidBrush(_Color1);
         case eBrushTypes.Linear:
             path.Flatten();
             rect = path.GetBounds();
             if (rect.Width > 0.0f && rect.Height > 0.0f)
                 return new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
             else
                 return null;
         case eBrushTypes.Reflected:
             LinearGradientBrush lBrush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
             lBrush.SetSigmaBellShape(_BrushSBSFocus, _BrushSBSScale);
             return lBrush;
         case eBrushTypes.Centered:
             PointF pt = new PointF();
             rect = path.GetBounds();
             PathGradientBrush pBrush = new PathGradientBrush(path);
             pt.X = rect.X + rect.Width * center.X;
             pt.Y = rect.Y + rect.Height * center.Y;
             pBrush.CenterPoint = pt;
             pBrush.CenterColor = _Color1;
             pBrush.SurroundColors = new Color[] { _Color2 };
             return pBrush;
         default:
             return new SolidBrush(_Color1);
     }
 }