Exemple #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.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;

                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;
            }
        }