コード例 #1
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_gauge_customization, container, false);

            gauge = (RadRadialGaugeView)rootView.FindViewById(Resource.Id.radial_gauge);

            GaugeRadialScale scale = new GaugeRadialScale(Activity);

            scale.StartAngle  = 0;
            scale.SweepAngle  = 360;
            scale.LineVisible = false;
            scale.SetRange(0, 100);
            scale.TicksVisible  = false;
            scale.LabelsVisible = false;

            // >> gauges-indicators-bars
            int[] transparentColors = new int[] {
                Color.Argb(100, 224, 151, 36),
                Color.Argb(100, 196, 241, 57),
                Color.Argb(100, 132, 235, 247)
            };

            int[] colors = new int[] {
                Color.Argb(255, 224, 151, 36),
                Color.Argb(255, 196, 241, 57),
                Color.Argb(255, 132, 235, 247)
            };

            for (int i = 0; i < 3; i++)
            {
                GaugeRadialBarIndicator trnspIndicator = new GaugeRadialBarIndicator(Activity);
                trnspIndicator.Minimum   = 0;
                trnspIndicator.Maximum   = 100;
                trnspIndicator.FillColor = transparentColors[i];
                trnspIndicator.BarWidth  = 0.2f;
                trnspIndicator.Location  = 0.5f + i * 0.25f;
                scale.AddIndicator(trnspIndicator);

                GaugeRadialBarIndicator indicator = new GaugeRadialBarIndicator(Activity);
                indicator.Minimum = 0;
                Random r = new Random();
                indicator.Maximum           = r.Next(100);
                indicator.Animated          = true;
                indicator.AnimationDuration = 500;
                indicator.BarWidth          = 0.2f;
                indicator.Location          = 0.5f + i * 0.25f;
                indicator.FillColor         = colors[i];
                indicator.Cap = GaugeBarIndicatorCapMode.Round;
                scale.AddIndicator(indicator);
            }
            // << gauges-indicators-bars
            gauge.AddScale(scale);
            return(rootView);
        }
コード例 #2
0
        private void SetupGauge(RadGaugeView gauge)
        {
            gauge.Subtitle.Text          = "km/h";
            gauge.SubtitleVerticalOffset = 20;

            GaugeRadialScale scale = new GaugeRadialScale(Activity);

            scale.SetRange(0, 180);
            scale.Radius          = 0.98f;
            scale.LabelsCount     = 10;
            scale.MajorTicksCount = 19;
            scale.MinorTicksCount = 1;
            scale.LabelsOffset    = 0.15f;
            scale.TicksOffset     = 0;
            scale.MajorTicksStrokePaint.StrokeWidth = 2;
            scale.MajorTicksStrokeColor             = Color.Rgb(132, 132, 132);
            scale.LineVisible = false;
            gauge.AddScale(scale);

            // >> gauge-indicators-needle
            needle             = new GaugeRadialNeedle(Activity);
            needle.Length      = 0.8f;
            needle.BottomWidth = 8;
            needle.TopWidth    = 8;
            // << gauge-indicators-needle

            // >> gauge-animations-turn-on
            needle.Animated          = true;
            needle.AnimationDuration = 500;
            // << gauge-animations-turn-on

            // >> gauge-animations-timing-func
            needle.Interpolator = new AccelerateDecelerateInterpolator();
            // << gauge-animations-timing-func

            scale.AddIndicator(needle);

            scale.AddIndicator(GetIndicator(0, 60, Color.Rgb(132, 132, 132)));
            scale.AddIndicator(GetIndicator(61, 120, Color.Rgb(54, 54, 54)));
            scale.AddIndicator(GetIndicator(121, 180, Color.Rgb(198, 85, 90)));
        }
コード例 #3
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View rootView            = inflater.Inflate(Resource.Layout.fragment_gauge_scales, container, false);
            RadRadialGaugeView gauge = (RadRadialGaugeView)rootView.FindViewById(Resource.Id.radial_gauge);

            // >> radial-scale-instantiate
            GaugeRadialScale scale1 = new GaugeRadialScale(Activity);

            scale1.LineVisible = true;
            scale1.Minimum     = 34;
            scale1.Maximum     = 40;
            // << radial-scale-instantiate

            // >> radial-scale-config
            scale1.Radius      = 0.6f;
            scale1.StrokeWidth = 2;
            // << radial-scale-config

            // >> radial-scale-config-ticks-labels
            scale1.LabelsColor          = Color.Gray;
            scale1.LabelsCount          = 7;
            scale1.MajorTicksCount      = 7;
            scale1.LabelsPaint.TextSize = 30;
            scale1.TicksOffset          = 0;
            scale1.LabelsOffset         = 0.1f;
            // << radial-scale-config-ticks-labels

            // >> radial-scale-config2
            GaugeRadialScale scale2 = new GaugeRadialScale(Activity);

            scale2.LineVisible = true;
            scale2.StrokeWidth = 2;
            scale2.Radius      = 0.7f;
            scale2.SetRange(93.2f, 104);
            scale2.TicksLayoutMode      = GaugeScaleTicksLayoutMode.Outer;
            scale2.MajorTicksCount      = 7;
            scale2.MinorTicksCount      = 20;
            scale2.LabelsCount          = 7;
            scale2.LabelsLayoutMode     = GaugeScaleLabelsLayoutMode.Outer;
            scale2.LabelsPaint.TextSize = 30;
            scale2.LabelsColor          = Color.Gray;
            scale2.TicksOffset          = 0;
            scale2.LabelsOffset         = 0.1f;
            // << radial-scale-config2

            // >> add-scale-to-gauge
            gauge.AddScale(scale1);
            gauge.AddScale(scale2);
            // << add-scale-to-gauge

            // >> add-indicators-to-scale
            GaugeRadialNeedle needle = new GaugeRadialNeedle(Activity);

            needle.Value       = 36.5f;
            needle.Length      = 0.5f;
            needle.TopWidth    = 8;
            needle.BottomWidth = 8;
            scale1.AddIndicator(needle);
            scale1.AddIndicator(GetIndicator(34, 36, Color.Blue));
            scale1.AddIndicator(GetIndicator(36.05f, 40, Color.Red));
            // << add-indicators-to-scale

            // >> gauge-set-title
            gauge.Title.Text          = "celsius";
            gauge.Subtitle.Text       = "fahrenheit";
            gauge.TitleVerticalOffset = 90;
            // << gauge-set-title

            return(rootView);
        }