Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string path = Environment.CommandLine.Trim(' ', '"');

            if (!(path.Contains('\\') || path.Contains('/'))) {
                Console.WriteLine("Please start ClipUpload 3 from Explorer, or add the absolute path.");
                mustExit = true;
                this.Close();
            }

            string curDir = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(path.Substring(0, path.LastIndexOf('\\')));

            this.settings = new Settings("settings.txt");

            LoadSettings();
            LoadAddons();
            UpdateList();

            this.Text = "ClipUpload " + Version;

            if (this.settings.GetBool("CheckForUpdates")) {
                try {
                    WebClient wc = new WebClient();
                    wc.Proxy = null;
                    string latestVersion = wc.DownloadString("http://" + "clipupload.net/?update");
                    if (latestVersion != Version) {
                        this.canUpdate = latestVersion;
                        this.Tray.ShowBalloonTip(10, "ClipUpload Update", "A new update for ClipUpload is available, version " + latestVersion + ". Click \"Update to " + latestVersion + "\" in the ClipUpload menu to automatically update.", ToolTipIcon.Info);
                    }
                } catch (Exception ex) {
                    Program.Debug("Update check threw " + ex.GetType().FullName + ": '" + ex.Message + "'");
                }
            }

            if (curDir != Directory.GetCurrentDirectory())
                mustHide = true;

            keyboardHandler = new KeyEventHandler(keyboardListener_KeyDown);

            this.keyboardListener = new KeyboardHookListener(new GlobalHooker());
            this.keyboardListener.Enabled = true;
            this.keyboardListener.KeyDown += keyboardHandler;
        }