Beispiel #1
0
 public static double LinearPointToValue(C1LinearGauge linearGauge, Point point)
 {
     if (linearGauge.Orientation.Equals(Orientation.Horizontal))
     {
         double min = linearGauge.ActualWidth * linearGauge.XAxisLocation;
         double max = linearGauge.ActualWidth * (1 - linearGauge.XAxisLocation);
         if (point.X <= min)
         {
             return(0);
         }
         if (point.X >= max)
         {
             return(100);
         }
         double maxvalue = linearGauge.ActualWidth * linearGauge.XAxisLength;
         double locatX   = point.X - min;
         return(locatX / maxvalue * 100);
     }
     else
     {
         if (point.Y < 0)
         {
             return(0);
         }
         if (point.Y > linearGauge.ActualHeight)
         {
             return(100);
         }
         return(point.Y / linearGauge.ActualHeight * 100);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_using_ranges);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.using_ranges);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mSwitchRange = (Switch)FindViewById(Resource.Id.switchRange);
            mLinearGauge = (C1LinearGauge)FindViewById(Resource.Id.linearGauge1);
            mRadialGauge = (C1RadialGauge)FindViewById(Resource.Id.radialGauge1);
            mValueText   = (TextView)FindViewById(Resource.Id.valueText);

            // setting dafault values
            mValueText.Text = mVal.ToString();

            setRange(0, 40, Color.ParseColor("#22B14C"));
            setRange(40, 80, Color.ParseColor("#FF8080"));
            setRange(80, 100, Color.ParseColor("#EEE04A"));

            //mRadialGauge.Ranges = mRanges;
            //mLinearGauge.Ranges = mRanges;

            mRadialGauge.ShowRanges = false;
            mLinearGauge.ShowRanges = false;

            mLinearGauge.Value    = mVal;
            mLinearGauge.Min      = mMin;
            mLinearGauge.Max      = mMax;
            mLinearGauge.Step     = 1;
            mLinearGauge.ShowText = GaugeShowText.None;
            //mLinearGauge.GaugeWidth = .5f;

            mRadialGauge.Value    = mVal;
            mRadialGauge.Min      = mMin;
            mRadialGauge.Max      = mMax;
            mRadialGauge.Step     = 1;
            mRadialGauge.ShowText = GaugeShowText.None;
            //mRadialGauge.GaugeWidth = .5f;

            mSwitchRange.CheckedChange += mSwitchRange_CheckedChange;

            Button minusButton = (Button)FindViewById(Resource.Id.buttonMinus);

            minusButton.Click += button_Click;
            Button plusButton = (Button)FindViewById(Resource.Id.buttonPlus);

            plusButton.Click += button_Click;

            mLinearGauge.ValueChanged += OnValueChanged;
            mRadialGauge.ValueChanged += OnValueChanged;
        }
Beispiel #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_direction);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.direction);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mBulletGraph      = (C1BulletGraph)FindViewById(Resource.Id.bulletGraph1);
            mLinearGauge      = (C1LinearGauge)FindViewById(Resource.Id.linearGauge1);
            mDirectionSpinner = (Spinner)FindViewById(Resource.Id.directionSpinner);
            mLayout           = (LinearLayout)FindViewById(Resource.Id.layout1);

            // creating and initializing adapter to string array
            ArrayAdapter adapter1 = ArrayAdapter.CreateFromResource(this, Resource.Array.directionSpinnerValues, Android.Resource.Layout.SimpleSpinnerItem);

            // Specify the layout to use when the list of choices appears
            adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            mDirectionSpinner.Adapter       = adapter1;
            mDirectionSpinner.ItemSelected += mDirectionSpinner_ItemSelected;

            // setting dafault values
            mBulletGraph.Value    = 40;
            mBulletGraph.Bad      = 45;
            mBulletGraph.Good     = 80;
            mBulletGraph.Max      = 100;
            mBulletGraph.Target   = 90;
            mBulletGraph.Step     = 1;
            mBulletGraph.ShowText = GaugeShowText.All;
            //mBulletGraph.GaugeWidth = .5f;

            mLinearGauge.Value    = 40;
            mLinearGauge.Min      = 0;
            mLinearGauge.Max      = 100;
            mLinearGauge.ShowText = GaugeShowText.All;
            //mLinearGauge.GaugeWidth = .5f;
        }
