Exemplo n.º 1
0
        public DocumentViewModel CreateNew(string documentName)
        {
            if (!IsFolder) throw new InvalidOperationException("Parent must be a folder");

     

            var document = new DocumentViewModel(MainViewModel, GetDocumentPathFromName(Path, documentName), isFolder: false);

            var insertAfter = Children.FirstOrDefault(x => string.Compare(document.Path, x.Path, StringComparison.OrdinalIgnoreCase) >= 0);
            Children.Insert(insertAfter == null ? 0 : Children.IndexOf(insertAfter) + 1, document);
            return document;
        }
        public OpenDocumentViewModel(MainViewModel mainViewModel, DocumentViewModel document)
        {
            Document = document;
            MainViewModel = mainViewModel;
            NuGet = new NuGetDocumentViewModel(mainViewModel.NuGet);
            _dispatcher = Dispatcher.CurrentDispatcher;

            var roslynHost = mainViewModel.RoslynHost;

            _workingDirectory = Directory.GetCurrentDirectory();

            Platform = Platform.X86;
            _executionHost = new ExecutionHost(GetHostExeName(), _workingDirectory,
                roslynHost.DefaultReferences.OfType<PortableExecutableReference>().Select(x => x.FilePath),
                roslynHost.DefaultImports, mainViewModel.NuGetProvider, mainViewModel.ChildProcessManager);
            _executionHost.ExecutionCompleted += OnExecutionCompleted;

            _resultsLock = new object();
            Results = new ObservableCollection<ResultObjectViewModel>();
            BindingOperations.EnableCollectionSynchronization(Results, _resultsLock);

            RunCommand = new DelegateCommand(Run, () => !IsRunning);
            RestartHostCommand = new DelegateCommand(RestartHost);
        }
Exemplo n.º 3
0
 private static string OrderByName(DocumentViewModel x)
 {
     return Regex.Replace(x.Name, "[0-9]+", m => m.Value.PadLeft(100, '0'));
 }
Exemplo n.º 4
0
 public void OpenDocument(DocumentViewModel document)
 {
     var openDocument = OpenDocuments.FirstOrDefault(x => x.Document == document);
     if (openDocument == null)
     {
         openDocument = new OpenDocumentViewModel(this, document);
         OpenDocuments.Add(openDocument);
     }
     CurrentOpenDocument = openDocument;
 }