mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 15:31:30 +12:00
In update message box when no button is pressed then disable auto update check until ShareX is restarted
This commit is contained in:
parent
2eb2536898
commit
5a5c544ec8
6 changed files with 21 additions and 61 deletions
|
@ -31,9 +31,9 @@ namespace ShareX.HelpersLib
|
|||
{
|
||||
public class GitHubUpdateManager : IDisposable
|
||||
{
|
||||
public bool AutoUpdateEnabled { get; set; } // ConfigureAutoUpdate function must be called after change this
|
||||
public bool AllowAutoUpdate { get; set; } // ConfigureAutoUpdate function must be called after change this
|
||||
public bool AutoUpdateEnabled { get; set; } = true;
|
||||
public TimeSpan UpdateCheckInterval { get; private set; } = TimeSpan.FromHours(1);
|
||||
public TimeSpan UpdateReCheckInterval { get; private set; } = TimeSpan.FromHours(24); // If "No" button pressed in update message box then this interval will be used
|
||||
public string GitHubOwner { get; set; }
|
||||
public string GitHubRepo { get; set; }
|
||||
public bool IsDev { get; set; } // If current build is dev and latest stable release is same version as current build then it will be downloaded
|
||||
|
@ -60,7 +60,7 @@ public void ConfigureAutoUpdate()
|
|||
{
|
||||
lock (updateTimerLock)
|
||||
{
|
||||
if (AutoUpdateEnabled)
|
||||
if (AllowAutoUpdate)
|
||||
{
|
||||
if (updateTimer == null)
|
||||
{
|
||||
|
@ -76,14 +76,14 @@ public void ConfigureAutoUpdate()
|
|||
|
||||
private void CheckUpdate()
|
||||
{
|
||||
if (!UpdateMessageBox.DontShow && !UpdateMessageBox.IsOpen)
|
||||
if (AutoUpdateEnabled && !UpdateMessageBox.IsOpen)
|
||||
{
|
||||
UpdateChecker updateChecker = CreateUpdateChecker();
|
||||
updateChecker.CheckUpdate();
|
||||
|
||||
if (UpdateMessageBox.Start(updateChecker, firstUpdateCheck) != DialogResult.Yes)
|
||||
if (UpdateMessageBox.Start(updateChecker, firstUpdateCheck) == DialogResult.No)
|
||||
{
|
||||
updateTimer.Change(UpdateReCheckInterval, UpdateReCheckInterval);
|
||||
AutoUpdateEnabled = false;
|
||||
}
|
||||
|
||||
firstUpdateCheck = false;
|
||||
|
|
|
@ -32,7 +32,6 @@ private void InitializeComponent()
|
|||
this.lblText = new System.Windows.Forms.Label();
|
||||
this.btnNo = new System.Windows.Forms.Button();
|
||||
this.btnYes = new System.Windows.Forms.Button();
|
||||
this.cbDontShow = new System.Windows.Forms.CheckBox();
|
||||
this.lblViewChangelog = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -55,13 +54,6 @@ private void InitializeComponent()
|
|||
this.btnYes.UseVisualStyleBackColor = true;
|
||||
this.btnYes.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnYes_MouseClick);
|
||||
//
|
||||
// cbDontShow
|
||||
//
|
||||
resources.ApplyResources(this.cbDontShow, "cbDontShow");
|
||||
this.cbDontShow.Name = "cbDontShow";
|
||||
this.cbDontShow.UseVisualStyleBackColor = false;
|
||||
this.cbDontShow.CheckedChanged += new System.EventHandler(this.cbDontShow_CheckedChanged);
|
||||
//
|
||||
// lblViewChangelog
|
||||
//
|
||||
resources.ApplyResources(this.lblViewChangelog, "lblViewChangelog");
|
||||
|
@ -78,10 +70,10 @@ private void InitializeComponent()
|
|||
this.Controls.Add(this.btnNo);
|
||||
this.Controls.Add(this.btnYes);
|
||||
this.Controls.Add(this.lblText);
|
||||
this.Controls.Add(this.cbDontShow);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "UpdateMessageBox";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UpdateMessageBox_FormClosing);
|
||||
this.Shown += new System.EventHandler(this.UpdateMessageBox_Shown);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
@ -93,7 +85,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Button btnYes;
|
||||
private System.Windows.Forms.Button btnNo;
|
||||
private System.Windows.Forms.Label lblText;
|
||||
private System.Windows.Forms.CheckBox cbDontShow;
|
||||
private System.Windows.Forms.Label lblViewChangelog;
|
||||
}
|
||||
}
|
|
@ -33,7 +33,6 @@ namespace ShareX.HelpersLib
|
|||
public partial class UpdateMessageBox : Form
|
||||
{
|
||||
public static bool IsOpen { get; private set; }
|
||||
public static bool DontShow { get; private set; }
|
||||
|
||||
public bool ActivateWindow { get; private set; }
|
||||
|
||||
|
@ -116,16 +115,19 @@ private void UpdateMessageBox_Shown(object sender, EventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateMessageBox_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (DialogResult == DialogResult.Cancel && e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
DialogResult = DialogResult.No;
|
||||
}
|
||||
}
|
||||
|
||||
private void lblViewChangelog_Click(object sender, EventArgs e)
|
||||
{
|
||||
URLHelpers.OpenURL(Links.Changelog);
|
||||
}
|
||||
|
||||
private void cbDontShow_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
DontShow = cbDontShow.Checked;
|
||||
}
|
||||
|
||||
private void btnYes_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Yes;
|
||||
|
|
|
@ -147,10 +147,10 @@
|
|||
<value>Arial, 12pt</value>
|
||||
</data>
|
||||
<data name="btnNo.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>280, 200</value>
|
||||
<value>272, 200</value>
|
||||
</data>
|
||||
<data name="btnNo.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>104, 32</value>
|
||||
<value>112, 32</value>
|
||||
</data>
|
||||
<data name="btnNo.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
|
@ -174,10 +174,10 @@
|
|||
<value>Arial, 12pt</value>
|
||||
</data>
|
||||
<data name="btnYes.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>168, 200</value>
|
||||
<value>152, 200</value>
|
||||
</data>
|
||||
<data name="btnYes.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>104, 32</value>
|
||||
<value>112, 32</value>
|
||||
</data>
|
||||
<data name="btnYes.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
|
@ -197,36 +197,6 @@
|
|||
<data name=">>btnYes.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cbDontShow.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="cbDontShow.Font" type="System.Drawing.Font, System.Drawing">
|
||||
<value>Arial, 8pt</value>
|
||||
</data>
|
||||
<data name="cbDontShow.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>16, 166</value>
|
||||
</data>
|
||||
<data name="cbDontShow.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>260, 18</value>
|
||||
</data>
|
||||
<data name="cbDontShow.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="cbDontShow.Text" xml:space="preserve">
|
||||
<value>Do not prompt again until ShareX starts next time</value>
|
||||
</data>
|
||||
<data name=">>cbDontShow.Name" xml:space="preserve">
|
||||
<value>cbDontShow</value>
|
||||
</data>
|
||||
<data name=">>cbDontShow.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>cbDontShow.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbDontShow.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="lblViewChangelog.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
|
|
|
@ -975,7 +975,7 @@ private void AfterApplicationSettingsJobs()
|
|||
|
||||
private void ConfigureAutoUpdate()
|
||||
{
|
||||
Program.UpdateManager.AutoUpdateEnabled = !SystemOptions.DisableUpdateCheck && Program.Settings.AutoCheckUpdate;
|
||||
Program.UpdateManager.AllowAutoUpdate = !SystemOptions.DisableUpdateCheck && Program.Settings.AutoCheckUpdate;
|
||||
Program.UpdateManager.CheckPreReleaseUpdates = Program.Settings.CheckPreReleaseUpdates;
|
||||
Program.UpdateManager.ConfigureAutoUpdate();
|
||||
}
|
||||
|
|
|
@ -1887,10 +1887,7 @@ public static async Task DownloadAppVeyorBuild()
|
|||
|
||||
await updateChecker.CheckUpdateAsync();
|
||||
|
||||
if (updateChecker.Status == UpdateStatus.UpdateAvailable)
|
||||
{
|
||||
updateChecker.DownloadUpdate();
|
||||
}
|
||||
UpdateMessageBox.Start(updateChecker);
|
||||
}
|
||||
|
||||
public static Image CreateQRCode(string text, int width, int height)
|
||||
|
|
Loading…
Reference in a new issue