Beispiel #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_getting_started);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.getting_started);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mRadialGauge = (C1RadialGauge)FindViewById(Resource.Id.radialGauge1);
            mLinearGauge = (C1LinearGauge)FindViewById(Resource.Id.linearGauge1);
            mBulletGraph = (C1BulletGraph)FindViewById(Resource.Id.bulletGraph1);
            mValueText   = (TextView)FindViewById(Resource.Id.valueText);

            // setting dafault values
            mValueText.Text         = mValue.ToString();
            mBulletGraph.Enabled    = true;
            mBulletGraph.Value      = mValue;
            mBulletGraph.Bad        = 45;
            mBulletGraph.Good       = 80;
            mBulletGraph.Min        = mMin;
            mBulletGraph.Max        = mMax;
            mBulletGraph.Target     = 90;
            mBulletGraph.ShowText   = GaugeShowText.All;
            mBulletGraph.Step       = 1;
            mBulletGraph.IsReadOnly = false;
            mBulletGraph.IsAnimated = true;

            mLinearGauge.Enabled    = true;
            mLinearGauge.Value      = mValue;
            mLinearGauge.Min        = mMin;
            mLinearGauge.Max        = mMax;
            mLinearGauge.Step       = 1;
            mLinearGauge.ShowText   = GaugeShowText.All;
            mLinearGauge.IsReadOnly = false;
            mLinearGauge.IsAnimated = true;

            mRadialGauge.Enabled    = true;
            mRadialGauge.Value      = mValue;
            mRadialGauge.Min        = mMin;
            mRadialGauge.Max        = mMax;
            mRadialGauge.Step       = 1;
            mRadialGauge.ShowText   = GaugeShowText.All;
            mRadialGauge.IsReadOnly = false;
            mRadialGauge.IsAnimated = true;

            Button minusButton = (Button)FindViewById(Resource.Id.buttonValueMinus);

            minusButton.Click += button_Click;
            Button plusButton = (Button)FindViewById(Resource.Id.buttonValuePlus);

            plusButton.Click += button_Click;

            mLinearGauge.ValueChanged += OnValueChanged;
            mRadialGauge.ValueChanged += OnValueChanged;
            mBulletGraph.ValueChanged += OnValueChanged;
        }
