/// <summary> /// Create and return an application node /// </summary> /// <param name="app"></param> /// <param name="session"></param> /// <returns></returns> private TreeNode CreateApplicationNode(IHostedApplication app, Microsoft.Ccf.Csr.Session session) { // Add the app's icon to the tabControl's list ImageList imageList = app.GetIconList(); if (imageList != null && imageList.Images.Count > 0) { System.Drawing.Image image = imageList.Images[0]; sessionsTree.ImageList.Images.Add(image); } TreeNode node = new TreeNode(app.ApplicationName); node.Tag = app; // if there was no image for this application, then the image for // the previous application will be used. node.ImageIndex = sessionsTree.ImageList.Images.Count - 1; node.SelectedImageIndex = node.ImageIndex; if (session != null) { // If this app has the current selection, select it in the tree if (app == session.FocusedApplication) { sessionsTree.SelectedNode = node; } } return(node); }
/// <summary> /// Add the application to the TabControl /// </summary> /// <param name="child">The application to add</param> /// <param name="bar">The CcfPanelToolbar to add to the control.</param> /// <param name="closeButton"></param> /// <returns>The tab page</returns> private TabPage addApplicationToTabControl(object child, CcfPanelToolbar bar, bool closeButton) { TabPage tabPage = null; Image icon = null; // Icon for the tab string text; // Text for the tab // Get the application name and icon to be displayed on the tab if (child is IHostedApplication) { IHostedApplication app = child as IHostedApplication; // Get the app's name text = app.ApplicationName; // Get the app's icon ImageList imageList = app.GetIconList(); if (imageList != null && imageList.Images.Count > 0) { icon = imageList.Images[0]; } tabPage = tabControl.ShowApplication(child, text, icon, closeButton); if (app == CCFAppsUI.AppWithFocus) { tabControl.SelectedTab = tabPage; } } else if (child is Control) { text = (child as Control).Text; tabPage = tabControl.ShowApplication(child, text, null, closeButton); } if (bar != null) { // if a toolbar already exists don't add additional ones foreach (Control toolbar in tabPage.Controls) { if (toolbar is CcfPanelToolbar) { tabPage.Controls.Remove(toolbar); break; } } tabPage.Controls.Add(bar); } return(tabPage); }