Пример #1
0
        public override void Execute(IMenuItemContext context)
        {
            if (!documentListLoader.CanLoad)
            {
                return;
            }

            documentListLoader.SaveCurrentDocumentsToList();

            var        win             = new OpenDocumentListDlg();
            const bool syntaxHighlight = true;
            var        vm = new OpenDocumentListVM(syntaxHighlight, classificationFormatMap, textElementProvider, documentListService, labelMsg => messageBoxService.Ask <string>(labelMsg, ownerWindow: win, verifier: s => string.IsNullOrEmpty(s) ? dnSpy_Resources.OpenList_MissingName : string.Empty));

            win.DataContext = vm;
            win.Owner       = appWindow.MainWindow;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var flvm        = win.SelectedItems.FirstOrDefault();
            var oldSelected = documentListService.SelectedDocumentList;

            if (!(flvm is null))
            {
                documentListLoader.SaveCurrentDocumentsToList();
                documentListService.Add(flvm.DocumentList);
                documentListService.SelectedDocumentList = flvm.DocumentList;
            }

            vm.Save();

            if (flvm is null)
            {
                return;
            }
            var documentList = flvm.DocumentList;

            if (documentList == oldSelected)
            {
                return;
            }

            documentListLoader.Load(documentList, new DsDocumentLoader(documentService, appWindow.MainWindow, null));
        }