Exemplo n.º 1
0
        private async Task SaveBookAction()
        {
            var config = new ProgressDialogConfig()
                         .SetTitle("Salvando")
                         .SetMaskType(MaskType.None)
                         .SetIsDeterministic(false);

            using (Mvx.Resolve <IUserDialogs>().Progress(config))
            {
                var addedBook = await _bookManager.Add(_title, _author, _genre);

                if (addedBook != null)
                {
                    ShowViewModel <BookDetailsViewModel>(new { jsonBook = JsonConvert.SerializeObject(addedBook) });
                }
            }

            //using (var dlg = Mvx.Resolve<IUserDialogs>().Progress("Progress (No Cancel)"))
            //{
            //    while (dlg.PercentComplete < 100)
            //    {
            //        var addedBook = await _bookManager.Add(_title, _author, _genre);

            //        //if (addedBook != null)
            //        //    ShowViewModel<BookDetailsViewModel>(new { jsonBook = JsonConvert.SerializeObject(addedBook) });

            //        //dlg.PercentComplete += 20;
            //    }
            //}
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        public async void LoadData(int count = 7)
        {
            ProgressDialogConfig config = new ProgressDialogConfig()
                                          .SetTitle("Analyzing results")
                                          .SetIsDeterministic(false)
                                          .SetMaskType(MaskType.Black);

            using (IProgressDialog progress = UserDialogs.Instance.Progress(config))
            {
                await Task.Delay(300);

                sleepViews     = new SleepDiagramView[count];
                commentStrings = new string[count];
                dateStrings    = new string[count];

                for (int i = 0; i < count; i++)
                {
                    dateStrings[i] = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");

                    sleepViews[i] = await GenerateSleepView(dateStrings[i]);

                    commentStrings[i] = "";
                }

                DrawFigures();
            }
        }
Exemplo n.º 3
0
        public IDisposable Progress(string title)
        {
            var config = new ProgressDialogConfig().SetTitle(title)
                         .SetIsDeterministic(false)
                         .SetMaskType(MaskType.Black);

            return(UserDialogs.Progress(config));
        }
Exemplo n.º 4
0
 public UserDialogs()
 {
     _progressDialogConfig = new ProgressDialogConfig()
     {
         MaskType = MaskType.Gradient,
         Title    = "Chargement..."
     };
     _progressDialog = new ProgressDialog(_progressDialogConfig);
 }
Exemplo n.º 5
0
 public UserDialogs()
 {
     _progressDialogConfig = new ProgressDialogConfig()
     {
         MaskType = MaskType.Gradient,
         Title    = "Chargement..."
     };
     _progressDialog = new Acr.UserDialogs.ProgressDialog(_progressDialogConfig, (MainActivity)Forms.Context); // (Activity)Xamarin.Forms.Forms.Context);
 }
Exemplo n.º 6
0
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var repoLogin = new LoginRepository();

                var pdcMessage = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(pdcMessage))
                {
                    APIResult apiResult;
                    if (UsingHttpGet == true)
                    {
                        apiResult = await repoLogin.GetAsync(Account, Password);
                    }
                    else
                    {
                        apiResult = await repoLogin.PostAsync(Account, Password);
                    }

                    apiResult = new APIResult()
                    {
                        Success = true
                    };                                            //跳過驗證debug

                    if (apiResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{apiResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var repoSystemStatus = new SystemStatusRepository();
                        await repoSystemStatus.ReadAsync();
                        repoSystemStatus.Item.LoginMethodAction = UsingHttpGet;
                        repoSystemStatus.Item.AccessToken       = repoLogin.Item.AccessToken;
                        await repoSystemStatus.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });
#if DEBUG
            Account  = "ycwu";
            Password = "******";
#endif
        }
Exemplo n.º 7
0
        public IDisposable Progress(CancellationTokenSource tokenSource, string title)
        {
            var config = new ProgressDialogConfig().SetTitle(title)
                         .SetIsDeterministic(false)
                         .SetMaskType(MaskType.Black)
                         .SetCancel(onCancel: tokenSource.Cancel);

            return(UserDialogs.Progress(config));
        }
Exemplo n.º 8
0
        public IProgressDialog GetProgress(string title)
        {
            var v = new ProgressDialogConfig();

            v.SetTitle(title);
            //v.MaskType = MaskType.Gradient;
            v.SetMaskType(Acr.UserDialogs.MaskType.Gradient);
            return(UserDialogs.Instance.Progress(v));
        }
