public ProjectWatcher AddProjectToWatcher(string fullPath)
        {
            var fullProjectPathHash = _service.GetHash(fullPath);

            var projectWatcher = GetWatchedProject(fullProjectPathHash);

            if (projectWatcher != null)
            {
                return(projectWatcher);
            }

            var indexOfLastBackSlash = fullPath.LastIndexOf('\\');
            var projectWatchPath     = fullPath.Substring(0, indexOfLastBackSlash);
            var fileToWatch          = fullPath.Substring(indexOfLastBackSlash + 1);

            var newestProjectWatcher = new ProjectWatcher
            {
                ProjectWatcherId    = Guid.NewGuid(),
                FullProjectPathHash = fullProjectPathHash,
                ProjectWatchPath    = projectWatchPath,
                FileToWatch         = fileToWatch
            };

            _projectWatcherRepository.AddProjectWatcher(newestProjectWatcher);

            return(newestProjectWatcher);
        }
        public void WatchTestProject(ProjectWatcher project)
        {
            var fileWatcher = new CustomFileWatcher(_memoryCache, project.ProjectWatcherId, project.ProjectWatchPath, project.FileToWatch);

            fileWatcher.OnChange = _testRunnerService.RunTests;
            _fileWatcherLookUp.Add(project.ProjectWatcherId, fileWatcher);
        }
Ejemplo n.º 3
0
        protected virtual void Runner_ProcessEnded(object sender, int exitCode)
        {
            runner = null;
            DisplayErrors();

            ProjectWatcher.ForceRefresh();
        }
Ejemplo n.º 4
0
        public async Task <bool> StartDebug(EditorViewModel editor, ProjectViewModel currentProject, LoggerResult logger)
        {
            if (currentProject == null)
            {
                await editor.Session.Dialogs.MessageBox(Tr._p("Message", "An executable project must be set as current project in the session explorer in order to process build."),
                                                        MessageBoxButton.OK, MessageBoxImage.Information);

                return(false);
            }

            try
            {
                var projectWatcher = new ProjectWatcher(currentProject.Session, false);
                await projectWatcher.Initialize();

                var executableOutputPath = Path.GetDirectoryName(projectWatcher.CurrentGameExecutable.OutputFilePath);

                var debuggerProcess = await GetDebuggerProcess(editor);

                var projectCouldFirstCompile = new TaskCompletionSource <bool>();
                Task.Run(() => StartDebugHost(executableOutputPath, projectWatcher, projectCouldFirstCompile, RecompilationDelay, debuggerProcess, logger)).Forget();

                return(await projectCouldFirstCompile.Task);
            }
            catch
            {
                return(false);
            }
        }
 public ProjectWatcherTests()
 {
     _project   = new Project(RelPath.FromString("Example.csproj"));
     _watcher   = new Mock <IFilesystemWatcher>(MockBehavior.Strict);
     _scheduler = new TestScheduler();
     _testee    = new ProjectWatcher(_project, _watcher.Object, _scheduler, new Mock <ILogger <ProjectWatcher> >().Object);
 }
 protected override void Run(string filename)
 {
     using (SvnClientWrapper client = new SvnClientWrapper()) {
         string propertyValue = client.GetPropertyValue(Path.GetDirectoryName(filename), "svn:ignore");
         if (propertyValue != null)
         {
             ProjectWatcher watcher       = WatchProjects();
             string         shortFileName = Path.GetFileName(filename);
             StringBuilder  b             = new StringBuilder();
             using (StringReader r = new StringReader(propertyValue)) {
                 string line;
                 while ((line = r.ReadLine()) != null)
                 {
                     if (!string.Equals(line, shortFileName, StringComparison.OrdinalIgnoreCase))
                     {
                         b.AppendLine(line);
                     }
                 }
             }
             client.SetPropertyValue(Path.GetDirectoryName(filename), "svn:ignore", b.ToString());
             MessageService.ShowMessageFormatted("${res:AddIns.Subversion.ItemRemovedFromIgnoreList}", shortFileName);
             watcher.Callback();
         }
     }
 }
Ejemplo n.º 7
0
        public void AddProjectWatcher(ProjectWatcher projectWatcher)
        {
            using (var db = _connectionFactory.CreateConnection())
            {
                var projectWatchers = db.GetCollection <ProjectWatcher>();

                projectWatchers.EnsureIndex(p => p.ProjectWatcherId);

                projectWatchers.Insert(projectWatcher);
            }
        }
