コード例 #1
0
        private void CreateSingletonDocument()
        {
            singletonDocumentType = new DocumentType(
                Constants.SINGLETON_DOCUMENT_TYPE);

            /*
             * Create the document type and register the open
             * document handler.
             */

            applicationManager.RegisterOpenDocumentHandler(
                singletonDocumentType, OpenSingletonDocument);

            /*
             * Create a menu item to open the document.
             */

            ToolStripMenuItem singletonMenuItem = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_SINGLETON,
                "&Singleton Document",
                null, Keys.None, null,
                SingletonMenuItem_Click,
                true); // Add a separator after this item

            ToolStripMenuItem toolsMenu = mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            toolsMenu.DropDownItems.Insert(0, singletonMenuItem);
        }
コード例 #2
0
        private void ActivatePlugin()
        {
            ModuleProxy.GetInstance().Module = this;

            _applicationManager = ApplicationManager.GetInstance();
            _codeAssistManager  = CodeAssistManager.GetInstance();

            ToolStripMenuItem editMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Editor.Constants.UI_EDIT_MENU);

            if (editMenu == null)
            {
                return;
            }

            _codeAssist = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_CODE_ASSIST,
                Resources.MainEditMenuCodeAssist,
                null,
                Keys.Control | Keys.Space, null,
                UI_EDIT_MENU_CODE_ASSIST_Click);

            _codeAssist.Enabled = false;

            editMenu.DropDownItems.Add(_codeAssist);

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(_mainForm_ActiveDocumentChanged);
        }
コード例 #3
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            _findTextHistory    = new List <String>();
            _replaceTextHistory = new List <String>();
            _fileSpecHistory    = new List <String>();

            /*
             * Access the output window.
             */

            _output = ApplicationManager.GetInstance().GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY) as OutputForm;

            if (_output == null)
            {
                return;
            }

            _output.ClearOutputViews();

            /*
             * Create the menu items.
             */

            ToolStripMenuItem editMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Editor.Constants.UI_EDIT_MENU);

            if (editMenu == null)
            {
                return;
            }

            int index = editMenu.DropDownItems.IndexOfKey(
                QuickSharp.Editor.Constants.UI_EDIT_MENU_REPLACE);

            if (index == -1)
            {
                return;
            }

            ToolStripMenuItem findMenu = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_FIND_IN_FILES,
                Resources.MainEditMenuFindInFiles,
                null, Keys.Control | Keys.Shift | Keys.F,
                null, delegate { FindInFiles(true); });

            ToolStripMenuItem replaceMenu = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_REPLACE_IN_FILES,
                Resources.MainEditMenuReplaceInFiles,
                null, Keys.Control | Keys.Shift | Keys.H,
                null, delegate { FindInFiles(false); }, true);

            editMenu.DropDownItems.Insert(index + 1, replaceMenu);
            editMenu.DropDownItems.Insert(index + 1, findMenu);
        }
コード例 #4
0
        private void ActivatePlugin()
        {
            _applicationManager = ApplicationManager.GetInstance();
            _settingsManager    = SettingsManager.GetInstance();

            /*
             * Create the menu item.
             */

            _workspaceMenuItem = MenuTools.CreateMenuItem(
                Constants.UI_VIEW_MENU_WORKSPACE,
                Resources.MainViewMenuWorkspace,
                null,
                Keys.Control | Keys.Alt | Keys.P, null,
                UI_VIEW_MENU_WORKSPACE_Click);

            ToolStripMenuItem viewMenu =
                _mainForm.GetMenuItemByName(
                    QuickSharp.Core.Constants.UI_VIEW_MENU);

            if (viewMenu != null)
            {
                viewMenu.DropDownItems.Add(_workspaceMenuItem);
                viewMenu.DropDownOpening +=
                    new EventHandler(UI_VIEW_MENU_DropDownOpening);
            }

            /*
             * Restore the previous workspace directory.
             */

            if (Directory.Exists(_settingsManager.CurrentWorkspace))
            {
                Directory.SetCurrentDirectory(_settingsManager.CurrentWorkspace);
            }

            /*
             * Create and register the form.
             */

            _workspaceForm = new WorkspaceForm(Constants.DOCKED_FORM_KEY);

            _applicationManager.RegisterDockedForm(_workspaceForm);

            /*
             * Register the options page.
             */

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new WorkspaceOptionsPage()); });
        }
コード例 #5
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            _applicationManager = ApplicationManager.GetInstance();

            /*
             * Create the UI elements.
             */

            _explorerMenuItem = MenuTools.CreateMenuItem(
                Constants.UI_VIEW_MENU_EXPLORER,
                Resources.MainViewMenuExplorer,
                null,
                Keys.Control | Keys.Alt | Keys.E, null,
                UI_VIEW_MENU_EXPLORER_Click);

            ToolStripMenuItem viewMenu =
                _mainForm.GetMenuItemByName(
                    QuickSharp.Core.Constants.UI_VIEW_MENU);

            if (viewMenu != null)
            {
                viewMenu.DropDownItems.Add(_explorerMenuItem);
                viewMenu.DropDownOpening +=
                    new EventHandler(UI_VIEW_MENU_DropDownOpening);
            }

            /*
             * Create and register the form.
             */

            _explorerForm = new ExplorerForm(Constants.DOCKED_FORM_KEY);

            _applicationManager.RegisterDockedForm(_explorerForm);

            /*
             * Register the options pages. Pages are saved in the order they
             * are registered. We have two here so we put the UpdateUI call
             * in the second so it is only called once when all the settings
             * have been updated.
             */

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new ExplorerOptionsPage()); });

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new FileFiltersOptionsPage()); });
        }