Exemplo n.º 9
0
        public async Task ApproveDenyRecord(LeaveAppForm leaveAppForm, bool isApprove)
        {
            #region 進行審核請假單
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行審核請假單清單中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooLeaveAppFormRepository = new LeaveAppFormRepository();
                if (isApprove == true)
                {
                    leaveAppForm.ApproveResult = "已審核";
                    leaveAppForm.FormsStatus   = "已生效";
                }
                else
                {
                    leaveAppForm.ApproveResult = "被否決";
                    leaveAppForm.FormsStatus   = "未生效";
                }
                fooResult = await fooLeaveAppFormRepository.PutAsync(leaveAppForm);

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"新增資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RetriveRecords();
            }
            IsRefreshing = false;
            #endregion
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles the clicked async.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        async void Handle_ClickedAsync(object sender, System.EventArgs e)
        {
            bool allCompleted = true;

            foreach (var view in feedbackStackLayout.Children)
            {
                var mView = view as RatingStars;

                if (mView != null)
                {
                    if (mView.SelectedRating == -1)
                    {
                        allCompleted = false;
                    }
                }
            }

            if (allCompleted)
            {
                string returnString = ViewTools.CommaSeparatedValue("Question,Rating",
                                                                    feedbackStackLayout, startTime,
                                                                    DateTime.Now.Subtract(startTime));

                int result = await App.Database.SaveItemAsync(new SleepFeedbackModel()
                {
                    CSV = returnString
                });


                if (CrossConnectivity.Current.IsConnected)
                {
                    CancellationTokenSource cancelSrc = new CancellationTokenSource();
                    ProgressDialogConfig    config    = new ProgressDialogConfig()
                                                        .SetTitle("Uploading to Server")
                                                        .SetIsDeterministic(false)
                                                        .SetMaskType(MaskType.Black)
                                                        .SetCancel(onCancel: cancelSrc.Cancel);

                    using (IProgressDialog progress = UserDialogs.Instance.Progress(config))
                    {
                        await DropboxServer.UploadFeedback(new System.IO.MemoryStream(Encoding.UTF8.GetBytes(returnString)), App.Database.GetLargestFeedbackID());

                        await Task.Delay(100);
                    }
                }

                App.RefreshServer = true;

                await Navigation.PopModalAsync();
            }
            else
            {
                await UserDialogs.Instance.AlertAsync("Please answer all questions", Title = "Error", okText : "Okay");
            }
        }
Exemplo n.º 11
0
        public static IDisposable ShowProgress(string title)
        {
            var config = new ProgressDialogConfig()
                         .SetTitle(title)
                         .SetIsDeterministic(false)
                         .SetMaskType(MaskType.Black);

            var progressDlg = UserDialogs.Instance.Progress(config);

            return(progressDlg);
        }
Exemplo n.º 12
0
        public static bool TryConnectStart(int id_attempt)
        {
            var config = new ProgressDialogConfig()
                         .SetTitle("Trying connect to internet...\n" + "Attempt: " + id_attempt)
                         .SetIsDeterministic(false)
                         .SetMaskType(MaskType.Clear);

            progress = UserDialogs.Instance.Progress(config);
            progress.Show();
            return(true);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Tries to connect device.
        /// </summary>
        /// <returns>The to connect device.</returns>
        /// <param name="deviceViewModel">Device view model.</param>
        /// <param name="showPrompt">If set to <c>true</c> show prompt.</param>
        private async Task <bool> TryToConnectDevice(int index = -1, bool showPrompt = true)
        {
            try
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource();

                var config = new ProgressDialogConfig()
                {
                    Title           = $"Trying to establish connection with '{DeviceName}'",
                    CancelText      = "Cancel",
                    IsDeterministic = false,
                    MaskType        = MaskType.None,
                    OnCancel        = tokenSource.Cancel
                };

                bool didConnect = false;
                using (var progress = _userDialogs.Progress(config))
                {
                    progress.Show();
                    if (index > -1)
                    {
                        didConnect = await _bluetoothService.ConnectDevice(SensorDevice, tokenSource, index);
                    }
                    else
                    {
                        didConnect = await _bluetoothService.ConnectDevice(SensorDevice, tokenSource, -1);
                    }
                }

                tokenSource.Dispose();

                if (!didConnect)
                {
                    return(false);
                }
                _userDialogs.Toast($"\tConnected to {SensorDevice.Name}");

                RaisePropertyChanged("ConnectOrDisposeActionString");
                RaisePropertyChanged("ImageSource");
                return(true);
            }
            catch (Exception ex)
            {
                _userDialogs.Alert(ex.Message, "Connection error");
                _log.Trace(ex.Message);
                return(false);
            }
            finally
            {
                _userDialogs.HideLoading();
                Update();
            }
        }
