当前位置: 首页>>代码示例>>C#>>正文


C# LinearGradientBrush.RotateTransform方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.LinearGradientBrush.RotateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradientBrush.RotateTransform方法的具体用法?C# LinearGradientBrush.RotateTransform怎么用?C# LinearGradientBrush.RotateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.LinearGradientBrush的用法示例。


在下文中一共展示了LinearGradientBrush.RotateTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawSolidDiamond

        //绘制实心菱形
        private static void DrawSolidDiamond(PointF[] p, Graphics g, Color c, Size sz)
        {
            PointF[] p2 = new PointF[5];
           
            RectangleF recf = new RectangleF(0, 0, sz.Width, sz.Height);

            LinearGradientBrush bsh = new LinearGradientBrush(recf, c, c, 0.0f);
            bsh.RotateTransform(45);

            float a = (float)Math.Sqrt(sz.Width * sz.Width + sz.Height * sz.Height);
            float halfa = a * 0.5f;

            for (int i = 0; i < p.Length; i++)
            {
                p2[0].X = p[i].X;
                p2[0].Y = p[i].Y - halfa;

                p2[1].X = p[i].X + halfa;
                p2[1].Y = p[i].Y;

                p2[2].X = p[i].X;
                p2[2].Y = p[i].Y + halfa;

                p2[3].X = p[i].X - halfa;
                p2[3].Y = p[i].Y;

                p2[4] = p2[0];
                
                g.FillPolygon(bsh, p2);
            }
        }
开发者ID:SanHot,项目名称:plotcontrol,代码行数:32,代码来源:DrawingCurveIcon.cs

