Пример #1
0
        private async void ChangeActiveWallet(WalletModel wallet)
        {
            if (MainWallet == null)
            {
                this.SetupWallet(wallet);
                return;
            }
            else if (MainWallet.Equals(wallet))
            {
                string             titleSame   = TextTools.RetrieveStringFromResource("Main_Dialog_SameWallet_Title");
                string             messageSame = TextTools.RetrieveStringFromResource("Main_Dialog_SameWallet_Message");
                MessageDialogStyle styleSame   = MessageDialogStyle.Affirmative;
                await _mview.ShowMessageAsync(titleSame, messageSame, styleSame);

                return;
            }

            string             title   = TextTools.RetrieveStringFromResource("Main_Dialog_ActiveWallet_Title");
            string             message = TextTools.RetrieveStringFromResource("Main_Dialog_ActiveWallet_Message");
            MessageDialogStyle style   = MessageDialogStyle.AffirmativeAndNegative;

            var result = await _mview.ShowMessageAsync(title, message, style);

            if (result == MessageDialogResult.Affirmative)
            {
                this.CloseWallet();
                this.SetupWallet(wallet);
            }
        }
Пример #2
0
        private IObservable <RecoveryOptionResult> ErrorHandler(UserError arg)
        {
            if (arg.RecoveryOptions.Count != 2)
            {
                throw new InvalidDataException("Expecting two recovery options, one affirmative, one negative");
            }
            var aff = arg.RecoveryOptions.OfType <RecoveryCommand>().FirstOrDefault(x => x.IsDefault);
            var neg = arg.RecoveryOptions.OfType <RecoveryCommand>().FirstOrDefault(x => x.IsCancel);
            MessageDialogStyle  style   = MessageDialogStyle.AffirmativeAndNegative;
            MetroDialogSettings options = new MetroDialogSettings
            {
                AffirmativeButtonText = aff.CommandName,
                NegativeButtonText    = neg.CommandName,
            };

            return(this.ShowMessageAsync("", arg.ErrorMessage, style, options).ToObservable().Select(r =>
            {
                switch (r)
                {
                case MessageDialogResult.Negative:
                    return RecoveryOptionResult.FailOperation;

                case MessageDialogResult.Affirmative:
                    return RecoveryOptionResult.RetryOperation;

                case MessageDialogResult.FirstAuxiliary:
                    return RecoveryOptionResult.CancelOperation;

                default:
                    throw new ArgumentOutOfRangeException(nameof(r), r, null);
                }
            }));
        }
Пример #3
0
        /// <summary>
        /// Creates a MessageDialog inside of the current window.
        /// </summary>
        /// <param name="title">The title of the MessageDialog.</param>
        /// <param name="message">The message contained within the MessageDialog.</param>
        /// <param name="style">The type of buttons to use.</param>
        /// <param name="settings">Optional Settings that override the global metro dialog settings.</param>
        /// <returns>A task promising the result of which button was pressed.</returns>
        public static Task<MessageDialogResult> ShowMessageAsync(this MetroWindow window, string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null)
        {
            window.Dispatcher.VerifyAccess();
            return window.ShowOverlayAsync().ContinueWith(z =>
                {
                    return (Task<MessageDialogResult>)window.Dispatcher.Invoke(new Func<Task<MessageDialogResult>>(() =>
                        {
                            if (settings == null)
                                settings = window.MetroDialogOptions;

                            //create the dialog control
                            MessageDialog dialog = new MessageDialog(window, settings);
                            dialog.Message = message;
                            dialog.Title = title;
                            dialog.ButtonStyle = style;

                            SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog);
                            dialog.SizeChangedHandler = sizeHandler;

                            return dialog.WaitForLoadAsync().ContinueWith(x =>
                            {
                                if (DialogOpened != null)
                                {
                                    window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs()
                                    {
                                    })));
                                }

                                return dialog.WaitForButtonPressAsync().ContinueWith(y =>
                                {
                                    //once a button as been clicked, begin removing the dialog.

                                    dialog.OnClose();

                                    if (DialogClosed != null)
                                    {
                                        window.Dispatcher.BeginInvoke(new Action(() => DialogClosed(window, new DialogStateChangedEventArgs()
                                        {
                                        })));
                                    }

                                    Task closingTask = (Task)window.Dispatcher.Invoke(new Func<Task>(() => dialog._WaitForCloseAsync()));
                                    return closingTask.ContinueWith<Task<MessageDialogResult>>(a =>
                                        {
                                            return ((Task)window.Dispatcher.Invoke(new Func<Task>(() =>
                                            {
                                                window.SizeChanged -= sizeHandler;

                                                window.messageDialogContainer.Children.Remove(dialog); //remove the dialog from the container

                                                return window.HideOverlayAsync();
                                                //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect

                                            }))).ContinueWith(y3 => y).Unwrap();
                                        });
                                }).Unwrap();
                            }).Unwrap().Unwrap();
                        }));
                }).Unwrap();
        }
