Exemple #1
0
        private void SyncthingTray_Shown(object sender, EventArgs e)
        {
            try
            {
                chkStartOnBoot.Checked = RegistryUtil.GetStartup();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            var syncthingPath = Settings.Default.SyncthingPath;

            CheckPath(syncthingPath);

            if (chkStartOnBoot.Checked && btnStart.Enabled && !IsSyncthingRunning())
            {
                btnStart.PerformClick();
            }
            else if (!btnStart.Enabled)
            {
                var expectedPath =
                    Path.Combine(
                        Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "syncthing"),
                        "syncthing.exe");
                try
                {
                    if (!File.Exists(expectedPath))
                    {
                        GitHubUtil.GetLatestVersion();
                        Settings.Default.SyncthingPath = expectedPath;
                        Settings.Default.Save();
                        txtPath.Text = Settings.Default.SyncthingPath;
                        CheckPath(txtPath.Text.Trim());
                    }
                }
                catch (Exception ex)
                {
                    textBoxLog.AppendText(ex.ToString());
                    Log.Error(ex.ToString());
                }
            }
        }