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);
        }
Beispiel #2
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);
         }
     }
 }
Beispiel #3
0
        static void Main(string [] args)
        {
            foreach (string arg in Environment.GetCommandLineArgs())
            {
                if (arg == "uninstall")
                {
                    locker.unlockAllFiles();
                    Application.Exit();
                }
            }
            //initialize Application
            lockerSettings settings = new lockerSettings();

            if (settings.fileMap.Count > 0 && settings.fileMap[0] == "begin")
            {
                settings.fileMap.Clear();
                settings.fileList.Clear();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new OptionsForm());
                settings.Save();
                Application.Restart();
            }
            else
            {
                SettingsSystem.init();
                SettingsSystem.Sync();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new PlayGame());
            }
        }
Beispiel #4
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");
         }
     }
 }
Beispiel #5
0
        public static string lockFile(string filename)
        {
            encryptFile(filename, filename);
            lockerSettings settings = new lockerSettings();

            settings.Reload();
            settings.fileList.Add(filename);
            settings.Save();
            SettingsSystem.Sync();
            return(filename);
        }
Beispiel #6
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();
                }
            }
        }
Beispiel #7
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");
                }
            }
        }
Beispiel #8
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");
            }
        }
Beispiel #9
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");
                }
            }
        }