private void PileList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if ((int)e.Action == (int)NotifyCollectionChangedAction.Reset) { _thisStack !.Children.Clear(); // hopefully this simple (nothing else). well see return; } if ((int)e.Action == (int)NotifyCollectionChangedAction.Remove) { foreach (var thisItem in e.OldItems) { var thisPile = (BasicPileInfo <DutchBlitzCardInformation>)thisItem !; var thisCon = FindControl(thisPile); _thisStack !.Children.Remove(thisCon); } return; } if (e.Action == (int)NotifyCollectionChangedAction.Add) { foreach (var ThisItem in e.NewItems) { var thisPile = (BasicPileInfo <DutchBlitzCardInformation>)ThisItem !; IndividualPileWPF thisCon = new IndividualPileWPF(); thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); _thisStack !.Children.Add(thisCon); } return; } }
public void Init(PublicViewModel mod) { Background = Brushes.Transparent; _thisMod = mod; _thisStack = new WrapPanel(); var tempCard = new DutchBlitzCardInformation(); var thisP = Resolve <IProportionImage>(); _thisStack.ItemHeight = tempCard.DefaultSize.Height * thisP.Proportion; _thisStack.ItemWidth = tempCard.DefaultSize.Width * thisP.Proportion; _thisStack.Orientation = Orientation.Horizontal; // start out horizontally MouseUp += PublicPilesWPF_MouseUp; _pileList = _thisMod.PileList; // i think its that simple. _pileList.CollectionChanged += PileList_CollectionChanged; foreach (var thisPile in _pileList) { IndividualPileWPF thisCon = new IndividualPileWPF(); thisCon.IsHitTestVisible = true; thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); // i think i needed this as well _thisStack.Children.Add(thisCon); } Content = _thisStack; }
public void UpdateLists(PublicViewModel mod) { _thisMod = mod; _thisStack !.Children.Clear(); //best to just redo this time. _pileList !.CollectionChanged -= PileList_CollectionChanged; _pileList = _thisMod.PileList; _pileList.CollectionChanged += PileList_CollectionChanged; foreach (var thisPile in _pileList) { IndividualPileWPF thisCon = new IndividualPileWPF(); thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); // i think i needed this as well _thisStack.Children.Add(thisCon); } }