/// <summary> /// Shows the dialog. /// </summary> /// <param name="context">Context.</param> public AlertDialog Show(Context context) { var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_date_time, null); var date = view.FindViewById <DatePicker>(Resource.Id.date); var time = view.FindViewById <TimePicker>(Resource.Id.time); var hours = 0; var minutes = 0; time.TimeChanged += (sender, e) => { hours = e.HourOfDay; minutes = e.Minute; }; date.MinDate = start.ToUTCMilliseconds(); date.MaxDate = end.ToUTCMilliseconds(); date.CalendarViewShown = false; var adb = new IONAlertDialog(context); adb.SetTitle(title); adb.SetView(view); adb.SetNegativeButton(context.GetString(Resource.String.cancel), (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); }); adb.SetPositiveButton(context.GetString(Resource.String.ok_done), (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); var dateTime = date.DateTime; dateTime = dateTime.AddHours(hours); dateTime = dateTime.AddMinutes(minutes); if (handler != null) { handler(obj, dateTime); } }); return(adb.Show()); }
public static Dialog ShowDialog(Context context, string title, string message, Action positive, Action negative = null) { var adb = new IONAlertDialog(context, title); adb.SetMessage(message); adb.SetNegativeButton(Resource.String.cancel, (sender, e) => { (sender as Dialog).Dismiss(); if (negative != null) { negative(); } }); adb.SetPositiveButton(Resource.String.ok, (sender, e) => { (sender as Dialog).Dismiss(); positive(); }); return(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()); }