Exemplo n.º 1
0
        public static ColorBlend GetColorBlend(GradientStop[] gradientStops)
        {
            int        length     = gradientStops.Length;
            ColorBlend colorBlend = new ColorBlend();

            float[] numArray   = new float[length];
            Color[] colorArray = new Color[length];
            for (int index = 0; index < length; ++index)
            {
                GradientStop gradientStop = gradientStops[index];
                numArray[index]   = gradientStop.Position;
                colorArray[index] = gradientStop.Color;
            }
            colorBlend.Colors    = colorArray;
            colorBlend.Positions = numArray;
            return(colorBlend);
        }
Exemplo n.º 2
0
        protected virtual void FillOfficeGlassOuterBorder(
            RectangleF originalRectangle,
            Color color3,
            int borderThicness,
            bool fillEllipse)
        {
            GradientStop gradientStop1 = new GradientStop(this.ReduceAlphaBasedOnOriginal(100, color3), 0.0f);
            GradientStop gradientStop2 = new GradientStop(color3, 1f);

            using (RadBrush linearGradientBrush = this.CreateLinearGradientBrush(originalRectangle, new GradientStop[2] {
                gradientStop1, gradientStop2
            }, RadLinearGradientMode.Vertical))
            {
                if (fillEllipse)
                {
                    this.DrawEllipse(originalRectangle, linearGradientBrush, (float)borderThicness);
                }
                else
                {
                    this.DrawRectangle(originalRectangle, linearGradientBrush, (float)borderThicness);
                }
            }
        }
Exemplo n.º 3
0
        private void FillGel(
            Path path,
            GradientStop[] colorStops,
            float gradientPercentage,
            float gradientPercentage2)
        {
            if (colorStops.Length < 2)
            {
                this.FillSolid(path, colorStops[0].Color);
            }
            else
            {
                this.FillLinear(path, colorStops, 90f);
            }
            RectangleF bounds = path.GetBounds();
            float      num1   = bounds.Height / 2f;
            float      num2   = (float)(int)Math.Round(100.0 * (double)gradientPercentage * 0.2);
            float      num3   = (float)(int)Math.Round((double)num1 * (double)gradientPercentage2 * 0.2);
            RectangleF rect   = new RectangleF(bounds.X + num2, bounds.Y, (float)((double)bounds.Width - (double)num2 * 2.0 - 1.0), num1 - num3 * 2f);

            if (this.IsInvalidRectangle(rect))
            {
                return;
            }
            using (RoundedRectangle roundedRectangle = this.CreateRoundedRectangle(rect, rect.Height / 2f))
            {
                RectangleF   rectangle     = RectangleF.Inflate(rect, 1f, 1f);
                Color        color         = this.GetColor(Color.White);
                GradientStop gradientStop1 = new GradientStop(this.ReduceAlphaBasedOnOriginal(253, color), 0.0f);
                GradientStop gradientStop2 = new GradientStop(this.ReduceAlphaBasedOnOriginal(42, color), 1f);
                using (RadBrush linearGradientBrush = this.CreateLinearGradientBrush(rectangle, new GradientStop[2] {
                    gradientStop1, gradientStop2
                }, RadLinearGradientMode.Vertical))
                    this.FillRoundedRectangleCore(roundedRectangle, linearGradientBrush);
            }
        }
Exemplo n.º 4
0
        public GdiLinearGradientBrush(
            RectangleF rectangle,
            GradientStop[] gradientStops,
            RadLinearGradientMode mode)
        {
            if (mode == RadLinearGradientMode.None)
            {
                throw new NotSupportedException("The brush cannot be initialized with " + (object)mode);
            }
            this.mode          = mode;
            this.angle         = 0.0f;
            this.gradientStops = gradientStops;
            rectangle.Width    = Math.Max(1f, rectangle.Width);
            rectangle.Height   = Math.Max(1f, rectangle.Height);
            this.rawBrush      = new LinearGradientBrush(rectangle, Color.Black, Color.Black, (LinearGradientMode)this.mode);
            LinearGradientBrush rawBrush = this.rawBrush;

            GradientStop[] gradientStops1;
            if (gradientStops.Length == 1)
            {
                gradientStops1 = new GradientStop[2]
                {
                    new GradientStop(gradientStops[0].Color, 0.0f),
                    new GradientStop(gradientStops[0].Color, 1f)
                }
            }
            ;
            else
            {
                gradientStops1 = gradientStops;
            }
            ColorBlend colorBlend = GdiUtility.GetColorBlend(gradientStops1);

            rawBrush.InterpolationColors = colorBlend;
            this.rawBrush.WrapMode       = WrapMode.TileFlipXY;
        }