Beispiel #1
0
        public Launcher()
        {
            InitializeComponent();
            hsTable = new HighScoreTable();
            pcDoc   = new PicturesDoc();

            DirectoryInfo d = new DirectoryInfo(@"..\\..\\Pictures\\");

            FileInfo[] Files = d.GetFiles("*.jpg");
            foreach (FileInfo file in Files)
            {
                if (!file.Name.Equals("Untitled.jpg"))
                {
                    pcDoc.addPicture(file);
                }
            }

            System.IO.Directory.CreateDirectory(System.IO.Path.GetFullPath(@"..\\..\\") + "High Scores");

            highScoreName = Path.GetFullPath(@"..\\..\\High Scores\\") + "hs.hst";

            players = new List <Player>();

            try
            {
                using (FileStream fileStream = new FileStream(highScoreName, FileMode.Open))
                {
                    IFormatter formater = new BinaryFormatter();
                    hsTable = (HighScoreTable)formater.Deserialize(fileStream);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Could not read file: " + highScoreName);

                using (FileStream fileStream = new FileStream(highScoreName, FileMode.Create))
                {
                    IFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(fileStream, hsTable);
                }
            }
        }
Beispiel #2
0
 public Game(HighScoreTable hst, PicturesDoc pcDoc)
 {
     InitializeComponent();
     currentScore         = 0;
     this.hst             = hst;
     this.pcDoc           = pcDoc;
     rand                 = new Random();
     startButton.Enabled  = false;
     guessBtn.Enabled     = false;
     guessTb.ReadOnly     = true;
     player               = new Player();
     nextImg              = null;
     label7.Text          = "";
     DialogResult         = DialogResult.No;
     timePb.Maximum       = 60;
     timePb.Step          = 1;
     pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
     plThread             = new Thread(new ThreadStart(bfsCall));
     b2         = new Bitmap(pictureFolder + "Untitled.jpg");
     currWidth  = this.Width;
     currHeight = this.Height;
 }