public BarItem CopyBarItem(BarItem barItem, out ICollection <BarItemLinkBase> barItemLinks) { BarItem copiedBarItem = (BarItem)Activator.CreateInstance(barItem.GetType()); copiedBarItem.Name = "CopiedBarItem" + namesGenerator.Get(); copiedBarItem.Content = barItem.Content; copiedBarItem.ContentTemplate = barItem.ContentTemplate; copiedBarItem.Glyph = barItem.Glyph; copiedBarItem.LargeGlyph = barItem.LargeGlyph; copiedBarItem.Hint = barItem.Hint; copiedBarItem.GlyphAlignment = barItem.GlyphAlignment; RibbonManager.SetAction(copiedBarItem, RibbonManager.GetAction(barItem)); CopyBarItemEditSettings(barItem, copiedBarItem); CopyBarItemPopupControl(barItem, copiedBarItem); barItemLinks = CopyBarItemItemLinks(barItem, copiedBarItem); return(copiedBarItem); }
public BarItem BarItemFromString(string s) { string[] parts = ReflectionHelper.SplitString(s); if (parts.Length != 7) { return(null); } Type type = (Type)ReflectionHelper.ObjectFromString(parts[0]); if (type == null) { return(null); } BarItem barItem = (BarItem)Activator.CreateInstance(type); barItem.Content = ReflectionHelper.ObjectFromString(parts[1]); barItem.Glyph = ImageSourceHelper.ImageSourceFromString(parts[2]); barItem.LargeGlyph = ImageSourceHelper.ImageSourceFromString(parts[3]); barItem.Hint = ReflectionHelper.ObjectFromString(parts[4]); barItem.GlyphAlignment = (Dock)ReflectionHelper.ObjectFromString(parts[5]); RibbonManager.SetAction(barItem, ReflectionHelper.ObjectFromString(parts[6])); return(barItem); }