Esempio n. 1
0
        /// <summary>
        /// Shows a dialog that will add a sensor to a manifold of the given side.
        /// </summary>
        /// <param name="analyzer">Analyzer.</param>
        /// <param name="index">Index.</param>
        private void ShowAddFromDialog(Analyzer analyzer, Analyzer.ESide side)
        {
            var ldb = new ListDialogBuilder(Activity);

            ldb.SetTitle(Resource.String.analyzer_add_from);
            ldb.AddItem(Resource.String.device_manager, () => {
                Toast.MakeText(Activity, "DEVICE MANAGER WAS REMOVED! IMPLEMENT DEVICE SELECTION LIST", ToastLength.Short).Show();

/*
 *                              var i = new Intent(Activity, typeof(DeviceManagerActivity));
 *                              i.SetAction(Intent.ActionPick);
 *                              StartActivityForResult(i, EncodeManifoldSideRequest(side));
 */
            });
            ldb.AddItem(Resource.String.sensor_create_manual_entry, () => {
                if (analyzer.IsSideFull(side))
                {
                    Toast.MakeText(Activity, string.Format(GetString(Resource.String.analyzer_cannot_set_manifold_side_full_1sarg), side.ToLocalizedString(Activity)), ToastLength.Long).Show();
                }
                else
                {
                    var d = new ManualSensorCreateDialog(Activity, SensorUtils.GetSensorTypeUnitMapping()).Show((sensor) => {
                        analyzer.PutSensor(analyzer.NextEmptySensorIndex(side), sensor, false);
                        analyzer.SetManifold(side, sensor);
                    });
                }
            });
            ldb.Show();
        }
Esempio n. 2
0
        private void ShowJobContextDialog(ReportJobHeaderRecord job)
        {
            var dialog = new ListDialogBuilder(Activity);

            dialog.SetTitle(Resource.String.report_job_details);
            dialog.AddItem(Resource.String.report_delete_sessions, () => {
                RequestDeleteSessions(job.sessions);
            });
            dialog.AddItem(Resource.String.report_check_all, () => {
                adapter.SetCheckStatus(job.sessions, true);
            });
            dialog.AddItem(Resource.String.report_uncheck_all, () => {
                adapter.SetCheckStatus(job.sessions, false);
            });
            dialog.Show();
        }
		private void ShowChangeUnitDialog(GaugeDeviceSensor sensor) {
			var ldb = new ListDialogBuilder(Activity);
			ldb.SetTitle(Resource.String.pick_unit);

			foreach (var unit in sensor.supportedUnits) {
				if (!unit.Equals(sensor.unit)) {
					ldb.AddItem(unit.ToString(), () => {
						var device = sensor.device;
						var p = device.protocol as IGaugeProtocol;
						device.connection.Write(p.CreateSetUnitCommand(device.IndexOfSensor(sensor) + 1, sensor.type, unit));
					});
				}
			}

			ldb.Show();
		}
Esempio n. 4
0
        /// <summary>
        /// Shows a dialog that will add a sensor to a sensor mount.
        /// </summary>
        /// <param name="analyzer">Analyzer.</param>
        /// <param name="index">Index.</param>
        private void ShowAddFromDialog(Analyzer analyzer, int index)
        {
            var ldb = new ListDialogBuilder(Activity);

            ldb.SetTitle(Resource.String.analyzer_add_from);
            ldb.AddItem(Resource.String.device_manager, () => {
                Toast.MakeText(Activity, "DEVICE MANAGER WAS REMOVED! IMPLEMENT DEVICE SELECTION LIST", ToastLength.Short).Show();

/*
 *                  var i = new Intent(Activity, typeof(DeviceManagerActivity));
 *      i.SetAction(Intent.ActionPick);
 *      StartActivityForResult(i, EncodeSensorMountRequest(index));
 */
            });
            ldb.AddItem(Resource.String.sensor_create_manual_entry, () => {
                var d = new ManualSensorCreateDialog(Activity, SensorUtils.GetSensorTypeUnitMapping()).Show((sensor) => {
                    analyzer.PutSensor(index, sensor, false);
                });
            });
            ldb.Show();
        }
        private static void TestDialogFlow2(BasePlayer sender)
        {
            sender.SendClientMessage("Test dialog flow started");
            var dialog = new DialogFlow(false)
                         .AddDialog(ListDialogBuilder.Create()
                                    .WithCaption("Dialog 1")
                                    .WithMessage("Pierwszy dialog")
                                    .WithLeftButton("Dalej")
                                    .WithRightButton("Wyjdź")
                                    .Continue()
                                    .WithRow("Pierwsza opcja")
                                    .WithRow("Druga opcja")
                                    .WithRow("Trzecia opocja")
                                    .Build())
                         .AddDialog(InputDialogBuilder.Create()
                                    .WithCaption("Dialog 2")
                                    .WithMessage("Dialog drugi")
                                    .WithLeftButton("Dalej")
                                    .WithRightButton("Cofnij")
                                    .Continue().PasswordStyle()
                                    .Build())
                         .AddDialog(MessageDialogBuilder.Create()
                                    .WithCaption("Dialog 3")
                                    .WithMessage("Trzeci dialog")
                                    .WithLeftButton("Gotowe")
                                    .WithRightButton("Cofnij")
                                    .Build())
                         .End((o, args) =>
            {
                foreach (var arg in args)
                {
                    sender.SendClientMessage(
                        $"Output {arg.Key}: input: {arg.Value.InputText} | listitem: {arg.Value.ListItem}");
                }
            });

            dialog.Show(sender);
        }