Exemplo n.º 14
0
        public async Task RetriveRecords()
        {
            #region 進行待審核請假單清單更新
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行待審核請假單清單更新中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooLoginRepository = new LoginRepository();
                await fooLoginRepository.ReadAsync();

                var fooLeaveAppFormRepository = new LeaveAppFormRepository();
                fooResult = await fooLeaveAppFormRepository.PostByUserIDAsync(new LeaveAppFormByUserModel()
                {
                    Account = fooLoginRepository.Item.MyUser.EmployeeID,
                    Mode    = MainHelper.LeaveAppFormManagerMode
                });

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        IsRefreshing = false;
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"更新資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RefreshCache();
            }
            IsRefreshing = false;
            #endregion
        }
Exemplo n.º 15
0
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var fooLoginRepository = new LoginRepository();

                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    APIResult fooResult;
                    if (UsingHttpGet == true)
                    {
                        fooResult = await fooLoginRepository.GetAsync(Account, Password);
                    }
                    else
                    {
                        fooResult = await fooLoginRepository.PostAsync(Account, Password);
                    }
                    if (fooResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var fooSystemStatusRepository = new SystemStatusRepository();
                        await fooSystemStatusRepository.ReadAsync();
                        fooSystemStatusRepository.Item.LoginMethodAction = UsingHttpGet;
                        fooSystemStatusRepository.Item.AccessToken       = fooLoginRepository.Item.AccessToken;
                        await fooSystemStatusRepository.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });

#if DEBUG
            Account  = "user1";
            Password = "******";
#endif
        }
Exemplo n.º 16
0
        private async void OnReadCommand(object obj)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            ProgressDialogConfig    progressDialogConfig    = new ProgressDialogConfig()
            {
                Title      = "Reading...",
                CancelText = "Cancel",
                OnCancel   = cancellationTokenSource.Cancel
            };
            var diag = _userDialogs.Progress(progressDialogConfig);

            try
            {
                var uri = new Uri(path);
                HttpResponseMessage response = await _client.GetAsync(uri, cancellationTokenSource.Token);

                if (response.IsSuccessStatusCode)
                {
                    var a = await response.Content.ReadAsStringAsync();

                    LightBoxConfigModel lightBoxConfigModel = (LightBoxConfigModel)JsonConvert.DeserializeObject(a, typeof(LightBoxConfigModel));
                    this.APName     = lightBoxConfigModel.accessPoint;
                    this.APPassword = lightBoxConfigModel.password;
                    this.MAC        = lightBoxConfigModel.mac;
                    this.Site       = lightBoxConfigModel.url;

                    //Saving to memory
                    await _appSettingsManager.AddDeviceAsync(new DeviceModel()
                    {
                        Mac   = lightBoxConfigModel.mac,
                        Site  = lightBoxConfigModel.url,
                        Panel = "1"
                    });
                }
            }
            catch (OperationCanceledException ex)
            {
                Debug.WriteLine("OperationCanceledException");
            }
            catch (Exception ex)
            {
                diag.Hide();
                await _userDialogs.AlertAsync("Something went wrong...");

                Debug.WriteLine(ex.Message);
            }
            finally
            {
                diag.Hide();
            }
            Debug.WriteLine("OnReadCommand");
        }
        public OnCallPageViewModel(INavigationService navigationService,
                                   IPageDialogService dialogService)
        {
            _navigationService = navigationService;
            _dialogService     = dialogService;

            CallPhoneCommand = new DelegateCommand <OnCallPhone>(async x =>
            {
                Plugin.Messaging.CrossMessaging.Current.PhoneDialer.MakePhoneCall(
                    x.PhoneNumber, x.Title);
            });

            DoRefreshCommand = new DelegateCommand(async() =>
            {
                IsRefreshing = true;
                #region 進行緊急電話清單更新
                APIResult fooResult;
                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    Title           = "請稍後,正在進行緊急電話清單更新中...",
                    IsDeterministic = false,
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    var fooOnCallPhoneRepository = new OnCallPhoneRepository();
                    fooResult = await fooOnCallPhoneRepository.GetAsync();
                    if (fooResult.Success == false)
                    {
                        try
                        {
                            var fooAlertConfig = new AlertConfig()
                            {
                                Title   = "警告",
                                Message = $"更新資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                                OkText  = "確定"
                            };
                            CancellationTokenSource fooCancelSrc = new CancellationTokenSource(3000);
                            await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                        }
                        catch (OperationCanceledException)
                        {
                        }
                    }
                }
                if (fooResult.Success == true)
                {
                    await Refresh();
                }
                IsRefreshing = false;
                #endregion
            });
        }
