First update message box can activate

This commit is contained in:
Jaex 2015-01-09 10:19:44 +02:00
parent 5f41b5771d
commit 34cade70a6
8 changed files with 32 additions and 14 deletions

View file

@ -42,8 +42,8 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Web;
using System.Windows.Forms;
namespace ShareX.HelpersLib
{
@ -668,7 +668,7 @@ public static void CreateDirectoryIfNotExist(string path, bool isFilePath = true
catch (Exception e)
{
DebugHelper.WriteException(e);
MessageBox.Show(Resources.Helpers_CreateDirectoryIfNotExist_Create_failed_ + "\r\n" + e, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(Resources.Helpers_CreateDirectoryIfNotExist_Create_failed_ + "\r\n\r\n" + e, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -673,7 +673,7 @@ internal class Resources {
}
/// <summary>
/// Looks up a localized string similar to Could not create directory, check your path settings:.
/// Looks up a localized string similar to Could not create directory, check your path settings..
/// </summary>
internal static string Helpers_CreateDirectoryIfNotExist_Create_failed_ {
get {

View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
@ -617,6 +616,6 @@ Would you like to download and install it?</value>
<value>Update is available</value>
</data>
<data name="Helpers_CreateDirectoryIfNotExist_Create_failed_" xml:space="preserve">
<value>Could not create directory, check your path settings:</value>
<value>Could not create directory, check your path settings.</value>
</data>
</root>

View file

@ -593,4 +593,7 @@ Dosya boyutu: {2:n0} / {3:n0} KB</value>
<data name="UpdateMessageBox_UpdateMessageBox_update_is_available" xml:space="preserve">
<value>Güncelleştirme mevcut</value>
</data>
<data name="Helpers_CreateDirectoryIfNotExist_Create_failed_" xml:space="preserve">
<value>Klasör yaratılamıyor, yol ayarlarını kontrol ediniz.</value>
</data>
</root>

View file

@ -66,6 +66,7 @@ private void InitializeComponent()
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "UpdateMessageBox";
this.Shown += new System.EventHandler(this.UpdateMessageBox_Shown);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UpdateMessageBox_Paint);
this.ResumeLayout(false);

View file

@ -34,6 +34,8 @@ public partial class UpdateMessageBox : Form
{
public static bool IsOpen { get; private set; }
public bool ActivateWindow { get; set; }
private Rectangle fillRect;
public UpdateMessageBox()
@ -47,7 +49,7 @@ public UpdateMessageBox()
fillRect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
}
public static void Start(UpdateChecker updateChecker)
public static void Start(UpdateChecker updateChecker, bool activateWindow = true)
{
if (updateChecker != null && updateChecker.Status == UpdateStatus.UpdateAvailable)
{
@ -59,6 +61,7 @@ public static void Start(UpdateChecker updateChecker)
using (UpdateMessageBox messageBox = new UpdateMessageBox())
{
messageBox.ActivateWindow = activateWindow;
result = messageBox.ShowDialog();
}
@ -84,7 +87,18 @@ public static void Start(UpdateChecker updateChecker)
protected override bool ShowWithoutActivation
{
get { return true; }
get
{
return !ActivateWindow;
}
}
private void UpdateMessageBox_Shown(object sender, System.EventArgs e)
{
if (ActivateWindow)
{
this.ShowActivate();
}
}
private void UpdateMessageBox_Paint(object sender, PaintEventArgs e)

View file

@ -131,6 +131,10 @@
<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="&gt;&gt;lblText.Name" xml:space="preserve">
<value>lblText</value>
</data>
@ -206,10 +210,6 @@
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>399, 135</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
</data>

View file

@ -43,7 +43,7 @@ public partial class MainForm : HotkeyForm
{
public bool IsReady { get; private set; }
private bool forceClose;
private bool forceClose, firstUpdateCheck = true;
private UploadInfoManager uim;
private ToolStripDropDownItem tsmiImageFileUploaders, tsmiTrayImageFileUploaders, tsmiTextFileUploaders, tsmiTrayTextFileUploaders;
private System.Threading.Timer updateTimer;
@ -662,7 +662,8 @@ private void CheckUpdate()
if (!UpdateMessageBox.IsOpen)
{
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
UpdateMessageBox.Start(updateChecker);
UpdateMessageBox.Start(updateChecker, firstUpdateCheck);
firstUpdateCheck = false;
}
}