コード例 #6
0
        private void ActivatePlugin()
        {
            ToolStripMenuItem toolMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            int index = toolMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS);

            /*
             * If we can't find the options item insert the
             * new items at the top of the menu.
             */

            if (index == -1)
            {
                index = 0;
            }

            _toolMenuRegexHelper = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_REGEX_HELPER,
                Resources.MainToolsMenuRegexHelper,
                null, Keys.None, null,
                UI_TOOLS_MENU_REGEX_HELPER_Click, true);

            toolMenu.DropDownOpening +=
                new EventHandler(toolMenu_DropDownOpening);

            _regexHistory = new List <String>();

            _toolMenuCreateGUID = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_CREATE_GUID,
                Resources.MainToolsMenuCreateGuid,
                null, Keys.None, null,
                UI_TOOLS_MENU_CREATE_GUID_Click);

            _toolMenuLibraryHelper = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_LIBRARY_HELPER,
                Resources.MainToolsMenuLibraryHelper,
                null, Keys.None, null,
                UI_TOOLS_MENU_LIBRARY_HELPER_Click, true);

            toolMenu.DropDownItems.Insert(index, _toolMenuLibraryHelper);
            toolMenu.DropDownItems.Insert(index, _toolMenuCreateGUID);
            toolMenu.DropDownItems.Insert(index, _toolMenuRegexHelper);
        }
コード例 #7
0
        private void CreateDockedForm()
        {
            /*
             * Create and register the form. Each docked form requires
             * a unique identifier (normally a GUID).
             */

            DockedForm dockedForm = new DockedForm(Constants.DOCKED_FORM_KEY);

            applicationManager.RegisterDockedForm(dockedForm);

            /*
             * Create the menu to allow the form to be shown and hidden
             * and add it to the main View menu.
             */

            ToolStripMenuItem dockedFormMenuItem = MenuTools.CreateMenuItem(
                Constants.UI_DOCKED_FORM_MENU_ITEM,
                "Sample &Docked Form", null, Keys.None, null,
                delegate // OnClick event handler
            {
                if (dockedForm.Visible)
                {
                    dockedForm.Hide();
                }
                else
                {
                    dockedForm.Show();
                }
            });

            ToolStripMenuItem viewMenu = mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_VIEW_MENU);

            viewMenu.DropDownItems.Add(dockedFormMenuItem);

            /*
             * Add an event handler to allow us to set the state of the
             * menu item according to the visibility of the form.
             */

            viewMenu.DropDownOpening += delegate
            { dockedFormMenuItem.Checked = dockedForm.Visible; };
        }
コード例 #8
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            _applicationManager =
                ApplicationManager.GetInstance();

            _persistenceManager = _applicationManager.
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            /*
             * Create the UI elements.
             */

            _outputMenuItem = MenuTools.CreateMenuItem(
                Constants.UI_VIEW_MENU_OUTPUT,
                Resources.MainViewMenuOutput,
                null,
                Keys.Control | Keys.Alt | Keys.O, null,
                UI_VIEW_MENU_OUTPUT_Click);

            ToolStripMenuItem viewMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_VIEW_MENU);

            if (viewMenu != null)
            {
                viewMenu.DropDownItems.Add(_outputMenuItem);
                viewMenu.DropDownOpening +=
                    new EventHandler(UI_VIEW_MENU_DropDownOpening);
            }

            /*
             * Create and register the form.
             */

            _outputForm = new OutputForm(Constants.DOCKED_FORM_KEY);

            _applicationManager.RegisterDockedForm(_outputForm);
        }
コード例 #9
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            _buildToolManager = BuildToolManager.GetInstance();
            _settingsManager  = SettingsManager.GetInstance();

            ApplicationManager _applicationManager =
                ApplicationManager.GetInstance();

            _applicationManager.RegisterOpenDocumentHandler(
                Constants.DOCUMENT_TYPE_EXE, OpenIldasmFile);

            _applicationManager.RegisterOpenDocumentHandler(
                Constants.DOCUMENT_TYPE_DLL, OpenIldasmFile);

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new SDKToolsOptionsPage()); });

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(ClientWindow_ActiveDocumentChanged);

            #region Menu Items

            ToolStripMenuItem toolMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            int index = toolMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS);

            /*
             * If the options menu isn't found insert at the top.
             */

            if (index == -1)
            {
                index = 0;
            }

            _toolMenuIldasm = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_ILDASM,
                Resources.MainToolsMenuIldasm,
                null, Keys.None, null, UI_TOOLS_MENU_ILDASM_Click);

            _toolMenuClrDbg = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_CLRDBG,
                Resources.MainToolsMenuClrDbg,
                Resources.Debug, Keys.Control | Keys.F11,
                null, UI_TOOLS_MENU_CLRDBG_Click,
                true);

            toolMenu.DropDownItems.Insert(index, _toolMenuClrDbg);
            toolMenu.DropDownItems.Insert(index, _toolMenuIldasm);
            toolMenu.DropDownOpening +=
                new EventHandler(toolMenu_DropDownOpening);

            ToolStripMenuItem helpMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_HELP_MENU);

            _helpMenuHelpContents = MenuTools.CreateMenuItem(
                Constants.UI_HELP_MENU_HELP_CONTENTS,
                Resources.MainHelpMenuHelpContents,
                Resources.Help,
                Keys.Control | Keys.F1,
                null, UI_HELP_MENU_HELP_CONTENTS_Click);

            _helpMenuContextHelp = MenuTools.CreateMenuItem(
                Constants.UI_HELP_MENU_CONTEXT_HELP,
                Resources.MainHelpMenuContextHelp,
                null, Keys.F1,
                null, UI_HELP_MENU_CONTEXT_HELP_Click, true);

            helpMenu.DropDownItems.Insert(0, _helpMenuContextHelp);
            helpMenu.DropDownItems.Insert(0, _helpMenuHelpContents);
            helpMenu.DropDownOpening +=
                new EventHandler(helpMenu_DropDownOpening);

            #endregion

            UpdateToolMenuStatus();
            UpdateHelpMenuStatus();
        }
