コード例 #1
0
ファイル: BrushFactory.cs プロジェクト: RichardHaggard/BDC
        public Brush CreateGradientBrush(RadialGaugeArc owner)
        {
            float num = (float)owner.OutherRadiusPercentage;

            if ((double)num == 0.0)
            {
                num = (float)(owner.Owner.LabelRadius - owner.Owner.LabelGap);
            }
            switch (owner.NumberOfColors)
            {
            case 1:
                return((Brush) new SolidBrush(owner.BackColor));

            case 2:
                return((Brush) new GdiRadialGradientBrush(owner.Owner.GaugeCenter, num, num, new GradientStop[4] {
                    new GradientStop(owner.BackColor, 0.0f), new GradientStop(owner.BackColor2, owner.GradientPercentage), new GradientStop(owner.BackColor, owner.GradientPercentage2), new GradientStop(owner.BackColor, 1f)
                }).RawBrush);

            case 3:
                return((Brush) new GdiRadialGradientBrush(owner.Owner.GaugeCenter, num, num, new GradientStop[4] {
                    new GradientStop(owner.BackColor, 0.0f), new GradientStop(owner.BackColor2, owner.GradientPercentage), new GradientStop(owner.BackColor3, owner.GradientPercentage2), new GradientStop(owner.BackColor2, 1f)
                }).RawBrush);

            case 4:
                return((Brush) new GdiRadialGradientBrush(owner.Owner.GaugeCenter, num, num, new GradientStop[4] {
                    new GradientStop(owner.BackColor, 0.0f), new GradientStop(owner.BackColor2, owner.GradientPercentage), new GradientStop(owner.BackColor3, owner.GradientPercentage2), new GradientStop(owner.BackColor3, 1f)
                }).RawBrush);

            default:
                return((Brush) new SolidBrush(owner.BackColor));
            }
        }
コード例 #2
0
ファイル: BrushFactory.cs プロジェクト: RichardHaggard/BDC
        public Brush CreateBrush(GaugeVisualElement owner, GaugeBrushType type)
        {
            RadialGaugeArc owner1 = owner as RadialGaugeArc;

            if (owner1 == null)
            {
                return((Brush)null);
            }
            switch (type)
            {
            case GaugeBrushType.Rainbow:
                return(this.CreateRainbowBrush(owner1));

            case GaugeBrushType.Rainbow2:
                return(this.CreateRainbow2Brush(owner1));

            case GaugeBrushType.Rainbow3:
                return(this.CreateRainbow3Brush(owner1));

            case GaugeBrushType.Gradient:
                return(this.CreateGradientBrush(owner1));

            default:
                return(this.CreateRainbowBrush(owner1));
            }
        }
コード例 #3
0
ファイル: BrushFactory.cs プロジェクト: RichardHaggard/BDC
        public Brush CreateRainbow2Brush(RadialGaugeArc owner)
        {
            float         num        = (float)(owner.Owner.LabelRadius - owner.Owner.LabelGap);
            List <PointF> pointFList = new List <PointF>(0);
            PointF        pointF1    = new PointF(num + 10f, 0.0f);

            for (float startAngle = (float)owner.startAngle; (double)startAngle < owner.endAngle; ++startAngle)
            {
                Matrix matrix = new Matrix();
                matrix.Rotate(startAngle);
                PointF[] pts = new PointF[1] {
                    pointF1
                };
                matrix.TransformPoints(pts);
                PointF pointF2 = new PointF(owner.Owner.GaugeCenter.X + pts[0].X, owner.Owner.GaugeCenter.Y + pts[0].Y);
                pointFList.Add(pointF2);
            }
            PathGradientBrush pathGradientBrush = new PathGradientBrush(pointFList.ToArray());

            pathGradientBrush.CenterColor = Color.Transparent;
            pathGradientBrush.CenterPoint = owner.Owner.GaugeCenter;
            Color[] baseColors = new Color[4] {
                Color.Green, Color.Yellow, Color.Red, Color.Magenta
            };
            double[] colorFactors = new double[4] {
                0.0, 0.5, 0.9, 1.0
            };
            Color[] colorArray = new Color[pointFList.Count];
            for (int index = 0; index < pointFList.Count; ++index)
            {
                Color color = BrushFactory.GetColor(Math.Abs(Math.Atan2((double)pointFList[index].Y - (double)owner.Owner.GaugeCenter.Y, (double)pointFList[index].X - (double)owner.Owner.GaugeCenter.X)) / Math.PI, baseColors, colorFactors);
                colorArray[index] = color;
            }
            pathGradientBrush.SurroundColors = colorArray;
            return((Brush)pathGradientBrush);
        }