Exemple #1
0
        private void addToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            tabControl1.TabPages.Add("New Stage");
            UNOOneGame unoOneGame = new UNOOneGame();

            unoOneGame.CreateUNOGame(playerCount, playerNames);
            unoOneGame.ShowHideResults(!showResultsToolStripMenuItem.Checked);
            unoOneGame.Dock = DockStyle.Top;
            unoOneGame.ScrollVisiblityChangeEvent += new EventHandler <ScrollVisiblityEventArgs>(unoOneGame_ScrollVisiblityChangeEvent);
            unoOneGame.NameChangedEvent           += new EventHandler <NameChangedEventArgs>(unoOneGame_NameChangedEvent);
            tabControl1.TabPages[tabControl1.TabPages.Count - 1].Tag = unoOneGame;
            tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(unoOneGame);

            if (!roundToolStripMenuItem.Enabled)
            {
                roundToolStripMenuItem.Enabled = true;
            }

            saved = false;
        }
Exemple #2
0
        private void LoadUNO()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "*.uno | *.uno";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                currentFile = ofd.FileName;
                ProjFileStream pfs = new ProjFileStream(currentFile, System.IO.FileMode.Open, System.IO.FileAccess.Read);

                if (tabControl1.TabPages.Count > 0)
                {
                    tabControl1.TabPages.Clear();
                }
                tabControl1.Visible           = true;
                gameToolStripMenuItem.Enabled = true;

                showResultsToolStripMenuItem.Checked = pfs.ReadBool();

                playerCount        = pfs.ReadInt();
                tabControl1.Height = UNOOneGame.ColumnHeaderHeight + playerCount * UNOOneGame.RowHeight + UNOOneGame.BottomHeight +
                                     tabControl1.ItemSize.Height;
                for (int i = 0; i < playerCount; i++)
                {
                    playerNames[i] = pfs.ReadString();
                }

                int stages = pfs.ReadInt();
                for (int i = 0; i < stages; i++)
                {
                    string name = pfs.ReadString();
                    string date = pfs.ReadString();
                    tabControl1.TabPages.Add(name);

                    UNOOneGame unoOneGame = new UNOOneGame();
                    unoOneGame.UNOStageName = name;
                    unoOneGame.UNOStageDate = date;
                    unoOneGame.CreateUNOGame(playerCount, playerNames);
                    unoOneGame.ShowHideResults(!showResultsToolStripMenuItem.Checked);
                    unoOneGame.Dock = DockStyle.Top;
                    unoOneGame.ScrollVisiblityChangeEvent += new EventHandler <ScrollVisiblityEventArgs>(unoOneGame_ScrollVisiblityChangeEvent);
                    unoOneGame.NameChangedEvent           += new EventHandler <NameChangedEventArgs>(unoOneGame_NameChangedEvent);
                    tabControl1.TabPages[tabControl1.TabPages.Count - 1].Tag = unoOneGame;
                    tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(unoOneGame);

                    if (!roundToolStripMenuItem.Enabled)
                    {
                        roundToolStripMenuItem.Enabled = true;
                    }

                    int roundCount = pfs.ReadInt();
                    for (int j = 0; j < roundCount; j++)
                    {
                        (tabControl1.TabPages[i].Tag as UNOOneGame).AddRound(playerCount);
                        for (int k = 0; k < playerCount; k++)
                        {
                            (tabControl1.TabPages[i].Tag as UNOOneGame).SetValue(j, k, pfs.ReadInt());
                            (tabControl1.TabPages[i].Tag as UNOOneGame).SetWinState(j, k, pfs.ReadBool());
                        }
                    }
                    unoOneGame.RefreshResults();
                }

                pfs.Close();
            }
        }