Пример #4
0
        public static async Task<string> ShowInputAnio(string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
            //return await metroWindow.ShowInputAsync("Agregar nueva actividad...", "Introduzca la descripción de la actividad");
            var result = await metroWindow.ShowInputAsync("Introduce el año de operación", "Introduzca el año del POA");
            //LoginDialogData result = await metroWindow.ShowLoginAsync("Introduce la nueva actividad", "Introduce descripción");
            int resultInt;
            if (result != null && int.TryParse(result, out resultInt))
            {
                if (result.Length > 4 || resultInt > 3000 || resultInt < 1960)
                {
                    await metroWindow.ShowMessageAsync("El valor introducido no es un año valido.", "Introdujo: " + result);
                    return string.Empty;
                }
                else
                {
                    await metroWindow.ShowMessageAsync("Has introducido", "Introdujo: " + result);
                    return result;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(result))
                {
                    await metroWindow.ShowMessageAsync(
                    "El valor introducido no es válido.", "Introdujo: " + result);
                }
                return string.Empty;
            }


        }
Пример #5
0
 public static async Task<MessageDialogResult> ShowMessage2(string title, string message, MessageDialogStyle dialogStyle)
 {
     var metroWindow = (Application.Current.MainWindow as MetroWindow);
     metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
     return await metroWindow.ShowMessageAsync(title, message, dialogStyle,
         metroWindow.MetroDialogOptions);
 }
 public ShowMessageDialogMessage(string title, string content, MessageDialogStyle style,
                                 ShowMessageDialogResultCallback callback, MetroDialogSettings settings = null) : this(title, content)
 {
     Style    = style;
     Callback = callback;
     Settings = settings;
 }
Пример #7
0
        public static async Task<MessageDialogResult> ShowMessage(MetroWindow Wnd, string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = Wnd as MetroWindow;
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;

            return await metroWindow.ShowMessageAsync("Atenção", message, dialogStyle, metroWindow.MetroDialogOptions);
        }        
Пример #8
0
 /// <summary>
 /// Metro Messagebox 공통메서드
 /// </summary>
 /// <param name="title"></param>
 /// <param name="message"></param>
 /// <param name="style"></param>
 /// <returns></returns>
 public static async Task <MessageDialogResult> ShowMessageAsync(
     string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative)
 {
     //this.
     return(await((MetroWindow)Application.Current.MainWindow)
            .ShowMessageAsync(title, message, style, null));
 }
Пример #9
0
 private async void ShowMessageAsync(string header, string message, MessageDialogStyle dialogStyle)
 {
     await dialogCoordinator.ShowMessageAsync(this, header, message, dialogStyle, new MetroDialogSettings
     {
         AnimateShow = false
     });
 }
        private MessageDialogStyle ConvertToMahAppsDialogStyle(DialogStyle style)
        {
            MessageDialogStyle mahAppsDialogStyle = MessageDialogStyle.Affirmative;

            switch (style)
            {
            case DialogStyle.Affirmative:
                mahAppsDialogStyle = MessageDialogStyle.Affirmative;
                break;

            case DialogStyle.AffirmativeAndNegative:
                mahAppsDialogStyle = MessageDialogStyle.AffirmativeAndNegative;
                break;

            case DialogStyle.AffirmativeAndNegativeAndDoubleAuxiliary:
                mahAppsDialogStyle = MessageDialogStyle.AffirmativeAndNegativeAndDoubleAuxiliary;
                break;

            case DialogStyle.AffirmativeAndNegativeAndSingleAuxiliary:
                mahAppsDialogStyle = MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary;
                break;
            }

            return(mahAppsDialogStyle);
        }
 public MessageDialogEventArgs(string messageHeader, string messageText, MessageDialogStyle dialogStyle)
     : base()
 {
     MessageHeader = messageHeader;
     MessageText   = messageText;
     DialogStyle   = dialogStyle;
 }
