private void PopulateList()
 {
     foreach (var firstDice in _diceList !)
     {
         RummyDiceGraphicsXF thisGraphics = new RummyDiceGraphicsXF(); // this does the bindings already as well
         thisGraphics.SendDiceInfo(firstDice, _board !);               //i think this too now.
         DiceBindings(thisGraphics, firstDice);
         _thisStack !.Children.Add(thisGraphics);
     }
 }
Esempio n. 2
0
        private void PopulateControls()
        {
            _thisStack !.Children.Clear();
            int x = 0;

            foreach (var firstDice in _handList !)
            {
                RummyDiceGraphicsXF thisGraphics = new RummyDiceGraphicsXF();
                thisGraphics.SendDiceInfo(firstDice, _mainGame !.MainBoard1);
                thisGraphics.Command = _thisMod !.DiceCommand;
                _thisStack.Children.Add(thisGraphics);
                x += 1;
            }
        }
 private void DiceList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (var ThisItem in e.NewItems)
         {
             var newDice = (RummyDiceInfo)ThisItem !;
             RummyDiceGraphicsXF thisD = new RummyDiceGraphicsXF();
             DiceBindings(thisD, newDice); // well see what we need
             thisD.SendDiceInfo(newDice, _board !);
             _thisStack !.Children.Add(thisD);
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Replace)
     {
         if (e.OldItems.Count == e.NewItems.Count)
         {
             int x;
             var loopTo = e.OldItems.Count;
             for (x = 1; x <= loopTo; x++)
             {
                 var oldDice = (RummyDiceInfo)e.OldItems[x - 1] !;
                 var newDice = (RummyDiceInfo)e.NewItems[x - 1] !;
                 var thisCon = FindControl(oldDice !);
                 thisCon !.BindingContext = newDice;
             }
         }
         else
         {
             throw new Exception("Not sure when the numbers don't match");
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Remove) //old cards
     {
         foreach (var thisItem in e.OldItems)
         {
             var oldDice = (RummyDiceInfo)thisItem !;
             var thisCon = FindControl(oldDice);
             _thisStack !.Children.Remove(thisCon); // because not there anymore.
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         _thisStack !.Children.Clear(); // needs to clear and do nothing else because no dice left
         PopulateList();
     }
     if ((int)e.Action == (int)NotifyCollectionChangedAction.Move)
     {
         if (e.OldStartingIndex == e.NewStartingIndex)
         {
             RefreshItems(); //several changes
         }
         else
         {
             var firstCon = _thisStack !.Children[e.OldStartingIndex];
             _ = _thisStack.Children[e.NewStartingIndex];
             _thisStack.Children.Remove(firstCon);
             _thisStack.Children.Insert(e.NewStartingIndex, firstCon);
         }
     }
 }
 private void DiceBindings(RummyDiceGraphicsXF thisGraphics, RummyDiceInfo thisDice) // needs the dice for the data context
 {
     thisGraphics.BindingContext = thisDice;
 }