Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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.º 3
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;
            }
        }