void RibbonSubGroupAddItemsRecursive( EditorRibbonDefaultConfiguration.Group subGroup, KryptonContextMenuCollection contextMenuItems ) { var items = new List<KryptonContextMenuItemBase>(); foreach( var child in subGroup.Children ) { //!!!!impl ////sub group //var subGroup = child as EditorRibbonDefaultConfiguration.Group; //if( subGroup != null ) //{ // var tripple = new KryptonRibbonGroupTriple(); // ribbonGroup.Items.Add( tripple ); // var button = new KryptonRibbonGroupButton(); // //button.Tag = action; // button.TextLine1 = subGroup.DropDownGroupText.Item1; // button.TextLine2 = subGroup.DropDownGroupText.Item2; // //button.ImageSmall = action.imageSmall; // button.ImageLarge = subGroup.DropDownGroupImage; // button.ToolTipBody = subGroup.Name; // button.ButtonType = GroupButtonType.DropDown; // button.KryptonContextMenu = new KryptonContextMenu(); // RibbonSubGroupAddItemsRecursive( subGroup, button.KryptonContextMenu.Items ); // tripple.Items.Add( button ); //} //action var action = child as EditorAction; if( action != null ) { EventHandler clickHandler = delegate ( object s, EventArgs e2 ) { var item2 = (KryptonContextMenuItem)s; var action2 = item2.Tag as EditorAction; if( action2 != null ) EditorAPI.EditorActionClick( EditorAction.HolderEnum.RibbonQAT, action2.Name ); }; var item = new KryptonContextMenuItem( action.GetContextMenuText(), null, clickHandler ); //var item = new KryptonContextMenuItem( action.GetContextMenuText(), action.imageSmall, clickHandler ); item.Tag = action; items.Add( item ); } //separator else if( child == null ) items.Add( new KryptonContextMenuSeparator() ); } if( items.Count != 0 ) contextMenuItems.Add( new KryptonContextMenuItems( items.ToArray() ) ); }
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; } }