/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButton class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonButton">Reference to source button definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupButton(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonButton != null); Debug.Assert(needPaint != null); // Remember incoming references _ribbon = ribbon; GroupButton = ribbonButton; _needPaint = needPaint; _currentSize = GroupButton.ItemSizeCurrent; // Associate this view with the source component (required for design time selection) Component = GroupButton; // Create the different views for different sizes of the button CreateLargeButtonView(); CreateMediumSmallButtonView(); // Update all views to reflect current button state UpdateEnabledState(); UpdateCheckedState(); UpdateDropDownState(); UpdateItemSizeState(); // Hook into changes in the ribbon button definition GroupButton.PropertyChanged += OnButtonPropertyChanged; _largeImagePadding = new Padding((int)(3 * FactorDpiX), (int)(2 * FactorDpiY), (int)(3 * FactorDpiX), (int)(3 * FactorDpiY)); _smallImagePadding = new Padding((int)(3 * FactorDpiX), (int)(3 * FactorDpiY), (int)(3 * FactorDpiX), (int)(3 * FactorDpiY)); }
private void buttonPalette_Clicked(object sender, EventArgs e) { // The tag property of the button is the enum string value of the palette we want KryptonRibbonGroupButton button = (KryptonRibbonGroupButton)sender; kryptonManager.GlobalPaletteMode = (PaletteModeManager)Enum.Parse(typeof(PaletteModeManager), (string)button.Tag); UpdateButtonsFromPalette(); }
private void buttonGrouping_Click(object sender, EventArgs e) { // Cache the new mode setting KryptonRibbonGroupButton button = (KryptonRibbonGroupButton)sender; _cellMode = (NavigatorMode)Enum.Parse(typeof(NavigatorMode), (string)button.Tag); UpdateCellsFromGrouping(); UpdateButtonsFromGrouping(); }
private void kryptonRibbonModeButton_Click(object sender, EventArgs e) { // Extract the navigator mode from the tag field of the ribbon button KryptonRibbonGroupButton button = (KryptonRibbonGroupButton)sender; _mode = (NavigatorMode)Enum.Parse(typeof(NavigatorMode), (string)button.Tag); UpdateModeButtons(); UpdateAllCells(); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButtonImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonButton">Reference to ribbon group button definition.</param> /// <param name="large">Show the large image.</param> public ViewDrawRibbonGroupButtonImage(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, bool large) : base(ribbon) { Debug.Assert(ribbonButton != null); _ribbonButton = ribbonButton; _large = large; _smallSize = new Size((int)(16 * FactorDpiX), (int)(16 * FactorDpiY)); _largeSize = new Size((int)(32 * FactorDpiX), (int)(32 * FactorDpiY)); }
private void OnGroupButtonClick(object sender, EventArgs e) { KryptonRibbonGroupButton button = (KryptonRibbonGroupButton)sender; string text = button.TextLine1; if (!string.IsNullOrEmpty(button.TextLine2)) { text += " " + button.TextLine2; } MessageBox.Show(this, "You selected the '" + text + "' button.", "Button"); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButtonText class. /// </summary> /// <param name="ribbon">Source ribbon control.</param> /// <param name="ribbonButton">Group button to display title for.</param> /// <param name="firstText">Should show the first button text.</param> public ViewDrawRibbonGroupButtonText(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, bool firstText) { Debug.Assert(ribbon != null); Debug.Assert(ribbonButton != null); _ribbon = ribbon; _ribbonButton = ribbonButton; _firstText = firstText; // Use a class to convert from ribbon group to content interface _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateNormal.RibbonGroupButtonText, ribbon.StateDisabled.RibbonGroupButtonText); }
private void OnAddTriple(object sender, EventArgs e) { if ((_ribbonGroup?.Ribbon != null) && _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup)) { // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction(@"KryptonRibbonGroup AddTriple"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonGroup)[@"Items"]; RaiseComponentChanging(propertyItems); // Get designer to create the new triple component KryptonRibbonGroupTriple triple = (KryptonRibbonGroupTriple)_designerHost.CreateComponent(typeof(KryptonRibbonGroupTriple)); _ribbonGroup.Items.Add(triple); // Get access to the Triple.Items property MemberDescriptor propertyTripleItems = TypeDescriptor.GetProperties(triple)[@"Items"]; RaiseComponentChanging(propertyTripleItems); // Get designer to create three new button components KryptonRibbonGroupButton button1 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); KryptonRibbonGroupButton button2 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); KryptonRibbonGroupButton button3 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); triple.Items.Add(button1); triple.Items.Add(button2); triple.Items.Add(button3); RaiseComponentChanged(propertyTripleItems, null, null); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it transaction?.Commit(); } } }
/// <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 _ribbonButton = component as KryptonRibbonGroupButton; if (_ribbonButton != null) { _ribbonButton.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; }
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); } } }
void RibbonButtonsCheckForRecreate() { var config = ProjectSettings.Get.RibbonAndToolbarActions; if (ribbonUpdatedForConfiguration == null || !config.Equals(ribbonUpdatedForConfiguration) || needRecreatedRibbonButtons) { ribbonUpdatedForConfiguration = config.Clone(); needRecreatedRibbonButtons = false; ribbonLastSelectedTabTypeByUser_DisableUpdate = true; kryptonRibbon.RibbonTabs.Clear(); foreach (var tabSettings in ProjectSettings.Get.RibbonAndToolbarActions.RibbonTabs) { if (!tabSettings.Enabled) { continue; } //can be null EditorRibbonDefaultConfiguration.Tab tab = null; if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic) { tab = EditorRibbonDefaultConfiguration.GetTab(tabSettings.Name); } var ribbonTab = new KryptonRibbonTab(); ribbonTab.Tag = tab; if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic) { ribbonTab.Text = EditorLocalization.Translate("Ribbon.Tab", tabSettings.Name); } else { ribbonTab.Text = tabSettings.Name; } ribbonTab.KeyTip = GetTabKeyTip(tabSettings.Name); kryptonRibbon.RibbonTabs.Add(ribbonTab); var usedKeyTips = new ESet <string>(); string GetKeyTip(string name) { foreach (var c in name + alphabetNumbers) { var s = c.ToString().ToUpper(); if (s != " " && !usedKeyTips.Contains(s)) { usedKeyTips.AddWithCheckAlreadyContained(s); return(s); } } return(""); } foreach (var groupSettings in tabSettings.Groups) { if (!groupSettings.Enabled) { continue; } var ribbonGroup = new KryptonRibbonGroup(); if (groupSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.GroupItem.TypeEnum.Basic) { ribbonGroup.TextLine1 = EditorLocalization.Translate("Ribbon.Group", groupSettings.Name); } else { ribbonGroup.TextLine1 = groupSettings.Name; } ribbonGroup.DialogBoxLauncher = false; //!!!!для группы Transform можно было бы в настройки снеппинга переходить //ribbonTab.Groups.Add( ribbonGroup ); foreach (var groupSettingsChild in groupSettings.Actions) { if (!groupSettingsChild.Enabled) { continue; } //sub group if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.SubGroupOfActions) { EditorRibbonDefaultConfiguration.Group subGroup = null; if (tab != null) { var group = tab.Groups.Find(g => g.Name == groupSettings.Name); if (group != null) { foreach (var child in group.Children) { var g = child as EditorRibbonDefaultConfiguration.Group; if (g != null && g.Name == groupSettingsChild.Name) { subGroup = g; break; } } } } if (subGroup != null) { var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var button = new KryptonRibbonGroupButton(); button.Tag = "SubGroup"; //button.Tag = action; var str = subGroup.DropDownGroupText.Item1; if (subGroup.DropDownGroupText.Item2 != "") { str += "\n" + subGroup.DropDownGroupText.Item2; } var str2 = EditorLocalization.Translate("Ribbon.Action", str); var strs = str2.Split(new char[] { '\n' }); button.TextLine1 = strs[0]; if (strs.Length > 1) { button.TextLine2 = strs[1]; } //button.TextLine1 = subGroup.DropDownGroupText.Item1; //button.TextLine2 = subGroup.DropDownGroupText.Item2; if (subGroup.DropDownGroupImageSmall != null) { button.ImageSmall = subGroup.DropDownGroupImageSmall; } else if (subGroup.DropDownGroupImageLarge != null) { button.ImageSmall = EditorAction.ResizeImage(subGroup.DropDownGroupImageLarge, 16, 16); } button.ImageLarge = subGroup.DropDownGroupImageLarge; //EditorLocalization.Translate( "EditorAction.Description", if (!string.IsNullOrEmpty(subGroup.DropDownGroupDescription)) { button.ToolTipBody = EditorLocalization.Translate("EditorAction.Description", subGroup.DropDownGroupDescription); } else { button.ToolTipBody = subGroup.Name; } button.ButtonType = GroupButtonType.DropDown; button.ShowArrow = subGroup.ShowArrow; button.KryptonContextMenu = new KryptonContextMenu(); RibbonSubGroupAddItemsRecursive(subGroup, button.KryptonContextMenu.Items); tripple.Items.Add(button); } } //action if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.Action) { var action = EditorActions.GetByName(groupSettingsChild.Name); if (action != null && !action.CompletelyDisabled) { if (action.ActionType == EditorAction.ActionTypeEnum.Button || action.ActionType == EditorAction.ActionTypeEnum.DropDown) { //Button, DropDown var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupButton(); //!!!! //control.ImageSmall = NeoAxis.Properties.Resources.Android_16; control.Tag = action; var str = action.RibbonText.Item1; if (action.RibbonText.Item2 != "") { str += "\n" + action.RibbonText.Item2; } var str2 = EditorLocalization.Translate("Ribbon.Action", str); var strs = str2.Split(new char[] { '\n' }); control.TextLine1 = strs[0]; if (strs.Length > 1) { control.TextLine2 = strs[1]; } //control.TextLine1 = action.RibbonText.Item1; //control.TextLine2 = action.RibbonText.Item2; control.ImageSmall = action.GetImageSmall(); control.ImageLarge = action.GetImageBig(); control.ToolTipBody = action.ToolTip; control.KeyTip = GetKeyTip(action.Name); //_buttonType = GroupButtonType.Push; //_toolTipImageTransparentColor = Color.Empty; //_toolTipTitle = string.Empty; //_toolTipBody = string.Empty; //_toolTipStyle = LabelStyle.SuperTip; if (action.ActionType == EditorAction.ActionTypeEnum.DropDown) { control.ButtonType = GroupButtonType.DropDown; control.KryptonContextMenu = action.DropDownContextMenu; } control.Click += Button_Click; tripple.Items.Add(control); } else if (action.ActionType == EditorAction.ActionTypeEnum.Slider) { //Slider var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupSlider(); control.Tag = action; control.ToolTipBody = action.ToolTip; control.Control.Size = new System.Drawing.Size((int)((float)control.Control.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer2.Size = new System.Drawing.Size((int)((float)control.Control.kryptonSplitContainer2.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer2.Panel1MinSize = (int)((float)control.Control.kryptonSplitContainer2.Panel1MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.Panel2MinSize = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.SplitterDistance = 10000; control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1); control.Control.Init(action.Slider.Minimum, action.Slider.Maximum, action.Slider.ExponentialPower); control.Control.SetValue(action.Slider.Value); control.Control.Tag = action; control.Control.ValueChanged += Slider_ValueChanged; tripple.Items.Add(control); } //else if( action.ActionType == EditorAction.ActionTypeEnum.ComboBox ) //{ // //ComboBox // var tripple = new KryptonRibbonGroupTriple(); // ribbonGroup.Items.Add( tripple ); // var control = new KryptonRibbonGroupComboBox(); // control.Tag = action; // control.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; // foreach( var item in action.ComboBox.Items ) // control.Items.Add( item ); // if( control.Items.Count != 0 ) // control.SelectedIndex = 0; // //control.MinimumLength = action.Slider.Length; // //control.MaximumLength = action.Slider.Length; // control.SelectedIndexChanged += ComboBox_SelectedIndexChanged; // tripple.Items.Add( control ); //} else if (action.ActionType == EditorAction.ActionTypeEnum.ListBox) { //ListBox var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupListBox(); control.Tag = action; control.ToolTipBody = action.ToolTip; control.Control.Size = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer1.Size = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer1.Panel2MinSize = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.SplitterDistance = 10000; //if( action.ListBox.Length != 172 ) // control.Control.Size = new System.Drawing.Size( action.ListBox.Length, control.Control.Size.Height ); control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1); var browser = control.Control.contentBrowser1; if (action.ListBox.Mode == EditorAction.ListBoxSettings.ModeEnum.Tiles) { browser.ListViewModeOverride = new ContentBrowserListModeTilesRibbon(browser); browser.Options.PanelMode = ContentBrowser.PanelModeEnum.List; browser.Options.ListMode = ContentBrowser.ListModeEnum.Tiles; browser.UseSelectedTreeNodeAsRootForList = false; browser.Options.Breadcrumb = false; browser.ListViewBorderDraw = BorderSides.Left | BorderSides.Right | BorderSides.Bottom; browser.Options.TileImageSize = 22; } else { browser.RemoveTreeViewIconsColumn(); browser.TreeView.RowHeight -= 2; } browser.Tag = action; //update items control.SetItems(action.ListBox.Items); browser.ItemAfterSelect += ListBrowser_ItemAfterSelect; if (browser.Items.Count != 0) { browser.SelectItems(new ContentBrowser.Item[] { browser.Items.ToArray()[0] }); } //browser.ItemAfterSelect += ListBrowser_ItemAfterSelect; tripple.Items.Add(control); } } } } if (ribbonGroup.Items.Count != 0) { ribbonTab.Groups.Add(ribbonGroup); } } //select var tabType = ""; if (tab != null) { tabType = tab.Type; } if (ribbonLastSelectedTabTypeByUser != "" && tabType == ribbonLastSelectedTabTypeByUser) { kryptonRibbon.SelectedTab = ribbonTab; } } ribbonLastSelectedTabTypeByUser_DisableUpdate = false; } }