示例2: DrawRoundRect

        public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
        {
            try
            {
                p.Width = 6;
                Rectangle r = this.ClientRectangle;
                // r.Width--; r.Height--;
                using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
                {
                    using (System.Drawing.Drawing2D.LinearGradientBrush gradBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, 90, false))
                    {

                        ColorBlend cb = new ColorBlend();
                        cb.Positions = new[] { 0, 1f };
                        cb.Colors = new[] { Color.Transparent, Color.Transparent };
                        gradBrush.InterpolationColors = cb;
                        // rotate
                        gradBrush.RotateTransform(0);
                        // paint
                        //g.FillPath(gradBrush, rr);
                        g.DrawPath(p, rr);
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
开发者ID:antonesterhuyse,项目名称:GrucoxScrumView,代码行数:29,代码来源:RoundedPamel.cs

示例3: GetBrush

        public Brush GetBrush(long transactionId, long revisionId, DateTime recordFrom, DateTime recordTo, DateTime validFrom, DateTime validTo, Rectangle bounds)
        {
            if (bounds.Width == 0 || bounds.Height == 0)
                return new SolidBrush(Color.Black);
            if (!gradientMappings.ContainsKey(revisionId))
                gradientMappings[revisionId] = gradients[(int)revisionId%gradients.Count];

            LinearGradientBrush br = new LinearGradientBrush(bounds, Color.Black, Color.Black, 0, false);
            ColorBlend cb = new ColorBlend();
            var grad = gradientMappings[revisionId];
            if (transactionId == highlightedTransaction)
                grad = Tuple.Create(grad.Item2, grad.Item1);
            cb.Positions = recordTo != DateTime.MaxValue ? new[] { 0, 1f } : new[] { 0, 0.1f, 1f };
            cb.Colors = recordTo != DateTime.MaxValue ? new[] { grad.Item2, grad.Item2 } : new[] { Color.White, Color.White, grad.Item2 };
            br.InterpolationColors = cb;
            // rotate
            br.RotateTransform(90);

            return br;
        }
开发者ID:Quantumplation,项目名称:BitemporalViewer,代码行数:20,代码来源:BrushProvider.cs

示例4: PaintGradient

        private void PaintGradient()
        {

            System.Drawing.Drawing2D.LinearGradientBrush gradBrush;
            gradBrush =
              new System.Drawing.Drawing2D.LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, 0, false);  // Opaque blue

            ColorBlend cb = new ColorBlend();
            cb.Positions = new[] { 0, 1/2f, 1f };
            cb.Colors = new[] { customColor1, customColor2, customColor3};
            gradBrush.InterpolationColors = cb;
            // rotate
            gradBrush.RotateTransform(0);
            // paint

            Bitmap bmp = new Bitmap(this.Width, this.Height);

            //Graphics g = this.CreateGraphics();
            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(gradBrush, new Rectangle(0, 0,
                            this.Width, this.Height));
            this.BackgroundImage = bmp;
            this.BackgroundImageLayout = ImageLayout.Stretch;
        }
开发者ID:antonesterhuyse,项目名称:GrucoxScrumView,代码行数:24,代码来源:GradientPanelHor3.cs

示例5: Transform_Operations_OnScalableAngle

		public void Transform_Operations_OnScalableAngle ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 360f, true);
			Matrix clone = lgb.Transform.Clone ();
			Matrix mul = clone.Clone ();
			Matrix m = new Matrix ();
			m.Scale (2, 1);
			m.Translate (rect.Width, rect.Height);
			m.Rotate (30f);

			clone.Multiply (mul, MatrixOrder.Append);
			lgb.MultiplyTransform (mul, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");

			clone.Multiply (mul, MatrixOrder.Prepend);
			lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");

			clone.Rotate (45, MatrixOrder.Append);
			lgb.RotateTransform (45, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");

			clone.Rotate (45, MatrixOrder.Prepend);
			lgb.RotateTransform (45, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");

			clone.Scale (0.25f, 2, MatrixOrder.Append);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Append");

			clone.Scale (0.25f, 2, MatrixOrder.Prepend);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");

			clone.Translate (10, 20, MatrixOrder.Append);
			lgb.TranslateTransform (10, 20, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Append");

			clone.Translate (30, 40, MatrixOrder.Prepend);
			lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");

			clone.Reset ();
			lgb.ResetTransform ();
			Assert.AreEqual (lgb.Transform, clone, "Reset");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:46,代码来源:LinearGradientBrushTest.cs

示例6: Transform_Operations

		public void Transform_Operations ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f);
			Matrix clone = lgb.Transform.Clone ();
			Matrix mul = clone.Clone ();

			clone.Multiply (mul, MatrixOrder.Append);
			lgb.MultiplyTransform (mul, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");

			clone.Multiply (mul, MatrixOrder.Prepend);
			lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");

			clone.Rotate (45, MatrixOrder.Append);
			lgb.RotateTransform (45, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");

			clone.Rotate (45, MatrixOrder.Prepend);
			lgb.RotateTransform (45, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");

			clone.Scale (0.25f, 2, MatrixOrder.Append);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Append");

			clone.Scale (0.25f, 2, MatrixOrder.Prepend);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");

			clone.Translate (10, 20, MatrixOrder.Append);
			lgb.TranslateTransform (10, 20, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Append");

			clone.Translate (30, 40, MatrixOrder.Prepend);
			lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");

			clone.Reset ();
			lgb.ResetTransform ();
			Assert.AreEqual (lgb.Transform, clone, "Reset");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:42,代码来源:LinearGradientBrushTest.cs

示例7: RotateTransform_InvalidOrder

		public void RotateTransform_InvalidOrder ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
			lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:LinearGradientBrushTest.cs

示例8: RotateTransform_Min

		public void RotateTransform_Min ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			lgb.RotateTransform (Single.MinValue);
			float[] elements = lgb.Transform.Elements;
			Assert.AreEqual (-5.93904E+36, elements[0], 1e32, "matrix.0");
			Assert.AreEqual (-5.93904E+36, elements[1], 1e32, "matrix.1");
			Assert.AreEqual (5.93904E+36, elements[2], 1e32, "matrix.2");
			Assert.AreEqual (-5.93904E+36, elements[3], 1e32, "matrix.3");
			Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
			Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:LinearGradientBrushTest.cs

示例9: RotateTransform

		public void RotateTransform ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			lgb.RotateTransform (90);
			float[] elements = lgb.Transform.Elements;
			Assert.AreEqual (0, elements[0], 0.1, "matrix.0");
			Assert.AreEqual (1, elements[1], 0.1, "matrix.1");
			Assert.AreEqual (-1, elements[2], 0.1, "matrix.2");
			Assert.AreEqual (0, elements[3], 0.1, "matrix.3");
			Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
			Assert.AreEqual (0, elements[5], 0.1, "matrix.5");

			lgb.RotateTransform (270);
			Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:LinearGradientBrushTest.cs

示例10: DrawInnerBackground

        /// <summary>
        /// Draws the background for the control
        /// using the background image and the 
        /// BaseColor.
        /// </summary>
        /// <param name="g">The graphics object used in the paint event.</param>
        private void DrawInnerBackground(Graphics g)
        {
            if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
            int alpha = (mButtonState == State.Pressed) ? 204 : 127;
            Rectangle r = this.ClientRectangle;
            r.X = r.X + 4;
            r.Y = r.Y + 4;
            r.Width = r.Width - 8;
            r.Height = r.Height - 8;
            using (GraphicsPath rr = RoundRect(r, CornerRadius - 4, CornerRadius - 4, CornerRadius - 4, CornerRadius - 4))
            {
                using (System.Drawing.Drawing2D.LinearGradientBrush gradBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, 90, false))
                {
                    if (this.mButtonState == State.None)
                    {
                        ColorBlend cb = new ColorBlend();
                        cb.Positions = new[] { 0, 1f };
                        cb.Colors = new[] { innerBackColorTop, innerBackColorBottom };
                        gradBrush.InterpolationColors = cb;
                        gradBrush.RotateTransform(45);
                        g.FillPath(gradBrush, rr);
                    }
                    else if (this.mButtonState == State.Pressed)
                    {
                        ColorBlend cb = new ColorBlend();
                        cb.Positions = new[] { 0, 1f };
                        cb.Colors = new[] { innerColorTopMouseDown, innerColorBottomMouseDown };
                        gradBrush.InterpolationColors = cb;
                        gradBrush.RotateTransform(45);
                        g.FillPath(gradBrush, rr);
                    }
                }

                //using (SolidBrush sb = new SolidBrush(this.BaseColor))
                //{
                //    g.FillPath(sb, rr);
                //}
                SetClip(g);
                if (this.BackImage != null) { g.DrawImage(this.BackImage, this.ClientRectangle); }
                g.ResetClip();
                //using (SolidBrush sb = new SolidBrush(Color.FromArgb(alpha, this.ButtonColor)))
                //{
                //    g.FillPath(sb, rr);
                //}
            }
        }
开发者ID:antonesterhuyse,项目名称:GrucoxScrumView,代码行数:52,代码来源:RetroButton.cs

示例11: PaintView5

        void PaintView5(Graphics g)
        {
            LinearGradientBrush br = new LinearGradientBrush(ClientRectangle, Color.Black, Color.Black, 0 , false);
            ColorBlend cb = new ColorBlend();
            cb.Positions = new[] {0, 1/6f, 2/6f, 3/6f, 4/6f, 5/6f, 1};
            cb.Colors = new[] {Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, Color.Violet};
            br.InterpolationColors= cb;
            // rotate
            br.RotateTransform(45);
            // paint
            g.FillRectangle(br, ClientRectangle);

            Pen myPen = new Pen(Color.Blue, 1);
            Pen myPen2 = new Pen(Color.Red, 1);

            // Create an array of points.
            Point[] myArray =
            {
                new Point(20, 20),
                new Point(120, 20),
                new Point(120, 120),
                new Point(20, 120),
                new Point(20,20)
            };

            // Draw the Points to the screen before applying the
            // transform.
            g.DrawLines(myPen, myArray);

            // Create a matrix and scale it.
            Matrix myMatrix = new Matrix();
            myMatrix.Scale(3, 2, MatrixOrder.Append);
            myMatrix.TransformPoints(myArray);

            // Draw the Points to the screen again after applying the
            // transform.
            g.DrawLines(myPen2, myArray);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:38,代码来源:DrawingView.cs

示例12: PaintView11

        void PaintView11(Graphics g)
        {
            // The emsize is calculated here until it can be fixed.
            float emsize = 24;
            var myRect = new RectangleF(10, 10, 200, 200);
            LinearGradientBrush myBrush = new LinearGradientBrush(myRect, Color.Black, Color.Black, 0 , false);
            ColorBlend cb = new ColorBlend();
            cb.Positions = new[] {0, 1/6f, 2/6f, 3/6f, 4/6f, 5/6f, 1};
            cb.Colors = new[] {Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, Color.Violet};
            myBrush.InterpolationColors= cb;

            // rotate
            myBrush.RotateTransform(45);

            //Font myFont = new Font("Times New Roman", emsize, FontStyle.Bold);
            Font myFont = new Font("Helvetica", emsize, FontStyle.Bold);

            g.DrawString("Look at this text!  It is Gradiented!!", myFont, myBrush, myRect);

            // reset and rotate again
            myBrush.ResetTransform();
            myBrush.RotateTransform(-45);

            g.DrawString("Look at this text!  It is Gradiented!!", myFont, myBrush, 10, 250);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:25,代码来源:DrawingView.cs

示例13: DrawProgressBar

		public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl ) {
			Rectangle	client_area = ctrl.client_area;
			int		barpos_pixels;
			Rectangle bar = ctrl.client_area;
			
			barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
			
			bar.Width = barpos_pixels + 1;
			
			// Draw bar background
			dc.FillRectangle( ResPool.GetSolidBrush( menu_separator_color ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
			
			/* Draw border */
			Pen tmp_pen = ResPool.GetPen( progressbar_edge_dot_color );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1 );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1 );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
			
			tmp_pen = ResPool.GetPen( scrollbar_border_color );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Y );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Bottom - 1 );
			dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
			
			if ( barpos_pixels <= 0 )
				return;
			
			if ((bar.Width - 2) <= 0 || (bar.Height - 1) <= 0)
				return;
			
			// Draw bar
			dc.DrawRectangle( ResPool.GetPen( combobox_focus_border_color ), bar.X - 1, bar.Y - 1, bar.Width, bar.Height + 1 );
			tmp_pen = ResPool.GetPen( progressbar_inner_border_color );
			dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.Right - 2, bar.Y );
			dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.X, bar.Bottom - 1 );
			
			using ( Bitmap bmp = new Bitmap( bar.Width - 2, bar.Height - 1 ) ) {
				using ( Graphics gr = Graphics.FromImage( bmp ) ) {
					gr.FillRectangle( ResPool.GetSolidBrush( tab_focus_color ), 0, 0, bmp.Width, bmp.Height );
					
					LinearGradientBrush lgbr = new LinearGradientBrush( new Rectangle( 0, 0, bmp.Height, bmp.Height ), progressbar_first_gradient_color, progressbar_second_gradient_color, 0.0f, true );
					
					lgbr.RotateTransform( 45.0f, MatrixOrder.Append );
					
					float pen_width = bmp.Height / 2;
					
					Pen pen = new Pen( lgbr, pen_width );
					
					int add = bmp.Height + (int)pen.Width / 2;
					
					int x_top = 0;
					int x_bottom = - bmp.Height;
					
					while ( x_bottom < bmp.Width ) {
						gr.DrawLine( pen, x_top, 0, x_bottom, bmp.Height );
						x_top += add;
						x_bottom += add;
					}
					pen.Dispose( );
					lgbr.Dispose( );
				}
				
				dc.DrawImage( bmp, bar.X + 1, bar.Y + 1 );
			}
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:66,代码来源:ThemeClearlooks.cs

示例14: genPlayButton

        Image genPlayButton()
        {
            Image play = new Bitmap(132, 32);
            Image icon = Bitmap.FromFile(Application.StartupPath + "\\icons\\play.png");

            ColorBlend blend = new ColorBlend();
            blend.Positions = new float[] { 0, 0.5f, 1 };
            blend.Colors = new Color[] { Color.FromArgb(100, Color.Gray), Color.FromArgb(192, 107, 107, 107), Color.FromArgb(192, 159, 159, 159) };

            LinearGradientBrush gradientBrush = new LinearGradientBrush(new Rectangle(0, 0, 1, 1), Color.Black, Color.Black, 0, false);
            gradientBrush.InterpolationColors = blend;

            gradientBrush.ResetTransform();
            gradientBrush.ScaleTransform(64, 64);
            gradientBrush.RotateTransform(90);

            Graphics gfx = Graphics.FromImage(play);
            gfx.SmoothingMode = SmoothingMode.HighQuality;

            gfx.FillPie(gradientBrush, new Rectangle(0, 0, 132, 64), 180, 180); //background
            gfx.DrawPie(new Pen(Color.Black, 4), new Rectangle(2, 2, 128, 56), 180, 180); //outline
            gfx.DrawImage(icon, 50, 0); //icon

            gradientBrush.Dispose();
            gfx.Dispose();
            icon.Dispose();

            return play;
        }
开发者ID:Winterstark,项目名称:Tesserax,代码行数:29,代码来源:Main.cs

示例15: DrawShadowBitmap

        public static Bitmap DrawShadowBitmap(int width, int height, int borderRadius, int blur, int spread, Color color)
        {
            int ex = blur + spread;
            int w = width + ex * 2;
            int h = height + ex * 2;
            int solidW = width + spread * 2;
            int solidH = height + spread * 2;

            var bitmap = new Bitmap(w, h);
            Graphics g = Graphics.FromImage(bitmap);
            // fill background
            g.FillRectangle(new SolidBrush(color)
                , blur, blur, width + spread * 2 + 1, height + spread * 2 + 1);
            // +1 to fill the gap

            if (blur > 0)
            {
                // four dir gradiant
                {
                    // left
                    var brush = new LinearGradientBrush(new Point(0, 0), new Point(blur, 0), Color.Transparent, color);
                    // will thorw ArgumentException
                    // brush.WrapMode = WrapMode.Clamp;

                    g.FillRectangle(brush, 0, blur, blur, solidH);
                    // up
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, 0, solidW, blur);

                    // right
                    // make sure parttern is currect
                    brush.ResetTransform();
                    brush.TranslateTransform(w % blur, h % blur);

                    brush.RotateTransform(180);
                    g.FillRectangle(brush, w - blur, blur, blur, solidH);
                    // down
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, h - blur, solidW, blur);
                }

                // four corner
                {
                    var gp = new GraphicsPath();
                    //gp.AddPie(0,0,blur*2,blur*2, 180, 90);
                    gp.AddEllipse(0, 0, blur * 2, blur * 2);

                    var pgb = new PathGradientBrush(gp);
                    pgb.CenterColor = color;
                    pgb.SurroundColors = new[] { Color.Transparent };
                    pgb.CenterPoint = new Point(blur, blur);

                    // lt
                    g.FillPie(pgb, 0, 0, blur * 2, blur * 2, 180, 90);
                    // rt
                    var matrix = new Matrix();
                    matrix.Translate(w - blur * 2, 0);

                    pgb.Transform = matrix;
                    //pgb.Transform.Translate(w-blur*2, 0);
                    g.FillPie(pgb, w - blur * 2, 0, blur * 2, blur * 2, 270, 90);
                    // rb
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, w - blur * 2, h - blur * 2, blur * 2, blur * 2, 0, 90);
                    // lb
                    matrix.Reset();
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, 0, h - blur * 2, blur * 2, blur * 2, 90, 90);
                }
            }

            //
            return bitmap;
        }
开发者ID:tranxuanloc,项目名称:Calculator,代码行数:76,代码来源:Dropshadow.cs


注:本文中的System.Drawing.Drawing2D.LinearGradientBrush.RotateTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。