Exemplo n.º 18
0
        async void ShowDialog(string Msg)
        {
            var config = new ProgressDialogConfig()
            {
                Title           = Msg,
                IsDeterministic = true,
                MaskType        = MaskType.Gradient,
            };

            using (var progress = _userDialogs.Progress(config))
            {
                progress.Show();
                await System.Threading.Tasks.Task.Delay(1000);
            }
        }
Exemplo n.º 19
0
        public BaseContentPage()
        {
            // Progress dialog Init
            var progressDialogConfig = new ProgressDialogConfig
            {
                AutoShow        = false,
                CancelText      = "Stop",
                IsDeterministic = true,
                MaskType        = MaskType.Gradient,
                OnCancel        = null,
                Title           = "Loading..."
            };

            ProgressDialog = UserDialogs.Instance.Progress(progressDialogConfig);
        }
Exemplo n.º 20
0
        private static async void Redeem_Clicked(object sender, EventArgs e)
        {
            var config = new ProgressDialogConfig
            {
                Title    = "View...",
                AutoShow = true,
                MaskType = MaskType.Black
            };

            using (var dialog = UserDialogs.Instance.Progress(config))
            {
                await _Navigation.PushAsync(new DustbinGoogleMapPage(), true);

                dialog.Hide();
            }
        }
        private async Task <bool> ConnectDeviceAsync(DeviceListItemViewModel device, bool showPrompt = true)
        {
            //if (device.IsConnected)
            //{
            //    return true;
            //}

            if (showPrompt && !await _userDialogs.ConfirmAsync($"Connect to device '{device.Name}'?"))
            {
                return(false);
            }
            try
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource();

                var config = new ProgressDialogConfig()
                {
                    Title           = $"Connecting to '{device.Id}'",
                    CancelText      = "Cancel",
                    IsDeterministic = false,
                    OnCancel        = tokenSource.Cancel
                };

                using (var progress = _userDialogs.Progress(config))
                {
                    progress.Show();

                    await Adapter.ConnectToDeviceAsync(device.Device, new ConnectParameters(forceBleTransport : false), tokenSource.Token);
                }

                _userDialogs.ShowSuccess($"Connected to {device.Device.Name}.");

                PreviousGuid = device.Device.Id;
                return(true);
            }
            catch (Exception ex)
            {
                _userDialogs.Alert(ex.Message, "Connection error");
                Mvx.Trace(ex.Message);
                return(false);
            }
            finally
            {
                _userDialogs.HideLoading();
                device.Update();
            }
        }
Exemplo n.º 22
0
        private async void OnWriteCommand(object obj)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            ProgressDialogConfig    progressDialogConfig    = new ProgressDialogConfig()
            {
                Title      = "Writing...",
                CancelText = "Cancel",
                OnCancel   = cancellationTokenSource.Cancel
            };
            var diag = _userDialogs.Progress(progressDialogConfig);

            try
            {
                var uri    = new Uri(path);
                var values = new Dictionary <string, string>
                {
                    { "accessPoint", this.APName },
                    { "password", this.APPassword },
                    { "reboot", "false" }
                };

                var content  = new FormUrlEncodedContent(values);
                var response = await _client.PostAsync(path, content, cancellationTokenSource.Token);

                var responseString = await response.Content.ReadAsStringAsync();

                Debug.WriteLine(responseString);
            }
            catch (OperationCanceledException ex)
            {
                Debug.WriteLine("OperationCanceledException");
            }
            catch (Exception ex)
            {
                diag.Hide();
                await _userDialogs.AlertAsync("Something went wrong...");

                Debug.WriteLine(ex.Message);
            }
            finally
            {
                diag.Hide();
            }
            Debug.WriteLine("OnWriteCommand");
        }