Esempio n. 6
0
        /// <summary>
        /// Shows the add subview dialog.
        /// </summary>
        /// <param name="manifold">Manifold.</param>
        private void ShowAddSubviewDialog(Manifold manifold)
        {
            Func <int, int, string> format = delegate(int full, int abrv) {
                return(GetString(full) + " (" + GetString(abrv) + ")");
            };

            var ldb = new ListDialogBuilder(Activity);

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

            if (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(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.primarySensor is ManualSensor) && !manifold.HasSensorPropertyOfType(typeof(RateOfChangeSensorProperty)))
            {
                ldb.AddItem(format(Resource.String.workbench_roc, Resource.String.workbench_roc_abrv), () => {
                    manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, 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(manifold);
            });

            ldb.Show();
        }
Esempio n. 7
0
        /// <summary>
        /// Shows a context dialog for a manifold. This will present all the options that are available for
        /// the manifold.
        /// </summary>
        private void ShowManifoldContextDialog(Manifold manifold)
        {
            var ldb = new ListDialogBuilder(Activity);

            ldb.SetTitle(string.Format(GetString(Resource.String.devices_actions_1arg), manifold.primarySensor.name));

            var dgs = manifold.primarySensor as GaugeDeviceSensor;

            if (dgs != null)
            {
                var connectionState = dgs.device.connection.connectionState;
                if (connectionState == EConnectionState.Disconnected || connectionState == EConnectionState.Broadcasting)
                {
                    ldb.AddItem(Resource.String.reconnect, () => {
                        dgs.device.connection.Connect();
                    });
                }

                if ((connectionState != EConnectionState.Disconnected && connectionState != EConnectionState.Broadcasting))
                {
                    ldb.AddItem(Resource.String.disconnect, () => {
                        dgs.device.connection.Disconnect();
                    });
                }

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

                if (dgs != null && dgs.device.isConnected)
                {
                    ldb.AddItem(GetString(Resource.String.remote_change_unit), () => {
                        var device = dgs.device;

                        if (device.sensorCount > 1)
                        {
                            var d = new ListDialogBuilder(Activity);
                            d.SetTitle(Resource.String.select_a_sensor);

                            for (int i = 0; i < device.sensorCount; i++)
                            {
                                var sensor = device[i];
                                d.AddItem(i + ": " + sensor.type.GetTypeString(), () => {
                                    ShowChangeUnitDialog(sensor);
                                });
                            }

                            d.Show();
                        }
                        else
                        {
                            ShowChangeUnitDialog(device.sensors[0]);
                        }
                    });
                }

                ldb.AddItem(Resource.String.alarm, () => {
                    var i = new Intent(Activity, typeof(SensorAlarmActivity));
                    i.PutExtra(SensorAlarmActivity.EXTRA_SENSOR, manifold.primarySensor.ToParcelable());
                    StartActivity(i);
                });
            }
            else
            {
                ldb.AddItem(Resource.String.edit_manual_entry, () => {
                    new ManualSensorEditDialog(Activity, manifold.primarySensor as ManualSensor).Show();
                });
            }

            /*
             * var s = analyzer[index];
             * if (s is GaugeDeviceSensor) {
             *  var side = Analyzer.ESide.Low;
             *  analyzer.GetSideOfIndex(index, out side);
             *  new ViewerDialog(this.Activity, analyzer, analyzer[index], side).Show();
             * } else if (s is ManualSensor) {
             *  new ManualSensorEditDialog(Activity, s as ManualSensor).Show();
             * }
             */


            ldb.AddItem(Resource.String.workbench_add_viewer_sub, () => {
                ShowAddSubviewDialog(manifold);
            });

            ldb.AddItem(Resource.String.remove, () => {
                analyzer.RemoveManifold(manifold);
            });

            ldb.Show();
        }