Пример #12
0
        public static MessageDialog CreateAndShow(MessageDialogStyle style, string title, string message)
        {
            MessageDialog messageDialog = new MessageDialog(style, title, message);

            messageDialog.Show();
            return(messageDialog);
        }
Пример #13
0
        public MessageDialogResult ShowModalMessageExternal(object context, string title, string message,
                                                            MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null)
        {
            var metroWindow = GetMetroWindow(context);

            return(metroWindow.ShowModalMessageExternal(title, message, style, settings));
        }
Пример #14
0
        public void ShowMessageDialog(string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, CallBack affirmative_callback = null, CallBack negative_callback = null, CallBack alwayse_callback = null, MetroDialogSettings settings = null)
        {
            //MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Theme;
            //var mySettings = new MetroDialogSettings()
            //{
            //	AffirmativeButtonText = "Ok",
            //	//NegativeButtonText = "Go away!",
            //	FirstAuxiliaryButtonText = "Cancel",
            //	//ColorScheme = UseAccentForDialogsMenuItem.IsChecked ? MetroDialogColorScheme.Accented : MetroDialogColorScheme.Theme
            //};

            MessageDialogResult result = this.ShowModalMessageExternal(title, message, style, settings);

            //MessageDialogResult result = await this.ShowMessageAsync(title, message, style);

            if (affirmative_callback != null && result == MessageDialogResult.Affirmative)
            {
                affirmative_callback();
            }

            if (negative_callback != null && result == MessageDialogResult.Negative)
            {
                negative_callback();
            }

            if (alwayse_callback != null)
            {
                alwayse_callback();
            }
        }
Пример #15
0
        /// <summary>
        /// Creates a <see cref="CustomMessageDialog"/> inside of the current window.
        /// </summary>
        /// <param name="window">The MetroWindow</param>
        /// <param name="title">The title of the <see cref="CustomMessageDialog"/>.</param>
        /// <param name="message">The message contained within the <see cref="CustomMessageDialog"/>.</param>
        /// <param name="style">The type of buttons to use.</param>
        /// <param name="settings">Optional settings that override the global metro dialog settings.</param>
        /// <returns>A task promising the result of which button was pressed.</returns>
        public static Task <MessageDialogResult> ShowCustomMessageAsync(
            this MetroWindow window, string title, object message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null)
        {
            settings = settings ?? window.MetroDialogOptions;
            var dialog = new CustomMessageDialog(window, settings)
            {
                Message     = message,
                Title       = title,
                ButtonStyle = style
            };

            var tcs = new TaskCompletionSource <MessageDialogResult>();

            dialog.WaitForButtonPressAsync().ContinueWith(async task =>
            {
                await window.Invoke(async() =>
                {
                    await window.HideMetroDialogAsync(dialog);
                    // The focus may have changed and altered the command-routing path, so suggest that command conditions be re-evaluated.
                    // Note that this may no longer necessary since making the "current document" content control
                    // focusable (which fixed a bunch of command condition re-evaluation issues).
                    CommandManager.InvalidateRequerySuggested();
                });
                tcs.TrySetResult(task.Result);
            });

            window.ShowMetroDialogAsync(dialog, settings ?? window.MetroDialogOptions);

            return(tcs.Task);
        }
Пример #16
0
		public async Task<MessageDialogResult> ShowMessage(string message, string caption, MessageDialogStyle dialogStyle)
		{
			var metroWindow = this;
			metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
			metroWindow.MetroDialogOptions.NegativeButtonText = "No";

			return await metroWindow.ShowMessageAsync(caption, message, dialogStyle, metroWindow.MetroDialogOptions);
		}