Exemplo n.º 23
0
        /// <summary>
        /// Send message to cloud
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ToolbarItem_Clicked_2(object sender, EventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                PromptResult userMessage = await UserDialogs.Instance.PromptAsync(new PromptConfig()
                                                                                  .SetMessage("Enter your message")
                                                                                  .SetText(""));

                if (userMessage.Ok && userMessage.Text.Trim().Length > 0)
                {
                    try
                    {
                        CancellationTokenSource cancelSrc = new CancellationTokenSource();
                        ProgressDialogConfig    config    = new ProgressDialogConfig()
                                                            .SetTitle("Uploading to Server")
                                                            .SetIsDeterministic(false)
                                                            .SetMaskType(MaskType.Black)
                                                            .SetCancel(onCancel: cancelSrc.Cancel);

                        using (IProgressDialog progress = UserDialogs.Instance.Progress(config))
                        {
                            await DropboxServer.UploadMessage(userMessage.Text);

                            await Task.Delay(500);
                        }

                        UserDialogs.Instance.Toast(new ToastConfig("Successfully Sent")
                                                   .SetDuration(TimeSpan.FromSeconds(3))
                                                   .SetPosition(ToastPosition.Bottom));
                    }
                    catch
                    {
                        UserDialogs.Instance.Toast(new ToastConfig("Error")
                                                   .SetDuration(TimeSpan.FromSeconds(3))
                                                   .SetPosition(ToastPosition.Bottom));
                    }
                }
            }
            else
            {
                UserDialogs.Instance.Toast(new ToastConfig("No Internet Connected")
                                           .SetDuration(TimeSpan.FromSeconds(3))
                                           .SetPosition(ToastPosition.Bottom));
            }
        }
Exemplo n.º 24
0
        public async Task UpdateRecord(WorkingLog workingLog)
        {
            #region 進行工作日誌清單更新
            APIResult fooResult;
            IsRefreshing = true;
            var fooProgressDialogConfig = new ProgressDialogConfig()
            {
                Title           = "請稍後,正在進行工作日誌清單更新中...",
                IsDeterministic = false,
            };
            using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
            {
                var fooWorkingLog = new WorkingLogRepository();
                fooResult = await fooWorkingLog.PutAsync(workingLog);

                if (fooResult.Success == false)
                {
                    if (await MainHelper.CheckAccessToken(fooResult) == false)
                    {
                        return;
                    }

                    try
                    {
                        var fooAlertConfig = new AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"更新資料發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定"
                        };
                        CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                }
            }
            if (fooResult.Success == true)
            {
                await RetriveRecords();
            }
            IsRefreshing = false;
            #endregion
        }
Exemplo n.º 25
0
        /// <summary>
        /// Sets up view async.
        /// </summary>
        private async void SetUpViewAsync()
        {
            ProgressDialogConfig config = new ProgressDialogConfig()
                                          .SetTitle("Querying Database")
                                          .SetIsDeterministic(false)
                                          .SetMaskType(MaskType.Black);

            using (IProgressDialog progress = UserDialogs.Instance.Progress(config))
            {
                await Task.Delay(300);

                var existingData = await App.Database.GetSleepRecordsAsync(DateStringIndex);

                if (existingData != null && existingData.Count > 0)
                {
                    var sleepItems = existingData.Where(m => m.Type == Constants.Namings.SleepCode);

                    SleepInstanceView slider;

                    labelAsleep.IsVisible = true;
                    foreach (var item in sleepItems)
                    {
                        slider = new SleepInstanceView(TargetType.Sleep, Convert.ToSingle(item.Lower), Convert.ToSingle(item.Upper), ReddrawCanvasView);

                        sleepStackLayout.Children.Add(slider);
                        sleepingSpans.Add(slider);
                    }

                    var downItems = existingData.Where(m => m.Type == Constants.Namings.DownCode);

                    labelBed.IsVisible = true;
                    foreach (var item in downItems)
                    {
                        slider = new SleepInstanceView(TargetType.Bed, Convert.ToSingle(item.Lower), Convert.ToSingle(item.Upper), ReddrawCanvasView);

                        bedStackLayout.Children.Add(slider);
                        downSpans.Add(slider);
                    }
                }

                canvasView = new SleepDiagramView(sleepingSpans, downSpans);

                recordingGrid.Children.Add(canvasView, 0, 1);
            }
        }
