Esempio n. 1
0
 static void ShowGUI(object sender, EventArgs e)
 {
     if (CSClockForm != null)
     {
         CSClockForm.Show();
         CSClockForm.BringToFront();
     }
     else
     {
         CSClockForm = new CSClock();
         CSClockForm.Show();
     }
 }
Esempio n. 2
0
        static void StartApplication(string[] args)
        {
            logger.Log(className, "Starting CSClock", Logger.LogType.Info);

            if ((args == null || args.Length == 0 || !args.Contains("-disup")) && Properties.Settings.Default.autoUpdate)
            {
                Properties.Settings.Default.properExit = true;
                Properties.Settings.Default.Save();

                CheckForUpdate();

                Properties.Settings.Default.properExit = false;
                Properties.Settings.Default.Save();
            }

            selectedLanguage = Properties.Settings.Default.selectedLanguage;
            rm_GUI           = new ResourceManager(string.Format("CSClock.Languages.{0}.GUI", selectedLanguage), assembly);

            if (args != null && args.Length > 0 && args.Contains("-disup"))
            {
                Properties.Settings.Default.autoUpdate = false;
                Properties.Settings.Default.Save();
            }
            else if (args != null && args.Length > 0 && args.Contains("-enup"))
            {
                Properties.Settings.Default.autoUpdate = true;
                Properties.Settings.Default.Save();

                CheckForUpdate();
            }

            if (args != null && args.Length > 0 && args.Contains("-uninstall"))
            {
                if (Application.ExecutablePath.StartsWith(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CSClock")))
                {
                    Uninstall();
                }
                else
                {
                    MessageBox.Show("Uninstallation not available nor needed in portable version", "CSClock", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                return;
            }

            if (args != null && args.Length > 0 && args.Contains("-reset"))
            {
                logger.Log(className, "Resetting CSClock", Logger.LogType.Info);

                Properties.Settings.Default.Reset();
                //Properties.Settings.Default.upgradeRequired = false;
                Properties.Settings.Default.Save();

                logger.Log(className, "Reset completed, closing CSClock", Logger.LogType.Info);

                if (((args == null && args.Length > 0) || !args.Contains("-deletelogs")) || (!File.Exists("log.txt") && !File.Exists("setuplog.txt")))
                {
                    Properties.Settings.Default.properExit = true;
                    Properties.Settings.Default.Save();
                    return;
                }
            }

            if (args != null && args.Length > 0 && args.Contains("-deletelogs") && (File.Exists("log.txt") || File.Exists("setuplog.txt")))
            {
                File.Delete("log.txt");
                File.Delete("setuplog.txt");
                Properties.Settings.Default.properExit = true;
                Properties.Settings.Default.Save();
                return;
            }

            CSClockForm = new CSClock();
            CSClockForm.startDateTime = DateTime.Now;

            LoadNotifyIcon();

            if (!Properties.Settings.Default.configured)
            {
                Properties.Settings.Default.overtimeDateTime       = default(DateTime);
                Properties.Settings.Default.secondsElapsedDateTime = default(DateTime);
                Properties.Settings.Default.startDate = default(DateTime);
                Properties.Settings.Default.Save();
            }

            try
            {
                var test = Properties.Settings.Default.startDate;
            }
            catch
            {
                Properties.Settings.Default.startDate = DateTime.Now;
                Properties.Settings.Default.Save();
            }

            logger.Log(className, "executing LoadApplySettings()", Logger.LogType.Info);
            try
            {
                CSClockForm.LoadApplySettings();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex.Message + "\r\n\r\n\r\nFull error details: " + ex, "CSClock", MessageBoxButtons.OK, MessageBoxIcon.Error);
                logger.Log(className, Convert.ToString(ex), Logger.LogType.Error);
                Properties.Settings.Default.properExit = true;
                Properties.Settings.Default.Save();
                Application.Exit();
                return;
            }

            if (args != null && args.Contains("-s"))
            {
                CSClockForm.startMinimized = true;
            }

            Application.Run(CSClockForm);
        }