Пример #1
0
        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);
        }
Пример #2
0
        protected override bool OnDestroyEvent(Event evnt)
        {
            var result = base.OnDestroyEvent(evnt);

            DialogClosed?.Invoke(this, EventArgs.Empty);
            return(result);
        }
Пример #3
0
        public override void OnDismiss(IDialogInterface dialog)
        {
            base.OnDismiss(dialog);
            string name = PFirst + " " + PLast;

            DialogClosed?.Invoke(this, name);
        }
Пример #4
0
 public void HideDialog(object Result)
 {
     HideDialogAnimation(PopUpDialogLayout, PopUpBgLayout);
     DialogClosed?.Invoke(null, new PopupClosedEventArgs()
     {
         result = Result
     });
 }
Пример #5
0
        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);
     }
 }
Пример #8
0
 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);
     }
 }
Пример #10
0
        private void GetResultAndCloseDialog()
        {
            if (!ResultFilename.EndsWith("." + FileFilter))
            {
                ResultFilename = ResultFilename + "." + FileFilter.ToLower();
            }

            Result = System.Windows.Forms.DialogResult.OK;
            DialogClosed?.Invoke(this);
        }
Пример #11
0
        public void CloseDialog()
        {
            Hide();
#if GTKCORE
            Close();
#else
            Destroy();
#endif
            DialogClosed?.Invoke(this, EventArgs.Empty);
        }
Пример #12
0
 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());
         }
     }));
 }
Пример #13
0
        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();
        }
Пример #15
0
        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;
        }
Пример #16
0
 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));
     }
 }
Пример #17
0
        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();
            }
        }
Пример #18
0
        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);
        }
Пример #19
0
 public void Show(DialogClosed closedCallback)
 {
     ShowDialog();
     closedCallback(this);
 }
Пример #20
0
 protected virtual void OnDialogClosed(EventArgs e)
 {
     DialogClosed?.Invoke(this, e);
 }
Пример #21
0
 public override void OnDismiss(IDialogInterface dialog)
 {
     base.OnDismiss(dialog);
     DialogClosed?.Invoke(this, null);
 }
Пример #22
0
 public void OnDialogClosed(string path)
 {
     DialogClosed?.Invoke(null, new FileDialogClosedEventArgs(path));
 }
Пример #23
0
        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());
        }
Пример #24
0
 private void OKExec()
 {
     Result = System.Windows.Forms.DialogResult.OK;
     DialogClosed?.Invoke(this);
 }
Пример #25
0
 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);
 }
Пример #28
0
 //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;
                        });
                    }
                }
            }
        }
Пример #30
0
 private void CancelExec()
 {
     Result = System.Windows.Forms.DialogResult.Cancel;
     DialogClosed?.Invoke(this);
 }