private void _CreateNewDocument()
        {
            if (_CheckKeepCurrentDocument())
            {
                return;
            }

            var plugins = Client.PluginLoader.Instance.GetPlugins();

            if (plugins != null && plugins.Count() > 0)
            {
                (System.Windows.Application.Current as App).Restart();
                return;
            }

            var doc = ProjectVIEW.CreateNew(this);

            if (doc == null)
            {
                return;
            }

            RecentFilesManager.InsertFile(doc.DocumentPath);

            _Document = doc;

            RaiseChanged(nameof(DocumentView));
        }
        private void _OpenDocument(String fPath)
        {
            if (_CheckKeepCurrentDocument())
            {
                return;
            }

            var filePath = new PathString(fPath);

            // if there's plugins already loaded, we need to load the new document with an application's restart
            var plugins = Client.PluginLoader.Instance.GetPlugins();

            if (plugins != null && plugins.Count() > 0)
            {
                (System.Windows.Application.Current as App).RestartAndLoad(filePath);
                return;
            }

            // load normally;

            var doc = ProjectVIEW.OpenFile(this, filePath);

            if (doc == null)
            {
                RecentFilesManager.RemoveFile(filePath); return;
            }

            RecentFilesManager.InsertFile(doc.DocumentPath);

            DocumentView = doc;
        }
        public bool CloseDocument()
        {
            if (_CheckKeepCurrentDocument())
            {
                return(false);
            }

            DocumentView = new HomeView(this);

            return(true);
        }
        private bool _CheckKeepCurrentDocument()
        {
            if (DocumentView is ProjectVIEW.Project prjv)
            {
                if (prjv.IsDirty)
                {
                    var r = _Dialogs.ShowSaveChangesDialog(prjv.DisplayName);
                    if (r == System.Windows.MessageBoxResult.Cancel)
                    {
                        return(true);
                    }
                    if (r == System.Windows.MessageBoxResult.Yes)
                    {
                        prjv.Save();
                    }
                }

                DocumentView = new HomeView(this); // saved or discarded, we can get rid of it.
            }

            return(false);
        }