public void UpdateBreadCrumb(RadTreeNode node) { this.ClearCurrentItems(); Stack <RadSplitButtonElement> stack = new Stack <RadSplitButtonElement>(); RadTreeNode lastNode = null; Image firstNodeImage = node.Image; // gets the image of the selected node while (node != null) { RadSplitButtonElement ddButton = new RadSplitButtonElement(); ddButton.Text = node.Text; ddButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; // split button without children shouldn't have an arrow next to it if (node.Nodes.Count == 0) { ddButton.ShowArrow = false; } this.SetDropDownItems(node, lastNode, ddButton); ddButton.Text = node.Text; stack.Push(ddButton); lastNode = node; node = node.Parent; } AddBreadCrumbsChildren(stack, firstNodeImage); }
/// <summary> /// Create main button element that is specific for RadSplitButton. /// </summary> /// <returns>The element that encapsulates the funtionality of RadSplitButton</returns> protected override RadDropDownButtonElement CreateButtonElement() { RadSplitButtonElement res = new RadSplitButtonElement(); res.DefaultItemChanged += new EventHandler(SplitButtonElement_DefaultItemChanged); return(res); }
private void currentSplitButton_MouseEnter(object sender, EventArgs e) { if (this.dropDownOpened) { RadSplitButtonElement splitButton = sender as RadSplitButtonElement; if (splitButton != null) { // if the current split button is the sender doesn't do anything // else if another split button is the sender then hides // the current drop down and openes the sender's one if (splitButton == this.currentExpandedSplitButton) { return; } if (this.currentExpandedSplitButton != null) { this.currentExpandedSplitButton.HideDropDown(); } this.currentExpandedSplitButton = splitButton; if (!splitButton.IsDropDownShown) { splitButton.ShowDropDown(); } } } }
private void AddBreadCrumbsChildren(Stack <RadSplitButtonElement> stack, Image firstNodeImage) { Size empty = Size.Empty; Graphics graphics = this.CreateGraphics(); bool flag = false; while (stack.Count > 0) { RadSplitButtonElement splitButtonElement = stack.Pop(); if (!flag) { Size size = Size.Ceiling(graphics.MeasureString(splitButtonElement.Text, splitButtonElement.Font)); if (!size.IsEmpty && firstNodeImage != null) { splitButtonElement.Image = (Image) new Bitmap(firstNodeImage, new Size(Math.Min(size.Height, firstNodeImage.Width), Math.Min(size.Height, firstNodeImage.Width))); } flag = true; } splitButtonElement.DropDownOpened += new EventHandler(this.currentSplitButton_DropDownOpened); splitButtonElement.DropDownClosed += new EventHandler(this.currentSplitButton_DropDownClosed); splitButtonElement.MouseEnter += new EventHandler(this.currentSplitButton_MouseEnter); this.breadCrumbElement.Items.Add((RadItem)splitButtonElement); } graphics.Dispose(); }
protected override RadDropDownButtonElement CreateButtonElement() { RadSplitButtonElement splitButtonElement = new RadSplitButtonElement(); splitButtonElement.DefaultItemChanged += new EventHandler(this.SplitButtonElement_DefaultItemChanged); return((RadDropDownButtonElement)splitButtonElement); }
private void ClearCurrentItems() { while (this.breadCrumbElement.Items.Count > 0) { RadSplitButtonElement splitButtonElement = this.breadCrumbElement.Items[0] as RadSplitButtonElement; splitButtonElement.DropDownOpened -= new EventHandler(this.currentSplitButton_DropDownOpened); splitButtonElement.DropDownClosed -= new EventHandler(this.currentSplitButton_DropDownClosed); splitButtonElement.MouseEnter -= new EventHandler(this.currentSplitButton_MouseEnter); foreach (RadElement radElement in (RadItemCollection)splitButtonElement.Items) { radElement.Click -= new EventHandler(this.item_Click); } this.breadCrumbElement.Items[0].Dispose(); } }
private void SetDropDownItems( RadTreeNode node, RadTreeNode lastNode, RadSplitButtonElement ddButton) { for (int index = 0; index < node.Nodes.Count; ++index) { RadBreadCrumb.AssociatedMenuItem associatedMenuItem = new RadBreadCrumb.AssociatedMenuItem(node.Nodes[index]); associatedMenuItem.Click += new EventHandler(this.item_Click); if (lastNode == node.Nodes[index]) { associatedMenuItem.Font = new Font(associatedMenuItem.Font, FontStyle.Bold); } associatedMenuItem.Image = node.Nodes[index].Image; associatedMenuItem.Text = node.Nodes[index].Text; ddButton.Items.Add((RadItem)associatedMenuItem); } }
private void SetDropDownItems(RadTreeNode node, RadTreeNode lastNode, RadSplitButtonElement ddButton) { // adds and initializes the drop down items of ddButton instance of RadSplitButtonElement for (int i = 0; i < node.Nodes.Count; i++) { AssociatedMenuItem item = new AssociatedMenuItem(node.Nodes[i]); item.Click += new EventHandler(item_Click); if (lastNode == node.Nodes[i]) { item.Font = new System.Drawing.Font(item.Font, System.Drawing.FontStyle.Bold); } item.Image = node.Nodes[i].Image; item.Text = node.Nodes[i].Text; ddButton.Items.Add(item); } }
private void AddBreadCrumbsChildren(Stack <RadSplitButtonElement> stack, Image firstNodeImage) { Size textSize = Size.Empty; Graphics graphics = this.CreateGraphics(); RadSplitButtonElement currentSplitButton = null; bool anyPoppedElements = false; while (stack.Count > 0) { currentSplitButton = stack.Pop(); if (!anyPoppedElements) { textSize = Size.Ceiling(graphics.MeasureString(currentSplitButton.Text, currentSplitButton.Font)); if (!textSize.IsEmpty && firstNodeImage != null) { // sets the selected node's image next to the first split button currentSplitButton.Image = new Bitmap(firstNodeImage, new Size( Math.Min(textSize.Height, firstNodeImage.Width), Math.Min(textSize.Height, firstNodeImage.Width) )); } anyPoppedElements = true; } // subscribes each splitbutton to the following events currentSplitButton.DropDownOpened += new EventHandler(currentSplitButton_DropDownOpened); currentSplitButton.DropDownClosed += new EventHandler(currentSplitButton_DropDownClosed); currentSplitButton.MouseEnter += new EventHandler(currentSplitButton_MouseEnter); this.breadCrumbElement.Items.Add(currentSplitButton); } graphics.Dispose(); }
private void currentSplitButton_MouseEnter(object sender, EventArgs e) { if (!this.dropDownOpened) { return; } RadSplitButtonElement splitButtonElement = sender as RadSplitButtonElement; if (splitButtonElement == null || splitButtonElement == this.currentExpandedSplitButton) { return; } if (this.currentExpandedSplitButton != null) { this.currentExpandedSplitButton.HideDropDown(); } this.currentExpandedSplitButton = splitButtonElement; if (splitButtonElement.IsDropDownShown) { return; } splitButtonElement.ShowDropDown(); }
public void UpdateBreadCrumb(RadTreeNode node) { this.ClearCurrentItems(); Stack <RadSplitButtonElement> stack = new Stack <RadSplitButtonElement>(); RadTreeNode lastNode = (RadTreeNode)null; if (node == null) { return; } Image image = node.Image; for (; node != null; node = node.Parent) { RadSplitButtonElement ddButton = new RadSplitButtonElement(); ddButton.Text = node.Text; ddButton.TextImageRelation = TextImageRelation.ImageBeforeText; if (node.Nodes.Count == 0) { ddButton.ShowArrow = false; } this.SetDropDownItems(node, lastNode, ddButton); if (this.SelectTreeNodeOnClick) { RadBreadCrumb.AssociatedMenuItem associatedMenuItem = new RadBreadCrumb.AssociatedMenuItem(node); associatedMenuItem.Click += new EventHandler(this.item_Click); associatedMenuItem.Visibility = ElementVisibility.Collapsed; ddButton.Items.Add((RadItem)associatedMenuItem); ddButton.DefaultItem = (RadItem)associatedMenuItem; } ddButton.Text = node.Text; stack.Push(ddButton); lastNode = node; } this.AddBreadCrumbsChildren(stack, image); }