public void Clone()
 {
     using (GraphicsPath gp = new GraphicsPath()) {
         gp.AddLines(pts_2f);
         using (PathGradientBrush pgb = new PathGradientBrush(gp)) {
             using (PathGradientBrush clone = (PathGradientBrush)pgb.Clone()) {
                 CheckPathDefaults(clone);
                 Assert.AreEqual(WrapMode.Clamp, clone.WrapMode, "WrapMode");
             }
         }
     }
 }
Exemplo n.º 2
0
        private void GenerateGradient()
        {
            if (radioButton1.Checked)
            {
                LinearGradientBrush lgb = new LinearGradientBrush(pictureBox1.ClientRectangle, Color.Black, Color.Black, 0f);
                ColorBlend          cb  = new ColorBlend();
                float max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;
                lgb.InterpolationColors    = cb;

                positions = cb.Positions;

                Graphics gp = pictureBox1.CreateGraphics();
                gp.FillRectangle(lgb, pictureBox1.ClientRectangle);
                gp.Dispose();

                finished = (LinearGradientBrush)lgb.Clone();

                lgb.Dispose();

                gtype = GradientType.Linear;
            }
            if (radioButton2.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddEllipse(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);
                pgb.CenterColor = gradientColorHolder1.Colors[0];

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                pgb.CenterPoint = CP1_init;

                positions = cb.Positions;

                pgb.InterpolationColors = cb;

                Graphics gn = pictureBox2.CreateGraphics();
                gn.Clear(SystemColors.Control);
                gn.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb.Clone();

                gn.Dispose();
                gp.Dispose();
                pgb.Dispose();
                gtype = GradientType.Circular;
            }
            if (radioButton3.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddRectangle(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);
                pgb.CenterColor = gradientColorHolder1.Colors[0];

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                pgb.CenterPoint = CP1_init;

                positions = cb.Positions;

                pgb.InterpolationColors = cb;

                Graphics gn = pictureBox2.CreateGraphics();
                gn.Clear(SystemColors.Control);
                gn.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb.Clone();

                gn.Dispose();
                gp.Dispose();
                pgb.Dispose();
                gtype = GradientType.Rectangular;
            }
        }