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 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 ActionSubmenuItemModel(IdeCollection <IdeBaseItem> source) : base(source) //new item { _action = new GroupActionSubmenu(); Items = new IdeCollection <IdeBaseItem>(this); Items.CollectionChanged += (a, b) => { ((GroupActionSubmenu)_action).Children = Items.Select(x => ((ActionSubmenuItemModel)x)._action); }; Name = "New Submenu"; Items.Add(new ActionItemModel(Items)); }
public ActionSubmenuItemModel(GroupActionSubmenu a, IdeCollection <IdeBaseItem> source) : base(source) //load item { _action = a; Items = new IdeCollection <IdeBaseItem>(this); foreach (var action in a.Children) { Items.Add(CreateActionItem(action, Items)); } Items.CollectionChanged += (b, c) => { ((GroupActionSubmenu)_action).Children = Items.Select(x => ((ActionSubmenuItemModel)x)._action); }; }
public PropertyTabViewModel() { Items = new IdeCollection <IdeBaseItem>(this); foreach (var property in ViewModelLocator.GameLoader.Game.CustomProperties) { Items.Add(new PropertyItemModel(property, Items)); } Items.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.CustomProperties = Items.Select(x => ((PropertyItemModel)x)._property).ToList(); Messenger.Default.Send(new CustomPropertyChangedMessage(args)); }; AddCommand = new RelayCommand(AddItem); //TODO: Make sure these property names aren't already set NameProperty = new PropertyItemModel(new PropertyDef() { Name = "Name" }, Items); IdProperty = new PropertyItemModel(new PropertyDef() { Name = "Id" }, Items); AlternateProperty = new PropertyItemModel(new PropertyDef() { Name = "Alternate" }, Items); SizeProperty = new PropertyItemModel(new PropertyDef() { Name = "CardSize" }, Items); //Proxy Properties ProxyNameProperty = new PropertyItemModel(new PropertyDef() { Name = "CardName" }, Items); SizeNameProperty = new PropertyItemModel(new PropertyDef() { Name = "CardSizeName" }, Items); SizeHeightProperty = new PropertyItemModel(new PropertyDef() { Name = "CardSizeHeight" }, Items); SizeWidthProperty = new PropertyItemModel(new PropertyDef() { Name = "CardSizeWidth" }, Items); }
public GameModeTabViewModel() { AddCommand = new RelayCommand(AddItem); Items = new IdeCollection <IdeBaseItem>(this, typeof(GameModeItemModel)); foreach (var mode in ViewModelLocator.GameLoader.Game.Modes) { Items.Add(new GameModeItemModel(mode, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Game.Modes = Items.Select(x => (x as GameModeItemModel)._gameMode).ToList(); }; }
public DocumentTabViewModel() { AddCommand = new RelayCommand(AddItem); Items = new IdeCollection <IdeBaseItem>(this, typeof(DocumentItemModel)); foreach (var document in ViewModelLocator.GameLoader.Game.Documents) { Items.Add(new DocumentItemModel(document, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Game.Documents = Items.Select(x => (x as DocumentItemModel)._document).ToList(); }; }
public SymbolTabViewModel() { AddCommand = new RelayCommand(AddItem); Items = new IdeCollection <IdeBaseItem>(this); foreach (var symbol in ViewModelLocator.GameLoader.Game.Symbols) { Items.Add(new SymbolItemModel(symbol, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Game.Symbols = Items.Select(x => (x as SymbolItemModel)._symbol).ToList(); }; }
public SetTabViewModel() { AddSetCommand = new RelayCommand(AddSet); Items = new IdeCollection <IdeBaseItem>(this); foreach (var set in ViewModelLocator.GameLoader.Sets) { Items.Add(new SetModel(set, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Sets = Items.Select(x => ((SetModel)x)._set); }; }
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; }
public BaseGroupItemModel(IdeCollection <IdeBaseItem> source) : base(source) //new 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(); GroupActions = new IdeCollection <IdeBaseItem>(this, typeof(IBaseAction)); CardActions = new IdeCollection <IdeBaseItem>(this, typeof(IBaseAction)); GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; }
public ActionSubmenuItemModel(ActionSubmenuItemModel a, IdeCollection <IdeBaseItem> source) : base(source) //copy item { _action = new GroupActionSubmenu { HeaderExecute = a._action.HeaderExecute, IsGroup = a.IsGroup, Name = a.Name, ShowExecute = a._action.ShowExecute }; Items = new IdeCollection <IdeBaseItem>(this); Items.CollectionChanged += (b, c) => { ((GroupActionSubmenu)_action).Children = Items.Select(x => ((ActionSubmenuItemModel)x)._action); }; foreach (ActionSubmenuItemModel action in a.Items) { Items.Add(CopyActionItems(action, Items)); } ; }
public GroupItemModel(IdeCollection <IdeBaseItem> source) : base(source) //new 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 { Icon = AssetManager.Instance.Assets.FirstOrDefault(x => x.Type == AssetType.Image)?.FullPath }; GroupActions = new IdeCollection <IdeBaseItem>(this); CardActions = new IdeCollection <IdeBaseItem>(this); GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; Name = "New Group"; RaisePropertyChanged("Asset"); }
public GroupItemModel(IdeCollection <IdeBaseItem> source) : base(source) //new 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(); GroupActions = new IdeCollection <IdeBaseItem>(this); CardActions = new IdeCollection <IdeBaseItem>(this); GroupActions.CollectionChanged += (a, b) => { _group.GroupActions = GroupActions.Select(x => ((IBaseAction)x)._action); }; CardActions.CollectionChanged += (a, b) => { _group.CardActions = CardActions.Select(x => ((IBaseAction)x)._action); }; Asset = new AssetController(AssetType.Image); _group.Icon = Asset.FullPath; Asset.PropertyChanged += AssetUpdated; Name = "New Group"; RaisePropertyChanged("Asset"); }
public PreviewTabViewModel() { var _game = ViewModelLocator.GameLoader.Game; if (_game.GlobalPlayer == null) { _game.GlobalPlayer = new GlobalPlayer() { Counters = new List <Counter>(), Groups = new List <Group>() }; } Table = new TableItemModel(_game.Table, new IdeCollection <IdeBaseItem>(this)) { CanRemove = false, CanCopy = false, CanInsert = false }; Piles = new IdeCollection <IdeBaseItem>(this); foreach (var pile in _game.Player.Groups) { Piles.Add(new GroupItemModel(pile, Piles)); } Piles.CollectionChanged += (sender, args) => { _game.Player.Groups = Piles.Select(x => ((GroupItemModel)x)._group); RaisePropertyChanged("CollapsedPiles"); RaisePropertyChanged("VisiblePiles"); Messenger.Default.Send(new GroupChangedMessage(args)); }; AddPileCommand = new RelayCommand(AddPile); Counters = new IdeCollection <IdeBaseItem>(this); foreach (var counter in _game.Player.Counters) { Counters.Add(new CounterItemModel(counter, Counters)); } Counters.CollectionChanged += (sender, args) => { _game.Player.Counters = Counters.Select(x => ((CounterItemModel)x)._counter); }; AddCounterCommand = new RelayCommand(AddCounter); GlobalPiles = new IdeCollection <IdeBaseItem>(this); foreach (var pile in _game.GlobalPlayer.Groups) { GlobalPiles.Add(new GroupItemModel(pile, GlobalPiles)); } GlobalPiles.CollectionChanged += (sender, args) => { _game.GlobalPlayer.Groups = GlobalPiles.Select(x => ((GroupItemModel)x)._group); RaisePropertyChanged("CollapsedGlobalPiles"); RaisePropertyChanged("VisibleGlobalPiles"); Messenger.Default.Send(new GroupChangedMessage(args)); }; AddGlobalPileCommand = new RelayCommand(AddGlobalPile); GlobalCounters = new IdeCollection <IdeBaseItem>(this); foreach (var counter in _game.GlobalPlayer.Counters) { GlobalCounters.Add(new CounterItemModel(counter, GlobalCounters)); } GlobalCounters.CollectionChanged += (sender, args) => { _game.GlobalPlayer.Counters = GlobalCounters.Select(x => ((CounterItemModel)x)._counter); }; AddGlobalCounterCommand = new RelayCommand(AddGlobalCounter); CardSizes = new IdeCollection <IdeBaseItem>(this); foreach (var sizeDef in _game.CardSizes) { var size = new SizeItemModel(sizeDef.Value, CardSizes); CardSizes.Add(size); if (sizeDef.Key == "") { CardSizes.DefaultItem = size; } } CardSizes.CollectionChanged += (sender, args) => { UpdateCardSizesDef(); Messenger.Default.Send(new CardSizeChangedMesssage(args)); }; CardSizes.DefaultItemChanged += (sender, args) => { UpdateCardSizesDef(); }; AddSizeCommand = new RelayCommand(AddSize); Phases = new IdeCollection <IdeBaseItem>(this); foreach (var phase in _game.Phases) { Phases.Add(new PhaseItemModel(phase, Phases)); } Phases.CollectionChanged += (sender, args) => { _game.Phases = Phases.Select(x => ((PhaseItemModel)x)._phase).ToList(); }; AddPhaseCommand = new RelayCommand(AddPhase); Boards = new IdeCollection <IdeBaseItem>(this); foreach (var boardDef in _game.GameBoards) { var board = new BoardItemModel(boardDef.Value, Boards); Boards.Add(board); if (boardDef.Key == "") { Boards.DefaultItem = board; } } ActiveBoard = (BoardItemModel)Boards.DefaultItem; Boards.CollectionChanged += (sender, args) => { UpdateBoardsDef(); }; Boards.DefaultItemChanged += (sender, args) => { UpdateBoardsDef(); }; AddBoardCommand = new RelayCommand(AddBoard); Cards = new ObservableCollection <SampleCardItemModel>(); var card = new SampleCardItemModel { Size = (SizeItemModel)CardSizes.DefaultItem }; Cards.Add(card); RaisePropertyChanged("Cards"); }
public void BuildPackageDef(NotifyCollectionChangedEventArgs args) { _set.Packs = PackageItems.Select(x => ((PackageModel)x)._pack); }
public PreviewTabViewModel() { #region table if (_game.Table == null) { _game.Table = new Group() { Name = "Table", Width = 640, Height = 480 }; } Table = new TableItemModel(_game.Table, new IdeCollection <IdeBaseItem>(this)) { CanRemove = false, CanCopy = false, CanInsert = false }; #endregion #region piles if (_game.Player == null) { _game.Player = new Player(); } Piles = new IdeCollection <IdeBaseItem>(this); foreach (var pile in _game.Player.Groups) { Piles.Add(new GroupItemModel(pile, Piles)); } Piles.CollectionChanged += (sender, args) => { _game.Player.Groups = Piles.Select(x => ((GroupItemModel)x)._group); RaisePropertyChanged("CollapsedPiles"); RaisePropertyChanged("VisiblePiles"); Messenger.Default.Send(new GroupChangedMessage(args)); }; AddPileCommand = new RelayCommand(AddPile); #endregion #region counters Counters = new IdeCollection <IdeBaseItem>(this); foreach (var counter in _game.Player.Counters) { Counters.Add(new CounterItemModel(counter, Counters)); } Counters.CollectionChanged += (sender, args) => { _game.Player.Counters = Counters.Select(x => ((CounterItemModel)x)._counter); }; AddCounterCommand = new RelayCommand(AddCounter); #endregion #region globalpiles if (_game.GlobalPlayer == null) { _game.GlobalPlayer = new GlobalPlayer(); } GlobalPiles = new IdeCollection <IdeBaseItem>(this); foreach (var pile in _game.GlobalPlayer.Groups) { GlobalPiles.Add(new GroupItemModel(pile, GlobalPiles)); } GlobalPiles.CollectionChanged += (sender, args) => { _game.GlobalPlayer.Groups = GlobalPiles.Select(x => ((GroupItemModel)x)._group); RaisePropertyChanged("CollapsedGlobalPiles"); RaisePropertyChanged("VisibleGlobalPiles"); Messenger.Default.Send(new GroupChangedMessage(args)); }; AddGlobalPileCommand = new RelayCommand(AddGlobalPile); #endregion #region globalcounters GlobalCounters = new IdeCollection <IdeBaseItem>(this); foreach (var counter in _game.GlobalPlayer.Counters) { GlobalCounters.Add(new CounterItemModel(counter, GlobalCounters)); } GlobalCounters.CollectionChanged += (sender, args) => { _game.GlobalPlayer.Counters = GlobalCounters.Select(x => ((CounterItemModel)x)._counter); }; AddGlobalCounterCommand = new RelayCommand(AddGlobalCounter); #endregion #region sizes CardSizes = new IdeCollection <IdeBaseItem>(this); foreach (var sizeDef in _game.CardSizes) { var size = new SizeItemModel(sizeDef.Value, CardSizes); CardSizes.Add(size); if (sizeDef.Key == "") { CardSizes.DefaultItem = size; } } CardSizes.CollectionChanged += (sender, args) => { UpdateCardSizesDef(); Messenger.Default.Send(new CardSizeChangedMesssage(args)); }; CardSizes.DefaultItemChanged += (sender, args) => { UpdateCardSizesDef(); }; AddSizeCommand = new RelayCommand(AddSize); #endregion #region phases Phases = new IdeCollection <IdeBaseItem>(this); foreach (var phase in _game.Phases) { Phases.Add(new PhaseItemModel(phase, Phases)); } Phases.CollectionChanged += (sender, args) => { _game.Phases = Phases.Select(x => ((PhaseItemModel)x)._phase).ToList(); }; AddPhaseCommand = new RelayCommand(AddPhase); #endregion #region boards Boards = new IdeCollection <IdeBaseItem>(this); foreach (var boardDef in _game.GameBoards) { var board = new BoardItemModel(boardDef.Value, Boards); Boards.Add(board); if (boardDef.Key == "") { Boards.DefaultItem = board; } } Boards.CollectionChanged += (sender, args) => { UpdateBoardsDef(); }; Boards.DefaultItemChanged += (sender, args) => { UpdateBoardsDef(); }; AddBoardCommand = new RelayCommand(AddBoard); #endregion #region samplecards Cards = new ObservableCollection <SampleCardItemModel>(); if (CardSizes.DefaultItem != null) { var card = new SampleCardItemModel { Size = (SizeItemModel)CardSizes.DefaultItem }; Cards.Add(card); } #endregion #region activeboard if (Boards.DefaultItem != null) { ActiveBoard = (BoardItemModel)Boards.DefaultItem; } #endregion }
public ScriptsTabViewModel() { GlobalVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.GlobalVariables) { GlobalVariables.Add(new GlobalVariableItemModel(globalvariable.Value, GlobalVariables)); } GlobalVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.GlobalVariables = GlobalVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddGlobalVariableCommand = new RelayCommand(AddGlobalVariable); PlayerVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.Player.GlobalVariables) { PlayerVariables.Add(new GlobalVariableItemModel(globalvariable.Value, PlayerVariables)); } PlayerVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.Player.GlobalVariables = PlayerVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddPlayerVariableCommand = new RelayCommand(AddPlayerVariable); Scripts = new IdeCollection <IdeBaseItem>(); foreach (var script in ViewModelLocator.GameLoader.Scripts) { Scripts.Add(new ScriptItemModel(script, Scripts)); } Scripts.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Scripts = Scripts.Select(x => ((ScriptItemModel)x)._script); }; AddScriptCommand = new RelayCommand(AddScript); Events = new IdeCollection <IdeBaseItem>(); foreach (var gameEventType in ViewModelLocator.GameLoader.Game.Events) { foreach (var gameEvent in gameEventType.Value) { Events.Add(new GameEventItemModel(gameEvent, Events)); } } Events.CollectionChanged += (a, b) => { var items = ViewModelLocator.GameLoader.Game.Events = Events.GroupBy(x => ((GameEventItemModel)x).Name) .ToDictionary( x => x.Key, y => y.Select(z => ((GameEventItemModel)z)._gameEvent).ToArray()); }; AddEventCommand = new RelayCommand(AddGameEvent); }