Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_gauge_getting_started, container, false);

            // >> radial-gauge-load
            RadRadialGaugeView gauge = (RadRadialGaugeView)rootView.FindViewById(Resource.Id.radial_gauge);
            // << radial-gauge-load

            // >> radial-scale-setup
            GaugeRadialScale scale = new GaugeRadialScale(this.Context);

            scale.Minimum         = 0;
            scale.Maximum         = 6;
            scale.MajorTicksCount = 7;
            scale.MinorTicksCount = 9;
            scale.LabelsCount     = 7;
            scale.LineVisible     = false;
            scale.Radius          = 0.95f;
            scale.TicksOffset     = 0;
            // << radial-scale-setup

            // >> radial-indicators-setup
            int[] colors = new int[] {
                Color.Rgb(221, 221, 221),
                Color.Rgb(157, 202, 86),
                Color.Rgb(240, 196, 77),
                Color.Rgb(226, 118, 51),
                Color.Rgb(167, 1, 14)
            };

            float rangeWidth = scale.Maximum / colors.Length;
            float start      = 0;

            foreach (var color in colors)
            {
                GaugeRadialBarIndicator indicator = new GaugeRadialBarIndicator(this.Context);
                indicator.Minimum   = start;
                indicator.Maximum   = start + rangeWidth;
                indicator.FillColor = color;
                scale.AddIndicator(indicator);
                start += rangeWidth;
            }

            GaugeRadialNeedle needle = new GaugeRadialNeedle(this.Context);

            needle.Value = 2;
            scale.AddIndicator(needle);
            // << radial-indicators-setup

            // >> add-radial-scale
            gauge.AddScale(scale);
            // << add-radial-scale

            return(rootView);
        }
Esempio n. 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)));
        }
Esempio n. 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);
        }