Esempio n. 1
0
        void SetProject(Project project, Boolean stealFocus, Boolean internalOpening)
        {
            if (Tree.Projects.Contains(project))
            {
                return;
            }
            if (activeProject != null)
            {
                CloseProject(true);
            }

            // configure
            var prefs = PluginMain.Settings.GetPrefs(project);

            project.UpdateVars(true);

            SetActiveProject(project);

            // events
            project.BeforeSave += new BeforeSaveHandler(ProjectBeforeSave);
            listenToPathChange  = true;

            // activate
            if (!internalOpening)
            {
                RestoreProjectSession(project);
            }

            if (stealFocus)
            {
                OpenPanel();
                pluginUI.Focus();
            }
            TabColors.UpdateTabColors(Settings);
        }
Esempio n. 2
0
        void CloseProject(bool internalClosing)
        {
            Project project = Tree.Projects.Count > 0 ? Tree.Projects[0] : null; // TODO we need a main project/solution

            if (project == null)
            {
                return;                  // already closed
            }
            listenToPathChange = false;

            // save project prefs
            ProjectPreferences prefs = Settings.GetPrefs(project);

            prefs.ExpandedPaths = Tree.ExpandedPaths;

            if (!PluginBase.MainForm.ClosingEntirely)
            {
                SaveProjectSession();
            }

            activeProject = null;
            if (projectResources != null)
            {
                projectResources.Close();
                projectResources = null;
            }

            if (!internalClosing)
            {
                pluginUI.SetProject(null);
                Settings.LastProject   = "";
                menus.DisabledForBuild = true;

                PluginBase.CurrentSolution = null;
                PluginBase.CurrentProject  = null;
                PluginBase.CurrentSDK      = null;
                PluginBase.MainForm.RefreshUI();

                BroadcastProjectInfo(null);
            }
            TabColors.UpdateTabColors(Settings);
        }
Esempio n. 3
0
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            TextEvent te = e as TextEvent;
            DataEvent de = e as DataEvent;

            switch (e.Type)
            {
            case EventType.UIStarted:
                // for some reason we have to do this on the next message loop for the tree
                // state to be restored properly.
                pluginUI.BeginInvoke((MethodInvoker) delegate
                {
                    BroadcastMenuInfo();
                    BroadcastToolBarInfo();
                    OpenLastProject();
                });
                break;

            case EventType.FileOpening:
                // if this is a project file, we can handle it ourselves
                if (FileInspector.IsProject(te.Value))
                {
                    te.Handled = true;
                    OpenProjectSilent(te.Value);
                }
                break;

            case EventType.FileOpen:
                SetDocumentIcon(MainForm.CurrentDocument);
                OpenNextFile();     // it's safe to open any other files on the queue
                break;

            case EventType.FileSave:
                TabColors.UpdateTabColors(Settings);
                break;

            case EventType.FileSwitch:
                TabColors.UpdateTabColors(Settings);
                break;

            case EventType.ProcessStart:
                break;

            case EventType.ProcessEnd:
                break;

            case EventType.ApplySettings:
                TabColors.UpdateTabColors(Settings);
                break;

            case EventType.Command:
                if (de.Action.StartsWith("ProjectManager."))
                {
                    if (de.Action == ProjectManagerCommands.NewProject)
                    {
                        NewProject();
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.OpenProject)
                    {
                        if (de.Data != null && File.Exists((string)de.Data))
                        {
                            OpenProjectSilent((string)de.Data);
                        }
                        else
                        {
                            OpenProject();
                        }
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.SendProject)
                    {
                        BroadcastProjectInfo(activeProject);
                        e.Handled = true;
                    }
                    else if (de.Action == ProjectManagerCommands.LineEntryDialog)
                    {
                        Hashtable       info    = (Hashtable)de.Data;
                        LineEntryDialog askName = new LineEntryDialog((string)info["title"], (string)info["label"], (string)info["suggestion"]);
                        DialogResult    choice  = askName.ShowDialog();
                        if (choice == DialogResult.OK && askName.Line.Trim().Length > 0 && askName.Line.Trim() != (string)info["suggestion"])
                        {
                            info["suggestion"] = askName.Line.Trim();
                        }
                        if (choice == DialogResult.OK)
                        {
                            e.Handled = true;
                        }
                    }
                }
                break;

            case EventType.Keys:
                e.Handled = HandleKeyEvent(e as KeyEvent);
                break;
            }
        }