Exemplo n.º 26
0
        private void FetchData(Action <Book> callback, string isbn)
        {
            Task.Run(() =>
            {
                var config = new ProgressDialogConfig()
                             .SetTitle("Carregando")
                             .SetMaskType(MaskType.None)
                             .SetIsDeterministic(false);

                using (Mvx.Resolve <IUserDialogs>().Progress(config))
                {
                    return(_bookManager.GetBookById(isbn));
                }
            }).ContinueWith((data) =>
            {
                callback(data.Result);
            });
        }
        private async void ConnectToPreviousDeviceAsync()
        {
            IDevice device;

            try
            {
                CancellationTokenSource tokenSource       = new CancellationTokenSource();
                ConnectParameters       connectParameters = new ConnectParameters();

                var config = new ProgressDialogConfig()
                {
                    Title           = $"Searching for '{PreviousGuid}'",
                    CancelText      = "Cancel",
                    IsDeterministic = false,
                    OnCancel        = tokenSource.Cancel
                };

                using (var progress = _userDialogs.Progress(config))
                {
                    progress.Show();

                    device = await Adapter.ConnectToKnownDeviceAsync(PreviousGuid, connectParameters, tokenSource.Token);
                }

                //_userDialogs.ShowSuccess($"Connected to {device.Name}.");

                var deviceItem = Devices.FirstOrDefault(d => d.Device.Id == device.Id);
                if (deviceItem == null)
                {
                    deviceItem = new DeviceListItemViewModel(device);
                    Devices.Add(deviceItem);
                    //await Task.Delay(9000);
                }
                else
                {
                    deviceItem.Update(device);
                }
            }
            catch (Exception ex)
            {
                _userDialogs.ShowError(ex.Message, 5000);
                return;
            }
        }
Exemplo n.º 28
0
        private async Task <bool> ConnectDeviceAsync(IDevice device, bool showPrompt = true)
        {
            if (showPrompt && !await _userDialogs.ConfirmAsync($"Connect to device '{device.Name}'?"))
            {
                return(false);
            }

            CancellationTokenSource tokenSource = new CancellationTokenSource();

            try
            {
                var config = new ProgressDialogConfig()
                {
                    Title           = $"Connecting to '{device.Id}'",
                    CancelText      = "Cancel",
                    IsDeterministic = false,
                    OnCancel        = tokenSource.Cancel
                };

                using (var progress = _userDialogs.Progress(config))
                {
                    progress.Show();

                    await _adapter.ConnectToDeviceAsync(device, new ConnectParameters(autoConnect : true, forceBleTransport : true), tokenSource.Token);
                }

                await _userDialogs.AlertAsync($"Connected to {device.Name}.");

                return(true);
            }
            catch (Exception ex)
            {
                await _userDialogs.AlertAsync(ex.Message, "Connection error");

                Trace.Message(ex.Message);
                return(false);
            }
            finally
            {
                _userDialogs.HideLoading();
                tokenSource.Dispose();
                tokenSource = null;
            }
        }
Exemplo n.º 29
0
        private static async void Redeem_Clicked(object sender, EventArgs e)
        {
            var config = new ProgressDialogConfig
            {
                Title    = "Redeem...",
                AutoShow = true,
                MaskType = MaskType.Black
            };

            using (var dialog = UserDialogs.Instance.Progress(config))
            {
                PointView._GlobalPoint = await w2x.Models.Logics.Points.RedeemPoint(GreetingView._UserId, Guid.Parse(((CustomButton)sender).ClassId));

                PointView._GlobalPointLbl.Text = PointView._GlobalPoint.ToString("#,##0");
                await _Navigation.PushAsync(new MessagePage(true), true);

                dialog.Hide();
            }
        }
        private async void ConnectToPreviousDeviceAsync()
        {
            IDevice device;

            try
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource();

                var config = new ProgressDialogConfig()
                {
                    Title           = $"Searching for '{PreviousGuid}'",
                    CancelText      = "Cancel",
                    IsDeterministic = false,
                    OnCancel        = tokenSource.Cancel
                };

                using (var progress = _userDialogs.Progress(config))
                {
                    progress.Show();

                    device = await Adapter.ConnectToKnownDeviceAsync(PreviousGuid, new ConnectParameters(autoConnect : UseAutoConnect, forceBleTransport : false), tokenSource.Token);
                }

                await _userDialogs.AlertAsync($"Connected to {device.Name}.");

                var deviceItem = Devices.FirstOrDefault(d => d.Device.Id == device.Id);
                if (deviceItem == null)
                {
                    deviceItem = new DeviceListItemViewModel(device);
                    Devices.Add(deviceItem);
                }
                else
                {
                    deviceItem.Update(device);
                }
            }
            catch (Exception ex)
            {
                _userDialogs.ErrorToast(string.Empty, ex.Message, TimeSpan.FromSeconds(5000));
                return;
            }
        }