private void AddCustomOptions(ListDialogBuilder adb)
 {
     foreach (var option in builder.customOptions)
     {
         adb.AddItem(option.title, option.action);
     }
 }
 private void AddAlarmOptions(ListDialogBuilder adb)
 {
     if (builder.showAlarmsOptions)
     {
         adb.AddItem(Resource.String.alarm, () => {
             Toast.MakeText(builder.context, "Showing alarms is fun", ToastLength.Long).Show();
         });
     }
 }
 private void AddSubviewOptions(ListDialogBuilder adb)
 {
     if (builder.showSubviewOptions)
     {
         adb.AddItem(Resource.String.manifold_calculation_subviews, () => {
             ShowSubviewDialog();
         });
     }
 }
Example #4
0
        public ManualSensorCreateDialog(Context context, Dictionary <ESensorType, IEnumerable <Unit> > options)
        {
            this.context = context;
            this.options = options;

            try {
                if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
                {
                    content = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_manual_sensor_create_4_4, null, false);
                }
                else
                {
                    content = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_manual_sensor_create, null, false);
                }
            } catch (Exception e) {
                Log.E(this, "Failed to set layout. Defaulting to old version", e);
                content = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_manual_sensor_create_4_4, null, false);
            }

            name        = content.FindViewById <EditText>(Resource.Id.name);
            measurement = content.FindViewById <EditText>(Resource.Id.measurement);

            type = content.FindViewById <Button>(Resource.Id.type);
            unit = content.FindViewById <Button>(Resource.Id.unit);

            sensorType = options.Keys.First();
            sensorUnit = options[sensorType].First();
            type.Text  = sensorType.GetTypeString();
            unit.Text  = sensorUnit.ToString();

            type.Click += (sensor, obj) => {
                var dialog = new ListDialogBuilder(context);
                dialog.SetTitle(Resource.String.sensor_select_type);

                foreach (var t in options.Keys)
                {
                    dialog.AddItem(t.GetTypeString(), () => {
                        sensorType = t;
                        type.Text  = t.GetTypeString();

                        sensorUnit = options[sensorType].First();
                        unit.Text  = sensorUnit.ToString();
                    });
                }

                dialog.Show();
            };

            unit.Click += (sender, e) => {
                UnitDialog.Create(context, options[sensorType], (s1, e1) => {
                    sensorUnit = e1;
                    unit.Text  = sensorUnit.ToString();
                }).Show();
            };
        }
 private void AddConnectOptions(ListDialogBuilder adb)
 {
     if (builder.showConnectOptions)
     {
         var gds = manifold.primarySensor as GaugeDeviceSensor;
         if (gds != null)
         {
             if (gds.device.connection.connectionState == EConnectionState.Disconnected)
             {
                 adb.AddItem(Resource.String.reconnect, () => {
                     gds.device.connection.Connect();
                 });
             }
             else
             {
                 adb.AddItem(Resource.String.disconnect, () => {
                     gds.device.connection.Disconnect();
                 });
             }
         }
     }
 }
