Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Register<DisplayToolbarMessage>(this, (action)=>HandleToolbarMessage(action));
            Messenger.Default.Register<ShowWindowMessage>(this, HandleShowWindowMessage);
            Messenger.Default.Register<ShowDialogMessage>(this, "MainWindow", HandleShowDialogMessage);
            Messenger.Default.Register<SelectTabMessage>(this, HandleSelectTabMessage);
            Messenger.Default.Register<AppExitMessage>(this, HandleAppExitMessage);
            Messenger.Default.Register<CloseTabMessage>(this, HandleCloseTabMessage);
            Messenger.Default.Register<ShowFileDialogMessage>(this, HandleShowFileDialogMessage);
            Messenger.Default.Register<AuthenticationRequiredMessage>(this, HandleAuthenticationRequiredMessage);

            if ((this.DataContext as MainViewModel).StoreSources.Count == 0)
            {
                var msg = new ShowDialogMessage(
                    Strings.NoConnectionsTitle,
                    Strings.NoConnectionsMessage,
                    MessageBoxImage.Information,
                    MessageBoxButton.YesNo,
                    (result) =>
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                var showWindowMessage = new ShowWindowMessage {Name = "NewConnection"};
                                Messenger.Default.Send(showWindowMessage);
                            }
                        });
                Messenger.Default.Send(msg, "MainWindow");
            }
        }
Exemplo n.º 2
0
 private void HandleShowDialogMessage(ShowDialogMessage msg)
 {
     var result = MessageBox.Show(this, msg.Content, msg.Title, msg.Button, msg.Icon);
     if (msg.Callback != null) msg.Callback(result);
 }