示例#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);
 }
 private RummyDiceGraphicsXF?FindControl(RummyDiceInfo thisDice)
 {
     foreach (var thisCon in _thisStack !.Children)
     {
         var deck = (RummyDiceGraphicsXF)thisCon !;
         if (deck.BindingContext.Equals(thisDice) == true)
         {
             return(deck);
         }
     }
     return(null);
 }
        private async Task DiceChosenAsync(RummyDiceInfo dice)
        {
            int x = HandList.IndexOf(dice);

            if (_mainGame.BasicData !.MultiPlayer == true)
            {
                SendSet thisSet = new SendSet();
                thisSet.WhichSet = Index;
                thisSet.Dice     = x;
                await _mainGame.Network !.SendAllAsync("diceset", thisSet);
            }
            await SelectUnselectDiceAsync(x);
        }
示例#4
0
        public void LoadList(RummyDiceHandVM thisMod, RummyDiceMainGameClass mainGame)
        {
            _thisMod    = thisMod;
            _mainGame   = mainGame;
            DataContext = thisMod;
            _handList   = thisMod.HandList;
            _handList.CollectionChanged += HandList_CollectionChanged;
            Text = $"Temp Set {thisMod.Index}";
            SetBinding(IsEnabledProperty, nameof(RummyDiceHandVM.IsEnabled));
            RummyDiceInfo firstDice = new RummyDiceInfo();

            if (firstDice.HeightWidth == 0)
            {
                throw new BasicBlankException("You must specify the height/width of the dice");
            }
            IProportionImage thisI     = new CustomProportionWPF();
            SKSize           firstSize = new SKSize(firstDice.HeightWidth, firstDice.HeightWidth);
            var  sizeUsed  = firstSize.GetSizeUsed(thisI.Proportion);
            Grid firstGrid = new Grid();

            GridHelper.AddPixelRow(firstGrid, (int)sizeUsed.Height + 50);
            GridHelper.AddLeftOverRow(firstGrid, 1);
            Margin                 = new Thickness(3, 3, 3, 3);
            _thisStack             = new StackPanel();
            _thisStack.Orientation = Orientation.Horizontal;
            Button thisBut = GetGamingButton("Place Tiles", nameof(RummyDiceHandVM.BoardCommand));

            //i think since its a different view model, has to do manually.
            thisBut.Name    = "";
            thisBut.Command = thisMod.BoardCommand;
            thisBut.Margin  = new Thickness(5, 5, 5, 5);
            GridHelper.AddControlToGrid(firstGrid, _thisStack, 0, 0);
            GridHelper.AddControlToGrid(firstGrid, thisBut, 1, 0);
            _thisGrid = new Grid();
            //hopefully does not need visible.  if we need visible, rethink.


            //SetBinding(VisibilityProperty, GetVisibleBinding(nameof(RummyDiceHandVM.Visible)));
            _thisGrid.Children.Add(ThisDraw);
            _thisGrid.Children.Add(firstGrid);
            var thisRect = ThisFrame.GetControlArea();

            _thisStack.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3);
            Width             = 1520; //different on xamarin forms.
            Height            = 250;
            PopulateControls();       //just in case there is something to start with.
            Content = _thisGrid;
        }