Beispiel #5
0
        private void CreateGauges()
        {
            c1Gauge1.Gauges.ClearAndDispose();
            if (_source == null || _source.Count == 0)
            {
                return;
            }
            var unitConv  = new UnitConverter();
            var colorConv = new BarColorConverter();
            var badConv   = new BadValueConverter();
            var goodConv  = new GoodValueConverter();
            int mul       = c1Gauge1.Height / 5;

            for (int i = 0; i < _source.Count; i++)
            {
                SaleGoalItem  item     = _source[i];
                var           goal     = (double)unitConv.Convert(item.Goal, null, null, null);
                var           sale     = (double)unitConv.Convert(item.Sales, null, null, null);
                var           color    = (Color)colorConv.Convert(item.CompletePrecent, null, null, null);
                var           badGoal  = (double)badConv.Convert(item.Goal, null, null, null);
                var           goodGoal = (double)goodConv.Convert(item.Goal, null, null, null);
                C1LinearGauge g        = new C1LinearGauge();
                g.Maximum         = 100;
                g.Viewport.Y      = i * mul;
                g.Viewport.X      = 80;
                g.Viewport.Height = mul;
                g.Pointer.Visible = false;
                var d = new C1GaugeRange()
                {
                    To = sale, Width = mul, Filling = new C1GaugeFilling()
                    {
                        Color = color
                    }
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                var width = mul * 2;
                d = new C1GaugeRange()
                {
                    To = badGoal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.FromArgb(0x4C000000)
                    }, Width = width
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                d = new C1GaugeRange()
                {
                    To = goodGoal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.FromArgb(0x26000000)
                    }, Width = width
                };
                d.Border.LineStyle = C1GaugeBorderStyle.None;
                g.Decorators.Add(d);
                g.Decorators.Add(new C1GaugeRange()
                {
                    From = goal - 0.2, To = goal, Filling = new C1GaugeFilling()
                    {
                        Color = Color.Black
                    }, Width = width
                });

                g.FaceShapes.Add(new C1GaugeCaption()
                {
                    Text = item.Name, CenterPointX = -68.0 / Width
                });
                c1Gauge1.Gauges.Add(g);
            }
            var gauge = c1Gauge1.Gauges[_source.Count - 1];
            var marks = new C1GaugeMarks()
            {
                From = 0, To = 100, Interval = 20, Location = mul * 2 + 40, Shape = C1GaugeMarkShape.Round
            };

            gauge.Decorators.Add(marks);
            var labels = new C1GaugeLabels()
            {
                From = 0, To = 100, Interval = 20, Location = mul * 2 + 90
            };

            gauge.Decorators.Add(labels);
        }
Beispiel #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_displaying_values);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.displaying_values);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mLinearGauge     = (C1LinearGauge)FindViewById(Resource.Id.linearGauge1);
            mRadialGauge     = (C1RadialGauge)FindViewById(Resource.Id.radialGauge1);
            mShowTextSpinner = (Spinner)FindViewById(Resource.Id.showTextSpinner);
            mValueText       = (TextView)FindViewById(Resource.Id.valueText);

            // creating and initializing adapter to string array
            ArrayAdapter adapter1 = ArrayAdapter.CreateFromResource(this, Resource.Array.showTextSpinnerValues, Android.Resource.Layout.SimpleSpinnerItem);

            // Specify the layout to use when the list of choices appears
            adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            mShowTextSpinner.Adapter       = adapter1;
            mShowTextSpinner.ItemSelected += mShowTextSpinner_ItemSelected;

            // setting dafault values
            mValueText.Text = ((int)(mValue * 100)).ToString();

            mLinearGauge.ShowText = GaugeShowText.All;
            mRadialGauge.ShowText = GaugeShowText.All;

            setRange(0, 40, -65536);
            setRange(40, 80, -256);
            setRange(80, 100, -16711936);

            mLinearGauge.Min  = 0;
            mLinearGauge.Max  = 1;
            mLinearGauge.Step = .01f;
            // mLinearGauge.Ranges = mRanges;
            mLinearGauge.ShowRanges = false;
            mLinearGauge.ShowText   = GaugeShowText.All;
            //mLinearGauge.GaugeWidth = .5f;
            mLinearGauge.Animate();
            mLinearGauge.Format = "0%";
            mLinearGauge.Value  = mValue;

            mRadialGauge.Min  = 0;
            mRadialGauge.Max  = 1;
            mRadialGauge.Step = .01f;
            //mRadialGauge.Ranges = mRanges;
            mRadialGauge.ShowRanges = false;
            mRadialGauge.ShowText   = GaugeShowText.All;
            //mRadialGauge.GaugeWidth = .5f;
            mRadialGauge.Animate();
            mRadialGauge.Format = "0%";
            mRadialGauge.Value  = mValue;

            Button minusButton = (Button)FindViewById(Resource.Id.buttonMinus);

            minusButton.Click += button_Click;
            Button plusButton = (Button)FindViewById(Resource.Id.buttonPlus);

            plusButton.Click += button_Click;

            mLinearGauge.ValueChanged += OnValueChanged;
            mRadialGauge.ValueChanged += OnValueChanged;
        }