/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { // Let base class do standard stuff base.Initialize(component); Debug.Assert(component != null); // Cast to correct type _ribbonComboBox = component as KryptonRibbonGroupComboBox; if (_ribbonComboBox != null) { _ribbonComboBox.ComboBoxDesigner = this; // Update designer properties with actual starting values Visible = _ribbonComboBox.Visible; Enabled = _ribbonComboBox.Enabled; // Update visible/enabled to always be showing/enabled at design time _ribbonComboBox.Visible = true; _ribbonComboBox.Enabled = true; // Tell the embedded text box it is in design mode _ribbonComboBox.ComboBox.InRibbonDesignMode = true; // Hook into events _ribbonComboBox.DesignTimeContextMenu += OnContextMenu; } // Get access to the services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // We need to know when we are being removed/changed _changeService.ComponentChanged += OnComponentChanged; }
/// <summary> /// Initialize a new instance of the ComboBoxController class. /// </summary> /// <param name="ribbon">Reference to owning ribbon instance.</param> /// <param name="comboBox">Source definition.</param> /// <param name="target">Target view element.</param> public ComboBoxController(KryptonRibbon ribbon, KryptonRibbonGroupComboBox comboBox, ViewDrawRibbonGroupComboBox target) { Debug.Assert(ribbon != null); Debug.Assert(comboBox != null); Debug.Assert(target != null); _ribbon = ribbon; _comboBox = comboBox; _target = target; }
/// <summary> /// Propagates the theme selector. /// </summary> /// <param name="target">The target.</param> public static void PropagateThemeSelector(KryptonRibbonGroupComboBox target) { try { foreach (var theme in ThemeManager.SupportedThemeArray) { target.Items.Add(theme); } } catch { throw; } }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupComboBox class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonComboBox">Reference to source combobox.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupComboBox(KryptonRibbon ribbon, KryptonRibbonGroupComboBox ribbonComboBox, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonComboBox != null); Debug.Assert(needPaint != null); // Remember incoming references _ribbon = ribbon; GroupComboBox = ribbonComboBox; _needPaint = needPaint; _currentSize = GroupComboBox.ItemSizeCurrent; // Hook into the combobox events GroupComboBox.MouseEnterControl += OnMouseEnterControl; GroupComboBox.MouseLeaveControl += OnMouseLeaveControl; // Associate this view with the source component (required for design time selection) Component = GroupComboBox; if (_ribbon.InDesignMode) { // At design time we need to know when the user right clicks the combobox ContextClickController controller = new(); controller.ContextClick += OnContextClick; MouseController = controller; } // Create controller needed for handling focus and key tip actions _controller = new ComboBoxController(_ribbon, GroupComboBox, this); SourceController = _controller; KeyController = _controller; // We need to rest visibility of the combobox for each layout cycle _ribbon.ViewRibbonManager.LayoutBefore += OnLayoutAction; _ribbon.ViewRibbonManager.LayoutAfter += OnLayoutAction; // Define back reference to view for the combo box definition GroupComboBox.ComboBoxView = this; // Give paint delegate to combobox so its palette changes are redrawn GroupComboBox.ViewPaintDelegate = needPaint; // Hook into changes in the ribbon custom definition GroupComboBox.PropertyChanged += OnComboBoxPropertyChanged; NULL_CONTROL_WIDTH = (int)(50 * FactorDpiX); }
public static void PropagateThemes(KryptonRibbonGroupComboBox themeList, bool sort = true) { ArrayList themeCollection = new ArrayList(15); themeCollection.Add("Global"); themeCollection.Add("Professional System"); themeCollection.Add("Professional Office 2003"); themeCollection.Add("Office 2007 Blue"); themeCollection.Add("Office 2007 Black"); themeCollection.Add("Office 2007 Silver"); themeCollection.Add("Office 2010 Blue"); themeCollection.Add("Office 2010 Black"); themeCollection.Add("Office 2010 Silver"); themeCollection.Add("Office 2013"); themeCollection.Add("Office 2013 White"); themeCollection.Add("Sparkle Blue"); themeCollection.Add("Sparkle Orange"); themeCollection.Add("Sparkle Purple"); themeCollection.Add("Custom"); if (sort) { themeCollection.Sort(); } foreach (string item in themeCollection) { themeList.Items.Add(item); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_ribbonComboBox != null) { // Must unhook to prevent memory leaks _ribbonComboBox.MouseEnterControl -= new EventHandler(OnMouseEnterControl); _ribbonComboBox.MouseLeaveControl -= new EventHandler(OnMouseLeaveControl); _ribbonComboBox.ViewPaintDelegate = null; _ribbonComboBox.PropertyChanged -= new PropertyChangedEventHandler(OnComboBoxPropertyChanged); _ribbon.ViewRibbonManager.LayoutAfter -= new EventHandler(OnLayoutAction); _ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction); // Remove association with definition _ribbonComboBox.ComboBoxView = null; _ribbonComboBox = null; } } base.Dispose(disposing); }
/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { Debug.Assert(component != null); // Validate the parameter reference if (component == null) { throw new ArgumentNullException("component"); } // Let base class do standard stuff base.Initialize(component); // Cast to correct type _ribbonComboBox = (KryptonRibbonGroupComboBox)component; _ribbonComboBox.ComboBoxDesigner = this; // Update designer properties with actual starting values Visible = _ribbonComboBox.Visible; Enabled = _ribbonComboBox.Enabled; // Update visible/enabled to always be showing/enabled at design time _ribbonComboBox.Visible = true; _ribbonComboBox.Enabled = true; // Tell the embedded text box it is in design mode _ribbonComboBox.ComboBox.InRibbonDesignMode = true; // Hook into events _ribbonComboBox.DesignTimeContextMenu += new MouseEventHandler(OnContextMenu); // Get access to the services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // We need to know when we are being removed/changed _changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); }
public void InitializeRibbonTools(KryptonRibbon ribbon) { ribbon.RibbonTabs.Clear(); var tools = extensionManager.GetExtensions <Tool>().ToList(); var toolsGroupedByTabs = from tool in tools group tool by tool.ToolTab into toolTabGroup orderby toolTabGroup.Key.OrderingIndex select toolTabGroup; foreach (var toolGroupingTabDefinition in toolsGroupedByTabs) { var ribbonTab = new KryptonRibbonTab { Text = toolGroupingTabDefinition.Key.Name, KeyTip = toolGroupingTabDefinition.Key.KeyTip }; ribbon.RibbonTabs.Add(ribbonTab); var toolsGroupedByGroup = from tool in toolGroupingTabDefinition group tool by tool.ToolGroup into toolGroup orderby toolGroup.Key.OrderingIndex select toolGroup; foreach (var toolGroupingDefinition in toolsGroupedByGroup) { var ribbonGroup = new KryptonRibbonGroup { TextLine1 = toolGroupingDefinition.Key.Name }; var toolContainerTriple = new KryptonRibbonGroupTriple(); var toolContainerLines = new KryptonRibbonGroupLines { MaximumSize = GroupItemSize.Large }; foreach (var tool in toolGroupingDefinition.OrderBy(t => t.OrderingIndex)) { switch (tool) { case ButtonTool buttonTool: var button = new KryptonRibbonGroupButton { TextLine1 = buttonTool.ToolName, ImageSmall = buttonTool.ToolIconSmall, ImageLarge = buttonTool.ToolIconLarge, ToolTipStyle = LabelStyle.ToolTip, ToolTipTitle = buttonTool.ToolTip, Tag = buttonTool }; button.Click += Button_Click; if (buttonTool.IsFocusedTool) { var splittedTexts = buttonTool.ToolName.Split(' ', '-'); if (splittedTexts.Length == 2) { button.TextLine1 = splittedTexts[0]; button.TextLine2 = splittedTexts[1]; } else { button.TextLine1 = buttonTool.ToolName; } toolContainerTriple.Items.Add(button); } else { toolContainerLines.Items.Add(button); } toolStrips.Add(button); break; case DropdownTool dropDownTool: var dropDown = new KryptonRibbonGroupComboBox(); toolContainerLines.Items.Add(dropDown); break; } } if (toolContainerTriple.Items.Any()) { ribbonGroup.Items.Add(toolContainerTriple); } if (toolContainerLines.Items.Any()) { ribbonGroup.Items.Add(toolContainerLines); } ribbonTab.Groups.Add(ribbonGroup); } } }