Example #6
0
        public void Show()
        {
            var adb = new ListDialogBuilder(_context);

            adb.SetTitle(Resource.String.select_a_sensor);
            foreach (var sensor in _sensors)
            {
                adb.AddItem(string.Format("{0}: {1}", sensor.device.serialNumber.deviceModel.GetTypeString(), sensor.type.GetSensorTypeName()), () => {
                    _onSensorSelected(sensor);
                });
            }
//      adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { });
//      adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { });

            adb.Show();
        }
        public Android.App.Dialog Show()
        {
            var r = context.Resources;

            var view  = LayoutInflater.From(context).Inflate(Resource.Layout.analyzer_dialog_viewer, null);
            var state = view.FindViewById <TextView>(Resource.Id.state);

            switch (side)
            {
            case Analyzer.ESide.High:
                state.SetText(Resource.String.analyzer_side_high);
                state.SetBackgroundColor(Resource.Color.red.AsResourceColor(context));
                state.SetTextColor(Resource.Color.white.AsResourceColor(context));
                break;

            case Analyzer.ESide.Low:
                state.SetText(Resource.String.analyzer_side_low);
                state.SetBackgroundColor(Resource.Color.blue.AsResourceColor(context));
                state.SetTextColor(Resource.Color.white.AsResourceColor(context));
                break;

            default:
                state.SetText(Resource.String.analyzer_side_none);
                state.SetBackgroundColor(Resource.Color.white.AsResourceColor(context));
                state.SetTextColor(Resource.Color.black.AsResourceColor(context));
                break;
            }

            var template = new ManifoldViewTemplate(view, cache);

            template.Bind(new Manifold(sensor));

            var adb = new IONAlertDialog(context);

            adb.SetTitle(sensor.name);
            adb.SetView(view);

            adb.SetNegativeButton(Resource.String.cancel, (obj, which) => {
                var d = obj as Android.App.Dialog;
                d.Dismiss();
                cache.Clear();
            });

            if (analyzer.isEditable)
            {
                adb.SetPositiveButton(Resource.String.actions, (sender, e) => {
                    var ldb = new ListDialogBuilder(context);
                    ldb.SetTitle(string.Format(context.GetString(Resource.String.devices_actions_1arg), sensor.name));

                    var dgs = sensor as GaugeDeviceSensor;

                    if (dgs != null && !dgs.device.isConnected)
                    {
                        ldb.AddItem(Resource.String.reconnect, () => {
                            dgs.device.connection.Connect();
                        });
                    }

                    ldb.AddItem(Resource.String.rename, () => {
                        if (sensor is GaugeDeviceSensor)
                        {
                            var gds = sensor as GaugeDeviceSensor;
                            new RenameDialog(gds.device).Show(context);
                        }
                        else
                        {
                            new RenameDialog(sensor).Show(context);
                        }
                    });

                    ldb.AddItem(Resource.String.alarm, () => {
                        var i = new Intent(context, typeof(SensorAlarmActivity));
                        i.PutExtra(SensorAlarmActivity.EXTRA_SENSOR, sensor.ToParcelable());
                        context.StartActivity(i);
                    });

                    if (dgs != null && dgs.device.isConnected)
                    {
                        ldb.AddItem(Resource.String.disconnect, () => {
                            dgs.device.connection.Disconnect();
                        });
                    }

                    ldb.AddItem(Resource.String.remove, () => {
                        analyzer.RemoveSensor(sensor);
                    });

                    ldb.Show();
                    cache.Clear();
                });
            }

            return(adb.Show());
        }
        private void ShowSubviewDialog()
        {
            Func <int, int, string> format = delegate(int full, int abrv) {
                return(context.GetString(full) + " (" + context.GetString(abrv) + ")");
            };

            var ldb = new ListDialogBuilder(context);

            ldb.SetTitle(context.GetString(Resource.String.manifold_add_subview));
            ldb.SetTitle(Resource.String.pick_unit);

            if ((manifold.primarySensor.type == ESensorType.Pressure ||
                 manifold.primarySensor.type == ESensorType.Temperature) && manifold.secondarySensor != null)
            {
                if (!manifold.HasSensorPropertyOfType(typeof(SecondarySensorProperty)))
                {
                    var t    = manifold.secondarySensor.type;
                    var type = t.GetTypeString();
                    var abrv = t.GetTypeAbreviationString();
                    ldb.AddItem(String.Format(context.GetString(Resource.String.workbench_linked_sensor_2sarg), type, abrv), () => {
                        manifold.AddSensorProperty(new SecondarySensorProperty(manifold));
                    });
                }
            }

            if (!manifold.HasSensorPropertyOfType(typeof(AlternateUnitSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_alt, Resource.String.workbench_alt_abrv), () => {
                    manifold.AddSensorProperty(new AlternateUnitSensorProperty(manifold));
                });
            }

            if (!manifold.HasSensorPropertyOfType(typeof(RateOfChangeSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_roc, Resource.String.workbench_roc_abrv), () => {
                    manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, builder.ion.preferences.device.trendInterval));
                });
            }

            if (!manifold.HasSensorPropertyOfType(typeof(MinSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_min, Resource.String.workbench_min_abrv), () => {
                    manifold.AddSensorProperty(new MinSensorProperty(manifold));
                });
            }

            if (!manifold.HasSensorPropertyOfType(typeof(MaxSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_max, Resource.String.workbench_max_abrv), () => {
                    manifold.AddSensorProperty(new MaxSensorProperty(manifold));
                });
            }

            if (!manifold.HasSensorPropertyOfType(typeof(HoldSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_hold, Resource.String.workbench_hold_abrv), () => {
                    manifold.AddSensorProperty(new HoldSensorProperty(manifold));
                });
            }

            if (!manifold.HasSensorPropertyOfType(typeof(TimerSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_timer, Resource.String.workbench_timer_abrv), () => {
                    manifold.AddSensorProperty(new TimerSensorProperty(manifold));
                });
            }

            if (ESensorType.Pressure == manifold.primarySensor.type || ESensorType.Temperature == manifold.primarySensor.type)
            {
                if (!manifold.HasSensorPropertyOfType(typeof(PTChartSensorProperty)))
                {
                    ldb.AddItem(format(Resource.String.workbench_ptchart, Resource.String.fluid_pt_abrv), () => {
                        manifold.AddSensorProperty(new PTChartSensorProperty(manifold));
                    });
                }

                if (!manifold.HasSensorPropertyOfType(typeof(SuperheatSubcoolSensorProperty)))
                {
                    ldb.AddItem(format(Resource.String.workbench_shsc, Resource.String.workbench_shsc_abrv), () => {
                        manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold));
                    });
                }
            }

            ldb.AddItem(Resource.String.workbench_add_all, () => {
                AddAllSubviews();
            });

            ldb.Show();
        }