예제 #1
0
        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));
        }
예제 #2
0
        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;
        }
예제 #3
0
        public bool CloseDocument()
        {
            if (_CheckKeepCurrentDocument())
            {
                return(false);
            }

            DocumentView = new HomeView(this);

            return(true);
        }
예제 #4
0
        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);
        }