private async void ConfirmBtn_Clicked(object sender, EventArgs e) { if (Edited) { var alertPage = new AlertPopupPage(false, "Сохранить новые координаты?", confirmText: "Да"); alertPage.Confirm += async(s, events) => { using (var connection = new SqliteConnection(ConnectionClass.NewDatabasePath)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = $"update V_ISSO set P1_LATITUDE={StartGeo.Latitude}, P1_LONGITUDE={StartGeo.Longitude}, P2_LATITUDE={EndGeo.Latitude}," + $" P2_LONGITUDE={EndGeo.Longitude} where C_ISSO={CIsso}"; command.CommandTimeout = 30; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); } connection.Close(); } await Navigation.PopModalAsync(); // ReSharper disable once PossibleNullReferenceException SaveChanges(new[] { StartGeo.Latitude, StartGeo.Longitude, EndGeo.Latitude, EndGeo.Longitude }, EventArgs.Empty); }; await Navigation.PushPopupAsync(new CommonPopupPage(alertPage, "Сохранение новых коорлинат")); } else { var alertPage = new AlertPopupPage(true, "Координаты не были изменены. Измените хотя бы одну координату для сохранения.", "ОК"); alertPage.Confirm += async(o, args) => { await Navigation.PopPopupAsync(); }; await Navigation.PushPopupAsync(new CommonPopupPage(alertPage, "Сохранение новых координат")); } }
public async Task <AlertPopupResult> AlertPopup(string title, string message, string dismissButtonText) { var popup = new AlertPopupPage(title, message, dismissButtonText); await PushPopup(popup); return(await popup.Result.Task); }
private async void CancelBtn_Clicked(object sender, EventArgs eventArgs) { var alertPage = new AlertPopupPage(false, "Вы хотите выйти без сохранения?", confirmText: "Да"); alertPage.Confirm += async(s, e) => { await Navigation.PopModalAsync(); }; await Navigation.PushPopupAsync(new CommonPopupPage(alertPage, "Предупреждение: Координаты не сохранены")); //var result = await DisplayAlert("Внимание!", "Вы хотите выйти без сохранения?", "Да", "Отмена"); }
private async void EditPointButton_Clicked(object sender, EventArgs eventArgs, bool isStart) { if (MyPosition.Accuracy < Accuracy) { // Создаем наше модальное окно var alertPage = new AlertPopupPage(false, $"Использовать текущее местоположение как новые координаты {(isStart ? "начала ИССО" : "конца ИССО")}?", confirmText: "Да"); // Описываем метод при нажатии на Ок alertPage.Confirm += (s, e) => { // Записываем новые координаты if (isStart) { StartGeo.Latitude = MyPosition.Latitude; StartGeo.Longitude = MyPosition.Longitude; } else { EndGeo.Latitude = MyPosition.Latitude; EndGeo.Longitude = MyPosition.Longitude; } SetupPins(StartGeo, EndGeo); if (StartGeo != null && EndGeo != null) { CenterMap(new List <GeoCoords> { StartGeo, EndGeo }); } else if (MyPosition != null) { CenterMap(new List <GeoCoords> { new GeoCoords(MyPosition.Latitude, MyPosition.Longitude) }); } if (StartGeo != null && EndGeo != null) { CurrentISSOLength.Text = $"{(GeoCodeCalc.CalcDistance(StartGeo.Latitude, StartGeo.Longitude, EndGeo.Latitude, EndGeo.Longitude) * 1000):F1} м."; } EditIssoLocations(); Edited = true; }; await Navigation.PushPopupAsync(new CommonPopupPage(alertPage, "Изменение координат")); } else { DependencyService.Get <IMessage>().LongAlert("Нельзя установить новые координаты, т.к. погрешность > 10 м."); } }
private async void MicrophonePressed(object sender, EventArgs e) { var speechStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Speech); var microStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Microphone); if (speechStatus != PermissionStatus.Granted || microStatus != PermissionStatus.Granted) { var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Speech, Permission.Microphone); microStatus = results[Permission.Microphone]; speechStatus = results[Permission.Speech]; } if (speechStatus == PermissionStatus.Granted && microStatus == PermissionStatus.Granted) { //listener = CrossSpeechRecognition.Current.ContinuousDictation().Subscribe( // phrase => // { // EntryComment.Text += phrase; // }, // completed => // { // listener.Dispose(); // }); //CrossSpeechRecognition.Current.ContinuousDictation().Subscribe(phrase => { EntryComment.Text += phrase; }, // () => { CrossSpeechRecognition.Current.ContinuousDictation().Subscribe().Dispose(); }); CrossSpeechRecognition.Current.ListenUntilPause().Subscribe(phrase => { EntryComment.Text += phrase; }, async() => { Animate_Button(false); await Navigation.PopPopupAsync(); }); var loadingPopupPage = new LoadingPopupPage("Пожалуйста, говорите!", true); Animate_Button(true); await Navigation.PushPopupAsync(loadingPopupPage); } else { var alertPage = new AlertPopupPage(true, "Распознавание речи невозможно, т.к. недостаточно разрешений для этого."); await Navigation.PushPopupAsync(new CommonPopupPage(alertPage, "Недостаточно разрешений")); //await DisplayAlert("Недостаточно разрешений", "Распознавание речи невозможно, т.к. недостаточно разрешений для этого.", "OK"); //On iOS you may want to send your user to the settings screen. //CrossPermissions.Current.OpenAppSettings(); } }
/// <summary> /// Обработчик нажатия кнопки синхронизации /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Sync_Click(object sender, EventArgs e) { SaveSettings(); if (string.IsNullOrEmpty(Login.Text) || string.IsNullOrEmpty(Password.Text)) { var alertPopupPage = new AlertPopupPage(true, "Данные учетной записи не заполнены. Проверьте Логин и Пароль."); Navigation.PushPopupAsync(new CommonPopupPage(alertPopupPage, "Ошибка синхронизации")); //DisplayAlert("Ошибка", "Данные учетной записи не заполнены. Проверьте Логин и Пароль.", "Ок"); } else { switch (AppType) { case ApplicationType.IssoI: InitUserCollections(); break; default: Begin_Sync(); break; } } }
private void ButtonForward_OnClicked(object sender, EventArgs e) { // Если дошли до конца и нажали на Добавить дефект, то вызываем окно предупередительное и добавляем собсна if (CarouselView.Position == _indexSummary) { var addPopupPage = new AlertPopupPage(false, "Вы уверены, что хотите добавить новый дефект?", confirmText: "Добавить"); // При нажатии на Да добавляем и вырубаем окно addPopupPage.Confirm += (o, args) => { var popupPage = new LoadingPopupPage("Добавление дефекта в БД...", true); Navigation.PushPopupAsync(popupPage); Task.Factory.StartNew(() => { if (_vm.AddDefectToDatabase()) { Device.BeginInvokeOnMainThread(() => { DoneWithDefect(); Navigation.PopPopupAsync(); }); } else { Device.BeginInvokeOnMainThread(() => { DependencyService.Get <IMessage>().ShortAlert("Невозможно создать дефект. Ошибка при добавлении."); Navigation.PopPopupAsync(); }); } }); }; Navigation.PushPopupAsync(new CommonPopupPage(addPopupPage, "Добавление дефекта")); } // иначе идем дальше else { if (!_interactors[CarouselView.Position] && CarouselView.Position != _indexAdvanced) { return; } CarouselView.Position += 1; ButtonBack.IsVisible = CarouselView.Position != 0; ButtonForward.IsEnabled = _interactors[CarouselView.Position]; // Если дошли до доп инфы, прописываем поведение кнопок if (CarouselView.Position == _indexAdvanced) { ButtonForward.Text = _interactors[_indexAdvanced] ? "Далее" : "Пропустить"; ButtonForward.Style = _interactors[_indexAdvanced] ? (Style)Application.Current.Resources["ButtonStandard"] : (Style)Application.Current.Resources["ButtonStandardCancel"]; // для доп инфы всегда можно нажимать ButtonForward.IsEnabled = true; } // Если же дошли до даты, то прописываем там поведение else if (CarouselView.Position == _indexAdvanced + 1) { ButtonForward.Text = "Далее"; ButtonForward.Style = _interactors[_indexAdvanced + 1] ? (Style)Application.Current.Resources["ButtonStandard"] : (Style)Application.Current.Resources["ButtonStandardCancel"]; } // Дошли до конца - прописываем соответствующее поведение else if (CarouselView.Position == _indexSummary) { ButtonForward.Text = "Добавить дефект"; ButtonForward.Style = (Style)Application.Current.Resources["ButtonStandard"]; } else { ButtonForward.Text = "Далее"; ButtonForward.Style = _interactors[CarouselView.Position] ? (Style)Application.Current.Resources["ButtonStandard"] : (Style)Application.Current.Resources["ButtonStandardCancel"]; } } // Навигация по мастеру вперед //if (CarouselView.Position == _indexSummary) // ButtonForward.Text = "Добавить дефект"; //else // ButtonForward.Text = CarouselView.Position == _indexAdvanced ? "Пропустить" : "Далее"; //ButtonForward.Style = CarouselView.Position == _indexSummary // ? (Style)Application.Current.Resources["ButtonStandard"] // : (Style)Application.Current.Resources["ButtonStandardCancel"]; }