コード例 #1
0
ファイル: MessageDialogDemos.cs プロジェクト: RyanFu/MLib
        /// <summary>
        /// Shows the dialog in a seperate window displayed over the current main window.
        /// </summary>
        /// <param name="parentWindow"></param>
        internal void ShowDialogOutside(IMetroWindow parentWindow)
        {
            var viewModel = new MessageDialogViewModel()
            {
                Title   = "Hello!",
                Message = "Welcome to the world of metro!" + string.Join(Environment.NewLine, "abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yz"),

                DefaultResult = (int)ButtonList.NegativButtonValue,
            };

            viewModel.SetCaption((int)ButtonList.AffirmativeButtonValue, "Hi");
            viewModel.SetCaption((int)ButtonList.NegativButtonValue, "Go away!");
            viewModel.SetCaption((int)ButtonList.FirstAuxilaryButtonValue, "Cancel");

            var customDialog = new MWindowDialogLib.Dialogs.CustomDialog(new Demos.Views.MessageView(), viewModel);

            var dlg     = GetService <IContentDialogService>();
            var manager = dlg.Manager;

            var result = manager.ShowModalDialogExternal(parentWindow, customDialog
                                                         , dlg.DialogSettings);

            // user pressed cancel, press ESC or closed via (x) button
            if (result != (int)ButtonList.FirstAuxilaryButtonValue)
            {
                var answer = string.Format("You said: " + viewModel.ConvertResultToString(result));

                dlg.MsgBox.Show(parentWindow, answer, "Result");
            }
        }
コード例 #2
0
ファイル: MessageDialogDemos.cs プロジェクト: RyanFu/MLib
        internal async void ShowDialog(IMetroWindow parentWindow)
        {
            var viewModel = new MessageDialogViewModel()
            {
                Title   = "Hello!",
                Message = "Welcome to the world of metro!",

                DefaultResult = (int)ButtonList.NegativButtonValue
            };

            viewModel.SetCaption((int)ButtonList.AffirmativeButtonValue, "Hi");
            viewModel.SetCaption((int)ButtonList.NegativButtonValue, "Go away!");
            viewModel.SetCaption((int)ButtonList.FirstAuxilaryButtonValue, "Cancel");

            var customDialog = new MWindowDialogLib.Dialogs.CustomDialog(new Demos.Views.MessageView(), viewModel);

            var dlg     = GetService <IContentDialogService>();
            var manager = dlg.Manager;

            var result = await manager.ShowMetroDialogAsync(parentWindow, customDialog);

            // user pressed cancel, press ESC or closed via (x) button
            if (result != (int)ButtonList.FirstAuxilaryButtonValue)
            {
                var answer = string.Format("You said: " + viewModel.ConvertResultToString(result));

                await dlg.MsgBox.ShowAsync(parentWindow, answer, "Result");
            }
        }