Ejemplo n.º 8
0
        public static void Execute(string command, string path1, string path2)
        {
            string           args = String.Format("/command:{0} /path:\"{1}\" /path2:\"{2}\"", command, path1, path2);
            ProcessStartInfo info = new ProcessStartInfo(GetTortoiseProc(), args);

            info.UseShellExecute = true;

            var proc = new Process
            {
                StartInfo           = info,
                EnableRaisingEvents = true
            };

            proc.Exited += (sender, eventArgs) => ProjectWatcher.ForceRefresh();
            proc.Start();
        }
Ejemplo n.º 9
0
        public static void ExecuteCustom(string command, string arguments)
        {
            string args = "/command:" + command + " " + arguments;
            var    info = new ProcessStartInfo(GetTortoiseProc(), args)
            {
                UseShellExecute = true
            };

            var proc = new Process
            {
                StartInfo           = info,
                EnableRaisingEvents = true
            };

            proc.Exited += (sender, eventArgs) => ProjectWatcher.ForceRefresh();
            proc.Start();
        }
Ejemplo n.º 10
0
        static public void Execute(string command, string path)
        {
            string           args = String.Format("{0} \"{1}\"", command, path);
            ProcessStartInfo info = new ProcessStartInfo(GetTortoiseProc(), args);

            info.UseShellExecute = false;
            info.CreateNoWindow  = true;

            var proc = new Process
            {
                StartInfo           = info,
                EnableRaisingEvents = true
            };

            proc.Exited += (sender, eventArgs) => ProjectWatcher.ForceRefresh();
            proc.Start();
        }
Ejemplo n.º 11
0
        public CodeViewModel(StrideAssetsViewModel strideAssetsViewModel) : base(strideAssetsViewModel.SafeArgument(nameof(strideAssetsViewModel)).ServiceProvider)
        {
            projectWatcherTask = Task.Run(async() =>
            {
                var result = new ProjectWatcher(strideAssetsViewModel.Session);
                await result.Initialize();
                return(result);
            });

            workspaceTask = projectWatcherTask.Result.RoslynHost.ContinueWith(roslynHost => roslynHost.Result.Workspace);

            workspaceTask = workspaceTask.ContinueWith(workspaceTask =>
            {
                var projectWatcher = projectWatcherTask.Result;
                var workspace      = workspaceTask.Result;

                // Load and update roslyn workspace with latest compiled version
                foreach (var trackedAssembly in projectWatcher.TrackedAssemblies)
                {
                    var project = trackedAssembly.Project;
                    if (project != null)
                    {
                        workspace.AddOrUpdateProject(project);
                    }
                }

                void TrackedAssemblies_CollectionChanged(object sender, Core.Collections.TrackingCollectionChangedEventArgs e)
                {
                    var project = ((ProjectWatcher.TrackedAssembly)e.Item).Project;
                    if (project != null)
                    {
                        switch (e.Action)
                        {
                        case NotifyCollectionChangedAction.Add:
                            {
                                workspace.AddOrUpdateProject(project);
                                break;
                            }

                        case NotifyCollectionChangedAction.Remove:
                            {
                                workspace.RemoveProject(project.Id);
                                break;
                            }
                        }
                    }
                }
                projectWatcher.TrackedAssemblies.CollectionChanged += TrackedAssemblies_CollectionChanged;

                // TODO: Right now, we simply replace the solution with newly loaded one
                // Ideally, we should keep our existing solution and update it to follow external changes after initial loading (similar to VisualStudioWorkspace)
                // This should provide better integration with background changes and local changes
                projectWatcher.AssembliesChangedBroadcast.LinkTo(new ActionBlock <List <AssemblyChangedEvent> >(events =>
                {
                    if (events.Count == 0)
                    {
                        return;
                    }

                    Dispatcher.InvokeAsync(async() =>
                    {
                        // Update projects
                        foreach (var e in events.Where(x => x.ChangeType == AssemblyChangeType.Project))
                        {
                            var project = e.Project;
                            if (project != null)
                            {
                                await ReloadProject(strideAssetsViewModel.Session, project);
                            }
                        }

                        // Update files
                        foreach (var e in events.Where(x => x.ChangeType == AssemblyChangeType.Source))
                        {
                            var documentId = workspace.CurrentSolution.GetDocumentIdsWithFilePath(e.ChangedFile).FirstOrDefault();
                            if (documentId != null)
                            {
                                workspace.HostDocumentTextLoaderChanged(documentId, new FileTextLoader(e.ChangedFile, null));
                            }
                        }
                    }).Wait();
                }), new DataflowLinkOptions());

                return(workspace);
            });

            // Apply syntax highlighting for tooltips
            keywordBrush = new SolidColorBrush(ClassificationHighlightColorsDark.KeywordColor);
            typeBrush    = new SolidColorBrush(ClassificationHighlightColorsDark.TypeColor);
            keywordBrush.Freeze();
            typeBrush.Freeze();

            // TODO: Update with latest RoslynPad
            //SymbolDisplayPartExtensions.StyleRunFromSymbolDisplayPartKind = StyleRunFromSymbolDisplayPartKind;
            //SymbolDisplayPartExtensions.StyleRunFromTextTag = StyleRunFromTextTag;
        }
