private System.Windows.Controls.TabControl GetTabFromLocation(TabLocation tabLocation) { System.Windows.Controls.TabControl tabControl = null; switch (tabLocation) { case TabLocation.Center: case TabLocation.CenterBottom: tabControl = this.mainPanelControl.CenterBottomTabControl; break; case TabLocation.RightBottom: tabControl = this.mainPanelControl.RightBottomTabControl; break; case TabLocation.RightTop: tabControl = this.mainPanelControl.RightTopTabControl; break; case TabLocation.CenterTop: tabControl = this.mainPanelControl.CenterTopTabControl; break; case TabLocation.Left: tabControl = this.mainPanelControl.LeftTabControl; break; default: throw new NotImplementedException($"Tab location {tabLocation} not supported"); } return(tabControl); }
private TabControl GetTabFromLocation(TabLocation tabLocation) { TabControl tabControl = null; switch (tabLocation) { case TabLocation.Center: case TabLocation.CenterBottom: tabControl = this.MiddleTabControl; break; case TabLocation.Right: tabControl = this.RightTabControl; break; case TabLocation.CenterTop: tabControl = this.tabControl1; break; default: throw new NotImplementedException($"Tab location {tabLocation} not supported"); } return(tabControl); }
/// <summary> /// Draws a tab location display. /// </summary> private void DrawTab(Graphics g, TabLocation location, Rectangle bounds, Brush backBrush, Pen borderPen) { int w = bounds.Width / 5; int h = bounds.Height / 5; int x = 0; int y = 0; if ((location & TabLocation.Top) != TabLocation.None || (location & TabLocation.Bottom) != TabLocation.None) { if ((location & TabLocation.Top) != TabLocation.None) { y = bounds.Top; } else { y = bounds.Top + 4 * h; } if ((location & TabLocation.Near) != TabLocation.None) { x = bounds.Left + w; } else if ((location & TabLocation.Center) != TabLocation.None) { x = bounds.Left + 2 * w; } else { x = bounds.Left + 3 * w; } } else if ((location & TabLocation.Left) != TabLocation.None || (location & TabLocation.Right) != TabLocation.None) { if ((location & TabLocation.Left) != TabLocation.None) { x = bounds.Left; } else { x = bounds.Left + 4 * w; } if ((location & TabLocation.Near) != TabLocation.None) { y = bounds.Top + h; } else if ((location & TabLocation.Center) != TabLocation.None) { y = bounds.Top + 2 * h; } else { y = bounds.Top + 3 * h; } } g.FillRectangle(backBrush, x, y, w, h); g.DrawRectangle(borderPen, x, y, w, h); }
protected void ShowTab(PluginTab pluginTab, TabLocation tabLocation) { var container = GetTabContainerFromLocation(tabLocation); if (container.Controls.Contains(pluginTab) == false) { container.Controls.Add(pluginTab); } }
protected override void OnMouseLeave(EventArgs e) { if (hoveredLocation != TabLocation.None) { hoveredLocation = TabLocation.None; Invalidate(); } base.OnMouseLeave(e); }
protected override void OnMouseMove(MouseEventArgs e) { var newHoveredLocation = HitTest(e.X, e.Y); if (hoveredLocation != newHoveredLocation) { hoveredLocation = newHoveredLocation; Invalidate(); } base.OnMouseMove(e); }
protected override void OnMouseClick(MouseEventArgs e) { TabLocation newLoc = HitTest(e.X, e.Y); if (newLoc != TabLocation.None && newLoc != TabLocation) { TabLocation = newLoc; Invalidate(); } base.OnMouseClick(e); }
public TabPage AddWinformsControl(Control control, string tabTitle, TabLocation tabLocation) { // todo: check if control has already been added. Right now this can't be done trough the Gum commands // so it's only used "internally", so no checking is being done. var tabControl = GetTabFromLocation(tabLocation); var tabPage = CreateTabPage(tabTitle); control.Dock = DockStyle.Fill; tabControl.Controls.Add(tabPage); tabPage.Controls.Add(control); return(tabPage); }
private static TabControl GetTabContainerFromLocation(TabLocation tabLocation) { System.Windows.Forms.TabControl tabContainer = null; switch (tabLocation) { case TabLocation.Top: tabContainer = PluginManager.TopTab; break; case TabLocation.Left: tabContainer = PluginManager.LeftTab; break; case TabLocation.Center: tabContainer = PluginManager.CenterTab; break; case TabLocation.Right: tabContainer = PluginManager.RightTab; break; case TabLocation.Bottom: tabContainer = PluginManager.BottomTab; break; } return(tabContainer); }
public PluginTab AddWinformsControl(Control control, string tabTitle, TabLocation tabLocation) { // todo: check if control has already been added. Right now this can't be done trough the Gum commands // so it's only used "internally", so no checking is being done. //var tabControl = GetTabFromLocation(tabLocation); //var tabPage = CreateTabPage(tabTitle); //control.Dock = DockStyle.Fill; //tabControl.Controls.Add(tabPage); //tabPage.Controls.Add(control); //return new PluginTab //{ // Page = tabPage //}; var host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = control; return(AddWpfControl(host, tabTitle, tabLocation)); }
public PluginTab AddWinformsControl(Control control, string tabTitle, TabLocation tabLocation) { return(mMainWindow.AddWinformsControl(control, tabTitle, tabLocation)); }
public PluginTab AddControl(System.Windows.Forms.Control control, string tabTitle, TabLocation tabLocation) { CheckForInitialization(); return(mMainWindow.AddWinformsControl(control, tabTitle, tabLocation)); }
public PluginTab AddControl(System.Windows.Controls.UserControl control, string tabTitle, TabLocation tabLocation = TabLocation.CenterBottom) { CheckForInitialization(); return(mMainWindow.AddWpfControl(control, tabTitle, tabLocation)); }
public TabPage AddControl(System.Windows.Controls.UserControl control, string tabTitle, TabLocation tabLocation = TabLocation.CenterBottom) { return(mMainWindow.AddWpfControl(control, tabTitle, tabLocation)); }
/// <summary> /// Determines the tab location display under the mouse cursor. /// </summary> private TabLocation HitTest(int x, int y) { var bounds = ClientRectangle; int w = bounds.Width / 5; int h = bounds.Height / 5; TabLocation newLoc = TabLocation.None; if (y < h && x > w && x < 4 * w) { newLoc = TabLocation.Top; } else if (y > 4 * h && x > w && x < 4 * w) { newLoc = TabLocation.Bottom; } else if (x < w && y > h && y < 4 * h) { newLoc = TabLocation.Left; } else if (x > 4 * w && y > h && y < 4 * h) { newLoc = TabLocation.Right; } if (newLoc != TabLocation.None) { if (newLoc == TabLocation.Top || newLoc == TabLocation.Bottom) { if (x < 2 * w) { newLoc |= TabLocation.Near; } else if (x < 3 * w) { newLoc |= TabLocation.Center; } else { newLoc |= TabLocation.Far; } } else if (newLoc == TabLocation.Left || newLoc == TabLocation.Right) { if (y < 2 * h) { newLoc |= TabLocation.Near; } else if (y < 3 * h) { newLoc |= TabLocation.Center; } else { newLoc |= TabLocation.Far; } } } return(newLoc); }
public PluginTab AddWpfControl(System.Windows.FrameworkElement control, string tabTitle, TabLocation tabLocation = TabLocation.CenterBottom) { string AppTheme = "Light"; control.Resources = new System.Windows.ResourceDictionary(); control.Resources.Source = new Uri($"/Themes/{AppTheme}.xaml", UriKind.Relative); //Style style = this.TryFindResource("UserControlStyle") as Style; //if (style != null) //{ // this.Style = style; //} //ResourceDictionary = Resources; var tabControl = GetTabFromLocation(tabLocation); var page = new System.Windows.Controls.TabItem(); page.Header = tabTitle; page.Content = control; tabControl.Items.Add(page); return(new PluginTab() { Page = page }); //TabPage existingTabPage; //TabControl existingTabControl; //GetContainers(control, out existingTabPage, out existingTabControl); //bool alreadyExists = existingTabControl != null; //TabPage tabPage = existingTabPage; //if (!alreadyExists) //{ // System.Windows.Forms.Integration.ElementHost wpfHost; // wpfHost = new System.Windows.Forms.Integration.ElementHost(); // wpfHost.Dock = DockStyle.Fill; // wpfHost.Child = control; // tabPage = CreateTabPage(tabTitle); // TabControl tabControl = GetTabFromLocation(tabLocation); // tabControl.Controls.Add(tabPage); // tabPage.Controls.Add(wpfHost); //} //return new PluginTab //{ // Page = tabPage //}; }
public PluginTab AddWpfControl(System.Windows.Controls.UserControl control, string tabTitle, TabLocation tabLocation = TabLocation.Center) { string AppTheme = "Light"; control.Resources = new System.Windows.ResourceDictionary(); control.Resources.Source = new Uri($"/Themes/{AppTheme}.xaml", UriKind.Relative); //Style style = this.TryFindResource("UserControlStyle") as Style; //if (style != null) //{ // this.Style = style; //} //ResourceDictionary = Resources; TabPage existingTabPage; TabControl existingTabControl; GetContainers(control, out existingTabPage, out existingTabControl); bool alreadyExists = existingTabControl != null; TabPage tabPage = existingTabPage; if (!alreadyExists) { System.Windows.Forms.Integration.ElementHost wpfHost; wpfHost = new System.Windows.Forms.Integration.ElementHost(); wpfHost.Dock = DockStyle.Fill; wpfHost.Child = control; tabPage = CreateTabPage(tabTitle); TabControl tabControl = GetTabFromLocation(tabLocation); tabControl.Controls.Add(tabPage); tabPage.Controls.Add(wpfHost); } return(new PluginTab { Page = tabPage }); }
public TabPage AddWpfControl(System.Windows.Controls.UserControl control, string tabTitle, TabLocation tabLocation = TabLocation.Center) { TabPage existingTabPage; TabControl existingTabControl; GetContainers(control, out existingTabPage, out existingTabControl); bool alreadyExists = existingTabControl != null; TabPage tabPage = existingTabPage; if (!alreadyExists) { System.Windows.Forms.Integration.ElementHost wpfHost; wpfHost = new System.Windows.Forms.Integration.ElementHost(); wpfHost.Dock = DockStyle.Fill; wpfHost.Child = control; tabPage = CreateTabPage(tabTitle); TabControl tabControl = GetTabFromLocation(tabLocation); tabControl.Controls.Add(tabPage); tabPage.Controls.Add(wpfHost); } return(tabPage); }