RotateTransform() public method

public RotateTransform ( float angle ) : void
angle float
return void
Ejemplo n.º 1
0
        //绘制实心菱形
        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);
            }
        }
        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);
            }
        }
        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;
        }
        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;
        }
Ejemplo n.º 5
0
		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");
		}
Ejemplo n.º 6
0
		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");
		}
Ejemplo n.º 7
0
		public void RotateTransform_InvalidOrder ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
			lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue);
		}
Ejemplo n.º 8
0
		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");
		}
Ejemplo n.º 9
0
		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");
		}
Ejemplo n.º 10
0
        /// <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);
                //}
            }
        }
        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);
        }
        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);
        }
Ejemplo n.º 13
0
		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 );
			}
		}
Ejemplo n.º 14
0
        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;
        }
Ejemplo n.º 15
0
        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;
        }
Ejemplo n.º 16
0
        void PaintView2(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);

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

            // Rotate the LinearGradientBrush.
            myLGBrush.RotateTransform(45.0f, MatrixOrder.Prepend);

            // Rejustify the brush to start at the left edge of the ellipse.
            myLGBrush.TranslateTransform(-100.0f, 0.0f);

            // Draw a second ellipse to the screen using
            // the transformed brush.
            g.FillEllipse(myLGBrush, 20, 150, 200, 100);

            title = "PaintView2";
        }
Ejemplo n.º 17
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);
		}
        /// <summary>
        /// The fill preview background.
        /// </summary>
        /// <param name="bmp">
        /// The bmp.
        /// </param>
        /// <param name="g">
        /// The g.
        /// </param>
        /// <param name="p">
        /// The p.
        /// </param>
        private void FillPreviewBackground(Bitmap bmp, Graphics g, Paragraph p)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(this._videoFileName) && LibVlcDynamic.IsInstalled)
                {
                    using (var vlc = new LibVlcDynamic())
                    {
                        vlc.Initialize(this.panelVlcTemp, this._videoFileName, null, null);
                        Application.DoEvents();
                        vlc.Volume = 0;
                        vlc.Pause();
                        vlc.CurrentPosition = p.StartTime.TotalSeconds;
                        Application.DoEvents();
                        var fileName = Path.GetTempFileName() + ".bmp";
                        vlc.TakeSnapshot(fileName, (uint)bmp.Width, (uint)bmp.Height);
                        Application.DoEvents();
                        Thread.Sleep(200);
                        using (var tempBmp = new Bitmap(fileName))
                        {
                            g.DrawImageUnscaled(tempBmp, new Point(0, 0));
                        }
                    }

                    return;
                }
            }
            catch
            {
                // Was unable to grap screenshot via vlc
            }

            // Draw background with generated image
            var rect = new Rectangle(0, 0, bmp.Width - 1, bmp.Height - 1);
            using (var br = new LinearGradientBrush(rect, Color.Black, Color.Black, 0, false))
            {
                var cb = new ColorBlend { Positions = new[] { 0, 1 / 6f, 2 / 6f, 3 / 6f, 4 / 6f, 5 / 6f, 1 }, Colors = new[] { Color.Black, Color.Black, Color.White, Color.Black, Color.Black, Color.White, Color.Black } };
                br.InterpolationColors = cb;
                br.RotateTransform(0);
                g.FillRectangle(br, rect);
            }
        }
Ejemplo n.º 19
0
        public static Bitmap MakeGradientPattern(int width, int height,
                                                            int period, float angle)
        {
            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);

            LinearGradientBrush lb = new LinearGradientBrush(new Point(0, 0),
                                     new Point(0, period), Color.Black, Color.White);
            lb.SetSigmaBellShape(0.5f);
            lb.RotateTransform(angle);

            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(lb, new Rectangle(0, 0, width, height));
            g.Dispose();

            lb.Dispose();

            return bmp;
        }