private void RemoveSmartPart(Control smartPartControl) { // get the task pane tool TaskPaneTool taskPane = this.GetTaskPane(smartPartControl); UltraTaskPaneToolbar toolbar = GetOwningToolbar(taskPane); // at design time, we won't remove the tool // if you remove the control // if (this.DesignMode == false) { // remove the root tool so all the instances are removed this.Tools.Remove(this.Tools[taskPane.Key]); } // remove the smart parts this.composer.Remove(taskPane, smartPartControl); // at design time, don't mess with the toolbar visibility if (this.DesignMode == false) { // get and hide the owning taskpane toolbar if necessary this.HideToolbarWithNoVisibleTools(toolbar); } if (this.MdiParentManager != null) { this.RefreshMerge(); } }
/// <summary> /// Activates the smart part within the workspace. /// </summary> /// <param name="smartPart">The smart part to activate</param> protected virtual void OnActivate(Control smartPart) { TaskPaneTool taskPane = this.GetTaskPane(smartPart); // make sure its visible taskPane.SharedProps.Visible = true; UltraTaskPaneToolbar taskPaneToolbar = taskPane.OwningToolbar as UltraTaskPaneToolbar; // make sure its the selected tool in the owning task pane if (taskPaneToolbar != null) { taskPaneToolbar.SelectedTaskPaneTool = taskPane; taskPaneToolbar.Visible = true; } // assuming the control is visible, give it the input focus if (taskPane.Control.Visible) { taskPane.Control.Focus(); } }
private void HideToolbarWithNoVisibleTools(UltraTaskPaneToolbar toolbar) { if (null != toolbar) { bool hasVisibleTools = false; // see if the toolbar has visible tools foreach (ToolBase tool in toolbar.Tools) { if (tool.VisibleResolved) { hasVisibleTools = true; break; } } if (hasVisibleTools == false) { toolbar.Visible = false; } } }
private TaskPaneTool CreateTaskPane(object smartPart, UltraToolbarsSmartPartInfo smartPartInfo) { // get the control that we will be siting Control ctrl = WorkspaceUtilities.GetSmartPartControl(smartPart); TaskPaneTool taskPane = null; UltraTaskPaneToolbar toolbar = null; DockedPosition defaultDockedPosition = smartPartInfo.PreferredDockedPosition; string toolbarKey = smartPartInfo.PreferredTaskPane; // create the task pane tool and set it up taskPane = new TaskPaneTool(Guid.NewGuid().ToString()); taskPane.Control = ctrl; // add it to the root tools collection this.Tools.Add(taskPane); this.composer.Add(taskPane, ctrl); // initialize its settings this.ApplySmartPartInfoHelper(taskPane, smartPartInfo); // if a key was specified... if (toolbarKey != null && this.Toolbars.Exists(toolbarKey)) { // as long as its an task pane toolbar key, use it if (this.Toolbars[toolbarKey] is UltraTaskPaneToolbar) { toolbar = this.Toolbars[toolbarKey] as UltraTaskPaneToolbar; } else // otherwise use a default key { toolbarKey = null; } } if (toolbar == null) { // if one wasn't specified use a guid to ensure uniqueness if (toolbarKey == null) { toolbarKey = Guid.NewGuid().ToString(); } // create a taskpane toolbar and add it to the controls collection toolbar = new UltraTaskPaneToolbar(toolbarKey); toolbar.DockedPosition = defaultDockedPosition; if (smartPartInfo.PreferredExtent != UltraToolbarsSmartPartInfo.DefaultExtent) { toolbar.DockedContentExtent = smartPartInfo.PreferredExtent; } toolbar.ShowHomeButton = smartPartInfo.PreferredShowHomeButton; toolbar.NavigationButtonStyle = smartPartInfo.PreferredNavigationStyle; this.Toolbars.Add(toolbar); } toolbar.Tools.AddTool(taskPane.Key); return(taskPane); }