Example #1
0
        public StartupViewModel(IShell shell, IAppModel appModel)
        {
            shell_    = shell;
            appModel_ = appModel;

            appModel_.LoadConfig();

            var recent = appModel_.GetRecentDocuments();

            BaseList = new ReactiveList <string>(recent);

            OpenRecentDbCommand = ReactiveCommand.Create <string>(uri =>
            {
                if (!OpenBoardView(uri))
                {
                    appModel_.RemoveRecent(uri);
                    appModel_.SaveConfig();

                    BaseList.Remove(uri);

                    DialogCoordinator.Instance.ShowMessageAsync(this, "Ошибка", "База была удалена или перемещена из данной папки");
                }
            });

            NewDbCommand = ReactiveCommand.Create(() => shell.ShowView <WizardView>());

            OpenDbCommand = ReactiveCommand.Create(() =>
            {
                var dialog = new OpenFileDialog()
                {
                    Filter = "SQLite DataBase | *.db",
                    Title  = "Открытие базы"
                };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    OpenBoardView(dialog.FileName);
                }
            });
        }//ctor