示例#5
0
        public void LoadList(RummyDiceHandVM thisMod, RummyDiceMainGameClass mainGame)
        {
            _thisMod                     = thisMod;
            _mainGame                    = mainGame;
            BindingContext               = thisMod;
            HorizontalOptions            = LayoutOptions.FillAndExpand; //hopefully this works too.
            _handList                    = thisMod.HandList;
            _handList.CollectionChanged += HandList_CollectionChanged;
            Text = $"Temp Set {thisMod.Index}";
            SetBinding(IsEnabledProperty, new Binding(nameof(RummyDiceHandVM.IsEnabled)));
            RummyDiceInfo firstDice = new RummyDiceInfo();

            if (firstDice.HeightWidth == 0)
            {
                throw new BasicBlankException("You must specify the height/width of the dice");
            }
            IProportionImage thisI     = new CustomProportionXF();
            SKSize           firstSize = new SKSize(firstDice.HeightWidth, firstDice.HeightWidth);
            var sizeUsed = firstSize.GetSizeUsed(thisI.Proportion);

            Margin                 = new Thickness(3, 3, 3, 3);
            _thisStack             = new StackLayout();
            _thisStack.Orientation = StackOrientation.Horizontal;
            _thisStack.Spacing     = 0;
            Button thisBut = GetSmallerButton("Place Tiles", "");

            thisBut.Command = thisMod.BoardCommand; //i think this way this time.
            StackLayout finalStack = new StackLayout();

            finalStack.Orientation = StackOrientation.Horizontal;
            finalStack.Children.Add(thisBut);
            finalStack.Spacing = 2;
            finalStack.Children.Add(_thisStack);
            thisBut.HorizontalOptions    = LayoutOptions.Start;
            thisBut.VerticalOptions      = LayoutOptions.Start;
            _thisStack.HorizontalOptions = LayoutOptions.FillAndExpand;
            thisBut.FontSize            *= .7f;
            _thisGrid = new Grid();
            _thisGrid.Children.Add(ThisDraw);
            _thisGrid.Children.Add(finalStack);
            var thisRect = ThisFrame.GetControlArea();

            thisBut.Margin    = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3);
            _thisStack.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3);
            PopulateControls(); //just in case there is something to start with.
            Content = _thisGrid;
        }
示例#6
0
        public void SendDiceInfo(RummyDiceInfo thisDice, RummyBoardCP board)
        {
            _board = board;
            _mains = new RummyDiceGraphicsCP(this);
            _mains.MinimumWidthHeight = thisDice.HeightWidth;
            SetBinding(IsSelectedProperty, new Binding(nameof(RummyDiceInfo.IsSelected))); //maybe i forgot this too.
            SetBinding(IsVisibleProperty, new Binding(nameof(RummyDiceInfo.Visible)));     //i think.
            SetBinding(ColorProperty, new Binding(nameof(RummyDiceInfo.Color)));
            SetBinding(ValueProperty, new Binding(nameof(RummyDiceInfo.Display)));         //decided to bind to display now.
            SKSize           tempSize = new SKSize(thisDice.HeightWidth, thisDice.HeightWidth);
            IProportionImage thisP    = new CustomProportionXF();
            SKSize           diceSize = tempSize.GetSizeUsed(thisP.Proportion);

            BindingContext = thisDice;
            HeightRequest  = diceSize.Height;
            WidthRequest   = diceSize.Width;
            Init();
        }
示例#7
0
        private async void Touch(object sender, SKTouchEventArgs e)
        {
            if (_board == null && Command == null)
            {
                return;
            }
            RummyDiceInfo dice = (RummyDiceInfo)BindingContext;

            if (Command != null)
            {
                if (Command.CanExecute(null) == false)
                {
                    return;
                }
                Command.Execute(dice);
                return;
            }

            await _board !.SelectDiceAsync((RummyDiceInfo)BindingContext);
        }
示例#8
0
        private async void RummyDiceGraphicsWPF_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (_board == null && Command == null)
            {
                return;
            }
            RummyDiceInfo dice = (RummyDiceInfo)DataContext;

            if (Command != null)
            {
                if (Command.CanExecute(null) == false)
                {
                    return;
                }
                Command.Execute(dice);
                return;
            }

            await _board !.SelectDiceAsync((RummyDiceInfo)DataContext);
        }
        public async Task SelectDiceAsync(RummyDiceInfo dice)
        {
            if (_command.IsExecuting)
            {
                return;
            }
            _command.IsExecuting = true;
            var list  = SaveRoot !.Invoke().DiceList;
            int index = list.IndexOf(dice);

            if (index == -1)
            {
                throw new BasicBlankException("had problems hooking up.  Rethink");
            }
            if (_basicData.MultiPlayer == true)
            {
                await _network !.SendAllAsync("diceclicked", index); //i think
            }
            await SelectOneMainAsync !.Invoke(index);
        }
 private void DiceBindings(RummyDiceGraphicsXF thisGraphics, RummyDiceInfo thisDice) // needs the dice for the data context
 {
     thisGraphics.BindingContext = thisDice;
 }