示例#1
0
 public FrameVM(GameVM gameVM, Frame frame)
 {
     GameVM = gameVM;
     Frame  = frame;
     GameVM.CurrentRollIndexChanged  += OnCurrentRollIndexChanged;
     GameVM.CurrentFrameIndexChanged += OnCurrentFrameIndexChanged;
 }
        void showLoadRollsDialog_Click(object sender, RoutedEventArgs e)
        {
            GameVM          gameVM          = (GameVM)DataContext;
            LoadRollsDialog loadRollsDialog = new LoadRollsDialog(gameVM.Rolls);

            if (loadRollsDialog.ShowDialog() == true)
            {
                gameVM.Reset();
                gameVM.LoadRolls(loadRollsDialog.Rolls);
            }
        }
示例#3
0
        private void OnCurrentRollIndexChanged(object sender, int currentRollIndexChanged)
        {
            if (GameVM.CurrentFrameIndex >= FrameIndex)
            {
                int rollCount = Frame.RollIndexes.Count;

                if (rollCount == 0)
                {
                    ScoreSlot1 = "";
                    ScoreSlot2 = "";
                    ScoreSlot3 = "";


                    ScoreSlotTotal = "";
                }
                else
                {
                    int firstRoll  = 0;
                    int secondRoll = 0;
                    int thirdRoll  = 0;

                    if (rollCount > 0)
                    {
                        firstRoll = GameVM.Rolls[Frame.RollIndexes[0]];
                    }

                    if (rollCount > 1)
                    {
                        secondRoll = GameVM.Rolls[Frame.RollIndexes[1]];
                    }

                    if (rollCount > 2)
                    {
                        thirdRoll = GameVM.Rolls[Frame.RollIndexes[2]];
                    }

                    if (FrameIndex == 9)
                    {
                        if (rollCount == 1)
                        {
                            if (firstRoll == 10)
                            {
                                ScoreSlot1 = "X";
                            }
                            else if (firstRoll == 0)
                            {
                                ScoreSlot1 = "-";
                            }
                            else
                            {
                                ScoreSlot1 = firstRoll.ToString();
                            }
                        }
                        else if (rollCount == 2)
                        {
                            if (firstRoll == 10)
                            {
                                if (secondRoll == 10)
                                {
                                    ScoreSlot2 = "X";
                                }
                                else if (secondRoll == 0)
                                {
                                    ScoreSlot2 = "-";
                                }
                                else
                                {
                                    ScoreSlot2 = secondRoll.ToString();
                                }
                            }
                            else
                            {
                                if (firstRoll + secondRoll == 10)
                                {
                                    ScoreSlot2 = "/";
                                }
                                else if (secondRoll == 0)
                                {
                                    ScoreSlot2 = "-";
                                }
                                else
                                {
                                    ScoreSlot2 = secondRoll.ToString();
                                }
                            }
                        }
                        else if (rollCount == 3)
                        {
                            if (thirdRoll == 10)
                            {
                                ScoreSlot3 = "X";
                            }
                            else if (thirdRoll == 0)
                            {
                                ScoreSlot3 = "-";
                            }
                            else
                            {
                                ScoreSlot3 = thirdRoll.ToString();
                            }
                        }
                    }
                    else
                    {
                        if (rollCount == 1)
                        {
                            if (firstRoll == 10)
                            {
                                ScoreSlot2 = "X";
                            }
                            else if (firstRoll == 0)
                            {
                                ScoreSlot1 = "-";
                            }
                            else
                            {
                                ScoreSlot1 = firstRoll.ToString();
                            }
                        }
                        else if (rollCount == 2)
                        {
                            if (firstRoll + secondRoll == 10)
                            {
                                ScoreSlot2 = "/";
                            }
                            else if (secondRoll == 0)
                            {
                                ScoreSlot2 = "-";
                            }
                            else
                            {
                                ScoreSlot2 = secondRoll.ToString();
                            }
                        }
                    }
                }
            }
            else
            {
                ScoreSlot1 = "";
                ScoreSlot2 = "";
                ScoreSlot3 = "";
            }

            if (GameVM.CurrentFrameIndex >= FrameIndex)
            {
                ScoreSlotTotal = GameVM.GetScoreByFrameIndex(FrameIndex).ToString();
            }
            else
            {
                ScoreSlotTotal = "";
            }
        }
示例#4
0
 public ApplicationVM()
 {
     GameVM = new GameVM();
 }