예제 #1
0
 private void timerTimedGame_Tick(object sender, EventArgs e)
 {
     //settings.Reload();
     settings = SettingsSystem.GetSettings(true);
     if (settings.alertBeforeKill)
     {
         //alert the user by sound
         if (settings.alertAudible)
         {
             SystemSounds.Beep.Play();
         }
         if (settings.alertTakeFocus)
         {
             this.Focus();
         }
     }
     if (!backgroundTimeSystem.IsBusy)
     {
         backgroundTimeSystem.RunWorkerAsync();
     }
     //alert the user visually
     if (settings.alertBeforeKill)
     {
         if (settings.alertVisual)
         {
             MessageBox.Show("The Game is shutting down in: " + settings.checkInWait.Hours + ":" + settings.checkInWait.Minutes + ":" + settings.checkInWait.Seconds, "Shutting down game", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
         }
     }
 }
예제 #2
0
        public Game CheckIn(bool emergency)
        {
            lockerSettings settings = SettingsSystem.GetSettings(true);

            //alert the user of its death
            if (!emergency)
            {
                proc.WaitForExit((int)settings.checkInWait.TotalMilliseconds);
            }

            while (!proc.HasExited)
            {
                proc.Kill();
                proc.WaitForExit(10000);
            }
            if (!timeLog.detectedLogError() || usingDetailedTime)
            {
                timeLog.endSession(proc.ExitTime);
            }
            else if (timeLog.detectedLogError())
            {
                timeLog.addNewSession(proc.StartTime, proc.ExitTime);
            }
            else
            {
                //forget this session
            }
            locker.removeFile(unlock);
            TimeLogFactory.saveLog(timeLog);
            settings         = SettingsSystem.GetSettings();
            settings.lastTry = DateTime.Now;
            checkedout       = false;
            SettingsSystem.Sync();
            return(this);
        }
예제 #3
0
 private void buttonTimed_Click(object sender, EventArgs e)
 {
     if (gameRunning == null)
     {
         settings = SettingsSystem.GetSettings();
         TimeSpan span = (DateTime.Now - settings.lastTry);
         if (settings.waitToPlay < span)
         {
             timerTimedGame.Interval = (int)settings.timedGame.TotalMilliseconds;
             Game game = (Game)listBoxGames.SelectedItem;
             if (game == null)
             {
                 return;
             }
             listBoxGames.Enabled   = false;
             gameRunning            = game.CheckOut();
             timerCheckOut.Enabled  = true;
             timerTimedGame.Enabled = true;
             label1.Visible         = true;
             label2.Visible         = true;
             progressBar1.Visible   = true;
         }
         else
         {
             TimeSpan sp = (settings.waitToPlay - (DateTime.Now - settings.lastTry));
             MessageBox.Show("You must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before you can play again");
         }
     }
 }
예제 #4
0
        private void buttonLock_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialogExecutible.ShowDialog();

            if (result == DialogResult.OK)
            {
                NameDialog named = new NameDialog();
                if (named.ShowDialog() == DialogResult.OK)
                {
                    locker.lockFile(openFileDialogExecutible.FileName);
                    settings = SettingsSystem.GetSettings();
                    settings.fileMap.Add(named.textBox1.Text);
                    settings.Save();
                    refreshList();
                }
            }
        }
예제 #5
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            //run the improbability drive
            imProbabilityDrive drive = new imProbabilityDrive();
            Random             rand  = new Random();
            TimeSpan           span;

            if (gameRunning == null)
            {
                span = DateTime.Now - settings.lastTry;
                if (settings.waitToPlay <= span)
                {
                    if (drive.ShowDialog() == DialogResult.OK)
                    {
                        if (drive.numericUpDownPicker.Value == rand.Next(settings.probability + 1))
                        {
                            settings.lastTry = DateTime.Now;
                            settings         = SettingsSystem.GetSettings();
                            Game game = (Game)listBoxGames.SelectedItem;
                            if (game == null)
                            {
                                return;
                            }
                            listBoxGames.Enabled  = false;
                            gameRunning           = game.CheckOut();
                            timerCheckOut.Enabled = true;
                        }
                        else
                        {
                            span = settings.incorrectWait;
                            MessageBox.Show("You have guessed incorrectly, you must wait " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before trying again", "oops");
                        }
                    }
                }
                else
                {
                    span = settings.waitToPlay - (DateTime.Now - settings.lastTry);
                    MessageBox.Show("Sorry, but you must wait at least " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " to try playing again", "Oops");
                }
            }
        }
예제 #6
0
        private void refreshList()
        {
            settings = SettingsSystem.GetSettings();
            listBoxGames.Items.Clear();
            treeViewStats.Nodes.Clear();
            treeViewStats.Nodes.Add(new TreeNode("Statistics"));
            Game games;

            for (int i = 0; i < settings.fileList.Count; i++)
            {
                games = new Game(settings.fileMap[i], settings.fileList[i]);
                listBoxGames.Items.Add(games);
                treeViewStats.Nodes[0].Nodes.Add(games.GameName, games.GameName);
                treeViewStats.Nodes[0].Nodes[i].Nodes.Add("Total Time Played");
                treeViewStats.Nodes[0].Nodes[i].Nodes[0].Nodes.Add(games.WhatIsTotalTime.Days + " days");
                treeViewStats.Nodes[0].Nodes[i].Nodes[0].Nodes.Add(games.WhatIsTotalTime.Hours + " hours");
                treeViewStats.Nodes[0].Nodes[i].Nodes[0].Nodes.Add(games.WhatIsTotalTime.Minutes + " mins");
                treeViewStats.Nodes[0].Nodes[i].Nodes[0].Nodes.Add(games.WhatIsTotalTime.Seconds + " secs");
                treeViewStats.Nodes[0].Nodes[i].Nodes[0].Nodes.Add(games.WhatIsTotalTime.TotalHours + " total hours");
            }
        }
예제 #7
0
        private void buttonOptions_Click(object sender, EventArgs e)
        {
            OptionsForm        options = new OptionsForm();
            imProbabilityDrive drive   = new imProbabilityDrive();
            Random             rand    = new Random();
            TimeSpan           span    = DateTime.Now - settings.lastTry;

            if (drive.ShowDialog() == DialogResult.OK)
            {
                if (drive.numericUpDownPicker.Value == rand.Next(settings.probability + 1))
                {
                    options.ShowDialog();
                    settings = SettingsSystem.GetSettings(true);
                }
                else
                {
                    span = settings.incorrectWait;
                    MessageBox.Show("You have guessed incorrectly, you must wait " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " before trying again", "oops");
                }
            }
        }