Пример #17
0
        /// <summary>
        /// Fonction pour afficher un message d'erreur si l'authentification n'a pas réussi.
        /// </summary>
        /// <param name="message">Le message a afficher s'il y a erreur.</param>
        /// <param name="dialogStyle">Le style de la fenêtre</param>
        /// <returns></returns>
        public Task <MessageDialogResult> AfficherMessage(string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = this as MetroWindow;

            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Theme;

            return(metroWindow.ShowMessageAsync("Erreur de login", message, dialogStyle, metroWindow.MetroDialogOptions));
        }
Пример #18
0
 public ShowMessageDialogMessageWithCallback(string title, string message, MessageDialogStyle style,
                                             Action <MessageDialogResult> callback)
     : base(null, callback)
 {
     Title   = title;
     Message = message;
     Style   = style;
 }
Пример #19
0
        public async Task <MessageDialogResult> ShowErrorAsync(string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);

            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;

            return(await metroWindow.ShowMessageAsync("Error", message, dialogStyle, metroWindow.MetroDialogOptions));
        }
Пример #20
0
 public static async void ShowMessage(this BaseViewModel vm,
                                      string message = "Please wait...", Action <MessageDialogResult> afterMessage = null,
                                      string title   = "Clinical Champion", MessageDialogStyle style = MessageDialogStyle.Affirmative,
                                      MetroDialogSettings extraSettings = null)
 {
     await((App)Application.Current).RealMainWindow
     .ShowMessageAsync(title, message, style, extraSettings)
     .ContinueWith(x => afterMessage?.Invoke(x.Result));
 }
 public Task <MessageDialogResult> ShowMessageAsync(string title,
                                                    string message,
                                                    MessageDialogStyle style = MessageDialogStyle.Affirmative,
                                                    DialogSettings settings  = null)
 {
     return(_shell.Dispatcher.AutoInvoke(
                () => _shell.ShowMessageAsync(title, message, (MetroMessageDialogStyle)style, settings == null ? null : settings.ToMetroDialogSettings())
                .ContinueWith <MessageDialogResult>(r => (MessageDialogResult)r.Result)));
 }
        public static Task <MessageDialogResult> ShowDialog(string title,
                                                            string message, MessageDialogStyle style = MessageDialogStyle.Affirmative,
                                                            MetroDialogSettings settings             = null)
        {
            LogManager.Default.Info($"{title} - {message}");

            return(MainWindow.Instance.ShowMessageAsync(
                       title, message, style, settings));
        }
Пример #23
0
 public async static Task <MessageDialogResult> ShowMessageAsync(
     string title,
     string message,
     MessageDialogStyle style     = MessageDialogStyle.Affirmative,
     MetroDialogSettings settings = null)
 => await WPFHelper.MainWindow?.ShowMessageAsync(
     title,
     message,
     style,
     settings);
Пример #24
0
    public async Task <MessageDialogResult> ShowMessageDialog(
        string title,
        string message,
        MessageDialogStyle style,
        MetroDialogSettings settings)
    {
        MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;

        return(await this.ShowMessageAsync(title, message, style, settings));
    }
Пример #25
0
        public static async Task<MessageDialogResult> ShowMessage(string message1, string message2 = "", MessageDialogStyle dialogStyle = MessageDialogStyle.Affirmative)
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);

            metroWindow.MetroDialogOptions.AffirmativeButtonText = "Valider";
            metroWindow.MetroDialogOptions.NegativeButtonText = "Annuler";
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Inverted;
            return await metroWindow.ShowMessageAsync(message1, message2, dialogStyle,
                metroWindow.MetroDialogOptions);
        }
 public void ShowInformationModern(string message, string title = null, MessageDialogStyle style = MessageDialogStyle.Affirmative)
 {
     try
     {
         var window = (Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive) as MetroWindow);
         window.ShowMessageAsync(title, message, style);
     } catch {
         ShowInformationWindow(title, message);
     }
 }
