mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 03:33:18 +01:00
"Check for updates" done (I hope)
This commit is contained in:
parent
cf158dac1a
commit
4d6f514f3f
25
src/Forms/CheckForUpdates.Designer.cs
generated
25
src/Forms/CheckForUpdates.Designer.cs
generated
@ -34,6 +34,7 @@
|
|||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonDownloadAndInstall = new System.Windows.Forms.Button();
|
this.buttonDownloadAndInstall = new System.Windows.Forms.Button();
|
||||||
this.timerCheckForUpdates = new System.Windows.Forms.Timer(this.components);
|
this.timerCheckForUpdates = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.buttonDontCheckUpdates = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelStatus
|
// labelStatus
|
||||||
@ -43,7 +44,7 @@
|
|||||||
this.labelStatus.Location = new System.Drawing.Point(10, 15);
|
this.labelStatus.Location = new System.Drawing.Point(10, 15);
|
||||||
this.labelStatus.Name = "labelStatus";
|
this.labelStatus.Name = "labelStatus";
|
||||||
this.labelStatus.Size = new System.Drawing.Size(41, 13);
|
this.labelStatus.Size = new System.Drawing.Size(41, 13);
|
||||||
this.labelStatus.TabIndex = 0;
|
this.labelStatus.TabIndex = 3;
|
||||||
this.labelStatus.Text = "label1";
|
this.labelStatus.Text = "label1";
|
||||||
//
|
//
|
||||||
// textBoxChangeLog
|
// textBoxChangeLog
|
||||||
@ -56,7 +57,7 @@
|
|||||||
this.textBoxChangeLog.Name = "textBoxChangeLog";
|
this.textBoxChangeLog.Name = "textBoxChangeLog";
|
||||||
this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||||
this.textBoxChangeLog.Size = new System.Drawing.Size(618, 53);
|
this.textBoxChangeLog.Size = new System.Drawing.Size(618, 53);
|
||||||
this.textBoxChangeLog.TabIndex = 1;
|
this.textBoxChangeLog.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
@ -66,7 +67,7 @@
|
|||||||
this.buttonCancel.Location = new System.Drawing.Point(556, 90);
|
this.buttonCancel.Location = new System.Drawing.Point(556, 90);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||||
this.buttonCancel.TabIndex = 5;
|
this.buttonCancel.TabIndex = 2;
|
||||||
this.buttonCancel.Text = "C&ancel";
|
this.buttonCancel.Text = "C&ancel";
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
@ -74,10 +75,10 @@
|
|||||||
//
|
//
|
||||||
this.buttonDownloadAndInstall.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonDownloadAndInstall.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonDownloadAndInstall.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
this.buttonDownloadAndInstall.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||||
this.buttonDownloadAndInstall.Location = new System.Drawing.Point(390, 90);
|
this.buttonDownloadAndInstall.Location = new System.Drawing.Point(224, 90);
|
||||||
this.buttonDownloadAndInstall.Name = "buttonDownloadAndInstall";
|
this.buttonDownloadAndInstall.Name = "buttonDownloadAndInstall";
|
||||||
this.buttonDownloadAndInstall.Size = new System.Drawing.Size(160, 21);
|
this.buttonDownloadAndInstall.Size = new System.Drawing.Size(160, 21);
|
||||||
this.buttonDownloadAndInstall.TabIndex = 4;
|
this.buttonDownloadAndInstall.TabIndex = 0;
|
||||||
this.buttonDownloadAndInstall.Text = "&OK";
|
this.buttonDownloadAndInstall.Text = "&OK";
|
||||||
this.buttonDownloadAndInstall.UseVisualStyleBackColor = true;
|
this.buttonDownloadAndInstall.UseVisualStyleBackColor = true;
|
||||||
this.buttonDownloadAndInstall.Click += new System.EventHandler(this.buttonDownloadAndInstall_Click);
|
this.buttonDownloadAndInstall.Click += new System.EventHandler(this.buttonDownloadAndInstall_Click);
|
||||||
@ -86,11 +87,24 @@
|
|||||||
//
|
//
|
||||||
this.timerCheckForUpdates.Tick += new System.EventHandler(this.timerCheckForUpdates_Tick);
|
this.timerCheckForUpdates.Tick += new System.EventHandler(this.timerCheckForUpdates_Tick);
|
||||||
//
|
//
|
||||||
|
// buttonDontCheckUpdates
|
||||||
|
//
|
||||||
|
this.buttonDontCheckUpdates.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDontCheckUpdates.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||||
|
this.buttonDontCheckUpdates.Location = new System.Drawing.Point(390, 90);
|
||||||
|
this.buttonDontCheckUpdates.Name = "buttonDontCheckUpdates";
|
||||||
|
this.buttonDontCheckUpdates.Size = new System.Drawing.Size(160, 21);
|
||||||
|
this.buttonDontCheckUpdates.TabIndex = 1;
|
||||||
|
this.buttonDontCheckUpdates.Text = "Don\'t check for updates";
|
||||||
|
this.buttonDontCheckUpdates.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDontCheckUpdates.Click += new System.EventHandler(this.buttonDontCheckUpdates_Click);
|
||||||
|
//
|
||||||
// CheckForUpdates
|
// CheckForUpdates
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(643, 123);
|
this.ClientSize = new System.Drawing.Size(643, 123);
|
||||||
|
this.Controls.Add(this.buttonDontCheckUpdates);
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.buttonDownloadAndInstall);
|
this.Controls.Add(this.buttonDownloadAndInstall);
|
||||||
this.Controls.Add(this.textBoxChangeLog);
|
this.Controls.Add(this.textBoxChangeLog);
|
||||||
@ -115,5 +129,6 @@
|
|||||||
private System.Windows.Forms.Button buttonCancel;
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
private System.Windows.Forms.Button buttonDownloadAndInstall;
|
private System.Windows.Forms.Button buttonDownloadAndInstall;
|
||||||
private System.Windows.Forms.Timer timerCheckForUpdates;
|
private System.Windows.Forms.Timer timerCheckForUpdates;
|
||||||
|
private System.Windows.Forms.Button buttonDontCheckUpdates;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,11 +9,17 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
private CheckForUpdatesHelper _updatesHelper;
|
private CheckForUpdatesHelper _updatesHelper;
|
||||||
private double _seconds = 0;
|
private double _seconds = 0;
|
||||||
|
private bool _performCheckOnShown = true;
|
||||||
|
|
||||||
public CheckForUpdates()
|
public CheckForUpdates()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
InitLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitLanguage()
|
||||||
|
{
|
||||||
Text = Configuration.Settings.Language.CheckForUpdates.Title;
|
Text = Configuration.Settings.Language.CheckForUpdates.Title;
|
||||||
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdates;
|
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdates;
|
||||||
buttonDownloadAndInstall.Text = Configuration.Settings.Language.CheckForUpdates.InstallUpdate;
|
buttonDownloadAndInstall.Text = Configuration.Settings.Language.CheckForUpdates.InstallUpdate;
|
||||||
@ -21,6 +27,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
textBoxChangeLog.Visible = false;
|
textBoxChangeLog.Visible = false;
|
||||||
buttonCancel.Text = Configuration.Settings.Language.General.OK;
|
buttonCancel.Text = Configuration.Settings.Language.General.OK;
|
||||||
buttonCancel.Visible = false;
|
buttonCancel.Visible = false;
|
||||||
|
buttonDontCheckUpdates.Text = Configuration.Settings.Language.CheckForUpdates.NoUpdates;
|
||||||
|
buttonDontCheckUpdates.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckForUpdates(CheckForUpdatesHelper checkForUpdatesHelper)
|
public CheckForUpdates(CheckForUpdatesHelper checkForUpdatesHelper)
|
||||||
@ -28,7 +36,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_updatesHelper = checkForUpdatesHelper;
|
_updatesHelper = checkForUpdatesHelper;
|
||||||
ShowAvailableUpdate();
|
InitLanguage();
|
||||||
|
ShowAvailableUpdate(true);
|
||||||
|
_performCheckOnShown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckForUpdates_KeyDown(object sender, KeyEventArgs e)
|
private void CheckForUpdates_KeyDown(object sender, KeyEventArgs e)
|
||||||
@ -39,11 +49,19 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
private void CheckForUpdates_Shown(object sender, EventArgs e)
|
private void CheckForUpdates_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_performCheckOnShown)
|
||||||
|
return;
|
||||||
|
|
||||||
_updatesHelper = new CheckForUpdatesHelper();
|
_updatesHelper = new CheckForUpdatesHelper();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
Refresh();
|
Refresh();
|
||||||
_updatesHelper.CheckForUpdates();
|
_updatesHelper.CheckForUpdates();
|
||||||
timerCheckForUpdates.Start();
|
timerCheckForUpdates.Start();
|
||||||
|
|
||||||
|
if (buttonDownloadAndInstall.Visible)
|
||||||
|
buttonDownloadAndInstall.Focus();
|
||||||
|
else if (buttonCancel.Visible)
|
||||||
|
buttonCancel.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void timerCheckForUpdates_Tick(object sender, EventArgs e)
|
private void timerCheckForUpdates_Tick(object sender, EventArgs e)
|
||||||
@ -65,12 +83,12 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
timerCheckForUpdates.Stop();
|
timerCheckForUpdates.Stop();
|
||||||
if (_updatesHelper.IsUpdateAvailable())
|
if (_updatesHelper.IsUpdateAvailable())
|
||||||
{
|
{
|
||||||
ShowAvailableUpdate();
|
ShowAvailableUpdate(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesNoneAvailable;
|
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesNoneAvailable;
|
||||||
Height = 550;
|
Height = 600;
|
||||||
textBoxChangeLog.Text = _updatesHelper.LatestChangeLog;
|
textBoxChangeLog.Text = _updatesHelper.LatestChangeLog;
|
||||||
textBoxChangeLog.Visible = true;
|
textBoxChangeLog.Visible = true;
|
||||||
buttonCancel.Visible = true;
|
buttonCancel.Visible = true;
|
||||||
@ -79,15 +97,24 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
_seconds += timerCheckForUpdates.Interval / 1000.0;
|
_seconds += timerCheckForUpdates.Interval / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowAvailableUpdate()
|
private void ShowAvailableUpdate(bool fromAutoCheck)
|
||||||
{
|
{
|
||||||
Height = 550;
|
Height = 600;
|
||||||
textBoxChangeLog.Text = _updatesHelper.LatestChangeLog;
|
textBoxChangeLog.Text = _updatesHelper.LatestChangeLog;
|
||||||
textBoxChangeLog.Visible = true;
|
textBoxChangeLog.Visible = true;
|
||||||
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesNewVersion;
|
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesNewVersion;
|
||||||
buttonDownloadAndInstall.Visible = true;
|
buttonDownloadAndInstall.Visible = true;
|
||||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||||
buttonCancel.Visible = true;
|
buttonCancel.Visible = true;
|
||||||
|
if (Configuration.Settings.General.CheckForUpdates && fromAutoCheck)
|
||||||
|
{
|
||||||
|
buttonDontCheckUpdates.Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonDontCheckUpdates.Visible = false;
|
||||||
|
buttonDownloadAndInstall.Left = buttonCancel.Left - 6 - buttonDownloadAndInstall.Width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDownloadAndInstall_Click(object sender, EventArgs e)
|
private void buttonDownloadAndInstall_Click(object sender, EventArgs e)
|
||||||
@ -95,5 +122,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
System.Diagnostics.Process.Start("https://github.com/SubtitleEdit/subtitleedit/releases");
|
System.Diagnostics.Process.Start("https://github.com/SubtitleEdit/subtitleedit/releases");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonDontCheckUpdates_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Configuration.Settings.General.CheckForUpdates = false;
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
|||||||
{
|
{
|
||||||
private static Regex regex = new Regex(@"\d\.\d", RegexOptions.Compiled); // 3.4.0 (xth June 2014)
|
private static Regex regex = new Regex(@"\d\.\d", RegexOptions.Compiled); // 3.4.0 (xth June 2014)
|
||||||
|
|
||||||
private const string ReleasesUrl = "https://api.github.com/repos/SubtitleEdit/subtitleedit/releases";
|
// private const string ReleasesUrl = "https://api.github.com/repos/SubtitleEdit/subtitleedit/releases";
|
||||||
private const string ChangeLogUrl = "https://raw.githubusercontent.com/SubtitleEdit/subtitleedit/master/src/Changelog.txt";
|
private const string ChangeLogUrl = "https://raw.githubusercontent.com/SubtitleEdit/subtitleedit/master/src/Changelog.txt";
|
||||||
|
|
||||||
private string _jsonReleases;
|
// private string _jsonReleases;
|
||||||
private string _changeLog;
|
private string _changeLog;
|
||||||
private int _successCount;
|
private int _successCount;
|
||||||
|
|
||||||
@ -54,20 +54,20 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishWebRequestReleases(IAsyncResult result)
|
//void FinishWebRequestReleases(IAsyncResult result)
|
||||||
{
|
//{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
_jsonReleases = GetStringFromResponse(result);
|
// _jsonReleases = GetStringFromResponse(result);
|
||||||
}
|
// }
|
||||||
catch (Exception exception)
|
// catch (Exception exception)
|
||||||
{
|
// {
|
||||||
if (Error == null)
|
// if (Error == null)
|
||||||
{
|
// {
|
||||||
Error = exception.Message;
|
// Error = exception.Message;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void FinishWebRequestChangeLog(IAsyncResult result)
|
void FinishWebRequestChangeLog(IAsyncResult result)
|
||||||
{
|
{
|
||||||
@ -161,6 +161,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//string[] currentVersionInfo = "3.3.14".Split('.'); // for testing...
|
||||||
string[] currentVersionInfo = Utilities.AssemblyVersion.Split('.');
|
string[] currentVersionInfo = Utilities.AssemblyVersion.Split('.');
|
||||||
string minorMinorVersion = string.Empty;
|
string minorMinorVersion = string.Empty;
|
||||||
if (currentVersionInfo.Length >= 3 && currentVersionInfo[2] != "0")
|
if (currentVersionInfo.Length >= 3 && currentVersionInfo[2] != "0")
|
||||||
|
Loading…
Reference in New Issue
Block a user