コード例 #1
0
        public bool GetDialog(string reason, object data, out IDialogService dialogService, out INotifyPropertyChanged vmodel, out INotifyPropertyChanged parent)
        {
            dialogService = null;
            vmodel        = null;
            parent        = null;

            if (reason == "OnRemove")
            {
                if (data.GetType() == typeof(StickerBoardViewModel))
                {
                    var board = (StickerBoardViewModel)data;
                    if (board.Stickers.Count == 0)
                    {
                        return(false);
                    }

                    var dialog = new MessageDialogViewModel();
                    dialog.Header  = "S-MANAGER";
                    dialog.Message = "Are you sure that you want to remove the sticker board?";
                    vmodel         = dialog;

                    parent        = this;
                    dialogService = ParentFacade.DialogService;
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: MessageDialogDemos.cs プロジェクト: RyanFu/MLib
        internal Action ShowDialogFromVM(object context, string startingThread)
        {
            return(() =>
            {
                var message = $"MVVM based messages!\n\nThis dialog was created by {startingThread} Thread with ID=\"{Thread.CurrentThread.ManagedThreadId}\"\n" +
                              $"The current DISPATCHER_THREAD Thread has the ID=\"{Application.Current.Dispatcher.Thread.ManagedThreadId}\"";

                var viewModel = new MessageDialogViewModel()
                {
                    Title = $"Message from VM created by {startingThread}",
                    Message = message,

                    DefaultResult = (int)ButtonList.AffirmativeButtonValue,
                };
                viewModel.SetCaption((int)ButtonList.AffirmativeButtonValue, "OK");

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    var customDialog = new MWindowDialogLib.Dialogs.CustomDialog(new Demos.Views.MessageView(), viewModel);

                    var coord = GetService <IContentDialogService>().Coordinator;

                    coord.ShowMetroDialogAsync(context, customDialog).ContinueWith(t => Console.WriteLine(t.Result));
                }));
            });
        }
コード例 #3
0
        public bool GetDialog(string reason, object data, out IDialogService dialogService, out INotifyPropertyChanged vmodel, out INotifyPropertyChanged parent)
        {
            dialogService = null;
            vmodel        = null;
            parent        = null;

            if (reason == "OnRemove")
            {
                if (data.GetType() == typeof(StickerViewModel))
                {
                    var sticker = (StickerViewModel)data;
                    if (string.IsNullOrEmpty(sticker.Text))
                    {
                        return(false);
                    }

                    var dialog = new MessageDialogViewModel();
                    dialog.Header  = "S-MANAGER";
                    dialog.Message = "Are you sure that you want to remove the sticker?";

                    vmodel        = dialog;
                    dialogService = ((IFacadeViewModel)ParentCollection.ParentViewModel).ParentFacade.DialogService;
                    parent        = ParentCollection.ParentViewModel;
                    return(true);
                }
            }

            return(false);
        }
コード例 #4
0
        public MessageDialogWindow(string windowTitle, string prompt, MessageBoxButton buttons, string checkText = "Don't ask me again", bool isChecked = false)
        {
            InitializeComponent();

            ViewModel = new MessageDialogViewModel()
            {
                WindowTitle        = windowTitle,
                Message            = prompt,
                CheckboxText       = checkText,
                CheckboxVisibility = Visibility.Visible,
                IsChecked          = isChecked
            };

            if (buttons == MessageBoxButton.YesNo)
            {
                btnOkay.Visibility = Visibility.Hidden;
            }
            else
            {
                btnYes.Visibility = Visibility.Hidden;
                btnNo.Visibility  = Visibility.Hidden;
            }

            this.DataContext = ViewModel;
            btnOkay.Focus();
        }
コード例 #5
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");
            }
        }