Пример #27
0
        public async Task <MessageDialogResult> ShowMessageAsync(string message, string title = null,
                                                                 MessageDialogStyle style     = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null)
        {
            var result = await Application.Current.Dispatcher.InvokeAsync(async() =>
            {
                title = title ?? Window.Title;
                return(await Window.ShowMessageAsync(title, message, style, settings));
            }).Task;

            return(await result);
        }
Пример #28
0
        public async Task <bool> ShowWarningAffirmativeDialogAsync(
            string question, string title  = "Warning",
            MessageDialogStyle dialogStyle = MessageDialogStyle.AffirmativeAndNegative)
        {
            var mainview = Application.Current.MainWindow as MetroWindow;

            var dialogResult = await mainview.ShowMessageAsync(title,
                                                               question
                                                               , dialogStyle);

            return(dialogResult == MessageDialogResult.Affirmative);
        }
Пример #29
0
        private async void SaveFromExcelAsync()
        {
            var metroWindow          = (Application.Current.MainWindow as MetroWindow);
            MessageDialogStyle style = MessageDialogStyle.AffirmativeAndNegative;
            var result = await metroWindow.ShowMessageAsync("Confirm", "Are you sure to add these records to database ?", style);

            if (result == MessageDialogResult.Affirmative)
            {
                var controller = await metroWindow.ShowProgressAsync("Adding", "Please wait...");

                controller.SetIndeterminate();


                using (var db = new PCEntities())
                {
                    try
                    {
                        await Task.Run(() =>
                        {
                            var list = pcViewModelList.AsQueryable().ProjectTo <Pc>(config);

                            foreach (Pc item in list)
                            {
                                item.Active = true;
                                db.Pcs.Add(item);
                            }
                        });

                        await db.SaveChangesAsync();

                        await controller.CloseAsync();

                        var mesDialogResult = await metroWindow.ShowMessageAsync("Success", "Saved to Database.");

                        btnSaveExcel.Content   = "Saved";
                        btnSaveExcel.IsEnabled = false;

                        if (mesDialogResult == MessageDialogResult.Affirmative)
                        {
                            metroWindow.FindChild <MetroAnimatedSingleRowTabControl>("MainTabControl").SelectedIndex = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        await controller.CloseAsync();

                        await metroWindow.ShowMessageAsync("Error", ex.Message);

                        Util.WriteLog(ex.Message + "\n" + ex.StackTrace);
                    }
                }
            }
        }
        public async Task <DialogResult> ShowMessageAsync(object context, string title, string message, DialogStyle style = DialogStyle.Affirmative)
        {
            MessageDialogStyle mahAppsDialogStyle = ConvertToMahAppsDialogStyle(style);

            //Task<MessageDialogResult> task = _dialogCoordinator.ShowMessageAsync(context, title, message, mahAppsDialogStyle);
            MessageDialogResult result = await _dialogCoordinator.ShowMessageAsync(context, title, message, mahAppsDialogStyle);

            //MessageDialogResult mahAppsMessageDialogResult = awaiter.GetResult();/*task.Result;*/

            return(ConvertToBaseDialogResult(result));
            //return DialogResult.Affirmative;
        }
Пример #31
0
        internal async Task <bool> ShowMessageDialog
            (string title, string description, MessageDialogStyle messageDialogStyle = MessageDialogStyle.AffirmativeAndNegative)
        {
            var dialog = new Dialogs.MessageDialog(this, title, description, messageDialogStyle);

            await this.ShowMetroDialogAsync(dialog);

            await
            dialog.WaitUntilUnloadedAsync();

            return(dialog.Result);
        }
        /// <summary>
        /// Shows a message to the user, and have the results wrapped in a observable.
        /// </summary>
        /// <param name="this">The user control that hosts the message box.</param>
        /// <param name="title">The title of the message box.</param>
        /// <param name="message">The message to show to the user.</param>
        /// <param name="style">The style settings of the message box.</param>
        /// <param name="settings">General settings of the message box.</param>
        /// <returns>An observable of the result from the message box.</returns>
        public static IObservable <MessageDialogResult> ShowMessage(
            this UserControl @this,
            string title,
            string message,
            MessageDialogStyle style     = MessageDialogStyle.Affirmative,
            MetroDialogSettings settings = null)
        {
            var window = (MetroWindow)Window.GetWindow(@this);

            return(window
                   .ShowMessageAsync(title, message, style, settings)
                   .ToObservable());
        }
Пример #33
0
        private async void Cancel()
        {
            MessageDialogStyle  style    = MessageDialogStyle.AffirmativeAndNegative;
            MetroDialogSettings settings = new MetroDialogSettings {
                AffirmativeButtonText = "Ja, jeg vil avbryte", NegativeButtonText = "Nei, ikke avbryt"
            };
            var answer = await m_popupDialog.Dialog.ShowMessageAsync(this, $"Avbryte redigering?", $"Vil du avbryte redigering av ''{TheDish.Name}'' og forkaste endringer som ikke er lagret?", style, settings);

            if (answer == MessageDialogResult.Affirmative)
            {
                ResetDish();
            }
        }
Пример #34
0
        public static async Task <MessageDialogResult> MessageBox(string msg, string title = "",
                                                                  MessageDialogStyle messageDialogStyle   = MessageDialogStyle.Affirmative,
                                                                  MetroDialogSettings metroDialogSettings = null)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = Application.Current.MainWindow?.Title;
            }

            var mw = (Application.Current.MainWindow as MetroWindow);

            return(await mw.ShowMessageAsync(title, msg, messageDialogStyle, metroDialogSettings));
        }