コード例 #10
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            /*
             * Web server tools menu option.
             */

            ToolStripMenuItem toolMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            int index = toolMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS);

            /*
             * If menu item not found insert at the top.
             */

            if (index == -1)
            {
                index = 0;
            }

            _toolMenuWebServer = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_WEB_SERVER,
                Resources.MainToolsMenuWebServer,
                null, Keys.None, null,
                UI_TOOLS_MENU_WEB_SERVER_Click,
                true);

            _toolMenuWebServer.Enabled = false;

            toolMenu.DropDownItems.Insert(index, _toolMenuWebServer);

            toolMenu.DropDownOpening +=
                new EventHandler(ToolMenu_DropDownOpening);

            /*
             * Server options.
             */

            ApplicationManager applicationManager =
                ApplicationManager.GetInstance();

            applicationManager.RegisterOptionsPageFactory(
                delegate { return(new WebServerOptionsPage()); });

            _settingsManager = SettingsManager.GetInstance();

            /*
             * One time only: initialize the web server path to the
             * QuickSharp home directory.
             */

            if (_settingsManager.ServerPath == String.Empty)
            {
                /*
                 * Determine the server path.
                 */

                _settingsManager.ServerPath = Path.Combine(
                    applicationManager.QuickSharpHome,
                    Constants.WEBSERVER_EXE);

                _settingsManager.Save();
            }
        }
コード例 #11
0
        /*
         * Toolbar notes: The original design called for the ObjectBrowser buttons to be
         * added to the main toolbar when the form is created and removed when it is closed.
         * A later enhancement required the option of the buttons being added to a separate
         * toolbar. This presented a problem in that the buttons, belonging as they originally
         * did to the form, are created, managed and destroyed within the form and are
         * inaccessible to the module where they need to be created in order to provide
         * a separate toolbar. The solution is to provide a 'permanent' toolbar with dummy
         * buttons to start with which are then replaced by the form when it is created.
         * The form is passed the 'permanent' toolbar on creation and takes over its
         * management until the form is closed. The toolbar is disabled and re-enabled
         * the next time the form is opened. The original behaviour is preserved
         * by passing a null toolbar to the form at which it uses the main application
         * as before.
         */

        private void ActivatePlugin()
        {
            _applicationManager = ApplicationManager.GetInstance();

            /*
             * Menu setup.
             */

            ToolStripMenuItem toolMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            _toolMenuObjectBrowser = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_OBJECT_BROWSER,
                Resources.MainToolsMenuObjectBrowser,
                Resources.ObjectBrowser,
                Keys.Control | Keys.Alt | Keys.J, null,
                UI_TOOLS_MENU_OBJECT_BROWSER_Click,
                true);

            int index = toolMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS);

            /*
             * If menu not found insert at top.
             */

            if (index == -1)
            {
                index = 0;
            }

            toolMenu.DropDownItems.Insert(index, _toolMenuObjectBrowser);

            /*
             * Separate toolbar setup.
             */

            _useMainToolbar = _applicationManager.ClientProfile.HaveFlag(
                ClientFlags.CodeAssistObjectBrowserUseMainToolbar);

            if (!_useMainToolbar)
            {
                _toolbar      = new ToolStrip();
                _toolbar.Name = Constants.UI_OBJECT_BROWSER_TOOLBAR;
                _toolbar.Text = Resources.ToolbarText;

                #region Dummy Buttons

                _toolbar.SuspendLayout();

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_VIEW_MODULES,
                                       Resources.OBViewByContainer,
                                       Resources.ViewByContainer, null));

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_VIEW_NAMESPACES,
                                       Resources.OBViewByNamespace,
                                       Resources.ViewByNamespace, null));

                if (_applicationManager.ClientProfile.HaveFlag(
                        ClientFlags.CodeAssistObjectBrowserIncludeWorkspace))
                {
                    _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                           Constants.UI_TOOLBAR_SHOW_WORKSPACE_ONLY,
                                           Resources.OBShowWorkspaceOnly,
                                           Resources.ShowWorkspaceOnly, null));
                }

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_SHOW_NONPUBLIC,
                                       Resources.OBShowNonPublic,
                                       Resources.ShowNonPublic, null));

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_SHOW_HIDDEN,
                                       Resources.OBShowHidden,
                                       Resources.ShowHidden, null));

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_SHOW_INHERITED,
                                       Resources.OBShowInherited,
                                       Resources.ShowInherited, null));

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_REFRESH_VIEW,
                                       Resources.OBRefresh,
                                       Resources.RefreshView, null));

                _toolbar.Items.Add(MenuTools.CreateToolbarButton(
                                       Constants.UI_TOOLBAR_SHOW_PROPERTIES,
                                       Resources.OBShowProperties,
                                       Resources.PROPERTIES, null));

                foreach (ToolStripItem item in _toolbar.Items)
                {
                    item.Enabled = false;
                }

                _toolbar.ResumeLayout(true);

                #endregion

                _mainForm.AddDockedToolStrip(_toolbar, 0, 50);
            }

            /*
             * OpenDocument handler registration.
             */

            _applicationManager.RegisterOpenDocumentHandler(
                new DocumentType(Constants.OBJECT_BROWSER_DOCUMENT_TYPE),
                OpenObjectBrowser);
        }
