public static double RadialPointToValue(C1RadialGauge radialGauge, Point point) { Point center = new Point(radialGauge.PointerOrigin.X * radialGauge.RenderSize.Width, radialGauge.PointerOrigin.Y * radialGauge.RenderSize.Height); double angle = Mod360(Math.Atan2(point.X - center.X, center.Y - point.Y) * 180 / Math.PI); return(AngleToValue(radialGauge, angle)); }
static double LogicalToValue(C1RadialGauge radialGauge, double alpha) { if (alpha <= 0) { return(radialGauge.Minimum); } if (1 <= alpha) { return(radialGauge.Maximum); } double linearValue; if (!radialGauge.IsLogarithmic) { linearValue = alpha; } else { if (radialGauge.LogarithmicBase <= 1) { return(radialGauge.Minimum); } linearValue = (Math.Pow(radialGauge.LogarithmicBase, alpha) - 1) / (radialGauge.LogarithmicBase - 1); } return(radialGauge.Minimum + (radialGauge.Maximum - radialGauge.Minimum) * linearValue); }
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; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_automatic_scaling); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.automatic_scaling); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); // initialize required widgets mStartText = (TextView)FindViewById(Resource.Id.startAngleText); mSweepText = (TextView)FindViewById(Resource.Id.sweepAngleText); mRadialGauge = (C1RadialGauge)FindViewById(Resource.Id.radialGauge1); // setting default values mStartText.Text = mRadialGauge.StartAngle.ToString(); mSweepText.Text = mRadialGauge.SweepAngle.ToString(); mRadialGauge.Value = 60; mRadialGauge.Max = 200; mRadialGauge.ShowText = GaugeShowText.All; mRadialGauge.Step = 1; mRadialGauge.Animate(); mRadialGauge.AutoScale = true; // setting timer for auto scaling //timer.Elapsed += new System.Timers.ElapsedEventHandler(elapsedEventHandler); //timer.Enabled = true; //timer.AutoReset = true; //timer.Start(); minusButton = (Button)FindViewById(Resource.Id.buttonStartMinus); minusButton.Enabled = false; minusButton.Click += button_Click; plusButton = (Button)FindViewById(Resource.Id.buttonStartPlus); plusButton.Click += button_Click; minusSweepButton = (Button)FindViewById(Resource.Id.buttonSweepMinus); minusSweepButton.Click += button_Click; plusSweepButton = (Button)FindViewById(Resource.Id.buttonSweepPlus); plusSweepButton.Click += button_Click; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.activity_snapshot); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.snapshot); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); mRadialGauge = this.FindViewById <C1RadialGauge>(Resource.Id.radialGauge1); mRadialGauge.Enabled = false; mRadialGauge.Value = 25; mRadialGauge.Step = 1; mRadialGauge.Max = 100; mRadialGauge.Min = 1; mRadialGauge.ShowText = GaugeShowText.All; }
static double AngleToLogical(C1RadialGauge radialGauge, double angle) { var relativeAngle = Mod360(angle - radialGauge.StartAngle); var absSweepAngle = radialGauge.SweepAngle; if (absSweepAngle == 0 || relativeAngle == 0) { return(0); } if (absSweepAngle < 0) { relativeAngle = 360 - relativeAngle; absSweepAngle = -absSweepAngle; } var overflow = relativeAngle - absSweepAngle; if (overflow > 0) { var underflow = 360 - relativeAngle; return(overflow < underflow ? 1 : 0); } return(relativeAngle / absSweepAngle); }
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; }
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; }
static double AngleToValue(C1RadialGauge radialGauge, double angle) { double alpha = AngleToLogical(radialGauge, angle); return(LogicalToValue(radialGauge, alpha)); }