private void cbbColorTable_SelectedIndexChanged(object sender, EventArgs e) { var type = cbbRenderer.SelectedItem as Type; if (type != null) { var colorTable = Activator.CreateInstance(type) as ProfessionalColorTable; if (colorTable != null) { if (colorTable.Equals(currentColorTable) == false) { var panelColorTable = colorTable.PanelColorTable; if (panelColorTable != null) { PanelSettingsManager.SetPanelProperties( Controls, panelColorTable); } currentColorTable = colorTable; currentRenderer = Activator.CreateInstance(currentRenderer.GetType(), new object[] { colorTable }) as ToolStripProfessionalRenderer; ToolStripManager.Renderer = currentRenderer; } } } }
private void tsbTheme_Click(object sender, EventArgs e) { var renderer = ToolStripManager.Renderer as ToolStripProfessionalRenderer; if (renderer != null) { var colorTable = (ProfessionalColorTable)renderer.ColorTable; if (colorTable != null) { colorTable.UseSystemColors = !colorTable.UseSystemColors; renderer = Activator.CreateInstance(renderer.GetType(), new object[] { colorTable }) as ToolStripProfessionalRenderer; var panelColors = colorTable.PanelColorTable; if (panelColors != null) { panelColors.UseSystemColors = colorTable.UseSystemColors; PanelSettingsManager.SetPanelProperties( Controls, panelColors); } ToolStripManager.Renderer = renderer; } } }
public void SetStyle(Style style) { ToolStripProfessionalRenderer toolStripRenderer = new Office2007Renderer(); Panels.ProfessionalColorTable colorTable = StyleBuilderFactory.GetOffice2007ColorTable(style); PanelColors panelColorTable = colorTable.PanelColorTable; if (panelColorTable != null) { ControlCollection controls = new ControlCollection(this); PanelSettingsManager.SetPanelProperties( //this.Controls, controls, panelColorTable); } this.m_currentToolStripRenderer = toolStripRenderer; if (colorTable.Equals(this.m_currentProfessionalColorTable) == false) { this.m_currentProfessionalColorTable = colorTable; object renderer = Activator.CreateInstance(this.m_currentToolStripRenderer.GetType(), new object[] { colorTable }); this.m_currentToolStripRenderer = renderer as ToolStripProfessionalRenderer; ToolStripManager.Renderer = this.m_currentToolStripRenderer; } this.Refresh(); }
public MenuStripW(IContainer container) { container.Add(this); InitializeComponent(); ToolStripProfessionalRenderer toolStripRenderer = new Office2007Renderer(); Panels.ProfessionalColorTable colorTable = new Office2007BlueColorTable(); // XiaoCai.WinformUI.Panels.ProfessionalColorTable colorTable = new OfficeColorTable(); //XiaoCai.WinformUI.Panels.ProfessionalColorTable colorTable = new Office2007BlueColorTable(); //XiaoCai.WinformUI.Panels.ProfessionalColorTable colorTable = new Office2007BlackColorTable(); PanelColors panelColorTable = colorTable.PanelColorTable; if (panelColorTable != null) { ControlCollection controls = new ControlCollection(this); PanelSettingsManager.SetPanelProperties( //this.Controls, controls, panelColorTable); } this.m_currentToolStripRenderer = toolStripRenderer; if (colorTable.Equals(this.m_currentProfessionalColorTable) == false) { this.m_currentProfessionalColorTable = colorTable; object renderer = Activator.CreateInstance(this.m_currentToolStripRenderer.GetType(), new object[] { colorTable }); this.m_currentToolStripRenderer = renderer as ToolStripProfessionalRenderer; ToolStripManager.Renderer = this.m_currentToolStripRenderer; } }
private void cbbRenderer_SelectedValueChanged(object sender, EventArgs e) { var type = cbbRenderer.SelectedItem as Type; if (type != null) { var toolStripRenderer = Activator.CreateInstance(type) as ToolStripProfessionalRenderer; if (toolStripRenderer != null) { if (toolStripRenderer.Equals(currentRenderer) == false) { cbbRenderer.Items.Clear(); var baseType = toolStripRenderer.ColorTable.GetType().BaseType; if (baseType != null) { var assembly = toolStripRenderer.ColorTable.GetType().Assembly; var types = assembly.GetTypes(); foreach (var colorTableType in types) { if (colorTableType.IsClass && baseType.IsAssignableFrom(colorTableType) && (baseType != colorTableType) && (baseType.BaseType == typeof(ProfessionalColorTable))) { cbbRenderer.Items.Add(colorTableType); } } } var colorTable = toolStripRenderer.ColorTable as ProfessionalColorTable; if (colorTable != null) { var panelColorTable = colorTable.PanelColorTable; if (panelColorTable != null) { PanelSettingsManager.SetPanelProperties( Controls, panelColorTable); } } else { var panelColorTable = new PanelColors(); PanelSettingsManager.SetPanelProperties( Controls, panelColorTable); } currentRenderer = toolStripRenderer; ToolStripManager.Renderer = currentRenderer; } } } }
private static void SetPanelsStyle(Control control, Style style) { ToolStripRenderer m_currentToolStripRenderer; ToolStripProfessionalRenderer toolStripRenderer = new Office2007Renderer(); Panels.ProfessionalColorTable colorTable = StyleBuilderFactory.GetOffice2007ColorTable(style); PanelColors panelColorTable = colorTable.PanelColorTable; if (panelColorTable != null) { PanelSettingsManager.SetPanelProperties( control.Controls, panelColorTable); } m_currentToolStripRenderer = toolStripRenderer; object renderer = Activator.CreateInstance(m_currentToolStripRenderer.GetType(), new object[] { colorTable }); m_currentToolStripRenderer = renderer as ToolStripProfessionalRenderer; ToolStripManager.Renderer = m_currentToolStripRenderer; }