コード例 #12
0
ファイル: Module.cs プロジェクト: grtwall/QuickSharp
        private void ActivatePlugin()
        {
            ModuleProxy.GetInstance().Module = this;

            _applicationManager   = ApplicationManager.GetInstance();
            _pluginManager        = PluginManager.GetInstance();
            _sqlConnectionManager = SqlConnectionManager.GetInstance();
            _sqlConnectionManager.Load();

            /*
             * Enable SqlMetal/DMBL extract features if client flag set.
             */

            bool enableSqlMetal =
                _applicationManager.ClientProfile.HaveFlag(
                    ClientFlags.SqlManagerEnableDbmlExtract);

            _output = _applicationManager.GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY) as
                      OutputForm;

            _toolsMenuRunQuery = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_RUN_QUERY,
                Resources.MainToolsMenuRunQuery,
                Resources.RunQuery,
                Keys.F5, null, UI_TOOLBAR_RUN_SQL_QUERY_Click,
                true);

            ToolStripMenuItem toolsMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            int index = toolsMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS);

            /*
             * If menu not found insert at the top.
             */

            if (index == -1)
            {
                index = 0;
            }

            toolsMenu.DropDownItems.Insert(index, _toolsMenuRunQuery);

            /*
             * Create toolbar buttons.
             */

            _toolbarSqlConnection = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_SQL_CONNECTION,
                Resources.ToolbarSqlConnection,
                Resources.SqlConnection,
                UI_TOOLBAR_SQL_CONNECTION_Click,
                true);

            _toolbarSqlConnection.ToolTipText =
                Resources.ToolbarActivateConnection;

            _toolbarSqlConnectionSelect =
                MenuTools.CreateToolbarDropDownButton(
                    Constants.UI_TOOLBAR_SQL_CONNECTION_SELECT, null);

            _toolbarSqlConnectionSelect.DropDownOpening +=
                new EventHandler(
                    ToolbarSqlConnectionSelect_DropDownOpening);

            _toolbarSqlRunQuery = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_SQL_RUN_QUERY,
                Resources.ToolbarSqlRunQuery,
                Resources.RunQuery,
                UI_TOOLBAR_RUN_SQL_QUERY_Click);

            _toolbarSqlExtractDbml = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_SQL_EXTRACT_DBML,
                Resources.ToolbarSqlExtractDbml,
                Resources.ExtractDbml,
                UI_TOOLBAR_SQL_EXTRACT_DBML_Click);

            _mainForm.MainToolbar.Items.Add(_toolbarSqlConnection);
            _mainForm.MainToolbar.Items.Add(_toolbarSqlConnectionSelect);
            _mainForm.MainToolbar.Items.Add(_toolbarSqlRunQuery);

            if (enableSqlMetal)
            {
                _mainForm.MainToolbar.Items.Add(_toolbarSqlExtractDbml);
            }

            _mainForm.FormClosing +=
                new FormClosingEventHandler(MainForm_FormClosing);

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(ClientWindow_ActiveDocumentChanged);

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new SqlConnectionsOptionsPage()); });

            if (enableSqlMetal)
            {
                _applicationManager.RegisterOptionsPageFactory(
                    delegate { return(new SqlMetalOptionsPage()); });
            }

            _applicationManager.FileSystemChange +=
                new MessageHandler(UpdateUI);

            /*
             * We don't have any build tools but we want SQL files
             * recognised as source files. Register with the
             * non-tool source files list in the application store.
             */

            ApplicationStorage appStore = ApplicationStorage.GetInstance();

            /*
             * We have no dependency on the BuildTools plugin so we
             * can't assume the non-tool source list has been created.
             * Use the Get method to create the list if it doesn't exist.
             */

            List <String> nonToolSourceTypes = appStore.Get(
                Constants.APP_STORE_KEY_NON_TOOL_SOURCE_TYPES,
                typeof(List <String>)) as List <String>;

            if (nonToolSourceTypes != null)
            {
                nonToolSourceTypes.Add(Constants.DOCUMENT_TYPE_SQL);
            }

            UpdateUI();
        }
コード例 #13
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            /*
             * As this plugin only provides support for a scintilla object, not
             * a form or any other UI it must not register any document types
             * or set any document handlers.
             * On its own this plugin will gracefully reject calls to open
             * documents via the 'no handler register' alert so it is safe to
             * include standalone but without a UI it won't be much use!
             */

            UserContent.DeployContent(Constants.PLUGIN_NAME);

            _applicationManager = ApplicationManager.GetInstance();

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new EditorOptionsPage()); });

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new GlobalOptionsPage()); });

            _macroManager = MacroManager.GetInstance();

            /*
             * Define the snippets folder.
             */

            _snippetsFolderPath = Path.Combine(
                ApplicationManager.GetInstance().QuickSharpUserHome,
                Constants.SNIPPETS_FOLDER);

            /*
             * Keyboard Shortcuts Note
             *
             * Most menu commands are the sole access point for editor functions and are
             * enabled and disabled according to the state determined by their action state
             * handlers. In most cases the state of these commands changes only when the documents
             * are opened, closed or activated. This is important because the shortcut keys
             * only work when the corresponding menu is enabled; often a shortcut key is accessed
             * before the menu is opened (at which point the state is updated) and must be in the
             * correct state when the doucment is opened or activated. However, the status of
             * some commands (clipboard or selection dependent) changes continuously during
             * editing and it is not feasible to have these updated only when the menus are opened.
             * These commands are represented in the menus using text-only shortcut key assignments
             * and are activated using the key mappings provided by the Scintilla editor,
             * not via the menus. The action state handlers for these actions are provided only
             * to maintain the correct visual state of the corresponding menu commands.
             *
             * This means that, whereas other menu-based commands can have their shortcut
             * keys re-mapped simply by changing the assignment on the menu item, these cannot:
             * the shortcut keys presented on the menus must match the Scintilla mappings. (See
             * 'commands.cs' in the ScintillaNet project to see the relevant mappings.)
             */

            #region Menu Creation

            bool enableCodeFeatures = !_applicationManager.ClientProfile.
                                      HaveFlag(ClientFlags.EditorDisableCodeFeatures);

            /*
             * File Menu
             */

            #region Create Items

            _fileMenuPageSetup = MenuTools.CreateMenuItem(
                Constants.UI_FILE_MENU_PAGE_SETUP,
                Resources.MainFileMenuPageSetup,
                Resources.PageSetup,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _fileMenuPrintPreview = MenuTools.CreateMenuItem(
                Constants.UI_FILE_MENU_PRINT_PREVIEW,
                Resources.MainFileMenuPrintPreview,
                null,
                Keys.None, null,
                UI_EDIT_MENU_ITEM_Click);

            _fileMenuPrint = MenuTools.CreateMenuItem(
                Constants.UI_FILE_MENU_PRINT,
                Resources.MainFileMenuPrint,
                Resources.Print,
                Keys.Control | Keys.P, null, UI_EDIT_MENU_ITEM_Click,
                true);

            #endregion

            _fileMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_FILE_MENU);

            int i = _fileMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_FILE_MENU_SAVE_ALL);

            if (i != -1)
            {
                i++; // Insert after
                _fileMenu.DropDownItems.Insert(i, _fileMenuPrint);
                _fileMenu.DropDownItems.Insert(i, _fileMenuPrintPreview);
                _fileMenu.DropDownItems.Insert(i, _fileMenuPageSetup);
            }

            /*
             * Edit Menu
             */

            #region Create Items

            _editMenu = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU,
                Resources.MainEditMenu,
                null,
                Keys.None, null, null);

            _editMenuUndo = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_UNDO,
                Resources.MainEditMenuUndo,
                Resources.Undo,
                Keys.None, "Ctrl+Z", UI_EDIT_MENU_ITEM_Click);

            _editMenuRedo = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_REDO,
                Resources.MainEditMenuRedo,
                Resources.Redo,
                Keys.None, "Ctrl+Y", UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuCut = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_CUT,
                Resources.MainEditMenuCut,
                Resources.Cut,
                Keys.None, "Ctrl+X", UI_EDIT_MENU_ITEM_Click);

            _editMenuCopy = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_COPY,
                Resources.MainEditMenuCopy,
                Resources.Copy,
                Keys.None, "Ctrl+C", UI_EDIT_MENU_ITEM_Click);

            _editMenuPaste = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_PASTE,
                Resources.MainEditMenuPaste,
                Resources.Paste,
                Keys.None, "Ctrl+V", UI_EDIT_MENU_ITEM_Click);

            _editMenuSelectAll = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_SELECT_ALL,
                Resources.MainEditMenuSelectAll,
                null,
                Keys.None, "Ctrl+A", UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuFind = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_FIND,
                Resources.MainEditMenuFind,
                Resources.Find,
                Keys.Control | Keys.F, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuReplace = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_REPLACE,
                Resources.MainEditMenuReplace,
                null,
                Keys.Control | Keys.H, null, UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuGoTo = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_GOTO,
                Resources.MainEditMenuGoTo,
                null,
                Keys.Control | Keys.G, null, UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuMacros = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MACROS,
                Resources.MainEditMenuMacros,
                null,
                Keys.None, null, null);

            _editMenuMacroRecord = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MACRO_RECORD,
                Resources.MainEditMenuMacroStartRecord,
                null,
                Keys.Control | Keys.Shift | Keys.R, null,
                UI_EDIT_MENU_ITEM_Click);

            _editMenuMacroPlay = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MACRO_PLAY,
                Resources.MainEditMenuMacroPlay,
                null,
                Keys.Control | Keys.Shift | Keys.P, null,
                UI_EDIT_MENU_ITEM_Click);

            _editMenuMacroLoad = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MACRO_LOAD,
                Resources.MainEditMenuMacroLoad,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuMacroSave = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MACRO_SAVE,
                Resources.MainEditMenuMacroSave,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuSnippets = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_SNIPPETS,
                Resources.MainEditMenuSnippets,
                null,
                Keys.None, null, null);

            _editMenuSnippetsManage = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MANAGE_SNIPPETS,
                Resources.MainEditMenuManageSnippets,
                null,
                Keys.None, null, UI_EDIT_MENU_MANAGE_SNIPPETS_Click);

            _editMenuBookmarks = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_BOOKMARKS,
                Resources.MainEditMenuBookmarks,
                null,
                Keys.None, null, null);

            _editMenuBookmarkToggle = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_TOGGLE_BOOKMARK,
                Resources.MainEditMenuToggleBookmark,
                null,
                Keys.F3,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuBookmarksClear = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_CLEAR_BOOKMARKS,
                Resources.MainEditMenuClearBookmarks,
                null,
                Keys.Shift | Keys.F3,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuBookmarkNext = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_NEXT_BOOKMARK,
                Resources.MainEditMenuNextBookmark,
                null,
                Keys.F4,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuBookmarkPrevious = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_PREV_BOOKMARK,
                Resources.MainEditMenuPreviousBookmark,
                null,
                Keys.Shift | Keys.F4,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuFolding = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_FOLDING,
                Resources.MainEditMenuFolding,
                null,
                Keys.None, null, null);

            _editMenuFoldToggle = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_TOGGLE_FOLD,
                Resources.MainEditMenuToggleFold,
                null,
                Keys.F8,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuFoldCollapseAll = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_COLLAPSE_ALL,
                Resources.MainEditMenuCollapseAll,
                null,
                Keys.Control | Keys.F8,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuFoldExpandAll = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_EXPAND_ALL,
                Resources.MainEditMenuExpandAll,
                null,
                Keys.Shift | Keys.F8,
                null, UI_EDIT_MENU_ITEM_Click);

            _editMenuEncoding = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ENCODING,
                Resources.MainEditMenuEncoding,
                null,
                Keys.None, null, null);

            _editMenuEncodingANSI = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ENCODING_ANSI,
                Resources.MainEditMenuEncodingANSI,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuEncodingUTF8 = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ENCODING_UTF8,
                Resources.MainEditMenuEncodingUTF8,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuEncodingUTF16BE = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ENCODING_UTF16BE,
                Resources.MainEditMenuEncodingUTF16BE,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuEncodingUTF16LE = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ENCODING_UTF16LE,
                Resources.MainEditMenuEncodingUTF16LE,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuLineEnding = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_LINE_ENDING,
                Resources.MainEditMenuLineEnding,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuLineEndingCRLF = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_LINE_ENDING_CRLF,
                Resources.MainEditMenuLineEndingCRLF,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuLineEndingLF = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_LINE_ENDING_LF,
                Resources.MainEditMenuLineEndingLF,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuLineEndingCR = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_LINE_ENDING_CR,
                Resources.MainEditMenuLineEndingCR,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuAdvanced = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_ADVANCED,
                Resources.MainEditMenuAdvanced,
                null,
                Keys.None, null, null,
                true);

            _editMenuMakeUppercase = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MAKE_UPPERCASE,
                Resources.MainEditMenuMakeUppercase,
                null,
                Keys.None, "Ctrl+Shift+U", UI_EDIT_MENU_ITEM_Click);

            _editMenuMakeLowercase = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_MAKE_LOWERCASE,
                Resources.MainEditMenuMakeLowercase,
                null,
                Keys.None, "Ctrl+U", UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuLineComment = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_LINE_COMMENT,
                Resources.MainEditMenuLineComment,
                null,
                Keys.Control | Keys.Q, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuBlockComment = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_BLOCK_COMMENT,
                Resources.MainEditMenuBlockComment,
                null,
                Keys.Control | Keys.Shift | Keys.Q, null,
                UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuViewWhitespace = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_VIEW_WHITESPACE,
                Resources.MainEditMenuViewWhitespace,
                null,
                Keys.Control | Keys.W, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuTrimWhitespace = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_TRIM_WHITESPACE,
                Resources.MainEditMenuTrimWhitespace,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click,
                true);

            _editMenuWordWrap = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_WORD_WRAP,
                Resources.MainEditMenuWordWrap,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click);

            _editMenuSetReadOnly = MenuTools.CreateMenuItem(
                Constants.UI_EDIT_MENU_SET_READ_ONLY,
                Resources.MainEditMenuSetReadOnly,
                null,
                Keys.None, null, UI_EDIT_MENU_ITEM_Click,
                true);

            #endregion

            int fileMenuIndex =
                _mainForm.MainMenu.Items.IndexOf(_fileMenu);

            if (fileMenuIndex == -1)
            {
                _mainForm.MainMenu.Items.Add(_editMenu);
            }
            else
            {
                _mainForm.MainMenu.Items.Insert(
                    fileMenuIndex + 1, _editMenu);
            }

            _editMenu.DropDownItems.Add(_editMenuUndo);
            _editMenu.DropDownItems.Add(_editMenuRedo);
            _editMenu.DropDownItems.Add(_editMenuCut);
            _editMenu.DropDownItems.Add(_editMenuCopy);
            _editMenu.DropDownItems.Add(_editMenuPaste);
            _editMenu.DropDownItems.Add(_editMenuSelectAll);
            _editMenu.DropDownItems.Add(_editMenuFind);
            _editMenu.DropDownItems.Add(_editMenuReplace);
            _editMenu.DropDownItems.Add(_editMenuGoTo);
            _editMenu.DropDownItems.Add(_editMenuMacros);
            _editMenuMacros.DropDownItems.Add(_editMenuMacroRecord);
            _editMenuMacros.DropDownItems.Add(_editMenuMacroPlay);
            _editMenuMacros.DropDownItems.Add(_editMenuMacroLoad);
            _editMenuMacros.DropDownItems.Add(_editMenuMacroSave);

            if (Directory.Exists(_snippetsFolderPath))
            {
                _editMenu.DropDownItems.Add(_editMenuSnippets);
                _editMenuSnippets.DropDownItems.Add(_editMenuSnippetsManage);
            }

            _editMenu.DropDownItems.Add(_editMenuBookmarks);
            _editMenuBookmarks.DropDownItems.Add(_editMenuBookmarkToggle);
            _editMenuBookmarks.DropDownItems.Add(_editMenuBookmarksClear);
            _editMenuBookmarks.DropDownItems.Add(_editMenuBookmarkNext);
            _editMenuBookmarks.DropDownItems.Add(_editMenuBookmarkPrevious);
            _editMenu.DropDownItems.Add(_editMenuFolding);
            _editMenuFolding.DropDownItems.Add(_editMenuFoldToggle);
            _editMenuFolding.DropDownItems.Add(_editMenuFoldCollapseAll);
            _editMenuFolding.DropDownItems.Add(_editMenuFoldExpandAll);
            _editMenu.DropDownItems.Add(_editMenuEncoding);
            _editMenuEncoding.DropDownItems.Add(_editMenuEncodingANSI);
            _editMenuEncoding.DropDownItems.Add(_editMenuEncodingUTF8);
            _editMenuEncoding.DropDownItems.Add(_editMenuEncodingUTF16BE);
            _editMenuEncoding.DropDownItems.Add(_editMenuEncodingUTF16LE);
            _editMenu.DropDownItems.Add(_editMenuLineEnding);
            _editMenuLineEnding.DropDownItems.Add(_editMenuLineEndingCRLF);
            _editMenuLineEnding.DropDownItems.Add(_editMenuLineEndingCR);
            _editMenuLineEnding.DropDownItems.Add(_editMenuLineEndingLF);
            _editMenu.DropDownItems.Add(_editMenuAdvanced);
            _editMenuAdvanced.DropDownItems.Add(_editMenuMakeUppercase);
            _editMenuAdvanced.DropDownItems.Add(_editMenuMakeLowercase);

            if (enableCodeFeatures)
            {
                _editMenuAdvanced.DropDownItems.Add(_editMenuLineComment);
                _editMenuAdvanced.DropDownItems.Add(_editMenuBlockComment);
            }

            _editMenuAdvanced.DropDownItems.Add(_editMenuViewWhitespace);
            _editMenuAdvanced.DropDownItems.Add(_editMenuTrimWhitespace);
            _editMenuAdvanced.DropDownItems.Add(_editMenuWordWrap);
            _editMenuAdvanced.DropDownItems.Add(_editMenuSetReadOnly);

            #endregion

            _fileMenu.DropDownOpening +=
                new EventHandler(UI_FILE_MENU_DropDownOpening);
            _editMenu.DropDownOpening +=
                new EventHandler(UI_EDIT_MENU_DropDownOpening);
            _editMenuSnippets.DropDownOpening +=
                new EventHandler(UI_EDIT_MENU_SNIPPETS_DropDownOpening);
            _editMenuSnippets.Enabled          = false;
            _editMenuEncoding.DropDownOpening +=
                new EventHandler(UI_EDIT_MENU_ENCODING_DropDownOpening);
            _editMenuLineEnding.DropDownOpening +=
                new EventHandler(UI_EDIT_MENU_LINE_ENDING_DropDownOpening);

            _cursorPositionIndicator      = new ToolStripStatusLabel();
            _cursorPositionIndicator.Name =
                Constants.UI_STATUSBAR_CURSOR_POSITION_INDICATOR;
            _cursorPositionIndicator.Spring    = true;
            _cursorPositionIndicator.TextAlign = ContentAlignment.MiddleRight;

            _mainForm.StatusBar.Items.Add(_cursorPositionIndicator);

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(ClientWindow_ActiveDocumentChanged);

            /*
             * Create initial version of the snippets menu to
             * activate the shortcuts keys.
             */

            CreateSnippetsMenu();
        }
コード例 #14
0
        private void Module_PluginPostActivate()
        {
            /*
             * Find the templates and create the menus from the items found.
             * Need to do this here in case other plugins contribute templates.
             */

            _documentManager = DocumentManager.GetInstance();

            _templateFolderPath = Path.Combine(
                _applicationManager.QuickSharpUserHome,
                Constants.TEMPLATE_FOLDER);

            if (!Directory.Exists(_templateFolderPath))
            {
                return;
            }

            ToolStripMenuItem fileMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_FILE_MENU);

            if (fileMenu == null)
            {
                return;
            }

            int newMenuIndex = fileMenu.DropDownItems.IndexOfKey(
                QuickSharp.Core.Constants.UI_FILE_MENU_NEW);

            if (newMenuIndex == -1)
            {
                return;
            }

            _newFromTemplate = MenuTools.CreateMenuItem(
                Constants.UI_FILE_MENU_NEW_FROM_TEMPLATE,
                Resources.MainFileMenuNewFromTemplate,
                null, Keys.None, null, null);

            fileMenu.DropDownItems.Insert(
                newMenuIndex + 1, _newFromTemplate);

            CreateTemplateMenu(_templateFolderPath, _newFromTemplate);

            /*
             * Find the default document template.
             */

            foreach (string file in Directory.GetFiles(_templateFolderPath))
            {
                string name = Path.GetFileNameWithoutExtension(
                    Path.GetFileName(file));

                if (name == Constants.DEFAULT_DOCUMENT_NAME)
                {
                    _defaultDocumentPath = file;
                    break;
                }
            }

            /*
             * Creating files from templates relies on the open document
             * handlers for the template document types so we need to
             * disable templates if there are no handlers available.
             */

            if (_applicationManager.OpenDocumentHandlers.Count == 0)
            {
                _newFromTemplate.Enabled = false;
                return;
            }

            /*
             * If we have a default document claim the new document
             * type and handler.
             */

            if (_defaultDocumentPath != null)
            {
                _applicationManager.NewDocumentType =
                    new DocumentType(_defaultDocumentPath);

                _applicationManager.NewDocumentHandler =
                    TemplateNewDocumentHandler;
            }
        }
コード例 #15
0
ファイル: Module.cs プロジェクト: watchsnow/QuickSharp
        private void ActivatePlugin()
        {
            ModuleProxy.GetInstance().Module = this;

            _applicationManager = ApplicationManager.GetInstance();
            _applicationStorage = ApplicationStorage.GetInstance();

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new BuildToolOptionsPage()); });

            if (!_applicationManager.ClientProfile.HaveFlag(
                    ClientFlags.BuildToolsDisableBuildSettingsPage))
            {
                _applicationManager.RegisterOptionsPageFactory(
                    delegate { return(new BuildSettingsOptionsPage()); });
            }

            _applicationManager.DocumentFilterHandlers.Add(
                GetSourceFilesFilter);

            #region UI Elements

            bool disableCompilerUI = _applicationManager.ClientProfile.
                                     HaveFlag(ClientFlags.BuildToolsDisableCompilerUI);

            _output = _applicationManager.GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY)
                      as OutputForm;

            /* Menu items */

            _toolsMenuCompile = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_COMPILE,
                Resources.MainToolsMenuCompile,
                Resources.Compile,
                Keys.Shift | Keys.F5, null, UI_TOOLS_MENU_COMPILE_Click);

            _toolsMenuCompileAll = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_COMPILE_ALL,
                Resources.MainToolsMenuCompileAll,
                null,
                Keys.F6, null, UI_TOOLS_MENU_COMPILE_ALL_Click,
                true);

            _toolsMenuRun = MenuTools.CreateMenuItem(
                Constants.UI_TOOLS_MENU_RUN,
                Resources.MainToolsMenuRun,
                Resources.Run,
                Keys.Control | Keys.F5, null, UI_TOOLS_MENU_RUN_Click);

            if (disableCompilerUI)
            {
                _toolsMenuRun.Tag = new ToolStripItemTag {
                    IncludeSeparator = true
                }
            }
            ;

            ToolStripMenuItem toolsMenu = _mainForm.GetMenuItemByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            if (!disableCompilerUI)
            {
                toolsMenu.DropDownItems.Insert(0, _toolsMenuCompileAll);
                toolsMenu.DropDownItems.Insert(0, _toolsMenuCompile);
            }

            toolsMenu.DropDownItems.Insert(0, _toolsMenuRun);
            toolsMenu.DropDownOpening +=
                new EventHandler(ToolsMenu_DropDownOpening);

            /* Toolbar */

            _toolbarCompile = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_COMPILE,
                Resources.ToolbarCompile,
                Resources.Compile, UI_TOOLBAR_COMPILE_Click,
                true);
            _toolbarCompile.Enabled = false;
            _toolbarCompileSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_COMPILE_SELECT,
                UI_TOOLBAR_COMPILE_SELECT_Click);
            _toolbarCompileSelect.Enabled          = false;
            _toolbarCompileSelect.DropDownOpening +=
                new EventHandler(ToolbarCompileSelect_DropDownOpening);

            _toolbarRun = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_RUN,
                Resources.ToolbarRun,
                Resources.Run, UI_TOOLBAR_RUN_Click);

            if (disableCompilerUI)
            {
                _toolbarRun.Tag = new ToolStripItemTag {
                    IncludeSeparator = true
                }
            }
            ;

            _toolbarRun.Enabled = false;
            _toolbarRunSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_RUN_SELECT,
                UI_TOOLBAR_RUN_SELECT_Click);
            _toolbarRunSelect.Enabled          = false;
            _toolbarRunSelect.DropDownOpening +=
                new EventHandler(ToolbarRunSelect_DropDownOpening);

            _toolbarPin = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_PIN,
                Resources.ToolbarPinFile,
                Resources.Pin, UI_TOOLBAR_PIN_Click,
                true);
            _toolbarPin.Enabled = false;
            _toolbarPinSelect   = MenuTools.CreateToolbarDropDownButton(
                Constants.UI_TOOLBAR_PIN_SELECT,
                UI_TOOLBAR_PIN_SELECT_Click);
            _toolbarPinSelect.Enabled = false;

            if (!disableCompilerUI)
            {
                _mainForm.MainToolbar.Items.Add(_toolbarCompile);
                _mainForm.MainToolbar.Items.Add(_toolbarCompileSelect);
            }

            _mainForm.MainToolbar.Items.Add(_toolbarRun);
            _mainForm.MainToolbar.Items.Add(_toolbarRunSelect);
            _mainForm.MainToolbar.Items.Add(_toolbarPin);
            _mainForm.MainToolbar.Items.Add(_toolbarPinSelect);

            #endregion

            _mainForm.ClientWindow.ActiveDocumentChanged +=
                new EventHandler(MainForm_ActiveDocumentChanged);

            _buildToolManager = BuildToolManager.GetInstance();
            _buildToolManager.LoadSettings();
            _buildToolManager.LoadTools();
            _buildToolManager.BuildTools.SortTools();
            _buildToolManager.LoadPinnedFiles();

            _mainForm.FormClosed +=
                new FormClosedEventHandler(MainForm_FormClosed);

            _applicationManager.FileSystemChange +=
                new MessageHandler(UpdatePinFileStatus);

            PluginManager.GetInstance().PluginPostActivate +=
                new MessageHandler(PostActivationHandler);
        }
コード例 #16
0
        private void CreateDocument()
        {
            /*
             * Create a document type, set it as the default document and
             * register the new and open document handlers.
             *
             * For this demo we are creating a document that presents
             * bitmap images and allows them to be shown normally or
             * stretched. Open will open an existing .bmp file; New will
             * create blank documents. As this is a demo there is no
             * functionality to create or modify images but enough to
             * illustrate the document creation process.
             */

            documentType = new DocumentType(".bmp");
            applicationManager.NewDocumentType    = documentType;
            applicationManager.NewDocumentHandler = NewDocument;
            applicationManager.RegisterOpenDocumentHandler(
                documentType, OpenDocument);

            /*
             * Add a filter provider for the open file dialog.
             */

            applicationManager.DocumentFilterHandlers.Add(
                delegate { return("Bitmap Files (*.bmp)|*.bmp|"); });

            /*
             * Add an image menu before the Tools menu and add
             * a menu item to toggle the current image sizing mode.
             */

            imageMenu = MenuTools.CreateMenuItem(
                Constants.UI_IMAGE_MENU,
                "&Image", null, Keys.None, null, null);

            int index = mainForm.GetMainMenuItemIndexByName(
                QuickSharp.Core.Constants.UI_TOOLS_MENU);

            mainForm.MainMenu.Items.Insert(index, imageMenu);

            imageMenuStretch = MenuTools.CreateMenuItem(
                Constants.UI_IMAGE_MENU_STRETCH,
                "&Stretch Image",
                Resources.StetchImage,
                Keys.None, null, MenuItem_Click);

            /*
             * Document related menu items should start disabled.
             */

            imageMenuStretch.Enabled = false;

            /*
             * Add the item to the menu.
             */

            imageMenu.DropDownItems.Add(imageMenuStretch);

            /*
             * Add a button to the main toolbar.
             */

            toolbarButtonStretch = MenuTools.CreateToolbarButton(
                Constants.UI_TOOLBAR_STRETCH,
                "Stretch image",
                Resources.StetchImage,
                ToolbarItem_Click,
                true);                            // Add a separator before the button

            toolbarButtonStretch.Enabled = false; // Start disabled

            mainForm.MainToolbar.Items.Add(toolbarButtonStretch);

            /*
             * Assign event handlers for the menu being opened and the
             * active document changing. Both of these are required to
             * maintain the current state of the UI items.
             */

            imageMenu.DropDownOpening +=
                delegate { UpdateImageMenu(); };

            mainForm.ClientWindow.ActiveDocumentChanged +=
                delegate { ActiveDocumentChanged(); };
        }