public CustomDialog(string title, string message, CustomDialogType dialogType, string placeholderText = null)
        {
            DialogTitle     = title;
            DialogMessage   = message;
            DialogInputText = placeholderText;

            InitializeComponent();

            InputTextBox.Focus();
            InputTextBox.CaretIndex = DialogInputText == null ? 0 : DialogInputText.Length;

            Background            = CustomBrushes.WindowBackground;
            ButtonGrid.Background = CustomBrushes.DarkGray;

            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            switch (dialogType)
            {
            case CustomDialogType.OK:
                InputTextBox.Visibility = Visibility.Collapsed;
                CancelButton.Visibility = Visibility.Collapsed;
                break;

            case CustomDialogType.YesNo:
                InputTextBox.Visibility = Visibility.Collapsed;
                OkButton.Content        = "Yes";
                CancelButton.Content    = "No";
                break;

            case CustomDialogType.TextInput:
                break;
            }
        }
Esempio n. 2
0
        public async Task <bool> ShowCustomDialog(CustomDialogType dialogType)
        {
            ContentDialog       dialog;
            ContentDialogResult result;

            switch (dialogType)
            {
            case CustomDialogType.PASSWORD_DIALOG:
                dialog = new SettingsPasswordContentDialog();
                //diaglog.Closing += (sender, args) =>
                //{
                //    // This mean user does click on Primary or Secondary button
                //    if (args.Result == ContentDialogResult.None)
                //    {
                //        args.Cancel = true;
                //    }
                //};
                break;

            case CustomDialogType.LOGIN_PASSWORD_DIALOG:
                dialog = new LoginPasswordContentDialog();
                break;

            case CustomDialogType.ACCOUNTS_DIALOG:
                dialog = new AccountsContentDialog();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(dialogType), dialogType, "The provided dialog type doesnt exists");
            }
            dialog.RequestedTheme = (ElementTheme)_appSettings.AppTheme;
            result = await dialog.ShowAsync();

            if (result == ContentDialogResult.None)
            {
                return(false);
            }
            return(result == ContentDialogResult.Primary);
        }