コード例 #1
0
        /// <summary>
        /// Initializes the activity using the given manifold.
        /// </summary>
        /// <returns>The from manifold.</returns>
        /// <param name="manifold">Manifold.</param>
        private void InitFromManifold(Manifold manifold)
        {
            if (!IsSensorValid(manifold.primarySensor))
            {
                Error(GetString(Resource.String.ptchart_error_invalid_manifold));
                SetResult(Result.Canceled);
                Finish();
                return;
            }

            switch (manifold.primarySensor.type)
            {
            case ESensorType.Pressure:
                _sensor      = manifold.primarySensor;
                pressureUnit = manifold.primarySensor.unit;
                if (manifold.secondarySensor?.type == ESensorType.Temperature)
                {
                    temperatureUnit = manifold.secondarySensor.unit;
                }
                else
                {
                    var sp = manifold.GetSensorPropertyOfType <PTChartSensorProperty>();
                    if (sp != null)
                    {
                        temperatureUnit = sp.unit;
                    }
                }
                break;

            case ESensorType.Temperature:
                _sensor         = manifold.primarySensor;
                temperatureUnit = manifold.primarySensor.unit;
                if (manifold.secondarySensor?.type == ESensorType.Pressure)
                {
                    pressureUnit = manifold.secondarySensor.unit;
                }
                else
                {
                    var sp = manifold.GetSensorPropertyOfType <PTChartSensorProperty>();
                    if (sp != null)
                    {
                        temperatureUnit = sp.unit;
                    }
                }
                break;
            }

            initialManifold = manifold;
            sensorLocked    = true;
        }
コード例 #2
0
        private void LoadManifold()
        {
            var mp = Intent.GetParcelableExtra(EXTRA_MANIFOLD) as ManifoldParcelable;

            if (mp == null)
            {
                // TODO [email protected]: Localize
                Error("US Manifold was not passed to activity");
                Finish();
                return;
            }

            manifold = mp.Get(ion);
            if (manifold == null)
            {
                // TODO [email protected]: Localize
                Error("US Manifold did not load from parcelable");
                Finish();
                return;
            }

            // Primary sensor
            var ps = manifold.primarySensor;

            text1.Text = ps.type.GetSensorTypeName() + " " + ps.name;

            // Secondary sensor
            if (manifold.secondarySensor != null)
            {
                var ss = manifold.secondarySensor;
                text2.Text = ss.type.GetSensorTypeName() + " " + ss.name;
            }
            else
            {
                content2.Visibility = ViewStates.Gone;
            }

            // Title
            var values   = Resources.GetStringArray(Resource.Array.preferences_device_trend_interval_values);
            var entries  = Resources.GetStringArray(Resource.Array.preferences_device_trend_interval_entries);
            var interval = ion.preferences.device.trendInterval;

            var index = -1;

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i].Equals((int)interval.TotalMilliseconds + ""))
                {
                    index = i;
                }
            }

            if (index == -1)
            {
                Log.E(this, "Failed to find text for interval: " + interval);
            }
            else
            {
                title.Text = string.Format(GetString(Resource.String.trend_update_1arg), entries[index]);
            }

            roc = manifold.GetSensorPropertyOfType <RateOfChangeSensorProperty>();
            if (roc == null)
            {
                Error("How did you get here if the manifold doesn't have a RateOfChangeSensorProperty");
                Finish();
                return;
            }

            rocManager = new RocWidgetManager(roc.manifold, plot, true);
            rocManager.Initialize();
        }