コード例 #6
0
        void Vm_ShowMessageDialogRequested(MessageDialogTypeEnum messageDialogType, MessageDialogViewModel messageDialogViewModel)
        {
            var caption = messageDialogViewModel.Caption;
            var message = messageDialogViewModel.Message;

            if (messageDialogViewModel.Exception != null)
            {
                message += Environment.NewLine + Environment.NewLine + messageDialogViewModel.Exception.ToString();
            }

            switch (messageDialogType)
            {
            case MessageDialogTypeEnum.InfoMessage:
                MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case MessageDialogTypeEnum.ErrorMessage:
                MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
                break;

            case MessageDialogTypeEnum.Confirmation:
                var result = MessageBox.Show(message, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question);
                messageDialogViewModel.ConfirmationResult = result == MessageBoxResult.OK;
                break;

            default:
                throw new NotSupportedException(messageDialogType.ToString());
            }
        }
コード例 #7
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");
            }
        }
コード例 #8
0
        /// <summary>
        /// Отображает окно запроса с кнопками Да / Нет
        /// </summary>
        public async Task <bool> ShowRequest(string text, WindowType hostIdentifier = WindowType.Root)
        {
            try
            {
                var viewModel = new MessageDialogViewModel(text, false);
                var view      = new MessageDialog {
                    ViewModel = viewModel
                };

                object ret = null;

                await DialogHost.Show(view, Common.GetEnumDescription(hostIdentifier), (o, args) =>
                {
                    ret = args.Parameter;
                });

                if (ret == null)
                {
                    return(false);
                }
                return((bool)ret);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #9
0
        public MessageDialogWindow()
        {
            InitializeComponent();

            ViewModel        = new MessageDialogViewModel();
            this.DataContext = ViewModel;
            btnOkay.Focus();
        }
コード例 #10
0
        public void GivenMessage_WhenInstantiateMessageVm_ThenItFormatsMessageProperly()
        {
            const string message = "@#$%^&111133_7645";

            MessageDialogViewModel messageVmSubject = new MessageDialogViewModel(message);

            Assert.Equal(message, messageVmSubject.Message);
        }
コード例 #11
0
        public MainViewModel()
        {
            _dialogContainerService = new DialogContainerService();
            _jsonSerializer         = new JsonSerializer();

            _ruleManagement     = new RuleManagementViewModel();
            _messageDialog      = new MessageDialogViewModel();
            _validateCommand    = new RelayCommand(this.ValidateCommandHandler, this.CanExecuteValidateCommand);
            _manageRulesCommand = new RelayCommand(this.ManageRulesCommandHandler);
        }
コード例 #12
0
        private void ShowDialog()
        {
            var dialogViewModel = new MessageDialogViewModel()
            {
                Title    = "SampleDialog",
                Message  = "SampleMessage\nDummyDumy",
                IsOkOnly = true,
            };

            NotifyDialogMessageSent?.Invoke(this, new DialogMessageEventArgs(dialogViewModel));
        }
コード例 #13
0
        public async Task ShowMessage(string message, string title)
        {
            var viewModel = new MessageDialogViewModel
            {
                Message = message,
                Title   = title
            };

            var view = new YesNoDialog
            {
                DataContext = viewModel
            };

            await DialogHost.Show(view, "RootDialog");
        }
コード例 #14
0
        public static bool ShowError(Exception ex, string message, string caption = null, bool showCancel = false)
        {
            if (caption == null)
            {
                caption = Strings.TxtError;
            }

            if (ex == null)
            {
                return(false);
            }

            var viewModel = new MessageDialogViewModel();

            viewModel.WriteLog(message, ex);
            return(Show(null, string.Format(CultureInfo.InvariantCulture, "{0}: {1} {2}", message, ex.Message, Strings.TxtSeeLogForDetails), caption, false, showCancel, true));
        }
        /// <inheritdoc />
        public DialogTask ShowMessage
        (
            MessageDialogViewModel viewModel,
            IEnumerable <ButtonConfiguration> buttonConfigurations,
            DialogDisplayLocation displayLocation,
            DialogDisplayBehavior displayBehavior,
            DialogOptions dialogOptions,
            CancellationToken cancellationToken = default
        )
        {
            // Try to resolve the content views of all message models if necessary.
            foreach (var messageDialogModel in viewModel.MessageModels.Where(model => model.ContentViewModel != null))
            {
                messageDialogModel.ContentView = _wrappingViewProvider.GetViewInstance(messageDialogModel.ContentViewModel);
            }

            return(this.Show(viewModel, _dialogAssemblyViewProvider, buttonConfigurations, displayLocation, displayBehavior, dialogOptions, cancellationToken));
        }
コード例 #16
0
        public MessageDialogWindow(string windowTitle, string prompt, string details, MessageBoxButton buttons, MessageBoxImage image)
        {
            InitializeComponent();

            ViewModel = new MessageDialogViewModel()
            {
                WindowTitle        = windowTitle,
                Message            = prompt,
                Details            = details,
                ImageToDisplay     = image,
                DetailsVisibility  = Visibility.Visible,
                CheckboxVisibility = Visibility.Collapsed,
                MessageVisibility  = Visibility.Collapsed
            };

            this.Height = 300;
            this.Width  = 550;

            if (buttons == MessageBoxButton.YesNo)
            {
                btnOkay.Visibility   = Visibility.Hidden;
                btnCancel.Visibility = Visibility.Hidden;
                btnNo.Focus();
            }
            else if (buttons == MessageBoxButton.OKCancel)
            {
                btnYes.Visibility = Visibility.Hidden;
                btnNo.Visibility  = Visibility.Hidden;
                btnOkay.Focus();
            }
            else if (buttons == MessageBoxButton.OK)
            {
                btnYes.Visibility    = Visibility.Hidden;
                btnNo.Visibility     = Visibility.Hidden;
                btnCancel.Visibility = Visibility.Hidden;

                btnOkay.Margin = new Thickness(0, 0, 0, 10); // change Margin so the 'OK' button is center
                btnOkay.Focus();
            }

            this.DataContext = ViewModel;
        }
コード例 #17
0
        public virtual async Task ShowMessage(string message, string title)
        {
            var viewModel = new MessageDialogViewModel
            {
                Message = message,
                Title   = title
            };

            var view = new T
            {
                DataContext = viewModel
            };

            var result = await DialogHost.Show(view, "RootDialog", (sender, args) =>
            {
                // ProressDialog 表示後、フォーカスが外れているのを防ぐため
                view.Focus();
            }, this.DialogClosing);

            this.Result = (MessageBoxResult)result;
        }
コード例 #18
0
        /// <summary>
        /// Выводит простое сообщение
        /// </summary>
        public async Task ShowMessage(string text, WindowType hostIdentifier = WindowType.Root)
        {
            try
            {
                var viewModel = new MessageDialogViewModel(text);
                var view      = new MessageDialog {
                    ViewModel = viewModel
                };

                object ret = null;

                //var r = ViewModelLocator.Current.MessageDialog;

                await DialogHost.Show(view, Common.GetEnumDescription(hostIdentifier), (o, args) =>
                {
                    ret = args.Parameter;
                });
            }
            catch (Exception e)
            {
            }
        }
コード例 #19
0
 public MessageDialogView()
 {
     InitializeComponent();
     DataContext = new MessageDialogViewModel(this, ButtonCancel, ButtonClear, ButtonDelete, ButtonNo, ButtonOk, ButtonSave, ButtonYes, Message);
 }
コード例 #20
0
 public MessageDialog()
 {
     InitializeComponent();
     DataContext = MessageDialogViewModel.getInstance();
 }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: scbj/sb-toolkit
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     var  viewModel = new MessageDialogViewModel("Nouvelle mis à jour", "Une nouvelle mise à jour est disponible. Téléchargez là sans attendre !");
     bool?result    = DialogService.Show(viewModel, false);
 }
コード例 #22
0
        internal void ImportMissingMovies()
        {
            string warningMessage         = string.Format(ResourceHelper.Get(StringKey.ImportMissingMoviesWarningMessage), Sys.Settings.MovieFolder);
            MessageDialogViewModel result = MessageDialogWindow.Show(warningMessage, ResourceHelper.Get(StringKey.Warning), MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result.Result == MessageBoxResult.No)
            {
                return;
            }

            ImportButtonIsEnabled    = false;
            ImportProgressVisibility = Visibility.Visible;

            bool cancelProcess = false;
            int  totalFiles    = 0;
            int  filesCopied   = 0;

            Task importTask = Task.Factory.StartNew(() =>
            {
                Dictionary <string, string[]> missingMovies = GameConverter.GetMissingMovieFiles(Sys.Settings.MovieFolder);
                List <string> discsToInsert = GetDiscsToInsertForMissingMovies(missingMovies);

                totalFiles = missingMovies.Count;

                foreach (string disc in discsToInsert)
                {
                    List <string> driveLetters;

                    do
                    {
                        SetImportStatus($"{ResourceHelper.Get(StringKey.LookingFor)} {disc} ...");
                        driveLetters = GameLauncher.GetDriveLetters(disc);

                        if (driveLetters.Count == 0)
                        {
                            SetImportStatus(string.Format(ResourceHelper.Get(StringKey.InsertToContinue), disc));

                            App.Current.Dispatcher.Invoke(() =>
                            {
                                string discNotFoundMessage = string.Format(ResourceHelper.Get(StringKey.PleaseInsertToContinueCopying), disc);
                                MessageDialogViewModel insertDiscResult = MessageDialogWindow.Show(discNotFoundMessage, ResourceHelper.Get(StringKey.InsertDisc), MessageBoxButton.OKCancel, MessageBoxImage.Warning);

                                cancelProcess = (insertDiscResult.Result == MessageBoxResult.Cancel);
                            });
                        }

                        if (cancelProcess)
                        {
                            return;
                        }
                    } while (driveLetters.Count == 0);

                    SetImportStatus($"{string.Format(ResourceHelper.Get(StringKey.FoundDiscAt), disc)} {string.Join("  ", driveLetters)} ...");

                    // loop over missing files on the found disc and copy to data/movies destination
                    foreach (string movieFile in missingMovies.Where(kv => kv.Value.Any(s => s.Equals(disc, StringComparison.InvariantCultureIgnoreCase)))
                             .Select(kv => kv.Key))
                    {
                        foreach (string drive in driveLetters)
                        {
                            string fullTargetPath = Path.Combine(Sys.Settings.MovieFolder, movieFile);
                            string sourceFilePath = Path.Combine(drive, "ff7", "movies", movieFile);

                            if (File.Exists(sourceFilePath))
                            {
                                if (File.Exists(fullTargetPath))
                                {
                                    SetImportStatus($"{ResourceHelper.Get(StringKey.Overwriting)} {movieFile} ...");
                                }
                                else
                                {
                                    SetImportStatus($"{ResourceHelper.Get(StringKey.Copying)} {movieFile} ...");
                                }

                                File.Copy(sourceFilePath, fullTargetPath, true);
                                filesCopied++;
                                UpdateImportProgress(filesCopied, totalFiles);
                                break;
                            }
                            else
                            {
                                SetImportStatus(string.Format(ResourceHelper.Get(StringKey.FailedToFindAt), movieFile, sourceFilePath));
                            }
                        }
                    }
                }
            });

            importTask.ContinueWith((taskResult) =>
            {
                if (taskResult.IsFaulted)
                {
                    Logger.Error(taskResult.Exception);
                    SetImportStatus($"{ResourceHelper.Get(StringKey.AnErrorOccurredCopyingMovies)}: {taskResult.Exception.GetBaseException().Message}");
                }
                else if (cancelProcess)
                {
                    InitImportMovieOption();
                }
                else
                {
                    if (filesCopied == totalFiles)
                    {
                        SetImportStatus(ResourceHelper.Get(StringKey.SuccessfullyCopiedMovies));
                    }
                    else
                    {
                        SetImportStatus(ResourceHelper.Get(StringKey.FinishedCopyingMoviesSomeFailed));
                    }

                    ImportButtonIsEnabled    = !GameConverter.AllMovieFilesExist(Sys.Settings.MovieFolder);
                    ImportProgressValue      = 0;
                    ImportProgressVisibility = Visibility.Hidden;
                }
            });
        }
コード例 #23
0
 public MessageDialogView(MessageDialogViewModel messageDialogViewModel)
 {
     InitializeComponent();
     DataContext = messageDialogViewModel;
 }
コード例 #24
0
 public MessageDialog()
 {
     InitializeComponent();
     ViewModel   = new MessageDialogViewModel();
     DataContext = ViewModel;
 }