コード例 #1
0
ファイル: FormMain.cs プロジェクト: jlippold/ClipUpload
        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;
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: jamesmanning/Clipupload
        private void Form1_Load(object sender, EventArgs e)
        {
            string path = Environment.CommandLine.Trim(' ', '"');

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

              string curDir = Directory.GetCurrentDirectory();

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

              this.LoadSettings();
              this.LoadAddons();
              this.UpdateList();

              this.Text = "ClipUpload " + Version;

              if (this.settings.GetBool("CheckForUpdates")) {
            try {
              WebClient wc = new WebClient();
              wc.Proxy = GetProxy();
              string strResult = wc.DownloadString("https://nimble.tools/ping/update?product=2&cptversion=0");
              dynamic res = Json.JsonDecode(strResult);
              if (res["status"] != "OK") {
            throw new Exception();
              }
              Version vLatest = new Version(res["version"]);
              Version vNow = new Version(Version);
              int iVersionDiff = vNow.CompareTo(vLatest);
              if (iVersionDiff < 0) {
            this.Text += " (outdated)";
            this.Tray.ShowBalloonTip(5, "Clipupload Update", "A new update for ClipUpload is available, version " + res["version"] + ". Visit https://nimble.tools/clipupload to get the new version.", ToolTipIcon.Info);
              } else if (iVersionDiff > 0) {
            this.Text += " (pre-release)";
            this.Tray.ShowBalloonTip(5, "Clipupload Pre-release", "You are running on a pre-release version of Clipupload, version " + Version + ". The latest stable version is " + res["version"] + ". Please report all bugs.", ToolTipIcon.Warning);
              }
            } 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;

              new Thread(new ThreadStart(IPC_Server)).Start();
        }