Пример #35
0
        private bool App_askForExit()
        {
            MessageDialogResult result = MessageDialogResult.Negative;
            MessageDialogStyle  style  = MessageDialogStyle.AffirmativeAndNegative;

            Show();
            result = this.ShowModalMessageExternal("Il trasferimento di alcuni file non è completato", "Vuoi davvero uscire?", style);
            if (result == MessageDialogResult.Affirmative)
            {
                return(true);
            }
            return(false);
        }
Пример #36
0
 public async Task <MessageDialogResult> ShowMessage(string windowTitle, string message,
                                                     MessageDialogStyle dialogStyle, MetroDialogSettings metroDialogSettings)
 {
     foreach (var window in Application.Current.Windows.OfType <MetroWindow>())
     {
         if (window.Name == "FormotsMainWindow")
         {
             window.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
             return(await window.ShowMessageAsync(windowTitle, message, dialogStyle, metroDialogSettings));
         }
     }
     return(MessageDialogResult.Negative);
 }
Пример #37
0
        //NULL = CANCEL 
        public static async Task<string> ShowInput(string Tilte, string Message, MessageDialogStyle dialogStyle, int LimitMaxLength, string DefautText = "")
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
            metroWindow.MetroDialogOptions.NegativeButtonText = "Annuler";
            metroWindow.MetroDialogOptions.AffirmativeButtonText = "Valider";
            metroWindow.MetroDialogOptions.DefaultText = DefautText;

            var result = await metroWindow.ShowInputAsync(Tilte, Message, metroWindow.MetroDialogOptions);

            if (result.Length > LimitMaxLength)
            {
                await ShowMessage2("Nombre de caratcères maximum atteint.", "Vous avez dépassé le nombre de caractères maximum dans la zone de saise. \nLe maximum est de " + LimitMaxLength + " caractères.", MessageDialogStyle.Affirmative);
                return null;
            }

            return result;
        }
