public void AddMenuModel(string path, IMenuModel model) { CollectionMenuModel parentModel = FindOrCreateCollection(path); parentModel.AddModel(model); model.Register(this); }
public void AddCommand(ICommand command, AbstractMenuAttribute attribute) { var model = new CommandMenuModel(command, attribute.AfterMenuItem, attribute.SeperatorAbove, attribute.SeperatorBelow, attribute.Image); CollectionMenuModel parent = _root; if (!string.IsNullOrEmpty(attribute.Path)) { parent = FindOrCreateCollection(attribute.Path); } parent.AddModel(model); }
private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string[] fragments) { var childModel = (CollectionMenuModel)model.Children.FirstOrDefault(child => child.Name == fragments[0]); if (childModel == null) { childModel = new FolderMenuModel(fragments[0], null, fragments[0]); model.AddModel(childModel); } if (fragments.Length > 1) { var fragmentsLessOne = new string[fragments.Length - 1]; Array.ConstrainedCopy(fragments, 1, fragmentsLessOne, 0, fragmentsLessOne.Length); return(FindOrCreateCollection(childModel, fragmentsLessOne)); } return(childModel); }
private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string[] fragments) { var childModel = (CollectionMenuModel) model.Children.FirstOrDefault(child => child.Name == fragments[0]); if (childModel == null) { childModel = new FolderMenuModel(fragments[0], null, fragments[0]); model.AddModel(childModel); } if (fragments.Length > 1) { var fragmentsLessOne = new string[fragments.Length - 1]; Array.ConstrainedCopy(fragments, 1, fragmentsLessOne, 0, fragmentsLessOne.Length); return FindOrCreateCollection(childModel, fragmentsLessOne); } return childModel; }
private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string path) { string[] parts = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); return(FindOrCreateCollection(model, parts)); }
private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string path) { string[] parts = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); return FindOrCreateCollection(model, parts); }