/// <summary> /// Raises the <see cref="E:CommandBarStripElement.ItemsChanged"/> event. /// </summary> /// <param name="changed">The collection that is changed.</param> /// <param name="target">The targeted element of the collection.</param> /// <param name="operation">The type of the operation.</param> protected virtual void OnItemsChanged(RadCommandBarBaseItemCollection changed, RadCommandBarBaseItem target, ItemsChangeOperation operation) { if (this.ItemsChanged != null) { this.ItemsChanged(changed, target, operation); } }
protected override void CreateChildElements() { base.CreateChildElements(); this.MinSize = new Size(30, 30); this.DrawBorder = true; this.Text = ""; this.SetDefaultValueOverride(LightVisualElement.StretchHorizontallyProperty, false); this.SetDefaultValueOverride(LightVisualElement.StretchVerticallyProperty, true); this.items = new RadCommandBarBaseItemCollection(); this.grip = new RadCommandBarGrip(this); this.overflowButton = new RadCommandBarOverflowButton(this); this.itemsLayout = new RadCommandBarItemsPanel(this.items, this.overflowButton.ItemsLayout); this.items.Owner = this.itemsLayout; this.items.ItemTypes = new Type[] { typeof(CommandBarButton), typeof(CommandBarDropDownButton), typeof(CommandBarDropDownList), typeof(CommandBarHostItem), typeof(CommandBarSeparator), typeof(CommandBarLabel), typeof(CommandBarTextBox), typeof(CommandBarToggleButton), typeof(CommandBarSplitButton) }; this.Children.Add(this.grip); this.Children.Add(this.itemsLayout); this.Children.Add(this.overflowButton); this.WireEvents(); this.localMinSize = this.MinSize; }
public RadCommandBarItemsPanel( RadCommandBarBaseItemCollection itemsCollection, LayoutPanel overflowPannel) { this.items = itemsCollection; this.overflowPanel = overflowPannel; }
protected override SizeF ArrangeOverride(SizeF arrangeSize) { RadCommandBarBaseItemCollection children = this.items; int count = children.Count; // Get desired children size if EqualChildrenHeight or EqualChildrenWidth is used // ********************************************************* // SizeF maxDesiredChildrenSize = SizeF.Empty; bool equalChildrenHeight = false; // this.EqualChildrenHeight; bool equalChildrenWidth = false; // this.EqualChildrenWidth; if (equalChildrenHeight || equalChildrenWidth) { for (int i = 0; i < count; i++) { RadElement element = children[i]; if (equalChildrenHeight) { maxDesiredChildrenSize.Height = Math.Max(element.DesiredSize.Height, maxDesiredChildrenSize.Height); } if (equalChildrenWidth) { maxDesiredChildrenSize.Width = Math.Max(element.DesiredSize.Width, maxDesiredChildrenSize.Width); } } } // Parameters // ********************************************************* // bool isHorizontal = this.Orientation == Orientation.Horizontal; bool isRightToLeft = this.RightToLeft; float length = 0; RectangleF finalRect = new RectangleF(PointF.Empty, arrangeSize); if (isHorizontal && isRightToLeft) { finalRect.X = arrangeSize.Width; } float stretchedItemArrangedSpace = ArrangeStretchedItems(arrangeSize); // Main loop that does the actual arrangement of the children // ********************************************************* // for (int i = 0; i < count; i++) { RadElement element = children[i]; SizeF childArea = element.DesiredSize; if (element.Visibility == ElementVisibility.Collapsed) { element.Arrange(new RectangleF(PointF.Empty, childArea)); continue; } // ** 1. Calculate the ChildArea if (equalChildrenHeight) { if (isHorizontal) { childArea.Height = Math.Max(arrangeSize.Height, maxDesiredChildrenSize.Height); } else { childArea.Height = maxDesiredChildrenSize.Height; } } if (equalChildrenWidth) { if (isHorizontal) { childArea.Width = maxDesiredChildrenSize.Width; } else { childArea.Width = Math.Max(arrangeSize.Width, maxDesiredChildrenSize.Width); } } if (element.StretchHorizontally && isHorizontal && !float.IsInfinity(stretchedItemArrangedSpace)) { childArea.Width = stretchedItemArrangedSpace; } if (element.StretchVertically && !isHorizontal && !float.IsInfinity(stretchedItemArrangedSpace)) { childArea.Height = stretchedItemArrangedSpace; } // ** 2. Calculate the location and size (finalRect) that will be passed to the child's Arrange if (isHorizontal) { if (isRightToLeft) { length = childArea.Width; finalRect.X -= length; } else { finalRect.X += length; length = childArea.Width; } finalRect.Width = length; if (equalChildrenHeight) { SizeF arrangeArea = finalRect.Size; finalRect.Height = childArea.Height; // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed // by the size forcing // Note that the vertical alignment is not affected by RightToLeft... RectangleF alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), this.Alignment); finalRect.Y += alignedRect.Y; } else { finalRect.Height = arrangeSize.Height;// Math.Max(arrangeSize.Height, childArea.Height); } } else { finalRect.Y += length; length = childArea.Height; finalRect.Height = length; if (equalChildrenWidth) { SizeF arrangeArea = finalRect.Size; finalRect.Width = childArea.Width; // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed // by the size forcing // Note that the horizontal alignment is translated if RightToLeft is true. ContentAlignment alignment = isRightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment; RectangleF alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), alignment); finalRect.X += alignedRect.X; } else { finalRect.Width = arrangeSize.Width;// Math.Max(arrangeSize.Width, childArea.Width); } } // ** 3. Arrange the child if (element.StretchVertically && isHorizontal) { finalRect.Height = arrangeSize.Height; } else if (element.StretchHorizontally && !isHorizontal) { finalRect.Width = arrangeSize.Width; } element.Arrange(finalRect); } return(arrangeSize); }
protected override SizeF ArrangeOverride(SizeF arrangeSize) { RadCommandBarBaseItemCollection items = this.items; int count = items.Count; SizeF empty = SizeF.Empty; bool flag1 = false; bool flag2 = false; if (flag1 || flag2) { for (int index = 0; index < count; ++index) { RadElement radElement = (RadElement)items[index]; if (flag1) { empty.Height = Math.Max(radElement.DesiredSize.Height, empty.Height); } if (flag2) { empty.Width = Math.Max(radElement.DesiredSize.Width, empty.Width); } } } bool flag3 = this.Orientation == Orientation.Horizontal; bool rightToLeft = this.RightToLeft; float num = 0.0f; RectangleF finalRect = new RectangleF(PointF.Empty, arrangeSize); if (flag3 && rightToLeft) { finalRect.X = arrangeSize.Width; } float f = this.ArrangeStretchedItems(arrangeSize); for (int index = 0; index < count; ++index) { RadElement radElement = (RadElement)items[index]; SizeF desiredSize = radElement.DesiredSize; if (radElement.Visibility == ElementVisibility.Collapsed) { radElement.Arrange(new RectangleF(PointF.Empty, desiredSize)); } else { if (flag1) { desiredSize.Height = !flag3 ? empty.Height : Math.Max(arrangeSize.Height, empty.Height); } if (flag2) { desiredSize.Width = !flag3?Math.Max(arrangeSize.Width, empty.Width) : empty.Width; } if (radElement.StretchHorizontally && flag3 && !float.IsInfinity(f)) { desiredSize.Width = f; } if (radElement.StretchVertically && !flag3 && !float.IsInfinity(f)) { desiredSize.Height = f; } if (flag3) { if (rightToLeft) { num = desiredSize.Width; finalRect.X -= num; } else { finalRect.X += num; num = desiredSize.Width; } finalRect.Width = num; if (flag1) { SizeF size = finalRect.Size; finalRect.Height = desiredSize.Height; RectangleF rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), this.Alignment); finalRect.Y += rectangleF.Y; } else { finalRect.Height = arrangeSize.Height; } } else { finalRect.Y += num; num = desiredSize.Height; finalRect.Height = num; if (flag2) { SizeF size = finalRect.Size; finalRect.Width = desiredSize.Width; ContentAlignment align = rightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment; RectangleF rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), align); finalRect.X += rectangleF.X; } else { finalRect.Width = arrangeSize.Width; } } if (radElement.StretchVertically && flag3) { finalRect.Height = arrangeSize.Height; } else if (radElement.StretchHorizontally && !flag3) { finalRect.Width = arrangeSize.Width; } radElement.Arrange(finalRect); } } return(arrangeSize); }