Пример #38
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////#############                                Ожидаем пока пользователь нажмет кнопку                             #############/////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public static Task<MessageDialogResult> ShowFix(string text, string title = "Error :(", MessageDialogStyle DialogStyle = MessageDialogStyle.Affirmative, string Affirmative = "ok", string Negative = "close", string FirstAuxiliary = null, string SecondAuxiliary = null)
        {
            //Настройки
            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = Affirmative,
                NegativeButtonText = Negative,
                FirstAuxiliaryButtonText = FirstAuxiliary,
                SecondAuxiliaryButtonText = SecondAuxiliary,
                ColorScheme = (db.conf.theme.FlyoutsControl == "Accent" ? MetroDialogColorScheme.Accented : (db.conf.theme.FlyoutsControl == "Dark" ? MetroDialogColorScheme.Dark : MetroDialogColorScheme.Light)),
                UsingDark = db.conf.theme.them == "Light" ? false : true,
                UseAnimations = true
            };

            //Возвращаем результат
            Affirmative = null; Negative = null; FirstAuxiliary = null; SecondAuxiliary = null;
            return DialogManager.ShowMessageAsync(MainWindow.main, title, (text == null ? "null" : text), DialogStyle, mySettings);
        }
        /// <summary>
        /// Creates a MessageDialog inside of the current window.
        /// </summary>
        /// <param name="title">The title of the MessageDialog.</param>
        /// <param name="message">The message contained within the MessageDialog.</param>
        /// <param name="style">The type of buttons to use.</param>
        /// <returns>A task promising the result of which button was pressed.</returns>
        public static Task<MessageDialogResult> ShowMessageAsync(this MetroWindow window, string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative)
        {
            window.Dispatcher.VerifyAccess();
            return window.ShowOverlayAsync().ContinueWith(z =>
                {
                    return window.Dispatcher.Invoke(new Func<object>(() =>
                        {
                            //create the dialog control
                            MessageDialog dialog = new MessageDialog(window);
                            dialog.Message = message;
                            dialog.ButtonStyle = style;

                            dialog.AffirmativeButtonText = window.MetroDialogOptions.AffirmativeButtonText;
                            dialog.NegativeButtonText = window.MetroDialogOptions.NegativeButtonText;

                            SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, title, dialog);
                            dialog.SizeChangedHandler = sizeHandler;

                            return dialog.WaitForLoadAsync().ContinueWith(x =>
                            {
                                return dialog.WaitForButtonPressAsync().ContinueWith<MessageDialogResult>(y =>
                                {
                                    //once a button as been clicked, begin removing the dialog.

                                    dialog.OnClose();

                                    return ((Task)window.Dispatcher.Invoke(new Func<Task>(() =>
                                    {
                                        window.SizeChanged -= sizeHandler;

                                        window.messageDialogContainer.Children.Remove(dialog); //remove the dialog from the container

                                        return window.HideOverlayAsync();
                                        //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect
                                    }))).ContinueWith(y3 => y).Result.Result;

                                }).Result;
                            });
                        }));
                }).ContinueWith(x => ((Task<MessageDialogResult>)x.Result).Result);
        }
 private async void ShowMetroDialog(Action<MessageBoxResultButton> callback, string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative,
                                    MetroDialogSettings settings = null)
 {
     MetroWindow metroWindow = (MetroWindow)Application.Current.MainWindow;
     MessageDialogResult dialogResult = await metroWindow.ShowMessageAsync(title, message, style, settings);
     if (null != callback)
     {
         MessageBoxResultButton resultButton = MessageBoxResultButton.OK;
         switch (dialogResult)
         {
             case MessageDialogResult.Affirmative:
                 {
                     if (m_Style == MessageDialogStyle.Affirmative)
                     {
                         resultButton = MessageBoxResultButton.OK;
                     }
                     else
                     {
                         resultButton = MessageBoxResultButton.Yes;
                     }
                     break;
                 }
             case MessageDialogResult.Negative:
                 {
                     resultButton = MessageBoxResultButton.No;
                     break;
                 }
             case MessageDialogResult.FirstAuxiliary:
                 {
                     resultButton = MessageBoxResultButton.Cancel;
                     break;
                 }
         }
         callback(resultButton);
     }
 }
Пример #41
0
		public async Task<MessageDialogResult> Show(string title, string message, MessageDialogStyle dialogStyle, MetroDialogSettings settings)
		{
			var metroWindow = (MetroWindow) Application.Current.MainWindow;
			return await metroWindow.ShowMessageAsync(title, message, dialogStyle, settings);
		}
Пример #42
0
 public void ShowMessage(string pTitle, string pMessage, MessageDialogStyle pStyle = MessageDialogStyle.Affirmative, MetroDialogSettings pSettings = null)
 {            
     DialogCoordinator.ShowMessageAsync(this, pTitle, pMessage, pStyle, pSettings);
 }
