Пример #1
0
        private void SaveUNO(string name)
        {
            ProjFileStream pfs = new ProjFileStream(name, System.IO.FileMode.Create, System.IO.FileAccess.Write);

            pfs.WriteBool(showResultsToolStripMenuItem.Checked);

            pfs.WriteInt(playerCount);
            for (int i = 0; i < playerCount; i++)
            {
                pfs.WriteString(playerNames[i]);
            }

            pfs.WriteInt(tabControl1.TabPages.Count);
            for (int i = 0; i < tabControl1.TabPages.Count; i++)
            {
                pfs.WriteString((tabControl1.TabPages[i].Tag as UNOOneGame).UNOStageName);
                pfs.WriteString((tabControl1.TabPages[i].Tag as UNOOneGame).UNOStageDate);
                pfs.WriteInt((tabControl1.TabPages[i].Tag as UNOOneGame).RoundsCount);

                for (int j = 0; j < (tabControl1.TabPages[i].Tag as UNOOneGame).RoundsCount; j++)
                {
                    for (int k = 0; k < playerCount; k++)
                    {
                        pfs.WriteInt((tabControl1.TabPages[i].Tag as UNOOneGame).GetValue(j, k));
                        pfs.WriteBool((tabControl1.TabPages[i].Tag as UNOOneGame).GetWinState(j, k));
                    }
                }
            }

            saved = true;

            pfs.Close();
        }
Пример #2
0
        private void LoadingProcess()
        {
            ProjFileStream reader = new ProjFileStream(pathToFile, FileMode.Open, FileAccess.Read);

            resultViewSheet1.LoadSheet(reader);

            reader.Close();
        }
Пример #3
0
        private void SavingProcess()
        {
            ProjFileStream writer = new ProjFileStream(pathToFile, FileMode.Create, FileAccess.Write);

            resultViewSheet1.SaveSheet(writer, false);

            writer.Close();
            saved = true;
        }
Пример #4
0
        // Сохранение цветовых схем
        private void ColorSchemesWrite()
        {
            string colorFileName = Path.Combine(Application.StartupPath, "Colors");

            ProjFileStream writer = new ProjFileStream(colorFileName, FileMode.Create, FileAccess.Write);

            int cnt = schemes.Count;

            writer.WriteInt(cnt);
            for (int i = 0; i < cnt; i++)
            {
                SheetColorScheme.WriteToStream(writer, schemes[i]);
            }

            writer.Close();
        }
Пример #5
0
        // Загрузка цветовых схем
        private void ColorSchemesRead()
        {
            schemes.Clear();
            string colorFileName = Path.Combine(Application.StartupPath, "Colors");

            if (File.Exists(colorFileName))
            {
                ProjFileStream reader = new ProjFileStream(colorFileName, FileMode.Open, FileAccess.Read);

                int cnt = reader.ReadInt();
                for (int i = 0; i < cnt; i++)
                {
                    schemes.Add(SheetColorScheme.ReadFromStream(reader));
                }

                reader.Close();
            }
            else
            {
                schemes.Add(new SheetColorScheme());
            }
        }
Пример #6
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();
            }
        }