public RadCommandBarOverflowMenuItem( RadCommandBarBaseItem representedItem, RadDropDownMenu ownerMenu) { this.representedItem = representedItem; this.ownerMenu = ownerMenu; if (!string.IsNullOrEmpty(representedItem.DisplayName)) { this.menuElement.Text = this.CheckForLongText(representedItem.DisplayName); } else { this.menuElement.Text = this.CheckForLongText(representedItem.Name); } PropertyInfo property = this.representedItem.GetType().GetProperty(nameof(Image)); if ((object)property != null) { this.menuCheckMark.CheckState = Telerik.WinControls.Enumerations.ToggleState.On; this.Image = (Image)property.GetValue((object)this.representedItem, (object[])null); } if (this.menuElement.Image == null) { this.menuElement.Image = (Image) new Bitmap(16, 16); } else { this.Image = this.Image.GetThumbnailImage(16, 16, (Image.GetThumbnailImageAbort)null, IntPtr.Zero); } if (this.representedItem.VisibleInStrip) { return; } this.menuCheckMark.CheckState = Telerik.WinControls.Enumerations.ToggleState.Off; }
public void PopulateDropDownMenu() { this.addRemoveButtonsMenuItem.Items.Clear(); int count1 = this.owner.Items.Count; for (int index = 0; index < count1; ++index) { RadCommandBarBaseItem representedItem = this.owner.Items[index]; if (representedItem.VisibleInOverflowMenu) { this.addRemoveButtonsMenuItem.Items.Add((RadItem) new RadCommandBarOverflowMenuItem(representedItem, this.dropDownMenuElement)); } } int count2 = this.layout.Children.Count; for (int index = 0; index < count2; ++index) { RadCommandBarBaseItem child = this.layout.Children[index] as RadCommandBarBaseItem; if (child != null && child.VisibleInOverflowMenu) { this.addRemoveButtonsMenuItem.Items.Add((RadItem) new RadCommandBarOverflowMenuItem(child, this.dropDownMenuElement)); } } this.addRemoveButtonsMenuItem.MinSize = this.owner.OverflowMenuMinSize; this.addRemoveButtonsMenuItem.MaxSize = this.owner.OverflowMenuMaxSize; this.SetVisualStyles((LightVisualElement)this.dropDownMenuElement.Items[0]); this.dropDownMenuElement.Items[0].InvalidateMeasure(true); this.dropDownMenuElement.LoadElementTree(); }
private float ArrangeStretchedItems(SizeF arrangeSize) { int count = this.items.Count; float num1 = 0.0f; float num2 = this.Orientation == Orientation.Horizontal ? arrangeSize.Width : arrangeSize.Height; int num3 = 0; for (int index = 0; index < count; ++index) { RadCommandBarBaseItem commandBarBaseItem = this.items[index]; if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip && commandBarBaseItem.Visibility != ElementVisibility.Collapsed) { if ((!commandBarBaseItem.StretchHorizontally || this.Orientation != Orientation.Horizontal) && (!commandBarBaseItem.StretchVertically || this.Orientation != Orientation.Vertical)) { num1 += this.Orientation == Orientation.Horizontal ? commandBarBaseItem.DesiredSize.Width : commandBarBaseItem.DesiredSize.Height; } else { ++num3; } } } float num4 = num2 - num1; if ((double)num4 == 0.0) { return(0.0f); } return(num4 / (float)num3); }
protected virtual void moveDownButton_Click(object sender, EventArgs e) { int currentIndex = this.stripItemsListControl.SelectedIndex; int nextIndex = currentIndex + 1; if (nextIndex >= this.stripItemsListControl.Items.Count) { return; } RadCommandBarBaseItem currentItem = this.stripItemsListControl.Items[currentIndex].Value as RadCommandBarBaseItem; RadCommandBarBaseItem nextItem = this.stripItemsListControl.Items[nextIndex].Value as RadCommandBarBaseItem; if (currentItem == null || nextItem == null) { return; } CommandBarStripElement stripElement = (stripsDropDownList.SelectedItem.Value as CommandBarStripElement); LayoutPanel overflowPanelLayout = stripElement.OverflowButton.OverflowPanel.Layout; int currentItemIndex = stripElement.Items.IndexOf(currentItem); int nextItemIndex = stripElement.Items.IndexOf(nextItem); if (currentItemIndex != -1 && nextItemIndex != -1) { RadCommandBarBaseItem temp = stripElement.Items[currentItemIndex]; stripElement.Items.RemoveAt(currentItemIndex); stripElement.Items.Insert(nextItemIndex, temp); } else if (currentItemIndex != -1 && nextItemIndex == -1) { nextItemIndex = overflowPanelLayout.Children.IndexOf(nextItem); if (nextItemIndex != -1) { RadCommandBarBaseItem temp = overflowPanelLayout.Children[nextItemIndex] as RadCommandBarBaseItem; if (temp != null) { overflowPanelLayout.Children.RemoveAt(nextItemIndex); stripElement.Items.Insert(currentItemIndex, temp); } } } else { currentItemIndex = overflowPanelLayout.Children.IndexOf(currentItem); nextItemIndex = overflowPanelLayout.Children.IndexOf(nextItem); if (currentItemIndex != -1 && nextItemIndex != -1) { RadElement temp = overflowPanelLayout.Children[nextItemIndex]; overflowPanelLayout.Children.RemoveAt(nextItemIndex); overflowPanelLayout.Children.Insert(currentItemIndex, temp); } } toolstripsDownList_SelectedValueChanged(this, EventArgs.Empty); this.stripItemsListControl.SelectedIndex = nextIndex; }
private void ToggleStateChanged(object sender, StateChangedEventArgs args) { RadCommandBarBaseItem boundItem = (this.Data.DataBoundItem as RadCommandBarBaseItem); if (boundItem != null) { boundItem.VisibleInStrip = this.checkBox.Checked; } }
private XmlElement SaveFloatingStripsLayout(XmlDocument doc) { XmlElement element1 = doc.CreateElement("FloatingStrips"); foreach (CommandBarStripElement stripInfo in this.stripInfoHolder.StripInfoList) { if (stripInfo.FloatingForm != null && !stripInfo.FloatingForm.IsDisposed) { XmlElement element2 = doc.CreateElement("CommandBarStripElement"); element2.SetAttribute("Orientation", stripInfo.Orientation.ToString()); element2.SetAttribute("Name", stripInfo.Name); element2.SetAttribute("DesiredLocationX", stripInfo.DesiredLocation.X.ToString()); element2.SetAttribute("DesiredLocationY", stripInfo.DesiredLocation.Y.ToString()); element2.SetAttribute("FormLocationX", stripInfo.FloatingForm.Location.X.ToString()); element2.SetAttribute("FormLocationY", stripInfo.FloatingForm.Location.Y.ToString()); element2.SetAttribute("VisibleInCommandBar", stripInfo.VisibleInCommandBar.ToString()); element2.SetAttribute("StretchHorizontally", stripInfo.StretchHorizontally.ToString()); element2.SetAttribute("StretchVertically", stripInfo.StretchVertically.ToString()); element2.SetAttribute("RTL", stripInfo.RightToLeft.ToString()); element2.SetAttribute("EnableFloating", stripInfo.EnableFloating.ToString()); element2.SetAttribute("EnableDragging", stripInfo.EnableDragging.ToString()); int num = 0; for (int index = 0; index < stripInfo.Items.Count; ++index) { RadCommandBarBaseItem commandBarBaseItem = stripInfo.Items[index]; XmlElement element3 = doc.CreateElement("RadCommandBarBaseItem"); element3.SetAttribute("Orientation", commandBarBaseItem.Orientation.ToString()); element3.SetAttribute("Name", commandBarBaseItem.Name); element3.SetAttribute("VisibleInStrip", commandBarBaseItem.VisibleInStrip.ToString()); element3.SetAttribute("StretchHorizontally", commandBarBaseItem.StretchHorizontally.ToString()); element3.SetAttribute("StretchVertically", commandBarBaseItem.StretchVertically.ToString()); element3.SetAttribute("Index", num.ToString()); element2.AppendChild((XmlNode)element3); ++num; } for (int index = 0; index < stripInfo.FloatingForm.ItemsHostControl.Element.Layout.Children.Count; ++index) { RadCommandBarBaseItem child = stripInfo.FloatingForm.ItemsHostControl.Element.Layout.Children[index] as RadCommandBarBaseItem; if (child != null) { XmlElement element3 = doc.CreateElement("RadCommandBarBaseItem"); element3.SetAttribute("Orientation", child.Orientation.ToString()); element3.SetAttribute("Name", child.Name); element3.SetAttribute("VisibleInStrip", child.VisibleInStrip.ToString()); element3.SetAttribute("StretchHorizontally", child.StretchHorizontally.ToString()); element3.SetAttribute("StretchVertically", child.StretchVertically.ToString()); element3.SetAttribute("Index", num.ToString()); element2.AppendChild((XmlNode)element3); ++num; } } element1.AppendChild((XmlNode)element2); } } return(element1); }
private void HandleOverflowedItems(int visibleItemsCount, int currentIndex) { for (int index = visibleItemsCount - 1; index >= currentIndex; --index) { RadCommandBarBaseItem commandBarBaseItem = this.items[index]; this.items.Remove((RadItem)commandBarBaseItem); this.overflowPanel.Children.Insert(0, (RadElement)commandBarBaseItem); this.OnItemOverflowed((object)commandBarBaseItem, new EventArgs()); } }
//add items to overflow panel private void HandleOverflowedItems(int visibleItemsCount, int currentIndex) { for (int i = visibleItemsCount - 1; i >= currentIndex; --i) { RadCommandBarBaseItem child = this.items[i]; this.items.Remove(child); this.overflowPannel.Children.Insert(0, child); this.OnItemOverflowed(child, new EventArgs()); } }
private void ToggleStateChanged(object sender, StateChangedEventArgs args) { RadCommandBarBaseItem dataBoundItem = this.Data.DataBoundItem as RadCommandBarBaseItem; if (dataBoundItem == null) { return; } dataBoundItem.VisibleInStrip = this.checkBox.Checked; }
public AccessibleObject GetAccessibleObject( RadCommandBarBaseItem item, string name) { if (!this.cachedObjects.ContainsKey(item)) { this.cachedObjects.Add(item, new RadCommandBarItemAccessibleObject(item, this, name)); } return((AccessibleObject)this.cachedObjects[item]); }
public RadCommandBarItemAccessibleObject( RadCommandBarBaseItem owner, RadCommandBarAccessibleObject parent, string name) : base(owner.ElementTree.Control, name) { this.owner = owner; this.parent = parent; this.owner.MouseDown += new MouseEventHandler(this.owner_MouseDown); }
protected override System.Drawing.SizeF MeasureOverride(System.Drawing.SizeF constraint) { UVSize size = new UVSize(this.Orientation); UVSize size2 = new UVSize(this.Orientation); UVSize size3 = new UVSize(this.Orientation, constraint.Width, constraint.Height); float itemWidth = this.ItemWidth; float itemHeight = this.ItemHeight; bool flag = !float.IsNaN(itemWidth); bool flag2 = !float.IsNaN(itemHeight); SizeF availableSize = new SizeF(flag ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height); RadElementCollection internalChildren = base.Children; int num3 = 0; int count = internalChildren.Count; while (num3 < count) { RadCommandBarBaseItem element = internalChildren[num3] as RadCommandBarBaseItem; if (element != null) { if (!element.VisibleInStrip) { element.Measure(SizeF.Empty); } else { element.Measure(availableSize); } UVSize size5 = new UVSize(this.Orientation, flag ? itemWidth : element.DesiredSize.Width, flag2 ? itemHeight : element.DesiredSize.Height); if (DoubleUtil.GreaterThan(size.U + size5.U, size3.U)) { size2.U = Math.Max(size.U, size2.U); size2.V += size.V; size = size5; if (DoubleUtil.GreaterThan(size5.U, size3.U)) { size2.U = Math.Max(size5.U, size2.U); size2.V += size5.V; size = new UVSize(this.Orientation); } } else { size.U += size5.U; size.V = Math.Max(size5.V, size.V); } } num3++; } size2.U = Math.Max(size.U, size2.U); size2.V += size.V; return(new SizeF(size2.Width, size2.Height)); }
protected virtual void OnItemsChanged( RadCommandBarBaseItemCollection changed, RadCommandBarBaseItem target, ItemsChangeOperation operation) { if (this.ItemsChanged == null) { return; } this.ItemsChanged(changed, target, operation); }
protected virtual void moveDownButton_Click(object sender, EventArgs e) { int selectedIndex = this.stripItemsListControl.SelectedIndex; int index1 = selectedIndex + 1; if (index1 >= this.stripItemsListControl.Items.Count) { return; } RadCommandBarBaseItem commandBarBaseItem1 = this.stripItemsListControl.Items[selectedIndex].Value as RadCommandBarBaseItem; RadCommandBarBaseItem commandBarBaseItem2 = this.stripItemsListControl.Items[index1].Value as RadCommandBarBaseItem; if (commandBarBaseItem1 == null || commandBarBaseItem2 == null) { return; } CommandBarStripElement commandBarStripElement = this.stripsDropDownList.SelectedItem.Value as CommandBarStripElement; LayoutPanel layout = commandBarStripElement.OverflowButton.OverflowPanel.Layout; int index2 = commandBarStripElement.Items.IndexOf(commandBarBaseItem1); int index3 = commandBarStripElement.Items.IndexOf(commandBarBaseItem2); if (index2 != -1 && index3 != -1) { RadCommandBarBaseItem commandBarBaseItem3 = commandBarStripElement.Items[index2]; commandBarStripElement.Items.RemoveAt(index2); commandBarStripElement.Items.Insert(index3, commandBarBaseItem3); } else if (index2 != -1 && index3 == -1) { int index4 = layout.Children.IndexOf((RadElement)commandBarBaseItem2); if (index4 != -1) { RadCommandBarBaseItem child = layout.Children[index4] as RadCommandBarBaseItem; if (child != null) { layout.Children.RemoveAt(index4); commandBarStripElement.Items.Insert(index2, child); } } } else { int index4 = layout.Children.IndexOf((RadElement)commandBarBaseItem1); int index5 = layout.Children.IndexOf((RadElement)commandBarBaseItem2); if (index4 != -1 && index5 != -1) { RadElement child = layout.Children[index5]; layout.Children.RemoveAt(index5); layout.Children.Insert(index4, child); } } this.toolstripsDownList_SelectedValueChanged((object)this, EventArgs.Empty); this.stripItemsListControl.SelectedIndex = index1; }
public virtual int GetChildrenTotalWidth() { int totalWidth = 0; foreach (RadElement child in this.Layout.Children) { RadCommandBarBaseItem item = child as RadCommandBarBaseItem; if (item != null && item.VisibleInStrip) { totalWidth += (int)Math.Floor(item.DesiredSize.Width); } } return(totalWidth); }
public virtual int GetChildrenTotalWidth() { int num = 0; foreach (RadElement child in this.Layout.Children) { RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem; if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip) { num += (int)Math.Floor((double)commandBarBaseItem.DesiredSize.Width); } } return(num); }
public virtual int GetChildMaxWidth() { int val1 = 0; foreach (RadElement child in this.Layout.Children) { RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem; if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip) { val1 = Math.Max(val1, (int)Math.Floor((double)commandBarBaseItem.DesiredSize.Width)); } } return(val1); }
protected override SizeF MeasureOverride(SizeF constraint) { RadCommandBarOverflowPanel.UVSize uvSize1 = new RadCommandBarOverflowPanel.UVSize(this.Orientation); RadCommandBarOverflowPanel.UVSize uvSize2 = new RadCommandBarOverflowPanel.UVSize(this.Orientation); RadCommandBarOverflowPanel.UVSize uvSize3 = new RadCommandBarOverflowPanel.UVSize(this.Orientation, constraint.Width, constraint.Height); float itemWidth = this.ItemWidth; float itemHeight = this.ItemHeight; bool flag1 = !float.IsNaN(itemWidth); bool flag2 = !float.IsNaN(itemHeight); SizeF availableSize = new SizeF(flag1 ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height); RadElementCollection children = this.Children; int index = 0; for (int count = children.Count; index < count; ++index) { RadCommandBarBaseItem commandBarBaseItem = children[index] as RadCommandBarBaseItem; if (commandBarBaseItem != null) { if (!commandBarBaseItem.VisibleInStrip) { commandBarBaseItem.Measure(SizeF.Empty); } else { commandBarBaseItem.Measure(availableSize); } RadCommandBarOverflowPanel.UVSize uvSize4 = new RadCommandBarOverflowPanel.UVSize(this.Orientation, flag1 ? itemWidth : commandBarBaseItem.DesiredSize.Width, flag2 ? itemHeight : commandBarBaseItem.DesiredSize.Height); if (DoubleUtil.GreaterThan(uvSize1.U + uvSize4.U, uvSize3.U)) { uvSize2.U = Math.Max(uvSize1.U, uvSize2.U); uvSize2.V += uvSize1.V; uvSize1 = uvSize4; if (DoubleUtil.GreaterThan(uvSize4.U, uvSize3.U)) { uvSize2.U = Math.Max(uvSize4.U, uvSize2.U); uvSize2.V += uvSize4.V; uvSize1 = new RadCommandBarOverflowPanel.UVSize(this.Orientation); } } else { uvSize1.U += uvSize4.U; uvSize1.V = Math.Max(uvSize4.V, uvSize1.V); } } } uvSize2.U = Math.Max(uvSize1.U, uvSize2.U); uvSize2.V += uvSize1.V; return(new SizeF(uvSize2.Width, uvSize2.Height)); }
protected override void PropertySynchronized(RadProperty property) { RadCommandBarBaseItem dataBoundItem = this.Data.DataBoundItem as RadCommandBarBaseItem; if (dataBoundItem == null) { return; } if (property == CommandBarItemsListDataItem.VisibleProperty || property == CommandBarItemsListDataItem.NameProperty) { this.checkBox.Checked = dataBoundItem.VisibleInStrip; this.label.Text = dataBoundItem.DisplayName; } this.Text = ""; }
//move items out of overflow panel private void MeasureOverflowedItems(int overflowedItemsCount, SizeF availableSize, float sumOfSpace, ref SizeF totalSize) { bool isHorizontal = (this.Orientation == Orientation.Horizontal); for (int i = 0; i < overflowedItemsCount; ++i) { RadCommandBarBaseItem child = this.overflowPannel.Children[0] as RadCommandBarBaseItem; if (child == null) { continue; } if (!child.VisibleInStrip) { child.Measure(SizeF.Empty); this.items.Add(child); this.OnItemOutOfOverflow(child, new EventArgs()); continue; } child.Measure(LayoutUtils.InfinitySize); float desiredSpace = isHorizontal ? child.DesiredSize.Width : child.DesiredSize.Height; float availableSpace = isHorizontal ? availableSize.Width : availableSize.Height; if (sumOfSpace + desiredSpace > availableSpace) { break; } this.items.Add(child); this.OnItemOutOfOverflow(child, new EventArgs()); if (isHorizontal) { child.Measure(new SizeF(availableSize.Width - sumOfSpace, availableSize.Height)); totalSize.Width += child.DesiredSize.Width; totalSize.Height = Math.Max(totalSize.Height, child.DesiredSize.Height); } else { child.Measure(new SizeF(availableSize.Width, availableSize.Height - sumOfSpace)); totalSize.Height += child.DesiredSize.Height; totalSize.Width = Math.Max(totalSize.Width, child.DesiredSize.Width); } sumOfSpace += desiredSpace; } }
internal SizeF GetExpectedSize(SizeF availableSize) { SizeF result = SizeF.Empty; foreach (RadElement child in this.Children) { RadCommandBarBaseItem item = child as RadCommandBarBaseItem; if (item == null || !item.VisibleInStrip) { continue; } item.Measure(availableSize); if (this.Orientation == System.Windows.Forms.Orientation.Horizontal) { result.Width += item.DesiredSize.Width; result.Height = Math.Max(result.Height, item.DesiredSize.Height); } else { result.Height += item.DesiredSize.Height; result.Width = Math.Max(result.Width, item.DesiredSize.Width); } } foreach (RadElement child in this.overflowPannel.Children) { RadCommandBarBaseItem item = child as RadCommandBarBaseItem; if (item == null || !item.VisibleInStrip) { continue; } child.Measure(availableSize); if (this.Orientation == System.Windows.Forms.Orientation.Horizontal) { result.Width += child.DesiredSize.Width; result.Height = Math.Max(result.Height, child.DesiredSize.Height); } else { result.Height += child.DesiredSize.Height; result.Width = Math.Max(result.Width, child.DesiredSize.Width); } } return(result); }
private void MeasureOverflowedItems( int overflowedItemsCount, SizeF availableSize, float sumOfSpace, ref SizeF totalSize) { bool flag = this.Orientation == Orientation.Horizontal; for (int index = 0; index < overflowedItemsCount; ++index) { RadCommandBarBaseItem child = this.overflowPanel.Children[0] as RadCommandBarBaseItem; if (child != null) { if (!child.VisibleInStrip) { child.Measure(SizeF.Empty); this.items.Add(child); this.OnItemOutOfOverflow((object)child, new EventArgs()); } else { child.Measure(LayoutUtils.InfinitySize); float num1 = flag ? child.DesiredSize.Width : child.DesiredSize.Height; float num2 = flag ? availableSize.Width : availableSize.Height; if ((double)sumOfSpace + (double)num1 > (double)num2) { break; } this.items.Add(child); this.OnItemOutOfOverflow((object)child, new EventArgs()); if (flag) { child.Measure(new SizeF(availableSize.Width - sumOfSpace, availableSize.Height)); totalSize.Width += child.DesiredSize.Width; totalSize.Height = Math.Max(totalSize.Height, child.DesiredSize.Height); } else { child.Measure(new SizeF(availableSize.Width, availableSize.Height - sumOfSpace)); totalSize.Height += child.DesiredSize.Height; totalSize.Width = Math.Max(totalSize.Width, child.DesiredSize.Width); } sumOfSpace += num1; } } } }
public void PopulateDropDownMenu() { addRemoveButtonsMenuItem.Items.Clear(); int itemCount = this.owner.Items.Count; for (int i = 0; i < itemCount; ++i) { RadCommandBarBaseItem itemBase = this.owner.Items[i]; if (!itemBase.VisibleInOverflowMenu) { continue; } RadCommandBarOverflowMenuItem subMenuItem = new RadCommandBarOverflowMenuItem(itemBase, this.dropDownMenuElement); addRemoveButtonsMenuItem.Items.Add(subMenuItem); } int overflowedItemsCount = this.layout.Children.Count; for (int i = 0; i < overflowedItemsCount; ++i) { RadCommandBarBaseItem item = (this.layout.Children[i] as RadCommandBarBaseItem); if (item != null) { if (!item.VisibleInOverflowMenu) { continue; } RadCommandBarOverflowMenuItem subMenuItem = new RadCommandBarOverflowMenuItem(item, this.dropDownMenuElement); addRemoveButtonsMenuItem.Items.Add(subMenuItem); } } addRemoveButtonsMenuItem.MinSize = this.owner.OverflowMenuMinSize; addRemoveButtonsMenuItem.MaxSize = this.owner.OverflowMenuMaxSize; LightVisualElement lightVisualItem = (LightVisualElement)this.dropDownMenuElement.Items[0]; this.SetVisualStyles(lightVisualItem); this.dropDownMenuElement.Items[0].InvalidateMeasure(true); this.dropDownMenuElement.Items[0].PerformLayout(); this.dropDownMenuElement.LoadElementTree(); }
internal SizeF GetExpectedSize(SizeF availableSize) { SizeF empty = SizeF.Empty; foreach (RadElement child in this.Children) { RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem; if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip) { commandBarBaseItem.Measure(availableSize); if (this.Orientation == Orientation.Horizontal) { empty.Width += commandBarBaseItem.DesiredSize.Width; empty.Height = Math.Max(empty.Height, commandBarBaseItem.DesiredSize.Height); } else { empty.Height += commandBarBaseItem.DesiredSize.Height; empty.Width = Math.Max(empty.Width, commandBarBaseItem.DesiredSize.Width); } } } foreach (RadElement child in this.overflowPanel.Children) { RadCommandBarBaseItem commandBarBaseItem = child as RadCommandBarBaseItem; if (commandBarBaseItem != null && commandBarBaseItem.VisibleInStrip) { child.Measure(availableSize); if (this.Orientation == Orientation.Horizontal) { empty.Width += child.DesiredSize.Width; empty.Height = Math.Max(empty.Height, child.DesiredSize.Height); } else { empty.Height += child.DesiredSize.Height; empty.Width = Math.Max(empty.Width, child.DesiredSize.Width); } } } return(empty); }
private float ArrangeStretchedItems(SizeF arrangeSize) { int itemsCount = this.items.Count; float totalDesiredSpace = 0; float totalSpace = (this.Orientation == System.Windows.Forms.Orientation.Horizontal) ? arrangeSize.Width : arrangeSize.Height; int stretchedItemsCount = 0; for (int i = 0; i < itemsCount; ++i) { RadCommandBarBaseItem child = this.items[i] as RadCommandBarBaseItem; if (child == null || !child.VisibleInStrip || child.Visibility == ElementVisibility.Collapsed) { continue; } bool isChildStretched = (child.StretchHorizontally && this.Orientation == Orientation.Horizontal) || (child.StretchVertically && this.Orientation == Orientation.Vertical); if (!isChildStretched) { totalDesiredSpace += (this.Orientation == System.Windows.Forms.Orientation.Horizontal) ? child.DesiredSize.Width : child.DesiredSize.Height; } else { stretchedItemsCount++; } } float spaceForStretching = totalSpace - totalDesiredSpace; if (spaceForStretching == 0) { return(0); } float stretchedItemArrangedSpace = spaceForStretching / (float)stretchedItemsCount; return(stretchedItemArrangedSpace); }
/// <summary> /// Create RadCommandBarOverflowMenuItem instance /// </summary> /// <param name="representedItem">Which item will be show in menu</param> /// <param name="ownerMenu">Menu that should be updated on representedItem visibility is changed</param> public RadCommandBarOverflowMenuItem(RadCommandBarBaseItem representedItem, RadDropDownMenu ownerMenu) { this.representedItem = representedItem; this.ownerMenu = ownerMenu; if (!string.IsNullOrEmpty(representedItem.DisplayName)) { this.menuElement.Text = this.CheckForLongText(representedItem.DisplayName); } else { this.menuElement.Text = this.CheckForLongText(representedItem.Name); } Type t = this.representedItem.GetType(); PropertyInfo p = t.GetProperty("Image"); if (p != null) { this.menuCheckMark.CheckState = Enumerations.ToggleState.On; this.Image = (Image)(p.GetValue(this.representedItem, null)); } if (this.menuElement.Image == null) { this.menuElement.Image = new Bitmap(16, 16); } else { this.Image = this.Image.GetThumbnailImage(16, 16, null, IntPtr.Zero); } if (!this.representedItem.VisibleInStrip) { this.menuCheckMark.CheckState = Enumerations.ToggleState.Off; } }
public RadCommandBarItemAccessibleObject(RadCommandBarBaseItem owner, RadCommandBarAccessibleObject parent) { this.owner = owner; this.parent = parent; this.owner.MouseDown += new MouseEventHandler(owner_MouseDown); }
private void LoadFloatingStripsLayout(XmlNode floatingStripsNode) { foreach (XmlNode stripNode in floatingStripsNode.ChildNodes) { if (stripNode.Name != "CommandBarStripElement") { continue; } CommandBarStripElement strip = this.GetStripByName(stripNode.Attributes["Name"].Value); if (strip == null) { continue; } strip.SuspendLayout(true); bool oldRtl = this.RightToLeft; this.RightToLeft = false; if (stripNode.Attributes["FormLocationX"] != null && stripNode.Attributes["FormLocationY"] != null) { Point formLocation = new Point(int.Parse(stripNode.Attributes["FormLocationX"].Value), int.Parse(stripNode.Attributes["FormLocationY"].Value)); if (strip.FloatingForm != null && !strip.FloatingForm.IsDisposed) { strip.FloatingForm.Location = formLocation; } else { this.CreateFloatingStrip(strip, strip.Parent as CommandBarRowElement, formLocation); } } this.RightToLeft = oldRtl; strip.FloatingForm.EndMove(); for (int attr = 0; attr < stripNode.Attributes.Count; attr++) { switch (stripNode.Attributes[attr].Name) { case "Orientation": strip.Orientation = (stripNode.Attributes["Orientation"].Value == "Vertical") ? Orientation.Vertical : Orientation.Horizontal; break; case "VisibleInCommandBar": strip.VisibleInCommandBar = (stripNode.Attributes["VisibleInCommandBar"].Value == "True"); break; case "StretchHorizontally": strip.StretchHorizontally = (stripNode.Attributes["StretchHorizontally"].Value == "True"); break; case "StretchVertically": strip.StretchVertically = (stripNode.Attributes["StretchVertically"].Value == "True"); break; case "EnableFloating": strip.EnableFloating = (stripNode.Attributes["EnableFloating"].Value == "True"); break; case "EnableDragging": strip.EnableDragging = (stripNode.Attributes["EnableDragging"].Value == "True"); break; } } if (stripNode.Attributes["DesiredLocationX"] != null && stripNode.Attributes["DesiredLocationY"] != null) { strip.DesiredLocation = new PointF(float.Parse(stripNode.Attributes["DesiredLocationX"].Value), float.Parse(stripNode.Attributes["DesiredLocationY"].Value)); } foreach (XmlNode itemNode in stripNode.ChildNodes) { if (itemNode.Name != "RadCommandBarBaseItem") { continue; } RadCommandBarBaseItem item = this.GetItemByName(itemNode.Attributes["Name"].Value); if (item == null) { continue; } for (int attr = 0; attr < itemNode.Attributes.Count; attr++) { switch (itemNode.Attributes[attr].Name) { case "Orientation": item.Orientation = (itemNode.Attributes["Orientation"].Value == "Vertical") ? Orientation.Vertical : Orientation.Horizontal; break; case "VisibleInStrip": item.VisibleInStrip = (itemNode.Attributes["VisibleInStrip"].Value == "True"); break; case "StretchHorizontally": item.StretchHorizontally = (itemNode.Attributes["StretchHorizontally"].Value == "True"); break; case "StretchVertically": item.StretchVertically = (itemNode.Attributes["StretchVertically"].Value == "True"); break; case "Index": int index = int.Parse(itemNode.Attributes["Index"].Value); item.Parent.Children.Remove(item); strip.Items.Remove(item); if (strip.FloatingForm != null && !strip.FloatingForm.IsDisposed) { strip.FloatingForm.ItemsHostControl.Element.Layout.Children.Insert(index, item); } else { strip.Items.Insert(index, item); } break; } } } strip.ResumeLayout(true, true); } }
private void LoadStripsLayout(XmlNode lineNode, int maxLineIndex) { int currentLineIndex = 0; int.TryParse(lineNode.Attributes["LineIndex"].Value, out currentLineIndex); if (currentLineIndex < 0 || currentLineIndex > maxLineIndex) { currentLineIndex = 0; } foreach (XmlNode stripNode in lineNode.ChildNodes) { if (stripNode.Name != "CommandBarStripElement") { continue; } CommandBarStripElement strip = this.GetStripByName(stripNode.Attributes["Name"].Value); if (strip == null) { continue; } if (strip.FloatingForm != null && !strip.FloatingForm.IsDisposed) { strip.FloatingForm.TryDocking(this.ElementTree.Control as RadCommandBar); } if (strip.FloatingForm != null && !strip.FloatingForm.IsDisposed) { continue; } strip.SuspendLayout(true); strip.EnableFloating = false; for (int attr = 0; attr < stripNode.Attributes.Count; attr++) { switch (stripNode.Attributes[attr].Name) { case "Orientation": strip.Orientation = (stripNode.Attributes["Orientation"].Value == "Vertical") ? Orientation.Vertical : Orientation.Horizontal; break; case "VisibleInCommandBar": strip.VisibleInCommandBar = (stripNode.Attributes["VisibleInCommandBar"].Value == "True"); break; case "StretchHorizontally": strip.StretchHorizontally = (stripNode.Attributes["StretchHorizontally"].Value == "True"); break; case "StretchVertically": strip.StretchVertically = (stripNode.Attributes["StretchVertically"].Value == "True"); break; case "EnableFloating": strip.EnableFloating = (stripNode.Attributes["EnableFloating"].Value == "True"); break; case "EnableDragging": strip.EnableDragging = (stripNode.Attributes["EnableDragging"].Value == "True"); break; } } if (stripNode.Attributes["DesiredLocationX"] != null && stripNode.Attributes["DesiredLocationY"] != null) { strip.DesiredLocation = new PointF(float.Parse(stripNode.Attributes["DesiredLocationX"].Value), float.Parse(stripNode.Attributes["DesiredLocationY"].Value)); } CommandBarRowElement parentRow = (strip.Parent as CommandBarRowElement); if (parentRow != null) { parentRow.Strips.Remove(strip); } this.lines[currentLineIndex].Strips.Add(strip); foreach (XmlNode itemNode in stripNode.ChildNodes) { if (itemNode.Name != "RadCommandBarBaseItem") { continue; } RadCommandBarBaseItem item = this.GetItemByName(itemNode.Attributes["Name"].Value); if (item == null) { continue; } for (int attr = 0; attr < itemNode.Attributes.Count; attr++) { switch (itemNode.Attributes[attr].Name) { case "Orientation": item.Orientation = (itemNode.Attributes["Orientation"].Value == "Vertical") ? Orientation.Vertical : Orientation.Horizontal; break; case "VisibleInStrip": item.VisibleInStrip = (itemNode.Attributes["VisibleInStrip"].Value == "True"); break; case "StretchHorizontally": item.StretchHorizontally = (itemNode.Attributes["StretchHorizontally"].Value == "True"); break; case "StretchVertically": item.StretchVertically = (itemNode.Attributes["StretchVertically"].Value == "True"); break; case "Index": int index = int.Parse(itemNode.Attributes["Index"].Value); item.Parent.Children.Remove(item); strip.Items.Remove(item); strip.Items.Insert(index, item); break; } } } strip.ResumeLayout(true, true); strip.EnableFloating = true; } }
private XmlElement SaveFloatingStripsLayout(XmlDocument doc) { XmlElement floatingFormsNode = doc.CreateElement("FloatingStrips"); foreach (CommandBarStripElement stripElement in this.stripInfoHolder.StripInfoList) { if (stripElement.FloatingForm == null || stripElement.FloatingForm.IsDisposed) { continue; } XmlElement stripNode = doc.CreateElement("CommandBarStripElement"); stripNode.SetAttribute("Orientation", stripElement.Orientation.ToString()); stripNode.SetAttribute("Name", stripElement.Name); stripNode.SetAttribute("DesiredLocationX", stripElement.DesiredLocation.X.ToString()); stripNode.SetAttribute("DesiredLocationY", stripElement.DesiredLocation.Y.ToString()); stripNode.SetAttribute("FormLocationX", stripElement.FloatingForm.Location.X.ToString()); stripNode.SetAttribute("FormLocationY", stripElement.FloatingForm.Location.Y.ToString()); stripNode.SetAttribute("VisibleInCommandBar", stripElement.VisibleInCommandBar.ToString()); stripNode.SetAttribute("StretchHorizontally", stripElement.StretchHorizontally.ToString()); stripNode.SetAttribute("StretchVertically", stripElement.StretchVertically.ToString()); stripNode.SetAttribute("RTL", stripElement.RightToLeft.ToString()); stripNode.SetAttribute("EnableFloating", stripElement.EnableFloating.ToString()); stripNode.SetAttribute("EnableDragging", stripElement.EnableDragging.ToString()); int currentIndex = 0; for (int j = 0; j < stripElement.Items.Count; j++) { RadCommandBarBaseItem itemElement = stripElement.Items[j]; XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem"); itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString()); itemNode.SetAttribute("Name", itemElement.Name); itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString()); itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString()); itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString()); itemNode.SetAttribute("Index", currentIndex.ToString()); stripNode.AppendChild(itemNode); ++currentIndex; } for (int j = 0; j < stripElement.FloatingForm.ItemsHostControl.Element.Layout.Children.Count; j++) { RadCommandBarBaseItem itemElement = stripElement.FloatingForm.ItemsHostControl.Element.Layout.Children[j] as RadCommandBarBaseItem; if (itemElement == null) { continue; } XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem"); itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString()); itemNode.SetAttribute("Name", itemElement.Name); itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString()); itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString()); itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString()); itemNode.SetAttribute("Index", currentIndex.ToString()); stripNode.AppendChild(itemNode); ++currentIndex; } floatingFormsNode.AppendChild(stripNode); } return(floatingFormsNode); }