Пример #43
0
 /// <summary>
 /// Miguel Santana
 /// Created: 2015/03/13
 ///
 /// Show Message Dialog
 /// </summary>
 /// <param name="message"></param>
 /// <param name="title"></param>
 /// <param name="style"></param>
 /// <returns>awaitable Task of MessageDialogResult</returns>
 private async Task<MessageDialogResult> ShowMessage(string message, string title = null, MessageDialogStyle? style = null)
 {
     return await this.ShowMessageDialog(message, title, style);
 }
        public async Task<MessageDialogResult> ShowMessageAsnyc(string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null)
        {
            this.MainWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;

            return await this.MainWindow.ShowMessageAsync(title, message, style, this.MainWindow.MetroDialogOptions);
        }
Пример #45
0
 /// <summary>
 /// Display a generic dialog
 /// </summary>
 /// <param name="title">Dialog title</param>
 /// <param name="text">Dialog text</param>
 /// <param name="style">Dialog style</param>
 public static async void ShowDialog(string title, string text, MessageDialogStyle style)
 {
     var main = (MainWindow)Application.Current.MainWindow;
     await main.ShowMessageAsync(title, text, style);
 }
Пример #46
0
        public static async Task<string> ShowEditActividad(string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
            //return await metroWindow.ShowInputAsync("Agregar nueva actividad...", "Introduzca la descripción de la actividad");
            MetroDialogSettings settings = new MetroDialogSettings() { DefaultText = message };
            var result = await metroWindow.ShowInputAsync("Editar actividad...",
                "Introduzca la descripción de la actividad", settings);
            //LoginDialogData result = await metroWindow.ShowLoginAsync("Introduce la nueva actividad", "Introduce descripción");

            if (result == null)
                return message;
            else
            {
                await metroWindow.ShowMessageAsync("Has introducido", result);
                return result;
            }



        }
Пример #47
0
 /// <summary>
 /// Show Message Dialog
 /// </summary>
 /// <remarks>Miguel Santana 2015/03/11</remarks>
 /// <param name="control">Current control. In most cases use 'this'</param>
 /// <param name="message"></param>
 /// <param name="title"></param>
 /// <param name="style">MessageDialogStyle sets the buttons visible on the dialog</param>
 /// <param name="settings">
 /// <see cref="MetroDialogSettings" /> sets properties for dialog fields and buttons
 /// </param>
 /// <example><see cref="MessageDialogResult" /> result = await <see cref="DialogBox.ShowMessageDialog" />(...)</example>
 /// <returns>awaitable Task of type MessageDialogResult</returns>
 /// <exception cref="WanderingTurtleException" />
 public static Task<MessageDialogResult> ShowMessageDialog(this FrameworkElement control, string message, string title = null, MessageDialogStyle? style = null, MetroDialogSettings settings = null)
 {
     return control.GetVisualParent<MetroWindow>().ShowMessageAsync(title, message, style ?? MessageDialogStyle.Affirmative, settings);
 }
 public Task<MessageDialogResult> ShowInfoMessageBox(string content, MessageDialogStyle dialogStyle = MessageDialogStyle.Affirmative)
 {
     return this.ShowMessageAsync("Info", content, dialogStyle);
 }
Пример #49
0
		public async Task<MessageDialogResult> Show(string title, string message, MessageDialogStyle dialogStyle)
		{
			return await Show(title, message, dialogStyle, new MetroDialogSettings());
		}
Пример #50
0
 public DialogOptionInfo(string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings setting = null)
 {
     Title = title;
     Message = message;
     Style = style;
     Settings = setting;
     CallbackTaskSource = new TaskCompletionSource<MessageDialogResult>();
 }
Пример #51
0
		private async void AsyncMessageTask(string title, string message, MessageDialogStyle style)
		{
			await this.ShowMessageAsync(title, message, style, dlgSettings);
		}
Пример #52
0
		/* async message display */
		private void AsyncMessage(string title, string message, MessageDialogStyle style)
		{
			CancellationToken token;
			TaskScheduler uiSched = TaskScheduler.FromCurrentSynchronizationContext();
			Task.Factory.StartNew(() => AsyncMessageTask(title, message, style), token, TaskCreationOptions.None, uiSched);
		}