SetSigmaBellShape() 공개 메소드

public SetSigmaBellShape ( float focus ) : void
focus float
리턴 void
        protected override void RenderFrameByCenter(PaintEventArgs e, Rectangle r)
        {
            Graphics g = e.Graphics;

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddRectangle(GaugeFrame.Bounds);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.Start;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.End };

                    br.SetSigmaBellShape(GaugeFrame.FrameSigmaFocus, GaugeFrame.FrameSigmaScale);

                    g.FillRectangle(br, GaugeFrame.Bounds);
                }

                path.AddRectangle(r);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.End;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.Start };

                    g.FillRectangle(br, r);
                }
            }

            RenderFrameBorder(g, GaugeFrame.Bounds);
        }
예제 #2
0
        /// <summary>
        /// Fills titlebar button.
        /// </summary>
        /// <param name="rcBtn">Button bounding rectangle.</param>
        /// <param name="g">Graphics object.</param>
        /// <param name="clrStart">Color used to fill the button.</param>
        /// <param name="clrEnd">Color used to fill the outer glow.</param>
        /// <param name="XBoxClip">Path to perform clipping tasks.</param>
        private void FillButton(Rectangle rcBtn, Graphics g, Color clrStart, Color clrEnd, GraphicsPath XBoxClip)
        {
            switch (m_eFillMode)
            {
                case EButtonFillMode.UpperGlow:
                    rcBtn.Height = 3;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(rcBtn, clrStart, clrEnd, LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(lgb, rcBtn);
                    }
                    break;

                case EButtonFillMode.FullFill:
                    // restrict drawing inside button box / rectangle:
                    g.SetClip(XBoxClip);
                    g.SetClip(rcBtn, CombineMode.Intersect);

                    #region Fill button

                    using (SolidBrush sb = new SolidBrush(clrStart))
                    {
                        g.FillRectangle(sb, rcBtn);
                    }

                    #endregion

                    using (EAntiAlias xaa = new EAntiAlias(g))
                    {
                        #region Fill shine

                        using (GraphicsPath XBtnGlow = new GraphicsPath())
                        {
                            XBtnGlow.AddEllipse(rcBtn.Left - 5, rcBtn.Bottom - rcBtn.Height / 2 + 3, rcBtn.Width + 11, rcBtn.Height + 11);
                            using (PathGradientBrush pgb = new PathGradientBrush(XBtnGlow))
                            {
                                pgb.CenterColor = Color.FromArgb(235, Color.White);
                                pgb.SurroundColors = new Color[] { Color.FromArgb(0, clrEnd) };
                                pgb.SetSigmaBellShape(0.8f);

                                g.FillPath(pgb, XBtnGlow);
                            }
                        }

                        #endregion

                        #region Fill upper glow

                        rcBtn.Height = rcBtn.Height / 2 - 2;
                        using (LinearGradientBrush lgb = new LinearGradientBrush(rcBtn, Color.FromArgb(80, Color.White), Color.FromArgb(140, Color.White), LinearGradientMode.Vertical))
                        {
                            using (GraphicsPath XGlowPath = EFormHelper.RoundRect((RectangleF)rcBtn, 0, 0, 4, 4))
                            {
                                lgb.WrapMode = WrapMode.TileFlipXY;
                                g.FillPath(lgb, XGlowPath);
                            }
                        }

                        #endregion
                    }
                    // reset clipping back:
                    g.ResetClip();
                    break;
            }
        }
        /// <summary>
        /// Draws a panel in selected state
        /// </summary>
        /// <param name="e"></param>
        public void DrawPanelSelected(RibbonPanelRenderEventArgs e)
        {

            #region Office_2007

            if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007)
            {
                Rectangle darkBorder = Rectangle.FromLTRB(
                      e.Panel.Bounds.Left,
                      e.Panel.Bounds.Top,
                      e.Panel.Bounds.Right,
                      e.Panel.Bounds.Bottom);

                Rectangle lightBorder = Rectangle.FromLTRB(
                     e.Panel.Bounds.Left + 1,
                     e.Panel.Bounds.Top + 1,
                     e.Panel.Bounds.Right - 1,
                     e.Panel.Bounds.Bottom - 1);

                Rectangle textArea =
                     Rectangle.FromLTRB(
                     e.Panel.Bounds.Left + 1,
                     e.Panel.ContentBounds.Bottom,
                     e.Panel.Bounds.Right - 1,
                     e.Panel.Bounds.Bottom - 1);

                GraphicsPath dark = RoundRectangle(darkBorder, 3);
                GraphicsPath light = RoundRectangle(lightBorder, 3);
                GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest);

                using (Pen p = new Pen(ColorTable.PanelLightBorder))
                {
                    e.Graphics.DrawPath(p, light);
                }

                using (Pen p = new Pen(ColorTable.PanelDarkBorder))
                {
                    e.Graphics.DrawPath(p, dark);
                }

                using (SolidBrush b = new SolidBrush(ColorTable.PanelBackgroundSelected))
                {
                    e.Graphics.FillPath(b, light);
                }

                using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackgroundSelected))
                {
                    e.Graphics.FillPath(b, txt);
                }

                if (e.Panel.ButtonMoreVisible)
                {
                    if (e.Panel.ButtonMorePressed)
                    {
                        DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }
                    else if (e.Panel.ButtonMoreSelected)
                    {
                        DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }

                    DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled);
                }

                txt.Dispose();
                dark.Dispose();
                light.Dispose();
            }

            #endregion

            #region Office_2010

            if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010)
            {
                Rectangle innerLightBorder = Rectangle.FromLTRB(
                     e.Panel.Bounds.Left,
                     e.Panel.Bounds.Top,
                     e.Panel.Bounds.Right - 2,
                     e.Panel.Bounds.Bottom);

                Rectangle darkBorder = Rectangle.FromLTRB(
                      e.Panel.Bounds.Left,
                      e.Panel.Bounds.Top,
                      e.Panel.Bounds.Right - 1,
                      e.Panel.Bounds.Bottom);

                Rectangle outerLightBorder = Rectangle.FromLTRB(
                    e.Panel.Bounds.Left,
                    e.Panel.Bounds.Top,
                    e.Panel.Bounds.Right,
                    e.Panel.Bounds.Bottom);

                //Glow appears as a tall elipse, rather than circle
                Rectangle glowR = new Rectangle(
                     e.Panel.Bounds.Left + (int)(0.1 * e.Panel.Bounds.Width),
                     e.Panel.Bounds.Top,
                     e.Panel.Bounds.Width - (int)(0.2 * e.Panel.Bounds.Width),
                     (2 * e.Panel.Bounds.Height) - 1);

                //Highlight glow in panel
                using (GraphicsPath radialPath = new GraphicsPath())
                {
                    radialPath.AddArc(glowR, 180, 180);
                    radialPath.CloseFigure();

                    PathGradientBrush gr = new PathGradientBrush(radialPath);
                    gr.CenterPoint = new PointF(
                         Convert.ToSingle(innerLightBorder.Left + innerLightBorder.Width / 2),
                         Convert.ToSingle(innerLightBorder.Bottom));
                    gr.CenterColor = ColorTable.PanelBackgroundSelected;
                    gr.SurroundColors = new Color[] { Color.Transparent };
                    gr.SetSigmaBellShape(1.0f, 1.0f);

                    SmoothingMode sm = e.Graphics.SmoothingMode;
                    e.Graphics.SmoothingMode = SmoothingMode.None;
                    e.Graphics.FillPath(gr, radialPath);
                    e.Graphics.SmoothingMode = sm;

                    gr.Dispose();
                }

                // Panel divider left highlight
                using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(90, Color.White),
                   Color.FromArgb(220, Color.White), LinearGradientMode.Vertical))
                {
                    Blend blend = new Blend();
                    blend.Factors = new float[] { 0f, 1f, 1f };
                    blend.Positions = new float[] { 0f, 0.5f, 1f };
                    blendBrush.Blend = blend;
                    blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line.

                    using (Pen p = new Pen(blendBrush))
                    {
                        SmoothingMode sm = e.Graphics.SmoothingMode;
                        e.Graphics.SmoothingMode = SmoothingMode.None;
                        e.Graphics.DrawLine(p, innerLightBorder.Right, innerLightBorder.Top, innerLightBorder.Right, innerLightBorder.Bottom);
                        e.Graphics.SmoothingMode = sm;
                    }
                }

                // Panel divider right highlight
                using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelLightBorder),
                    ColorTable.PanelLightBorder, LinearGradientMode.Vertical))
                {
                    using (Pen p = new Pen(blendBrush))
                    {
                        SmoothingMode sm = e.Graphics.SmoothingMode;
                        e.Graphics.SmoothingMode = SmoothingMode.None;
                        e.Graphics.DrawLine(p, outerLightBorder.Right, outerLightBorder.Top, outerLightBorder.Right, outerLightBorder.Bottom);
                        e.Graphics.SmoothingMode = sm;
                    }
                }

                // Panel divider shading
                using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelDarkBorder),
                    ColorTable.PanelDarkBorder, LinearGradientMode.Vertical))
                {
                    blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line.

                    using (Pen p = new Pen(blendBrush))
                    {
                        SmoothingMode sm = e.Graphics.SmoothingMode;
                        e.Graphics.SmoothingMode = SmoothingMode.None;
                        e.Graphics.DrawLine(p, darkBorder.Right, darkBorder.Top, darkBorder.Right, darkBorder.Bottom);
                        e.Graphics.SmoothingMode = sm;
                    }
                }

                // Panel bottom border highlight
                /* For some reason this is not drawn except under certain circustances, like moving the mouse to a combobox, 
                 * or quickly outside the bounds of the Ribbon. Don't know exactly why, but probably clipping or the order of events being firing. 
                 * Have performed drawing tests with the ribbon, tab, panel drawn transparent and nothing appears to be drawing over the top. 
                 * Until resolved, will just leave the code in case some other change fixes it.*/
                using (Pen p = new Pen(Color.FromArgb(220, Color.White)))
                {
                    SmoothingMode sm = e.Graphics.SmoothingMode;
                    e.Graphics.SmoothingMode = SmoothingMode.None;
                    e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Bottom, innerLightBorder.Right, innerLightBorder.Bottom);
                    //Enabling the line below shows that the line is drawn, but only the right hand half is shown. The left hand half is clipped/missing.
                    //e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Bottom, innerLightBorder.Right, innerLightBorder.Bottom - 1);
                    e.Graphics.SmoothingMode = sm;
                }

                if (e.Panel.ButtonMoreVisible)
                {
                    if (e.Panel.ButtonMorePressed)
                    {
                        DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }
                    else if (e.Panel.ButtonMoreSelected)
                    {
                        DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon);
                    }

                    DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled);
                }
            }

            #endregion

            #region Office_2013

            #endregion
        }
        /// <summary>
        /// Update the button bitmap because the color changed
        /// </summary>
        protected internal virtual void UpdateBitmapAtImageIndex()
        {
            // Get the bitmap on which we will draw an icon.
            Image image;

            if (this.Parent == null || ((ToolStrip)this.Parent).ImageList == null)
                return;

            if (this.ImageIndex >= 0)
                image = this.Parent.ImageList.Images[this.ImageIndex];
            else
                image = this.Image;
            if( image.Width != templateImage.Width ||
                image.Height != templateImage.Height ||
                image.PixelFormat != templateImage.PixelFormat ) {

                Graphics g = Graphics.FromImage( image );
                g.Clear( Color.Transparent );

                // Draw the icon as a 3D-ish sphere.
                // FIXME: Use other attributes of DrawingAttributes besides color and transparency.

                // Srink the circle by -1 to compensate for pixel model, and by -3x-2 more
                // to compensate for ToolBarButton border.
                GraphicsPath ellipse = new GraphicsPath();
                ellipse.AddEllipse( new Rectangle( 0, 0, image.Size.Width - 4, image.Size.Height - 3 ) );

                // We'll now need this.DrawingAttributes, so lock to make sure it isn't changed unexpectedly.
                // Keep the lock until after we're done setting the bitmap to ensure it doesn't get out of sync
                // with the DrawingAttributes via a race condition.

                // Define the gradient to be light-colored in the middle and slightly off-center.
                if( this.CurrentStylusEntry != null ) {
                    PathGradientBrush gradient = new PathGradientBrush( ellipse );
                    gradient.CenterColor = Color.WhiteSmoke;
                    float sqrt2 = (float)Math.Sqrt( 2d );
                    gradient.CenterPoint = new PointF( gradient.CenterPoint.X / sqrt2, gradient.CenterPoint.Y / sqrt2 );
                    Color color = Color.FromArgb( byte.MaxValue - this.CurrentStylusEntry.DrawingAttributes.Transparency,
                        this.CurrentStylusEntry.DrawingAttributes.Color );
                    gradient.SurroundColors = new Color[] { color };
                    gradient.SetSigmaBellShape( 1f, 0.4f );

                    // Fill with a white background first to make the transparency look better.
                    // TODO: Maybe fill with a pattern to make the transparency more obvious.
                    g.FillPath( new SolidBrush( Color.White ), ellipse );

                    // Now fill the gradient.
                    g.FillPath( gradient, ellipse );
                }

                // Surround it with a thin black border.  In the unlikely case
                // that the current DrawingAttributes is null, this is all that will be visible.
                g.DrawPath( new Pen( Color.Black, 0.1f ), ellipse );

                // Force the button to reload its image (even though it's probably the same object as before).
                this.Parent.ImageList.Images[this.ImageIndex] = image;
            } else {
                // Sanity Check
                if( this.CurrentStylusEntry != null ) {
                    Color basecolor = this.CurrentStylusEntry.DrawingAttributes.Color;
                    // Draw each pixel in the image
                    for( int y = 0; y < this.templateImage.Height; y++ ) {
                        for( int x = 0; x < this.templateImage.Width; x++ ) {
                            Color col = templateImage.GetPixel( x, y );
                            // Check if this pixel is transparent or not
                            if( col.A != 0 ) {
                                int r = ((int)col.R + (int)basecolor.R) - 119;
                                r = Math.Min( 255, Math.Max( 0, r ) );
                                int g = ((int)col.G + (int)basecolor.G) - 119;
                                g = Math.Min( 255, Math.Max( 0, g ) );
                                int b = ((int)col.B + (int)basecolor.B) - 119;
                                b = Math.Min( 255, Math.Max( 0, b ) );

                                ((Bitmap)image).SetPixel( x, y,
                                                          Color.FromArgb( col.A, r, g, b ) );
                            } else {
                                ((Bitmap)image).SetPixel( x, y,
                                                          Color.FromArgb( 0, 0, 0, 0 ) );
                            }
                        }
                    }
                    // Replace the existing image with this one
                    Misc.ImageListHelper.Replace( (Bitmap)image, this.ImageIndex, this.Parent.ImageList );
                    this.Image = image;
                    this.Invalidate();
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Approximates a radial brush using a high-rez PathGradientBrush.
        /// </summary>
        /// <param name="inner"></param>
        /// <param name="outer"></param>
        /// <param name="pt"></param>
        /// <param name="width"></param>
        /// <returns></returns>
        public static Brush GenerateRadialBrush(Color inner, Color outer, PointF pt, float width)
        {
            //This should approximate one outer point per pixel.
            PointF[] path = new PointF[(int)Math.Round(width * 2 * Math.PI) + 1];
            for (int i = 0; i < path.Length - 1; i++)
            {
                double radians = ((double)i - width) / width; //calculate the radians at this index.
                //Calculate a point based off the radians.
                path[i] = new PointF((float)(Math.Sin(radians) * width + pt.X), (float)(Math.Cos(radians) * width + pt.Y));
            }
            path[path.Length - 1] = path[0]; //Loop back to complete the circle.

            PathGradientBrush b = new PathGradientBrush(path);
            b.CenterColor = inner;
            b.CenterPoint = pt;
            b.WrapMode = WrapMode.Clamp;
            //All outer colors are the same.
            Color[] colors = new Color[path.Length];
            for (int i = 0; i < colors.Length; i++) colors[i] = outer;
            b.SurroundColors = colors;
            b.SetSigmaBellShape(1);
            return b;
        }
예제 #6
0
        /// <summary>
        /// Prepares the bitmap used to draw the window. Layered windows (like this one) use a bitmap for their
        /// content, including alpha channel.
        /// </summary>
        protected void PrepareBitmap(bool showCancelButton)
        {
            if (contentBitmap != null)
            contentBitmap.Dispose();
              contentBitmap = new Bitmap(Width, Height);

              GraphicsPath path = GetPath();
              GraphicsPath innerPath = (GraphicsPath)path.Clone();

              // Increase size of the outline by the shadow size and move it to the center.
              // The inner path keeps the original bounds for clipping.
              Matrix matrix = new Matrix();

              float offsetX = Width / 2;
              float offsetY = Height / 2;
              matrix.Translate(offsetX + shadowOffset, offsetY + shadowOffset);
              matrix.Scale(1 + (2 * shadowSize + borderSize) / (float)baseSize.Width, 1 + (2 * shadowSize + borderSize) / (float)baseSize.Height);
              path.Transform(matrix);

              // Also move the inner part to its final place.
              matrix.Reset();
              matrix.Translate(offsetX, offsetY);
              innerPath.Transform(matrix);

              Graphics g = Graphics.FromImage(contentBitmap);
              g.SmoothingMode = SmoothingMode.HighQuality;
              using (Brush brush = new SolidBrush(Color.FromArgb(10, 0, 0, 0)))
            g.FillRectangle(brush, ClientRectangle);

              // Fill interior.
              using (Brush brush = new SolidBrush(Color.FromArgb(191, 0, 0, 0)))
            g.FillPath(brush, innerPath);

              // ... and draw border around the interior.
              using (Pen borderPen = new Pen(Color.FromArgb(200, Color.White)))
              {
            borderPen.EndCap = LineCap.Round;
            borderPen.StartCap = LineCap.Round;
            borderPen.Width = borderSize;
            GraphicsPath borderPath = (GraphicsPath)innerPath.Clone();
            borderPath.Widen(borderPen);
            using (SolidBrush brush = new SolidBrush(Color.FromArgb(255, Color.White)))
              g.FillPath(brush, borderPath);

            // Clip out interior. Exclude both, the panel itself as well as its border.
            using (Region region = new Region(innerPath))
              g.SetClip(region, CombineMode.Exclude);

            innerPath.Widen(borderPen);
            using (Region region = new Region(innerPath))
              g.SetClip(region, CombineMode.Exclude);
              }

              using (PathGradientBrush backStyle = new PathGradientBrush(path))
              {
            backStyle.CenterColor = shadowColor;
            backStyle.SurroundColors = new Color[] { Color.Transparent };

            // Make a smooth fade out of the shadow color using the built-in sigma bell curve generator.
            backStyle.SetSigmaBellShape(0.4f, 1f);

            // Now draw the shadow.
            g.FillPath(backStyle, path);
              }

              // Remove clipping for the remaining interior.
              g.ResetClip();
              RectangleF innerBounds = innerPath.GetBounds();
              Point targetLocation = pictureBox1.Location;
              targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
              g.DrawImageUnscaled(pictureBox1.Image, targetLocation);

              // Message text output.
              using (StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox))
              {
            targetLocation = label1.Location;
            targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
            RectangleF textBounds = new RectangleF(targetLocation,
              new SizeF(
            innerBounds.Right - targetLocation.X - Padding.Right,
            innerBounds.Bottom - targetLocation.Y - Padding.Bottom
              )
            );

            path.Dispose();
            innerPath.Dispose();

            using (Brush textBrush = new SolidBrush(label1.ForeColor))
              g.DrawString(label1.Text, label1.Font, textBrush, textBounds, format);

            targetLocation = label2.Location;
            targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
            textBounds = new RectangleF(targetLocation,
              new SizeF(
            innerBounds.Right - targetLocation.X - Padding.Right,
            innerBounds.Bottom - targetLocation.Y - Padding.Bottom
              )
            );

            using (Brush textBrush = new SolidBrush(label2.ForeColor))
              g.DrawString(label2.Text, label2.Font, textBrush, textBounds, format);

            if (showCancelButton)
            {
              Point buttonLocation = cancelButtonPicture.Location;
              buttonLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
              cancelButtonBounds = new RectangleF(buttonLocation, cancelButtonPicture.Size);
              g.DrawImageUnscaled(cancelButtonPicture.Image, buttonLocation);
            }
            else
              cancelButtonBounds = new RectangleF();
              }
        }
예제 #7
0
파일: Form1.cs 프로젝트: kinpauln/QRCode
 private void creat_image()
 {
     Point point;
     int num;
     GraphicsPath path;
     PathGradientBrush brush;
     System.Drawing.Color[] colorArray;
     Bitmap image = new Bitmap(0x1388, 0x1388);
     Graphics graphics = Graphics.FromImage(image);
     if (this.comboBox1.SelectedIndex == 4)
     {
         this.button18.Visible = false;
         this.button19.Visible = false;
         this.button20.Visible = false;
         this.label23.Visible = false;
         this.numericUpDown5.Visible = false;
         point = new Point(0x9c4, 0x9c4);
         num = (int) (2500.0 / Math.Cos(45.0));
         path = new GraphicsPath();
         path.AddEllipse((int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
         brush = new PathGradientBrush(path) {
             CenterPoint = (PointF) point,
             CenterColor = this.button11.BackColor
         };
         colorArray = new System.Drawing.Color[] { this.button10.BackColor };
         brush.SurroundColors = colorArray;
         brush.SetSigmaBellShape((float) this.numericUpDown2.Value);
         graphics.FillEllipse(brush, (int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
         brush.Dispose();
         graphics.Dispose();
         this.pictureBox3.Image = image;
     }
     else
     {
         Rectangle rectangle;
         LinearGradientBrush brush2;
         Point point2;
         int num2;
         GraphicsPath path2;
         PathGradientBrush brush3;
         if (this.comboBox1.SelectedIndex == 5)
         {
             this.button18.Visible = true;
             this.button19.Visible = true;
             this.button20.Visible = true;
             this.label23.Visible = true;
             this.numericUpDown5.Visible = true;
             rectangle = new Rectangle {
                 Width = 0x1388,
                 Height = 0x1388
             };
             brush2 = null;
             brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.Vertical);
             brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
             brush2.Dispose();
             point2 = new Point(0x9c4, 0x9c4);
             num2 = (int) (1000M * this.numericUpDown5.Value);
             path2 = new GraphicsPath();
             path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3 = new PathGradientBrush(path2) {
                 CenterPoint = (PointF) point2,
                 CenterColor = this.button18.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button11.BackColor };
             brush3.SurroundColors = colorArray;
             graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
         else if (this.comboBox1.SelectedIndex == 6)
         {
             this.button18.Visible = true;
             this.button19.Visible = true;
             this.button20.Visible = true;
             this.label23.Visible = true;
             this.numericUpDown5.Visible = true;
             rectangle = new Rectangle {
                 Width = 0x1388,
                 Height = 0x1388
             };
             brush2 = null;
             brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.Horizontal);
             brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
             brush2.Dispose();
             point2 = new Point(0x9c4, 0x9c4);
             num2 = (int) (1000M * this.numericUpDown5.Value);
             path2 = new GraphicsPath();
             path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3 = new PathGradientBrush(path2) {
                 CenterPoint = (PointF) point2,
                 CenterColor = this.button18.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button11.BackColor };
             brush3.SurroundColors = colorArray;
             graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
         else if (this.comboBox1.SelectedIndex == 7)
         {
             this.button18.Visible = true;
             this.button19.Visible = true;
             this.button20.Visible = true;
             this.label23.Visible = true;
             this.numericUpDown5.Visible = true;
             rectangle = new Rectangle {
                 Width = 0x1388,
                 Height = 0x1388
             };
             brush2 = null;
             brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.BackwardDiagonal);
             brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
             brush2.Dispose();
             point2 = new Point(0x9c4, 0x9c4);
             num2 = (int) (1000M * this.numericUpDown5.Value);
             path2 = new GraphicsPath();
             path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3 = new PathGradientBrush(path2) {
                 CenterPoint = (PointF) point2,
                 CenterColor = this.button18.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button11.BackColor };
             brush3.SurroundColors = colorArray;
             graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
         else if (this.comboBox1.SelectedIndex == 8)
         {
             this.button18.Visible = true;
             this.button19.Visible = true;
             this.button20.Visible = true;
             this.label23.Visible = true;
             this.numericUpDown5.Visible = true;
             rectangle = new Rectangle {
                 Width = 0x1388,
                 Height = 0x1388
             };
             brush2 = null;
             brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.ForwardDiagonal);
             brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
             brush2.Dispose();
             point2 = new Point(0x9c4, 0x9c4);
             num2 = (int) (1000M * this.numericUpDown5.Value);
             path2 = new GraphicsPath();
             path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3 = new PathGradientBrush(path2) {
                 CenterPoint = (PointF) point2,
                 CenterColor = this.button18.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button11.BackColor };
             brush3.SurroundColors = colorArray;
             graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
         else if (this.comboBox1.SelectedIndex == 9)
         {
             graphics.FillRectangle(new SolidBrush(this.button10.BackColor), 0, 0, 0x1388, 0x1388);
             this.button18.Visible = true;
             this.button19.Visible = true;
             this.button20.Visible = true;
             this.label23.Visible = true;
             this.numericUpDown5.Visible = true;
             point = new Point(0x9c4, 0x9c4);
             num = (int) (1800M * this.numericUpDown5.Value);
             path = new GraphicsPath();
             path.AddEllipse((int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
             brush = new PathGradientBrush(path) {
                 CenterPoint = (PointF) point,
                 CenterColor = this.button19.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button10.BackColor };
             brush.SurroundColors = colorArray;
             brush.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillEllipse(brush, (int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
             brush.Dispose();
             point2 = new Point(0x9c4, 0x9c4);
             num2 = (int) (1000M * this.numericUpDown5.Value);
             path2 = new GraphicsPath();
             path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3 = new PathGradientBrush(path2) {
                 CenterPoint = (PointF) point2,
                 CenterColor = this.button18.BackColor
             };
             colorArray = new System.Drawing.Color[] { this.button11.BackColor };
             brush3.SurroundColors = colorArray;
             graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
             brush3.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
         else
         {
             this.button18.Visible = false;
             this.button19.Visible = false;
             this.button20.Visible = false;
             this.label23.Visible = false;
             this.numericUpDown5.Visible = false;
             rectangle = new Rectangle {
                 Width = 0x1388,
                 Height = 0x1388
             };
             brush2 = null;
             if (this.comboBox1.SelectedIndex == 0)
             {
                 brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button11.BackColor, LinearGradientMode.Vertical);
             }
             else if (this.comboBox1.SelectedIndex == 1)
             {
                 brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button11.BackColor, LinearGradientMode.Horizontal);
             }
             else if (this.comboBox1.SelectedIndex == 2)
             {
                 brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button11.BackColor, LinearGradientMode.BackwardDiagonal);
             }
             else if (this.comboBox1.SelectedIndex == 3)
             {
                 brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button11.BackColor, LinearGradientMode.ForwardDiagonal);
             }
             else
             {
                 brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button11.BackColor, LinearGradientMode.Vertical);
             }
             brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
             graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
             brush2.Dispose();
             graphics.Dispose();
             this.pictureBox3.Image = image;
         }
     }
     this.Refresh();
 }
        protected override void RenderBackByCenter(PaintEventArgs e, Rectangle r)
        {
            Graphics g = e.Graphics;

            using (GraphicsPath path = GetRoundRectPath(r))
            {
                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterColor = GaugeFrame.BackColor.Start;
                    br.SurroundColors = new Color[] { GaugeFrame.BackColor.End };
                    br.CenterPoint = GaugeFrame.Center;

                    br.SetSigmaBellShape(GaugeFrame.BackSigmaFocus, GaugeFrame.BackSigmaScale);

                    g.FillRectangle(br, r);
                }

                RenderBackBorder(g, path);
            }
        }
예제 #9
0
		public void SetSigmaBellShape_ScaleTooBig ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				pgb.SetSigmaBellShape (1, 1.01f);
			}
		}
예제 #10
0
		public void SetSigmaBellShape_FocusTooSmall ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				pgb.SetSigmaBellShape (-1);
			}
		}
예제 #11
0
		public void SetSigmaBellShape_Scale ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				// max valid
				pgb.SetSigmaBellShape (0, 1);
				Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-1");
				// min valid
				pgb.SetSigmaBellShape (1, 0);
				Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-2");
				// middle
				pgb.SetSigmaBellShape (0.5f, 0.5f);
				Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-3");
				// no impact on matrix
			}
		}
예제 #12
0
		public void Rectangle ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.TileFlipXY)) {
				CheckDefaultRectangle ("Original", pgb.Rectangle);
				pgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
				CheckDefaultRectangle ("Multiply", pgb.Rectangle);
				pgb.ResetTransform ();
				CheckDefaultRectangle ("Reset", pgb.Rectangle);
				pgb.RotateTransform (90);
				CheckDefaultRectangle ("Rotate", pgb.Rectangle);
				pgb.ScaleTransform (4, 0.25f);
				CheckDefaultRectangle ("Scale", pgb.Rectangle);
				pgb.TranslateTransform (-10, -20);
				CheckDefaultRectangle ("Translate", pgb.Rectangle);

				pgb.SetBlendTriangularShape (0.5f);
				CheckDefaultRectangle ("SetBlendTriangularShape", pgb.Rectangle);
				pgb.SetSigmaBellShape (0.5f);
				CheckDefaultRectangle ("SetSigmaBellShape", pgb.Rectangle);
			}
		}