Ejemplo n.º 12
0
        private static async Task StartDebugHost(string executableOutputPath, ProjectWatcher projectWatcher, TaskCompletionSource <bool> projectCouldFirstCompile, TimeSpan recompilationDelay, Process debuggerProcess, LoggerResult logger)
        {
            // Clear logger, so we don't fail because of a previous debug session
            logger.Clear();
            logger.HasErrors = false;

            var assemblyRecompiler = new AssemblyRecompiler();

            AssemblyRecompiler.UpdateResult updateResult;

            // TODO: When should we do the NuGet restore? Should we do it only once, or every change?

            try
            {
                updateResult = await assemblyRecompiler.Recompile(projectWatcher.CurrentGameLibrary, logger);

                if (updateResult.HasErrors)
                {
                    // Failure during initial compilation
                    updateResult.Error("Initial LiveScripting compilation failed, can't start live scripting");
                    projectCouldFirstCompile.TrySetResult(false);
                    return;
                }
            }
            catch (Exception e)
            {
                projectCouldFirstCompile.TrySetException(e);
                throw;
            }

            // Notify project could compile succesfully
            projectCouldFirstCompile.TrySetResult(true);

            using (var debugHost = new DebugHost())
            {
                // Start the debug host and wait for it to be available
                debugHost.Start(executableOutputPath, debuggerProcess, logger);
                var debugTarget = await debugHost.GameHost.Target;

                bool firstLoad = true;

                // List of currently loaded assemblies
                var loadedAssemblies = new Dictionary <AssemblyRecompiler.SourceGroup, DebugAssembly>(AssemblyRecompiler.SourceGroupComparer.Default);

                // Listen for game exited event
                var gameExited = new CancellationTokenSource();
                debugHost.GameHost.GameExited += gameExited.Cancel;

                while (!gameExited.IsCancellationRequested)
                {
                    if (!updateResult.HasErrors)
                    {
                        // Assemblies to unload, based on currently loaded ones
                        var assembliesToUnload = updateResult.UnloadedProjects.Select(x => loadedAssemblies[x]).ToList();

                        // Load new assemblies
                        foreach (var loadedProject in updateResult.LoadedProjects)
                        {
                            var assembly = debugTarget.AssemblyLoadRaw(loadedProject.PE, loadedProject.PDB);
                            loadedAssemblies[loadedProject] = assembly;
                        }

                        // Assemblies to load, based on the updated SourceGroup mapping
                        var assembliesToLoad = updateResult.LoadedProjects.Select(x => loadedAssemblies[x]).ToList();

                        // Update runtime game to use new assemblies
                        debugTarget.AssemblyUpdate(assembliesToUnload, assembliesToLoad);

                        // Start game on first load
                        if (firstLoad)
                        {
                            // Arbitrarily launch first game (should be only one anyway?)
                            // TODO: Maybe game is not even necessary anymore and we should just instantiate a "DefaultSceneGame"?
                            var games = debugTarget.GameEnumerateTypeNames();
                            debugTarget.GameLaunch(games.First());

                            firstLoad = false;
                        }
                    }

                    // Wait for any file change that would trigger a recompilation (or a game exit event)
                    await projectWatcher.ReceiveAndDiscardChanges(recompilationDelay, gameExited.Token);

                    // Check if live session exited to avoid recompiling for nothing
                    if (gameExited.IsCancellationRequested)
                    {
                        break;
                    }

                    // Update result for next loop
                    updateResult = await assemblyRecompiler.Recompile(projectWatcher.CurrentGameLibrary, logger);
                }
            }
        }
