private void UpDown_DownButtonClicked(object sender, MouseEventArgs e) { RibbonUpDown rud = (sender as RibbonUpDown); if (rud != null) { double val = double.Parse(rud.TextBoxText); val--; rud.TextBoxText = val.ToString(); } }
private void InitializeComponent() { this.ribbonUpDown1 = new System.Windows.Forms.RibbonUpDown(); this.SuspendLayout(); // // ribbonUpDown1 // this.ribbonUpDown1.TextBoxText = ""; this.ribbonUpDown1.TextBoxWidth = 50; this.ResumeLayout(false); }
/// <summary> /// Add windows and tools to the control ribbon. /// </summary> private void AddRibbonItems() { foreach (var aTool in this.toolItems) { var tool = aTool; RibbonPanel group = GetRibbonPanel(tool); RibbonButton toolItem = new RibbonButton(tool.Caption); SetupToolbarItem(tool, toolItem); group.Items.Add(toolItem); tool.ToolbarItemInitialized(); } foreach (var aGroupedTool in this.groupedToolItems) { var groupedTool = aGroupedTool; RibbonPanel group = GetRibbonPanel(groupedTool); RibbonButtonList hostList = null; if (groupedTool.IsButtonList) { hostList = new RibbonButtonList(); hostList.ButtonsSizeMode = RibbonElementSizeMode.DropDown; //hostList.MaxSizeMode = RibbonElementSizeMode.Compact; //hostList.MinSizeMode = RibbonElementSizeMode.Compact; //hostList.Text = "Hello"; group.Items.Add(hostList); } foreach (var tool in groupedTool.ToolbarItems) { RibbonButton toolItem = new RibbonButton(tool.Caption); if (groupedTool.IsButtonList) { hostList.Buttons.Add(toolItem); } else { group.Items.Add(toolItem); } SetupToolbarItem(tool, toolItem); } groupedTool.ToolbarItemInitialized(); } foreach (var aMenuTool in this.menuButtonToolItems) { var menuTool = aMenuTool.Value; RibbonPanel group = GetRibbonPanel(menuTool); RibbonButton theButton = new RibbonButton(menuTool.Caption); theButton.Style = RibbonButtonStyle.SplitDropDown; theButton.DropDownItemClicked += delegate(object sender, RibbonItemEventArgs e) { menuTool.MenuItemClicked(e.Item.Text); }; SetupToolbarItem(menuTool, theButton); group.Items.Add(theButton); foreach (var menuItem in menuTool.MenuItems) { RibbonItem item = new RibbonButton(menuItem); theButton.DropDownItems.Add(item); } if (theButton.DropDownItems.Count == 0) { theButton.Style = RibbonButtonStyle.Normal; } menuTool.ToolbarItemInitialized(); } foreach (var aComboTool in this.comboToolItems) { var comboTool = aComboTool; RibbonPanel group = GetRibbonPanel(comboTool); RibbonComboBox theButton = new RibbonComboBox(); theButton.Text = ""; // comboTool.Caption; theButton.AllowTextEdit = false; //if (theButton.Text.Length == 0) //{ // theButton.LabelWidth = 1; //} //else if (comboTool.Image == null) { RibbonLabel label = new RibbonLabel(); label.Text = comboTool.Caption; group.Items.Add(label); } theButton.Image = comboTool.Image; //theButton.SmallImage = comboTool.SmallImage; //theButton.CheckOnClick = comboTool.CheckOnClick; //theButton.Style = RibbonButtonStyle.SplitDropDown; theButton.DropDownItemClicked += delegate(object sender, RibbonItemEventArgs e) { comboTool.ComboItemClicked(e.Item.Text); }; comboTool.ComboSelectedTextChanged += delegate(object o, Core.Window.Events.ComboSelectedTextChangedEventArgs e) { //theButton.SelectedValue = e.Text; theButton.TextBoxText = e.Text; }; this.toolToUiMap[comboTool] = theButton; group.Items.Add(theButton); //comboTool.ComboItemsChanged; foreach (var comboItem in comboTool.ComboItems) { RibbonItem item = new RibbonButton(comboItem); theButton.DropDownItems.Add(item); } comboTool.ComboItemsAdded += delegate(object sender, Core.Window.Events.ComboItemsAddedEvent e) { theButton.DropDownItems.Clear(); foreach (var item in comboTool.ComboItems) { theButton.DropDownItems.Add(new RibbonButton(item)); } }; comboTool.ToolbarItemInitialized(); } foreach (var aUpDownTool in this.upDownToolItems) { var upDownTool = aUpDownTool; RibbonPanel group = GetRibbonPanel(upDownTool); RibbonUpDown theButton = new RibbonUpDown(); theButton.Text = upDownTool.Caption; theButton.Image = upDownTool.Image; this.toolToUiMap[upDownTool] = theButton; theButton.Value = upDownTool.InitialValue.ToString(); theButton.UpButtonClicked += delegate(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int val = 0; if (int.TryParse(theButton.Value, out val)) { val += upDownTool.Interval; if (val <= upDownTool.MaximumValue) { upDownTool.Value = val; theButton.Value = val.ToString(); theButton.TextBoxText = theButton.Value; upDownTool.Click(); } } } }; theButton.DownButtonClicked += delegate(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int val = 0; if (int.TryParse(theButton.Value, out val)) { val -= upDownTool.Interval; if (val >= upDownTool.MinimumValue) { upDownTool.Value = val; theButton.Value = val.ToString(); theButton.TextBoxText = theButton.Value; upDownTool.Click(); } } } }; ////theButton. ////theButton.SmallImage = comboTool.SmallImage; ////theButton.CheckOnClick = comboTool.CheckOnClick; ////theButton.Style = RibbonButtonStyle.SplitDropDown; //theButton.DropDownItemClicked += // delegate(object sender, RibbonItemEventArgs e) // { // upDownTool.ComboItemClicked(e.Item.Text); // }; //group.Items.Add(theButton); //upDownTool.ButtonStatusChanged += // delegate(object o, Window.ToolbarItemEvent e) // { // theButton.Enabled = e.IsEnabled; // }; ////comboTool.ComboItemsChanged; //foreach (var comboItem in upDownTool.ComboItems) //{ // RibbonItem item = new RibbonButton(comboItem); // theButton.DropDownItems.Add(item); //} //upDownTool.ComboItemsAdded += // delegate(object sender, ComboItemsAddedEvent e) // { // theButton.DropDownItems.Clear(); // foreach (var item in upDownTool.ComboItems) // { // theButton.DropDownItems.Add(new RibbonButton(item)); // } // }; upDownTool.ToolbarItemInitialized(); } foreach (var hostItem in this.hostedItems) { RibbonPanel group = GetRibbonPanel(hostItem); RibbonButton theButton = new RibbonButton(); theButton.Text = hostItem.Caption; theButton.Image = hostItem.Image; theButton.SmallImage = hostItem.SmallImage; theButton.Style = RibbonButtonStyle.DropDown; this.toolToUiMap[hostItem] = theButton; var uiHost = new RibbonHost(); uiHost.HostedControl = hostItem.UserControl; theButton.DropDownItems.Add(uiHost); hostItem.UserControlFinished += delegate { uiHost.HostCompleted(); }; group.Items.Add(theButton); hostItem.ToolbarItemInitialized(); } this.ribbon.Tabs.Sort(TabSorter); }