/// <summary> /// Initialize a new instance of the ViewDrawRibbonDesignGroupTriple class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonTriple">Associated ribbon group triple.</param> /// <param name="currentSize">Size the view should use.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonDesignGroupTriple(KryptonRibbon ribbon, KryptonRibbonGroupTriple ribbonTriple, GroupItemSize currentSize, NeedPaintHandler needPaint) : base(ribbon, needPaint) { Debug.Assert(ribbonTriple != null); _ribbonTriple = ribbonTriple; _currentSize = currentSize; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonDesignGroupTriple class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonTriple">Associated ribbon group triple.</param> /// <param name="currentSize">Size the view should use.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonDesignGroupTriple(KryptonRibbon ribbon, KryptonRibbonGroupTriple ribbonTriple, GroupItemSize currentSize, NeedPaintHandler needPaint) : base(ribbon, needPaint) { Debug.Assert(ribbonTriple != null); _ribbonTriple = ribbonTriple; CurrentSize = currentSize; _preferredPaddingL = new Padding((int)(1 * FactorDpiX), (int)(3 * FactorDpiY), (int)(1 * FactorDpiX), (int)(3 * FactorDpiY)); _layoutPaddingL = new Padding((int)(1 * FactorDpiX), (int)(1 * FactorDpiY), (int)(1 * FactorDpiX), (int)(1 * FactorDpiY)); _outerPaddingL = new Padding(0, (int)(2 * FactorDpiY), 0, (int)(2 * FactorDpiY)); _paddingMS = new Padding(0, (int)(2 * FactorDpiY), 0, (int)(2 * FactorDpiY)); }
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> /// Initialize a new instance of the ViewLayoutRibbonGroupTriple class. /// </summary> /// <param name="ribbon">Owning ribbon control instance.</param> /// <param name="ribbonTriple">Reference to triple definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewLayoutRibbonGroupTriple(KryptonRibbon ribbon, KryptonRibbonGroupTriple ribbonTriple, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonTriple != null); Debug.Assert(needPaint != null); // Cache references _ribbon = ribbon; _ribbonTriple = ribbonTriple; _needPaint = needPaint; // Associate the component with this view element for design time selection Component = _ribbonTriple; // Use hashtables to store relationships _itemToView = new ItemToView(); _smallCache = new ViewToSize(); _mediumCache = new ViewToSize(); _largeCache = new ViewToSize(); // Get the initial size used for sizing and positioning SetCurrentSize(ribbonTriple.ItemSizeCurrent); // Hook into changes in the ribbon triple definition _ribbonTriple.PropertyChanged += OnTriplePropertyChanged; _ribbonTriple.TripleView = this; // At design time we want to track the mouse and show feedback if (_ribbon.InDesignMode) { ViewHightlightController controller = new(this, needPaint); controller.ContextClick += OnContextClick; MouseController = controller; } }
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; } }
/// <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 _ribbonTriple = (KryptonRibbonGroupTriple)component; _ribbonTriple.DesignTimeAddButton += new EventHandler(OnAddButton); _ribbonTriple.DesignTimeAddColorButton += new EventHandler(OnAddColorButton); _ribbonTriple.DesignTimeAddCheckBox += new EventHandler(OnAddCheckBox); _ribbonTriple.DesignTimeAddRadioButton += new EventHandler(OnAddRadioButton); _ribbonTriple.DesignTimeAddLabel += new EventHandler(OnAddLabel); _ribbonTriple.DesignTimeAddCustomControl += new EventHandler(OnAddCustomControl); _ribbonTriple.DesignTimeAddTextBox += new EventHandler(OnAddTextBox); _ribbonTriple.DesignTimeAddMaskedTextBox += new EventHandler(OnAddMaskedTextBox); _ribbonTriple.DesignTimeAddRichTextBox += new EventHandler(OnAddRichTextBox); _ribbonTriple.DesignTimeAddComboBox += new EventHandler(OnAddComboBox); _ribbonTriple.DesignTimeAddNumericUpDown += new EventHandler(OnAddNumericUpDown); _ribbonTriple.DesignTimeAddDomainUpDown += new EventHandler(OnAddDomainUpDown); _ribbonTriple.DesignTimeAddDateTimePicker += new EventHandler(OnAddDateTimePicker); _ribbonTriple.DesignTimeAddTrackBar += new EventHandler(OnAddTrackBar); _ribbonTriple.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.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); _changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); }