Esempio 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);

            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");
            }
        }
Esempio n. 2
0
        public void ServerEdit(Connection serverConnection)
        {
            var msg = new ShowWindowMessage {
                Name = "EditConnection", ViewModel = serverConnection
            };

            Messenger.Default.Send(msg);
        }
Esempio n. 3
0
        private void PrefixSettings()
        {
            var msg = new ShowWindowMessage {
                Name = "PrefixesDialog", ViewModel = Configuration
            };

            Messenger.Default.Send(msg);
        }
Esempio n. 4
0
        public void ServerCreateStore(Connection serverConnection)
        {
            var msg = new ShowWindowMessage {
                Name = "CreateStore", ViewModel = serverConnection, Continuation = ContinueCreateStore
            };

            Messenger.Default.Send(msg);
        }
Esempio n. 5
0
        public void NewConnection()
        {
            var msg = new ShowWindowMessage {
                Name = "NewConnection", ViewModel = this
            };

            Messenger.Default.Send(msg);
        }
Esempio n. 6
0
        public void About()
        {
            var msg = new ShowWindowMessage
            {
                Name      = "AboutDialog",
                ViewModel = new AboutViewModel()
            };

            Messenger.Default.Send(msg);
        }
Esempio n. 7
0
        private void handleOpenWindow(ShowWindowMessage msg)
        {
            bool?  dialogResult = null;
            object returnVal    = null;

            switch (msg.Window)
            {
            case WindowType.SettingsWindow:
                var settingsWindow = new SettingsWindow();
                settingsWindow.Owner = this;
                dialogResult         = settingsWindow.ShowDialog();
                break;

            case WindowType.FetchWindow:
                var fetchWindow = new FetchWindow(msg.Parameter as FetchViewModel);
                fetchWindow.Owner = this;
                dialogResult      = fetchWindow.ShowDialog();
                returnVal         = msg.Parameter;
                break;

            case WindowType.DownloadOutputWindow:
                DownloadOutputWindow.ShowDownloadOutputWindow(this);
                break;

#if VIVIDL
            case WindowType.FormatSelectionWindow:
                var formatSelectionWindow = new FormatSelectionWindow(msg.Parameter as FormatSelectionViewModel);
                formatSelectionWindow.Owner = this;
                dialogResult = formatSelectionWindow.ShowDialog();
                break;

            case WindowType.VideoDataWindow:
                var videoDataWindow = new VideoDataWindow(msg.Parameter as VideoViewModel);
                videoDataWindow.Owner = this;
                dialogResult          = videoDataWindow.ShowDialog();
                break;

            case WindowType.PlaylistDataWindow:
                var playlistDataWindow = new PlaylistDataWindow(msg.Parameter as VideoViewModel);
                playlistDataWindow.Owner = this;
                dialogResult             = playlistDataWindow.ShowDialog();
                break;
#else
            case WindowType.VideoDataWindow:
            case WindowType.PlaylistDataWindow:
                break;
#endif
            }
            msg.Callback?.Invoke(dialogResult, returnVal);
        }
Esempio n. 8
0
 public void Handle(ShowWindowMessage message)
 {
     ((Window)message.ViewModel.View).Owner = this;
 }
Esempio n. 9
0
        private void HandleShowWindowMessage(ShowWindowMessage msg)
        {
            switch (msg.Name)
            {
            case "NewConnection":
            {
                var connectionModel     = new Connection();
                var newConnectionDialog = new ConnectionPropertiesDialog {
                    DataContext = connectionModel
                };
                var dlgResult = newConnectionDialog.ShowDialog();
                if (dlgResult.HasValue && dlgResult.Value)
                {
                    var model = DataContext as MainViewModel;
                    if (model != null)
                    {
                        model.StoreSources.Add(connectionModel);
                        model.Configuration.ConnectionStrings.Add(new NamedConnectionString
                            {
                                Name             = connectionModel.Name,
                                ConnectionString =
                                    connectionModel.ConnectionString.
                                    ToString()
                            });
                        model.Configuration.Save();
                    }
                }
                break;
            }

            case "EditConnection":
            {
                var connectionModel = msg.ViewModel as Connection;
                if (connectionModel != null)
                {
                    var editModel = connectionModel.Clone();
                    var dlg       = new ConnectionPropertiesDialog {
                        DataContext = editModel
                    };
                    var dlgResult = dlg.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value)
                    {
                        connectionModel.Name             = editModel.Name;
                        connectionModel.ConnectionString = editModel.ConnectionString;
                        var mvm = DataContext as MainViewModel;
                        if (mvm != null)
                        {
                            mvm.ServerRefresh(connectionModel);
                        }
                    }
                }
                break;
            }

            case "PrefixesDialog":
            {
                var configuration = msg.ViewModel as PolarisConfigurationModel;
                if (configuration != null)
                {
                    var oldPrefixes = new List <PrefixConfiguration>(configuration.Prefixes);
                    var dlg         = new PrefixesDialog {
                        DataContext = configuration
                    };
                    var dlgResult = dlg.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value)
                    {
                        configuration.Save();
                    }
                    else
                    {
                        configuration.Prefixes = oldPrefixes;
                    }
                }
                break;
            }

            case "CreateStore":
            {
                var connection = msg.ViewModel as Connection;
                if (connection != null)
                {
                    var storeModel            = new Store(connection, Guid.NewGuid().ToString());
                    var storePropertiesDialog = new StorePropertiesDialog
                    {
                        DataContext = storeModel, Title = "New Store Properties"
                    };
                    var dlgResult = storePropertiesDialog.ShowDialog();
                    if (dlgResult.HasValue && dlgResult.Value && msg.Continuation != null)
                    {
                        msg.Continuation(storePropertiesDialog.DataContext);
                    }
                }
                break;
            }

            case "AboutDialog":
            {
                var dlg = new AboutDialog {
                    DataContext = msg.ViewModel
                };
                dlg.ShowDialog();
                break;
            }
            }
        }
        public static void ShowWindowHandler(ShowWindowMessage msg)
        {
            Window view = ServiceLocator.Current.GetInstance(msg.WindowType) as Window;

            view.ShowDialog();
        }