Ejemplo n.º 1
0
        /// <Docs>The integer request code originally supplied to
        ///  startActivityForResult(), allowing you to identify who this
        ///  result came from.</Docs>
        /// <param name="data">An Intent, which can return result data to the caller
        ///  (various data can be attached to Intent "extras").</param>
        /// <summary>
        /// Raises the activity result event.
        /// </summary>
        /// <param name="requestCode">Request code.</param>
        /// <param name="resultCode">Result code.</param>
        public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (Result.Ok != resultCode)
            {
                return;
            }

            var request = requestCode & MASK_REQUEST;

            switch (request)
            {
            case REQUEST_SHOW_SUPERHEAT_SUBCOOL: {
                var side = (Analyzer.ESide) unchecked ((requestCode & MASK_SIDE) >> 8);

                var manifold = analyzer.GetManifoldFromSide(side);

                if (analyzer.HasSensor(manifold.secondarySensor))
                {
                    // TODO [email protected]: Is this right?
                    Analyzer.ESide ss;
                    if (!analyzer.GetSideOfSensor(manifold.secondarySensor, out ss))
                    {
                        Appion.Commons.Util.Log.E(this, "Failed to get side of sensor");
                        return;
                    }

                    // The user returned from the SHSC activity with a sensor.
                    if (ss != side)
                    {
                        // The sensor that the user returned with is not on the side of the manifold.
                        if (analyzer.IsSideFull(side))
                        {
                            // We cannot swap the side of the sensor; the side is full.
                            L.E(this, "Tried to add sensor from opposite side to this side.");
                            Toast.MakeText(Activity, Resource.String.analyzer_error_failed_to_link_sensors, ToastLength.Long).Show();
                            manifold.SetSecondarySensor(null);
                        }
                        else
                        {
                            analyzer.SwapSensors(analyzer.IndexOfSensor(manifold.secondarySensor), analyzer.NextEmptySensorIndex(side), true);
                        }
                    }
                    else if (!analyzer.HasSensor(manifold.secondarySensor) && analyzer.IsSideFull(side))
                    {
                        Toast.MakeText(Activity, string.Format(GetString(Resource.String.analyzer_side_full_1sarg), side), ToastLength.Long).Show();
                        manifold.SetSecondarySensor(null);
                    }
                    else
                    {
                        if (!analyzer.IsSensorOnSide(manifold.secondarySensor, side))
                        {
                            var si = analyzer.IndexOfSensor(manifold.secondarySensor);
                            var di = analyzer.NextEmptySensorIndex(side);
//								analyzerView.SwapSensorMounts(di, si);
                            analyzer.SwapSensors(di, si, true);
                        }
                    }
                }
                else
                {
                    analyzer.AddSensorToSide(side, manifold.secondarySensor);
                }
            } break;

            case REQUEST_MANIFOLD_ON_SIDE: {
                Toast.MakeText(Activity, "DEVICE MANAGER WAS REMOVED! IMPLEMENT DEVICE SELECTION LIST", ToastLength.Short).Show();

/*
 *                                      var mside = (Analyzer.ESide)unchecked((requestCode & MASK_SIDE) >> 8);
 *        var msp = data.GetParcelableExtra(DeviceManagerActivity.EXTRA_SENSOR) as SensorParcelable;
 *        var s = msp.Get(ion);
 *
 *        TrySetManifold(mside, s);
 */
            } break;

            default:
                L.D(this, "Unknown request: " + request);
                break;
            }
        }