public GroupItemModel(Group g, IdeCollection <IdeBaseItem> source) : base(source) //load { NewActionCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewAction); NewSubmenuCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSubmenu); NewSeparatorCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSeparator); ActionsDropHandler = new ActionsDropHandler(); _group = g; GroupActions = new IdeCollection <IdeBaseItem>(this); foreach (var action in g.GroupActions) { GroupActions.Add(IBaseAction.CreateActionItem(action, GroupActions)); } GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; CardActions = new IdeCollection <IdeBaseItem>(this); foreach (var action in g.CardActions) { CardActions.Add(IBaseAction.CreateActionItem(action, CardActions)); } CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; }
public BaseGroupItemModel(BaseGroupItemModel g, IdeCollection <IdeBaseItem> source) : base(source) //copy item { _group = new Group { Visibility = g.GroupVisibility, }; Name = g.Name; NewActionCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewAction); NewSubmenuCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSubmenu); NewSeparatorCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSeparator); ActionsDropHandler = new ActionsDropHandler(); GroupActions = new IdeCollection <IdeBaseItem>(this, typeof(IBaseAction)); GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; foreach (var item in g.GroupActions) { GroupActions.Add(IBaseAction.CopyActionItems(item, GroupActions)); } CardActions = new IdeCollection <IdeBaseItem>(this, typeof(IBaseAction)); CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; foreach (var item in g.CardActions) { CardActions.Add(IBaseAction.CopyActionItems(item, CardActions)); } }
public static IBaseAction CopyActionItems(IdeBaseItem action, IdeCollection <IdeBaseItem> source) { IBaseAction ret = null; if (action is ActionItemModel) { ret = new ActionItemModel((ActionItemModel)action, source); } else if (action is ActionSubmenuItemModel) { ret = new ActionSubmenuItemModel((ActionSubmenuItemModel)action, source); } else if (action is ActionSeparatorItemModel) { ret = new ActionSeparatorItemModel((ActionSeparatorItemModel)action, source); } return(ret); }
public static IBaseAction CreateActionItem(IGroupAction action, IdeCollection <IdeBaseItem> source) { IBaseAction ret = null; if (action is GroupAction) { ret = new ActionItemModel((GroupAction)action, source); } else if (action is GroupActionSubmenu) { ret = new ActionSubmenuItemModel((GroupActionSubmenu)action, source); } else if (action is GroupActionSeparator) { ret = new ActionSeparatorItemModel((GroupActionSeparator)action, source); } return(ret); }
public GroupItemModel(GroupItemModel g, IdeCollection <IdeBaseItem> source) : base(source) // copy item { NewActionCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewAction); NewSubmenuCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSubmenu); NewSeparatorCommand = new RelayCommand <IdeCollection <IdeBaseItem> >(NewSeparator); ActionsDropHandler = new ActionsDropHandler(); _group = new Group { Visibility = g.GroupVisibility, Shortcut = g.Shortcut, Ordered = g.Ordered, MoveTo = g.MoveTo, ViewState = g.ViewState }; Name = g.Name; GroupActions = new IdeCollection <IdeBaseItem>(this); GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; foreach (var item in g.GroupActions) { GroupActions.Add(IBaseAction.CopyActionItems(item, GroupActions)); } CardActions = new IdeCollection <IdeBaseItem>(this); CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; foreach (var item in g.CardActions) { CardActions.Add(IBaseAction.CopyActionItems(item, CardActions)); } Asset = new AssetController(AssetType.Image); Asset.Register(g._group.Icon); _group.Icon = Asset.FullPath; Asset.PropertyChanged += AssetUpdated; }