mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
In update message box if no button is clicked then don't check for updates next 24 hours
This commit is contained in:
parent
4f2ac5e84f
commit
ca9f33a2cd
4 changed files with 23 additions and 9 deletions
|
@ -88,6 +88,7 @@ private void InitializeComponent()
|
|||
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);
|
||||
|
||||
|
|
|
@ -58,16 +58,16 @@ public UpdateMessageBox(bool activateWindow, bool isPortable = false)
|
|||
}
|
||||
}
|
||||
|
||||
public static void Start(UpdateChecker updateChecker, bool activateWindow = true)
|
||||
public static DialogResult Start(UpdateChecker updateChecker, bool activateWindow = true)
|
||||
{
|
||||
DialogResult result = DialogResult.None;
|
||||
|
||||
if (updateChecker != null && updateChecker.Status == UpdateStatus.UpdateAvailable)
|
||||
{
|
||||
IsOpen = true;
|
||||
|
||||
try
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
using (UpdateMessageBox messageBox = new UpdateMessageBox(activateWindow, updateChecker.IsPortable))
|
||||
{
|
||||
result = messageBox.ShowDialog();
|
||||
|
@ -83,6 +83,8 @@ public static void Start(UpdateChecker updateChecker, bool activateWindow = true
|
|||
IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override bool ShowWithoutActivation => !ActivateWindow;
|
||||
|
@ -95,6 +97,14 @@ private void UpdateMessageBox_Shown(object sender, System.EventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateMessageBox_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
DialogResult = DialogResult.No;
|
||||
}
|
||||
}
|
||||
|
||||
private void cbDontShow_CheckedChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
DontShow = cbDontShow.Checked;
|
||||
|
|
|
@ -131,10 +131,6 @@
|
|||
<data name="lblText.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="lblText.Text" type="System.Resources.ResXNullRef, System.Windows.Forms">
|
||||
<value />
|
||||
</data>
|
||||
<data name=">>lblText.Name" xml:space="preserve">
|
||||
<value>lblText</value>
|
||||
</data>
|
||||
|
@ -264,6 +260,7 @@
|
|||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>400, 192</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
</data>
|
||||
|
|
|
@ -695,7 +695,7 @@ private void ConfigureAutoUpdate()
|
|||
{
|
||||
if (updateTimer == null)
|
||||
{
|
||||
updateTimer = new System.Threading.Timer(state => CheckUpdate(), null, 0, 1000 * 60 * 60);
|
||||
updateTimer = new System.Threading.Timer(state => CheckUpdate(), null, TimeSpan.Zero, TimeSpan.FromHours(1));
|
||||
}
|
||||
}
|
||||
else if (updateTimer != null)
|
||||
|
@ -712,7 +712,13 @@ private void CheckUpdate()
|
|||
if (!UpdateMessageBox.DontShow && !UpdateMessageBox.IsOpen)
|
||||
{
|
||||
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
|
||||
UpdateMessageBox.Start(updateChecker, firstUpdateCheck);
|
||||
|
||||
if (UpdateMessageBox.Start(updateChecker, firstUpdateCheck) == DialogResult.No)
|
||||
{
|
||||
TimeSpan interval = TimeSpan.FromHours(24);
|
||||
updateTimer.Change(interval, interval);
|
||||
}
|
||||
|
||||
firstUpdateCheck = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue