/* * 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); }
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(); }
private void CreateToolbar() { /* * By default QuickSharp uses a single toolbar which you can * access via the MainForm.MainToolbar property. If additional * toolbars are registered it will automatically switch to * multi-toolbar mode. */ ToolStrip demoToolbar = new ToolStrip(); /* * These are required, the name is used to register the toolbar * in the toolbar collection and the text is used for the * toolbar menu entry. */ demoToolbar.Name = Constants.UI_TOOLBAR; demoToolbar.Text = "&Demo Toolbar"; /* * Create the buttons and add to the toolbar. */ ToolStripButton button1 = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_BUTTON1, "Button 1", Resources.ToolbarButton, DemoToolbarButton_Click); ToolStripButton button2 = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_BUTTON2, "Button 2", Resources.ToolbarButton, DemoToolbarButton_Click); ToolStripButton button3 = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_BUTTON3, "Button 3", Resources.ToolbarButton, DemoToolbarButton_Click, true); // Add a separator before the button demoToolbar.Items.Add(button1); demoToolbar.Items.Add(button2); demoToolbar.Items.Add(button3); /* * Register the toolbar with the main form. The numbers * are the row and column hints. For multi-row toolbars * the row hint indicates the row the toolbar should appear * on when first created. The column hint indicates a bias * for the horizontal positioning of the tool; the higher * the value the further to the right it will appear. Neither * of these are absolute and depend on the other toolbars * in the application. For example, a row hint of 3 will not * put a toolbar on row 3 if there is only one row. */ mainForm.AddDockedToolStrip(demoToolbar, 0, 10); }
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); }
private void PopulateToolbar() { _toolbar.SuspendLayout(); _toolbarSeparator = MenuTools.CreateSeparator( Constants.UI_TOOLBAR_OBJECT_BROWSER_SEP); _viewModulesButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_VIEW_MODULES, Resources.OBViewByContainer, Resources.ViewByContainer, UI_TOOLBAR_VIEW_MODULES_Click); _viewNamespacesButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_VIEW_NAMESPACES, Resources.OBViewByNamespace, Resources.ViewByNamespace, UI_TOOLBAR_VIEW_NAMESPACES_Click); if (_includeWorkspace) { _showWorkspaceOnlyButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SHOW_WORKSPACE_ONLY, Resources.OBShowWorkspaceOnly, Resources.ShowWorkspaceOnly, UI_TOOLBAR_SHOW_WORKSPACE_ONLY_Click); } _showNonPublicButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SHOW_NONPUBLIC, Resources.OBShowNonPublic, Resources.ShowNonPublic, UI_TOOLBAR_SHOW_NONPUBLIC_Click); _showHiddenButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SHOW_HIDDEN, Resources.OBShowHidden, Resources.ShowHidden, UI_TOOLBAR_SHOW_HIDDEN_Click); _showInheritedButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SHOW_INHERITED, Resources.OBShowInherited, Resources.ShowInherited, UI_TOOLBAR_SHOW_INHERITED_Click); _refreshViewButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_REFRESH_VIEW, Resources.OBRefresh, Resources.RefreshView, UI_TOOLBAR_REFRESH_VIEW_Click); _showPropertiesButton = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SHOW_PROPERTIES, Resources.OBShowProperties, Resources.PROPERTIES, UI_TOOLBAR_SHOW_PROPERTIES_Click); if (!_useMainToolbar) { _toolbar.Items.Clear(); } if (_useMainToolbar) { _toolbar.Items.Add(_toolbarSeparator); } _toolbar.Items.Add(_viewModulesButton); _toolbar.Items.Add(_viewNamespacesButton); if (_includeWorkspace) { _toolbar.Items.Add(_showWorkspaceOnlyButton); } _toolbar.Items.Add(_showNonPublicButton); _toolbar.Items.Add(_showHiddenButton); _toolbar.Items.Add(_showInheritedButton); _toolbar.Items.Add(_refreshViewButton); _toolbar.Items.Add(_showPropertiesButton); _toolbar.ResumeLayout(true); }
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(); }; }