Ejemplo n.º 13
0
 protected override void Runner_ProcessEnded(object sender, int exitCode)
 {
     base.Runner_ProcessEnded(sender, exitCode);
     ProjectWatcher.HandleFilesDeleted(paths);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            switch (e.Type)
            {
            case EventType.UIStarted:
                ProjectWatcher.Init();
                this.ready = true;
                break;

            // Catches Project change event and display the active project path
            case EventType.Command:
                if (!this.ready)
                {
                    return;
                }
                DataEvent de  = e as DataEvent;
                String    cmd = de.Action;
                if (!cmd.StartsWith("ProjectManager."))
                {
                    return;
                }
                switch (cmd)
                {
                case ProjectManagerEvents.Project:
                    ProjectWatcher.SetProject(de.Data as Project);
                    break;

                case ProjectManagerEvents.TreeSelectionChanged:
                    ProjectWatcher.SelectionChanged();
                    break;

                case ProjectManagerEvents.UserRefreshTree:
                    ProjectWatcher.ForceRefresh();
                    break;

                case ProjectFileActionsEvents.FileBeforeRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileBeforeRename(de.Data as String);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileRename(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileDeleteSilent:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], false);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileDelete:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], true);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileMove:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileMove(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;
                }
                break;
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Disposes the plugin
 /// </summary>
 public void Dispose()
 {
     ProjectWatcher.Dispose();
     this.SaveSettings();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.UIStarted:
                ProjectWatcher.Init();
                this.ready = true;
                break;

            // Catches Project change event and display the active project path
            case EventType.Command:
                if (!this.ready)
                {
                    return;
                }
                DataEvent de  = e as DataEvent;
                String    cmd = de.Action;
                if (!cmd.StartsWithOrdinal("ProjectManager."))
                {
                    return;
                }
                switch (cmd)
                {
                case ProjectManagerEvents.Project:
                    ProjectWatcher.SetProject(de.Data as Project);
                    break;

                case ProjectManagerEvents.TreeSelectionChanged:
                    ProjectWatcher.SelectionChanged();
                    break;

                case ProjectManagerEvents.UserRefreshTree:
                    ProjectWatcher.ForceRefresh();
                    break;

                case ProjectFileActionsEvents.FileBeforeRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileBeforeRename(de.Data as String);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileRename(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileDeleteSilent:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], false);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileDelete:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], true);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileMove:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileMove(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.BuildProject:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleBuildProject();
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.TestProject:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleTestProject();
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.BeforeSave:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleSaveProject((string)de.Data);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;
                }
                break;

            case EventType.FileOpen:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileOpen((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileReload:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileReload((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileModifyRO:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileModifyRO((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileNew:
            case EventType.FileTemplate:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileNew((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.ApplyTheme:
                AnnotatedDocument.ApplyTheme();
                break;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.UIStarted:
                ProjectWatcher.Init();
                this.ready = true;
                break;

            // Catches Project change event and display the active project path
            case EventType.Command:
                if (!this.ready)
                {
                    return;
                }
                DataEvent de  = e as DataEvent;
                String    cmd = de.Action;
                if (!cmd.StartsWithOrdinal("ProjectManager."))
                {
                    return;
                }
                switch (cmd)
                {
                case ProjectManagerEvents.Project:
                    ProjectWatcher.SetProject(de.Data as Project);
                    break;

                case ProjectManagerEvents.TreeSelectionChanged:
                    ProjectWatcher.SelectionChanged();
                    break;

                case ProjectManagerEvents.UserRefreshTree:
                    ProjectWatcher.ForceRefresh();
                    break;

                case ProjectFileActionsEvents.FileBeforeRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileBeforeRename(de.Data as String);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileRename:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileRename(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileDeleteSilent:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], false);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.FilePasted:         //ProjectFileActionsEvents.FilePaste
                    //cannot distinguish between copy and cut, so assume it was copied
                    var files = de.Data as Hashtable;
                    ProjectWatcher.HandleFileCopied((string)files["fromPath"], (string)files["toPath"]);
                    break;


                case ProjectFileActionsEvents.FileDelete:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], true);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileMove:         //this is never called, because CodeRefactor catches it before us
                    try
                    {
                        de.Handled = ProjectWatcher.HandleFileMove(de.Data as String[]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.FileMoved:
                    try
                    {
                        var file = de.Data as Hashtable;
                        ProjectWatcher.HandleFileMoved((string)file["fromPath"], (string)file["toPath"]);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.BuildProject:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleBuildProject();
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.TestProject:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleTestProject();
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;

                case ProjectManagerEvents.BeforeSave:
                    try
                    {
                        de.Handled = ProjectWatcher.HandleSaveProject((string)de.Data);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        de.Handled = true;
                    }
                    break;
                }
                break;

            case EventType.FileOpen:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileOpen((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileReload:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileReload((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileModifyRO:
                try
                {
                    e.Handled = ProjectWatcher.HandleFileModifyRO((e as TextEvent).Value);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.FileNew:
            case EventType.FileTemplate:
                try
                {
                    string file = (e as TextEvent).Value;
                    if (File.Exists(file))
                    {
                        e.Handled = ProjectWatcher.HandleFileNew(file);
                    }
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                    e.Handled = true;
                }
                break;

            case EventType.ApplyTheme:
                AnnotatedDocument.ApplyTheme();
                break;
            }
        }