public DialogResult ShowDialog(string title, IDialogViewModel viewModel) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } var window = new DialogWindow { Title = title, Owner = Application.Current.MainWindow, DataContext = viewModel }; try { DialogShown?.Invoke(this, EventArgs.Empty); window.ShowDialog(); viewModel.Close(window.Result); } finally { DialogClosed?.Invoke(this, EventArgs.Empty); } return(window.Result); }
protected override bool OnDestroyEvent(Event evnt) { var result = base.OnDestroyEvent(evnt); DialogClosed?.Invoke(this, EventArgs.Empty); return(result); }
public override void OnDismiss(IDialogInterface dialog) { base.OnDismiss(dialog); string name = PFirst + " " + PLast; DialogClosed?.Invoke(this, name); }
public void HideDialog(object Result) { HideDialogAnimation(PopUpDialogLayout, PopUpBgLayout); DialogClosed?.Invoke(null, new PopupClosedEventArgs() { result = Result }); }
private bool?Show(ModalDialog dialog) { DialogOpened?.Invoke(this, EventArgs.Empty); dialog.Show(); DialogClosed?.Invoke(this, EventArgs.Empty); return(dialog.Result); }
private void Dialog_Closed(object sender, DialogControlClosedEventArgs e) { if (_currentDialogControl == sender) { _currentDialogControl = null; DialogClosed.Raise(sender, e); } }
private void KeyInputBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { ViewModel.HasBeenCancelled = false; Close(); DialogClosed?.Invoke(this, ViewModel); } }
private void ContainerClosed(object sender, EventArgs e) { if (sender is IDialog dialog) { MinimizedDialogs.RemoveIfExists(dialog); ActiveDialogs.RemoveIfExists(dialog); DialogClosed?.Invoke(this, dialog); } }
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Escape) { e.Handled = true; ViewModel.HasBeenCancelled = true; Close(); DialogClosed?.Invoke(this, null); } }
private void GetResultAndCloseDialog() { if (!ResultFilename.EndsWith("." + FileFilter)) { ResultFilename = ResultFilename + "." + FileFilter.ToLower(); } Result = System.Windows.Forms.DialogResult.OK; DialogClosed?.Invoke(this); }
public void CloseDialog() { Hide(); #if GTKCORE Close(); #else Destroy(); #endif DialogClosed?.Invoke(this, EventArgs.Empty); }
static ContentDialogFrame() { IsVisibleProperty.Changed.AddClassHandler <ContentDialogFrame>(new Action <ContentDialogFrame, AvaloniaPropertyChangedEventArgs>((sender, e) => { if (!(bool)e.NewValue) { (sender.Parent as OverlayLayer).Children.Remove(sender); DialogClosed?.Invoke(sender, new EventArgs()); } })); }
public void CancelDialog() { // Trigger the dialog close event, passing a success argument // to any subscribers that indicates it was canceled DialogClosedEventArgs dialogArgs = new DialogClosedEventArgs { Success = false }; DialogClosed.Invoke(this, dialogArgs); mainCanvasGroup.interactable = true; Destroy(gameObject); }
public void CloseDialogSuccess() { Reestr.Customer = SelectedCustomer; Reestr.CustomerId = SelectedCustomer.Id; var model = new ModelDialogParameter <Reestr> { IsSuccess = true, Value = Reestr }; DialogClosed?.Invoke(model); _modalNavigationStore.Close(); }
private async Task OKExecAsync() { IsAuthorizing = true; App.Cloud = new GoogleDriveStorage(Username); if (await App.Cloud.Connect()) { await App.Local.Initialize(); await App.Local.InsertUsername(Username); DialogClosed?.Invoke(this); } else { ErrorMessage = $"Google Drive authorization failed for { Username }."; } IsAuthorizing = false; }
public void Close() { if (Parent != null) { var parentPanel = (Panel)Parent; if (contentControl.Content is IDisposable disposable) { disposable.Dispose(); } foreach (FrameworkElement element in parentPanel.Children) { if (!_tempDisabledElements.Contains(element)) { element.IsEnabled = true; } } parentPanel.Children.Remove(this); Closed?.Invoke(this, new RoutedEventArgs()); DialogClosed?.Invoke(this, new EventsArgs <object>(contentControl.Content)); } }
private async Task RemoveDialogAsync(IDialog dialog, CancellationToken cancellationToken) { await semaphore.WaitAsync(); try { if (dialog is IActivate activatable && activatable.IsActive) { await ScreenExtensions.TryDeactivateAsync(dialog, true, cancellationToken); } if (instanceCounter.ContainsKey(dialog)) { var remaining = instanceCounter[dialog]--; if (remaining > 0) { return; } instanceCounter.Remove(dialog); } Items.Remove(dialog); var topMostDialog = OpenDialogs.LastOrDefault(); if (topMostDialog != null) { topMostDialog.IsDialogEnabled = true; } DialogClosed?.Invoke(this, dialog); } finally { semaphore.Release(); } }
private async void ExecuteSubmitCommand() { ReestrSetting.RecipeId = SelectedRecipe.Id; ReestrSetting.CurrentRecipe = SelectedRecipe; ReestrSetting.Customer = SelectedCustomer; ReestrSetting.CustomerId = SelectedCustomer.Id; if (ReestrSetting.Id == 0) { await _reestrSettingDataService.CreateReestrSetting(ReestrSetting); } else { await _reestrSettingDataService.UpdateReestrSetting(ReestrSetting); } var result = new ModelDialogParameter <ReestrSetting> { IsSuccess = true, Value = (ReestrSetting)ReestrSetting.Clone() }; _modalNavigationStore.Close(); DialogClosed?.Invoke(result); }
public void Show(DialogClosed closedCallback) { ShowDialog(); closedCallback(this); }
protected virtual void OnDialogClosed(EventArgs e) { DialogClosed?.Invoke(this, e); }
public override void OnDismiss(IDialogInterface dialog) { base.OnDismiss(dialog); DialogClosed?.Invoke(this, null); }
public void OnDialogClosed(string path) { DialogClosed?.Invoke(null, new FileDialogClosedEventArgs(path)); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { //get the selected name from shared preference ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); var Name = prefs.GetString("SelectedName", ""); var view = Activity.LayoutInflater.Inflate(Resource.Layout.TrainingNominateDialog, null); TextView tvMessage = view.FindViewById <TextView>(Resource.Id.textView2); TextView tvwResultMsg = Activity.FindViewById <TextView>(Resource.Id.tvwMsgTrnReq); AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Confirm selection"); string Message = "are you nominating " + Name + " for the training?"; //alert.SetMessage(Message); tvMessage.Text = Message; string uri = Values.ApiRootAddress + "training/SaveNominee"; alert.SetPositiveButton("Nominate", async(senderAlert, args) => { AppPreferences appPrefs = new AppPreferences(); var NominateUser = new FormUrlEncodedContent(new Dictionary <string, string> { { "CompanyCode", appPrefs.GetValue(User.CompId) }, // "CO000001", { "TrainingCode", prefs.GetString("TrainingCode", "") }, { "TrainingSerialNo", prefs.GetInt("TrainingSerialNo", 0) + "" }, // 1, { "NomineeEmployeeNo", prefs.GetInt("NomineeEmployeeNo", 0) + "" }, //43, { "ReqEmployeeNo", appPrefs.GetValue(User.EmployeeNo) }, // 694, { "Reason", view.FindViewById <EditText>(Resource.Id.edtTxtReason).Text }, { "Username", appPrefs.GetValue(User.UserId) } }); tvwResultMsg.Text = Values.WaitingMsg; dynamic json = await new DataApi().PostAsync(uri, NominateUser); tvwResultMsg.Text = ""; if (DataApi.IsJsonObject(json)) { if (json != null) { if (json["status"] == 0) { DialogClosed?.Invoke(this, true); tvwResultMsg.SuccessMsg((string)json["message"]); } else { tvwResultMsg.ErrorMsg((string)json["message"]); } //Toast.MakeText(new Activity(), json["message"].ToString(), ToastLength.Short).Show(); } } else { tvwResultMsg.ErrorMsg((string)json); } Dismiss(); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { Dismiss(); //Toast.MakeText(Activity, "Cancelled!", ToastLength.Short).Show(); }); alert.SetView(view); return(alert.Create()); }
private void OKExec() { Result = System.Windows.Forms.DialogResult.OK; DialogClosed?.Invoke(this); }
void OnDialogClosed(object sender, EventArgs e) { DialogClosed?.Invoke(this, e); }
private void CancelButton_Click(object sender, RoutedEventArgs e) { Close(); DialogClosed?.Invoke(this, null); }
private void AcceptButton_Click(object sender, RoutedEventArgs e) { Close(); DialogClosed?.Invoke(this, ViewModel); }
//set callback public void SetDelegate(DialogClosed callback) { this.callback = callback; }
public async Task ShowAsync(FrameworkElement view, string title = "", object parameter = null, DialogParameters dialogParameters = null, bool AlwaysActiveViewOnOpen = true, bool AlwaysDeactiveViewOnClose = true) { var customDialog = new CustomDialog(); if (dialogParameters == null) { dialogParameters = new DialogParameters(); } FillParameters(customDialog, dialogParameters); if (view == null) { throw new Exception("View not found"); } customDialog.Child = view; customDialog.Title = title; var modal = view.DataContext as IModalDialog; if (modal != null) { customDialog.Title = string.IsNullOrEmpty(title) ? modal.Title : title; if (modal.AcceptCommand != null) { customDialog.AcceptCommandText = modal.AcceptLabel; customDialog.AcceptCommand = modal.AcceptCommand; } if (modal.CancelCloseCommand != null) { customDialog.CancelCommandText = modal.CancelLabel; customDialog.CancelCommand = modal.CancelCloseCommand; } } modal = null; var activatable = view.DataContext as INavigationAware; if (activatable != null) { activatable.OnNavigatedTo(new NavigatedToEventArgs() { NavigationMode = Windows.UI.Xaml.Navigation.NavigationMode.New, Parameter = parameter }, null ); } var deactivator = view.DataContext as INavigationAware; if (deactivator != null) { if (Window.Current != null) { var control = Window.Current.Content as UserControl; if (control == null) { return; } var grid = control.Content as Grid; if (grid == null) { Debug.WriteLine("Control must have a Grid as main container"); return; } var popups = grid.Children.OfType <Popup>(); if (popups != null && popups.Any()) { var modalPopup = popups.FirstOrDefault(x => x.Name == "ModalPopup"); } else { var modalPopup = createModalPopup(customDialog, grid, dialogParameters); grid.Children.Add(modalPopup); modalPopup.IsOpen = true; var closedEvent = Observable.FromEventPattern(modalPopup, "Closed"); IDisposable subscriber = null; subscriber = closedEvent.Subscribe(x => { var container = customDialog.FindName("Container") as ContentControl; if (container != null) { container.Content = null; } deactivator.OnNavigatingFrom(new NavigatingFromEventArgs() { NavigationMode = Windows.UI.Xaml.Navigation.NavigationMode.Back, }, null, false); DialogClosed?.Invoke(this, new DialogClosedEventArgs(Result, DialogCloseParameter)); deactivator = null; container = null; customDialog = null; if (view != null) { ((FrameworkElement)view).DataContext = null; view = null; } GC.Collect(); subscriber.Dispose(); closedEvent = null; }); } } } }
private void CancelExec() { Result = System.Windows.Forms.DialogResult.Cancel; DialogClosed?.Invoke(this); }