Exemple #1
0
 private void DiceBindings(RummyDiceGraphicsWPF thisGraphics, RummyDiceInfo thisDice) // needs the dice for the data context
 {
     thisGraphics.DataContext = thisDice;
     //thisGraphics.CommandParameter = thisDice;
     //var ThisBind = GetCommandBinding(nameof(RummyBoardCP.DiceCommand));
     //thisGraphics.SetBinding(RummyDiceGraphicsWPF.CommandProperty, ThisBind);
 }
Exemple #2
0
 private void PopulateList()
 {
     foreach (var firstDice in _diceList !)
     {
         RummyDiceGraphicsWPF thisGraphics = new RummyDiceGraphicsWPF(); // this does the bindings already as well
         thisGraphics.SendDiceInfo(firstDice, _board !);                 //i think this too now.
         DiceBindings(thisGraphics, firstDice);
         _thisStack !.Children.Add(thisGraphics);
     }
 }
Exemple #3
0
        private void PopulateControls()
        {
            _thisStack !.Children.Clear();
            int x = 0;

            foreach (var firstDice in _handList !)
            {
                RummyDiceGraphicsWPF thisGraphics = new RummyDiceGraphicsWPF();
                thisGraphics.SendDiceInfo(firstDice, _mainGame !.MainBoard1);
                thisGraphics.Command = _thisMod !.DiceCommand;
                thisGraphics.Margin  = new Thickness(5, 5, 5, 5); //hopefully this works as well (?)
                _thisStack.Children.Add(thisGraphics);
                x += 1;
            }
        }
Exemple #4
0
 private void DiceList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (var ThisItem in e.NewItems)
         {
             var newDice = (RummyDiceInfo)ThisItem !;
             RummyDiceGraphicsWPF thisD = new RummyDiceGraphicsWPF();
             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 !.DataContext = 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);
         }
     }
 }