private void OnChooseNearbyMarkerCountCommandExecute() { var actionSheetConfig = new ActionSheetConfig(); actionSheetConfig.Title = AppResources.ViewCell_NearbyMarkerCount; actionSheetConfig.Add("0", () => { Settings.NearbyMarkerCount = 0; RaisePropertyChanged(nameof(Settings)); }); foreach (var count in Enumerable.Range(0, 8).Select(i => Convert.ToInt32(Math.Pow(2, i)))) { actionSheetConfig.Add(count.ToString(), () => { Settings.NearbyMarkerCount = count; RaisePropertyChanged(nameof(Settings)); }); } _userDialogs.ActionSheet(actionSheetConfig); }
private void ActionSheet() { var asc = new ActionSheetConfig() .SetTitle("ActionSheet") .SetMessage("アクションシート") .SetUseBottomSheet(false); asc.Add("001", () => ShowActionSheetResult("イワン・ウイスキー")); asc.Add("002", () => ShowActionSheetResult("ジェット・リンク")); asc.Add("003", () => ShowActionSheetResult("フランソワーズ・アルヌール")); asc.Add("004", () => ShowActionSheetResult("アルベルト・ハインリヒ")); asc.Add("005", () => ShowActionSheetResult("ジェロニモ・ジュニア")); asc.Add("006", () => ShowActionSheetResult("張々湖")); asc.Add("007", () => ShowActionSheetResult("グレート・ブリテン")); asc.Add("008", () => ShowActionSheetResult("ピュンマ")); asc.Add("009", () => ShowActionSheetResult("島村ジョー")); // removeボタン asc.SetDestructive("削除", () => ShowActionSheetResult("削除")); // cancelボタン asc.SetCancel("キャンセル", () => ShowActionSheetResult("キャンセル")); // PopoverPresentationControllerの指定はできないっぽい // 吹き出しは画面下部中央からでてる _dialogs.ActionSheet(asc); }
private void OnImageTappedCommand() { _userDialogs.ActionSheet(new ActionSheetConfig() .SetUseBottomSheet(true) .SetTitle("") .SetCancel(LocalizedResources["CancelLabel"], null, "ic_cancel.png") .Add(LocalizedResources["FromGalleryLabel"], () => TakeFromGalleryAsync(), "ic_collections.png") .Add(LocalizedResources["TakePictureLabel"], () => TakeFromCameraAsync(), "ic_camera_alt.png")); }
private void HandleSelectedDevice(DeviceListItemViewModel device) { var config = new ActionSheetConfig(); if (device.IsConnected) { config.Add("Details", () => { ShowViewModel <ServiceListViewModel>(new MvxBundle(new Dictionary <string, string> { { DeviceIdKey, device.Device.Id.ToString() } })); }); config.Add("Update RSSI", async() => { try { _userDialogs.ShowLoading(); await device.Device.UpdateRssiAsync(); device.RaisePropertyChanged(nameof(device.Rssi)); _userDialogs.HideLoading(); _userDialogs.Toast($"RSSI updated {device.Rssi}", TimeSpan.FromSeconds(1000)); } catch (Exception ex) { _userDialogs.HideLoading(); await _userDialogs.AlertAsync($"Failed to update rssi. Exception: {ex.Message}"); } }); config.Destructive = new ActionSheetOption("Disconnect", () => DisconnectCommand.Execute(device)); } else { config.Add("Connect", async() => { if (await ConnectDeviceAsync(device)) { var navigation = Mvx.Resolve <IMvxNavigationService>(); await navigation.Navigate <ServiceListViewModel, MvxBundle>(new MvxBundle(new Dictionary <string, string> { { DeviceIdKey, device.Device.Id.ToString() } })); } }); config.Add("Connect & Dispose", () => ConnectDisposeCommand.Execute(device)); } config.Add("Copy GUID", () => CopyGuidCommand.Execute(device)); config.Cancel = new ActionSheetOption("Cancel"); config.SetTitle("Device Options"); _userDialogs.ActionSheet(config); }
public FileManagerViewModel(IUserDialogs dialogs, IFileSystem fileSystem) { this.dialogs = dialogs; this.fileSystem = fileSystem; this.Select = ReactiveCommand.Create <FileEntryViewModel>(entry => { var cfg = new ActionSheetConfig().AddCancel(); if (entry.IsDirectory) { cfg.Add("Enter", () => this.CurrentPath = entry.Entry.FullName); } else { cfg.Add("View", async() => { var text = File.ReadAllText(entry.Entry.FullName); await this.dialogs.Alert(text, entry.Entry.Name); }); //cfg.Add("Copy", () => //{ // //var progress = dialogs.Progress(new ProgressDialogConfig // //{ // // Title = "Copying File" // //}); // var fn = Path.GetFileNameWithoutExtension(entry.Entry.Name); // var ext = Path.GetExtension(entry.Entry.Name); // var newFn = ext.IsEmpty() ? $"fn_1" : $"{fn}_1.{ext}"; // var target = new FileInfo(newFn); // var file = new FileInfo(entry.Entry.FullName); // file // .CopyProgress(target, true) // .Subscribe(p => // { // //progress.Title = "Copying File - Seconds Left: " + p.TimeRemaining.TotalSeconds; // //progress.PercentComplete = p.PercentComplete; // }); //}); } //cfg.Add("Delete", () => Confirm("Delete " + entry.Name, entry.Entry.Delete)); dialogs.ActionSheet(cfg); }); this.showBack = this.WhenAnyValue(x => x.CurrentPath) .Select(x => x == this.CurrentPath) .ToProperty(this, x => x.ShowBack); this.WhenAnyValue(x => x.CurrentPath) .Skip(1) .Subscribe(_ => this.LoadEntries()) .DisposeWith(this.DestroyWith); }
private void DisplayEmployeeActionSheet(Employee employee) { var cfg = new ActionSheetConfig() .SetTitle("Select Action"); cfg.Add("Edit", async() => await NavigateToEditEmployeePage(employee)); cfg.Add("Delete", async() => await DeleteEmployee(employee)); cfg.Add("Manage Skills", async() => await NavigateToEmployeeSkillsPage(employee.ID)); cfg.SetCancel("Cancel"); _userDialogs.ActionSheet(cfg); }
private void TouchedPicture() { IUserDialogs userDialogs = UserDialogs.Instance; ActionSheetConfig config = new ActionSheetConfig(); List <ActionSheetOption> Options = new List <ActionSheetOption>(); Options.Add(new ActionSheetOption(AppResource.pick_at_gallery, OpenGallery, ListOfNames.pictureForFolder)); Options.Add(new ActionSheetOption(AppResource.take_photo_with_camera, TakePhoto, ListOfNames.pictureForCamera)); ActionSheetOption cancel = new ActionSheetOption(AppResource.cancel.ToUpper(), null, null); config.Options = Options; config.Cancel = cancel; userDialogs.ActionSheet(config); }
private async void ImageTap(object obj) { ActionSheetConfig config = new ActionSheetConfig(); config.SetUseBottomSheet(true); var galeryIcon = await BitmapLoader.Current.LoadFromResource("ic_collections.png", 500f, 500f); var photoIcon = await BitmapLoader.Current.LoadFromResource("ic_camera_alt.png", 500f, 500f); config.Add("Take Picture From Galery", SetPictureFromGalery, galeryIcon); config.Add("Take Picture From Camera", SetFromCamera, photoIcon); config.SetCancel(null, null, null); _userDialogs.ActionSheet(config); }
private async void OpenAddSkillActionSheet() { var cfg = new ActionSheetConfig() .SetTitle("Select Action"); try { _skillCache = await _skillsService.GetAllSkillsAsync(); } catch (Exception ex) { Debug.WriteLine(ex.Message); await _userDialogs.AlertAsync(ex.Message, "Error"); } foreach (var skill in _skillCache) { cfg.Add(skill.Name, async() => await AddSkillToEmployee(skill.ID)); } cfg.SetCancel("Cancel"); _userDialogs.ActionSheet(cfg); }
public IDisposable ShowActionSheet( string title, string cancel, string destructive, List <ActionSheetButtonModel> actionSheetButtons) { var config = new ActionSheetConfig(); config.SetTitle(title); config.SetCancel(cancel); config.Destructive = string.IsNullOrEmpty(destructive) ? null : new ActionSheetOption(destructive); foreach (var button in actionSheetButtons) { config.Add(button.Text, button.Action, button.IconName); } return(_dialogs.ActionSheet(config)); }
private void HandleSelectedDevice(DeviceListItemViewModel device, int type) { //type = 1 if slave, type = 2 if master. var config = new ActionSheetConfig(); if (device.IsConnected) { config.Destructive = new ActionSheetOption("Disconnect", () => DisconnectCommand.Execute(device)); } else { config.Add("Connect", async() => { if (await ConnectDeviceAsync(device)) { switch (type) { case 1: device.IsSlave = true; GraphViewModel.SlaveDeviceId = device.Device.Id; var ServiceSlave = await device.Device.GetServiceAsync(Guid.Parse("0000180d-0000-1000-8000-00805f9b34fb")); var CharacteristicSlave = await ServiceSlave.GetCharacteristicAsync(Guid.Parse("00002a37-0000-1000-8000-00805f9b34fb")); await CharacteristicSlave.StartUpdatesAsync(); break; case 2: device.IsMaster = true; GraphViewModel.MasterDeviceId = device.Device.Id; var ServiceMaster = await device.Device.GetServiceAsync(Guid.Parse("0000180d-0000-1000-8000-00805f9b34fb")); var CharacteristicMaster = await ServiceMaster.GetCharacteristicAsync(Guid.Parse("00002a37-0000-1000-8000-00805f9b34fb")); await CharacteristicMaster.StartUpdatesAsync(); break; } } }); } config.Cancel = new ActionSheetOption("Cancel"); config.SetTitle("Device Options"); _userDialogs.ActionSheet(config); }
public GpsViewModel(IGpsManager manager, IUserDialogs dialogs) { this.manager = manager; this.IsUpdating = this.manager.IsListening; this.WhenAnyValue(x => x.UseBackground) .Subscribe(x => this.Access = this.manager.GetCurrentStatus(this.UseBackground).ToString()); this.WhenAnyValue(x => x.IsUpdating) .Select(x => x ? "Stop Listening" : "Start Updating") .ToPropertyEx(this, x => x.ListenerText); this.GetCurrentPosition = ReactiveCommand.CreateFromTask(async _ => { var result = await dialogs.RequestAccess(() => this.manager.RequestAccess(true)); if (!result) { return; } var reading = await this.manager.GetLastReading(); if (reading == null) { await dialogs.Alert("Could not getting GPS coordinates"); } else { this.SetValues(reading); } }); this.BindBusyCommand(this.GetCurrentPosition); this.SelectPriority = ReactiveCommand.Create(() => dialogs.ActionSheet( new ActionSheetConfig() .SetTitle("Select Priority/Desired Accuracy") .Add("Highest", () => this.Priority = GpsPriority.Highest) .Add("Normal", () => this.Priority = GpsPriority.Normal) .Add("Low", () => this.Priority = GpsPriority.Low) .AddCancel() )); this.ToggleUpdates = ReactiveCommand.CreateFromTask( async() => { if (this.manager.IsListening) { await this.manager.StopListener(); this.gpsListener?.Dispose(); } else { var result = await dialogs.RequestAccess(() => this.manager.RequestAccess(this.UseBackground)); if (!result) { await dialogs.Alert("Insufficient permissions"); return; } var request = new GpsRequest { UseBackground = this.UseBackground, Priority = this.Priority, }; if (IsInterval(this.DesiredInterval)) { request.Interval = ToInterval(this.DesiredInterval); } if (IsInterval(this.ThrottledInterval)) { request.ThrottledInterval = ToInterval(this.ThrottledInterval); } await this.manager.StartListener(request); } this.IsUpdating = this.manager.IsListening; }, this.WhenAny( x => x.IsUpdating, x => x.DesiredInterval, x => x.ThrottledInterval, (u, i, t) => { if (u.GetValue()) { return(true); } var isdesired = IsInterval(i.GetValue()); var isthrottled = IsInterval(t.GetValue()); if (isdesired && isthrottled) { var desired = ToInterval(i.GetValue()); var throttle = ToInterval(t.GetValue()); if (throttle.TotalSeconds >= desired.TotalSeconds) { return(false); } } return(true); } ) ); this.UseRealtime = ReactiveCommand.Create(() => { var rt = GpsRequest.Realtime(false); this.ThrottledInterval = String.Empty; this.DesiredInterval = rt.Interval.TotalSeconds.ToString(); this.Priority = rt.Priority; }); this.RequestAccess = ReactiveCommand.CreateFromTask(async() => { var access = await this.manager.RequestAccess(this.UseBackground); this.Access = access.ToString(); }); this.BindBusyCommand(this.RequestAccess); }
private void HandleSelectedDevice(IDevice device) { var config = new ActionSheetConfig(); if (device.State == DeviceState.Connected) { config.Add("Update RSSI", async() => { try { _userDialogs.ShowLoading(); await device.UpdateRssiAsync(); _userDialogs.HideLoading(); _userDialogs.Toast($"RSSI updated {device.Rssi}", TimeSpan.FromSeconds(1)); } catch (Exception ex) { _userDialogs.HideLoading(); await _userDialogs.AlertAsync($"Failed to update rssi. Exception: {ex.Message}"); } }); config.Destructive = new ActionSheetOption("Disconnect", () => DisconnectDevice(device)); } else { config.Add("Connect", async() => { if (await ConnectDeviceAsync(device)) { // Connected //var services = await device.GetServicesAsync(); //var service = await device.GetServiceAsync(Guid.Parse("ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5")); //// Get characteristics //var characteristics = await service.GetCharacteristicsAsync(); //var characteristic = await service.GetCharacteristicAsync(Guid.Parse("d8de624e-140f-4a22-8594-e2216b84a5f2")); //// Read characteristic //var bytes = await characteristic.ReadAsync(); //// Write characteristic //await characteristic.WriteAsync(bytes); //// Characteristic notifications //characteristic.ValueUpdated += (o, args) => //{ // var bytes = args.Characteristic.Value; //}; //await characteristic.StartUpdatesAsync(); } }); } config.Cancel = new ActionSheetOption("Cancel"); config.SetTitle("Device Options"); _userDialogs.ActionSheet(config); }
public GpsViewModel(IGpsManager manager, IUserDialogs dialogs) { this.manager = manager; this.IsUpdating = this.manager.IsListening; this.WhenAnyValue(x => x.UseBackground) .Subscribe(x => this.Access = this.manager.GetCurrentStatus(this.UseBackground).ToString()); this.WhenAnyValue(x => x.IsUpdating) .Select(x => x ? "Stop Listening" : "Start Updating") .ToPropertyEx(this, x => x.ListenerText); this.GetCurrentPosition = ReactiveCommand.CreateFromTask(async _ => { var result = await dialogs.RequestAccess(() => this.manager.RequestAccess(true)); if (!result) { return; } var reading = await this.manager.GetLastReading(); if (reading == null) { dialogs.Alert("Could not getting GPS coordinates"); } else { this.SetValues(reading); } }); this.BindBusyCommand(this.GetCurrentPosition); this.SelectPriority = ReactiveCommand.Create(() => dialogs.ActionSheet( new ActionSheetConfig() .SetTitle("Select Priority/Desired Accuracy") .Add("Highest", () => this.Priority = GpsPriority.Highest) .Add("Normal", () => this.Priority = GpsPriority.Normal) .Add("Low", () => this.Priority = GpsPriority.Low) .SetCancel() )); this.ToggleUpdates = ReactiveCommand.CreateFromTask( async() => { if (this.manager.IsListening) { await this.manager.StopListener(); this.gpsListener?.Dispose(); } else { var result = await dialogs.RequestAccess(() => this.manager.RequestAccess(this.UseBackground)); if (!result) { dialogs.Alert("Insufficient permissions"); return; } var request = new GpsRequest { UseBackground = this.UseBackground, Priority = this.Priority }; var meters = ToDeferred(this.DeferredMeters); if (meters > 0) { request.DeferredDistance = Distance.FromMeters(meters); } var secs = ToDeferred(this.DeferredSeconds); if (secs > 0) { request.DeferredTime = TimeSpan.FromSeconds(secs); } await this.manager.StartListener(request); } this.IsUpdating = this.manager.IsListening; }, this.WhenAny( x => x.IsUpdating, x => x.DeferredMeters, x => x.DeferredSeconds, (u, m, s) => u.GetValue() || ( ToDeferred(m.GetValue()) >= 0 && ToDeferred(s.GetValue()) >= 0 ) ) ); this.RequestAccess = ReactiveCommand.CreateFromTask(async() => { var access = await this.manager.RequestAccess(this.UseBackground); this.Access = access.ToString(); }); this.BindBusyCommand(this.RequestAccess); }
public SettingsViewModel(IPermissions permissions, IGeofenceManager geofences, IUserDialogs dialogs, IViewModelManager viewModelMgr) { this.permissions = permissions; this.geofences = geofences; this.dialogs = dialogs; this.Menu = new Command(() => dialogs.ActionSheet(new ActionSheetConfig() .SetCancel() .Add("Add Geofence", async () => await viewModelMgr.PushNav<AddGeofenceViewModel>() ) .Add("Use Default Geofences", async () => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("This will stop monitoring all existing geofences and set the defaults. Are you sure you want to do this?")); if (result) { geofences.StopAllMonitoring(); await Task.Delay(500); geofences.StartMonitoring(new GeofenceRegion { Identifier = "FC HQ", Center = new Position(43.6411314, -79.3808415), // 88 Queen's Quay - Home Radius = Distance.FromKilometers(1) }); geofences.StartMonitoring(new GeofenceRegion { Identifier = "Close to HQ", Center = new Position(43.6411314, -79.3808415), // 88 Queen's Quay Radius = Distance.FromKilometers(3) }); geofences.StartMonitoring(new GeofenceRegion { Identifier = "Ajax GO Station", Center = new Position(43.8477697, -79.0435461), Radius = Distance.FromMeters(500) }); await Task.Delay(500); // ios needs a second to breathe when registering like this this.RaisePropertyChanged("CurrentRegions"); } }) .Add("Stop All Geofences", async () => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("Are you sure wish to stop monitoring all geofences?")); if (result) { this.geofences.StopAllMonitoring(); this.RaisePropertyChanged("CurrentRegions"); } }) )); this.Remove = new Command<GeofenceRegion>(x => { this.geofences.StopMonitoring(x); this.RaisePropertyChanged("CurrentRegions"); }); }
private void HandleSelectedDevice(DeviceListItemViewModel device) { var config = new ActionSheetConfig(); if (device.IsConnected) { config.Add("Update RSSI", async() => { try { _userDialogs.ShowLoading(); await device.Device.UpdateRssiAsync(); device.RaisePropertyChanged(nameof(device.Rssi)); _userDialogs.HideLoading(); _userDialogs.ShowSuccess($"RSSI updated {device.Rssi}", 1000); } catch (Exception ex) { _userDialogs.HideLoading(); _userDialogs.ShowError($"Failed to update rssi. Exception: {ex.Message}"); } }); config.Destructive = new ActionSheetOption("Disconnect", () => DisconnectCommand.Execute(device)); } else { config.Add("Connect", async() => { if (await ConnectDeviceAsync(device)) { ShowViewModel <ServiceListViewModel>(new MvxBundle(new Dictionary <string, string> { { DeviceIdKey, device.Device.Id.ToString() } })); } }); //config.Add("Connect & Dispose", () => ConnectDisposeCommand.Execute(device)); config.Add("Save Advertised Data", () => { if (device.Device.AdvertisementRecords == null || device.Device.AdvertisementRecords.Count == 0) { _userDialogs.Alert("No Data Found"); return; } var advModel = new AdvertisementData() { Id = Guid.NewGuid(), DeviceId = device.Id.ToString(), Name = device.Name, Data = device.Device.AdvertisementRecords[0].Data }; _advertisementDataRepository.InsertDevice(advModel); }); } config.Add("Copy ID", () => CopyGuidCommand.Execute(device)); config.Cancel = new ActionSheetOption("Cancel"); config.SetTitle("Device Options"); _userDialogs.ActionSheet(config); }
public CreateViewModel(INavigationService navigationService, IHttpTransferManager httpTransfers, IUserDialogs dialogs, IFileSystem fileSystem, AppSettings appSettings) { this.fileSystem = fileSystem; this.Url = appSettings.LastTransferUrl; this.WhenAnyValue(x => x.IsUpload) .Subscribe(upload => { if (!upload && this.FileName.IsEmpty()) { this.FileName = Guid.NewGuid().ToString(); } this.Title = upload ? "New Upload" : "New Download"; }); this.ManageUploads = navigationService.NavigateCommand("ManageUploads"); this.ResetUrl = ReactiveCommand.Create(() => { appSettings.LastTransferUrl = null; this.Url = appSettings.LastTransferUrl; }); this.SelectUpload = ReactiveCommand.Create(() => { var files = fileSystem.AppData.GetFiles("upload.*", SearchOption.TopDirectoryOnly); if (!files.Any()) { dialogs.Alert("There are not files to upload. Use 'Manage Uploads' below to create them"); } else { var cfg = new ActionSheetConfig().SetCancel(); foreach (var file in files) { cfg.Add(file.Name, () => this.FileName = file.Name); } dialogs.ActionSheet(cfg); } }); this.Save = ReactiveCommand.CreateFromTask( async() => { var path = Path.Combine(this.fileSystem.AppData.FullName, this.FileName); var request = new HttpTransferRequest(this.Url, path, this.IsUpload) { UseMeteredConnection = this.UseMeteredConnection }; await httpTransfers.Enqueue(request); appSettings.LastTransferUrl = this.Url; await navigationService.GoBackAsync(); }, this.WhenAny ( x => x.IsUpload, x => x.Url, x => x.FileName, (up, url, fn) => { this.ErrorMessage = String.Empty; if (!Uri.TryCreate(url.GetValue(), UriKind.Absolute, out _)) { this.ErrorMessage = "Invalid URL"; } else if (up.GetValue() && fn.GetValue().IsEmpty()) { this.ErrorMessage = "You must select or enter a filename"; } return(this.ErrorMessage.IsEmpty()); } ) ); }