Merge pull request #676 from InvertedAcceleration/master
Update to the AboutController as well as adding a Resharper settings file.
This commit is contained in:
commit
84028aaa97
1
AUTHORS
1
AUTHORS
|
@ -17,6 +17,7 @@ Code:
|
||||||
Alex Hudson <home@alexhudson.com>
|
Alex Hudson <home@alexhudson.com>
|
||||||
Benjamin Podszun <benjamin.podszun@gmail.com>
|
Benjamin Podszun <benjamin.podszun@gmail.com>
|
||||||
Bertrand Lorentz <bertrand.lorentz@gmail.com>
|
Bertrand Lorentz <bertrand.lorentz@gmail.com>
|
||||||
|
Chris Magee <chris.magee@gametheworld.com>
|
||||||
Gabriel Burt <gabriel.burt@gmail.com>
|
Gabriel Burt <gabriel.burt@gmail.com>
|
||||||
Garrett LeSage <garrett@novell.com>
|
Garrett LeSage <garrett@novell.com>
|
||||||
Hylke Bons <hylkebons@gmail.com>
|
Hylke Bons <hylkebons@gmail.com>
|
||||||
|
|
|
@ -14,33 +14,21 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
|
||||||
using System.Timers;
|
|
||||||
|
|
||||||
using SparkleLib;
|
using SparkleLib;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleAboutController {
|
public class SparkleAboutController {
|
||||||
|
|
||||||
public event ShowWindowEventHandler ShowWindowEvent;
|
public event Action ShowWindowEvent = delegate { };
|
||||||
public delegate void ShowWindowEventHandler ();
|
public event Action HideWindowEvent = delegate { };
|
||||||
|
public event Action VersionUpToDateEvent = delegate { };
|
||||||
public event HideWindowEventHandler HideWindowEvent;
|
public event Action CheckingForNewVersionEvent = delegate { };
|
||||||
public delegate void HideWindowEventHandler ();
|
|
||||||
|
|
||||||
public event NewVersionEventHandler NewVersionEvent;
|
|
||||||
public delegate void NewVersionEventHandler (string new_version);
|
|
||||||
|
|
||||||
public event VersionUpToDateEventHandler VersionUpToDateEvent;
|
|
||||||
public delegate void VersionUpToDateEventHandler ();
|
|
||||||
|
|
||||||
public event CheckingForNewVersionEventHandler CheckingForNewVersionEvent;
|
|
||||||
public delegate void CheckingForNewVersionEventHandler ();
|
|
||||||
|
|
||||||
|
public event NewVersionEventDelegate NewVersionEvent = delegate { };
|
||||||
|
public delegate void NewVersionEventDelegate (string new_version_string);
|
||||||
|
|
||||||
public string RunningVersion {
|
public string RunningVersion {
|
||||||
get {
|
get {
|
||||||
|
@ -48,28 +36,21 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleAboutController ()
|
public SparkleAboutController ()
|
||||||
{
|
{
|
||||||
Program.Controller.ShowAboutWindowEvent += delegate {
|
Program.Controller.ShowAboutWindowEvent += delegate {
|
||||||
if (ShowWindowEvent != null)
|
|
||||||
ShowWindowEvent ();
|
ShowWindowEvent ();
|
||||||
|
|
||||||
CheckForNewVersion ();
|
CheckForNewVersion ();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void WindowClosed ()
|
public void WindowClosed ()
|
||||||
{
|
{
|
||||||
if (HideWindowEvent != null)
|
|
||||||
HideWindowEvent ();
|
HideWindowEvent ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckForNewVersion ()
|
||||||
public void CheckForNewVersion ()
|
|
||||||
{
|
{
|
||||||
if (CheckingForNewVersionEvent != null)
|
|
||||||
CheckingForNewVersionEvent ();
|
CheckingForNewVersionEvent ();
|
||||||
|
|
||||||
WebClient web_client = new WebClient ();
|
WebClient web_client = new WebClient ();
|
||||||
|
@ -79,30 +60,61 @@ namespace SparkleShare {
|
||||||
if (args.Error != null)
|
if (args.Error != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int running_version = int.Parse (
|
string latest_version_string = args.Result.Trim ();
|
||||||
"" + RunningVersion [0] + RunningVersion [2] + RunningVersion [4]
|
|
||||||
);
|
|
||||||
|
|
||||||
string result = args.Result.Trim ();
|
|
||||||
int new_version = int.Parse (
|
|
||||||
"" + result [0] + result [2] + result [4]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add a little delay, making it seems we're
|
|
||||||
// actually doing hard work
|
|
||||||
Thread.Sleep (1000);
|
|
||||||
|
|
||||||
if (running_version >= new_version) {
|
|
||||||
if (VersionUpToDateEvent != null)
|
|
||||||
VersionUpToDateEvent ();
|
|
||||||
|
|
||||||
|
if (UpdateRequired (RunningVersion, latest_version_string)) {
|
||||||
|
NewVersionEvent (latest_version_string);
|
||||||
} else {
|
} else {
|
||||||
if (NewVersionEvent != null)
|
VersionUpToDateEvent ();
|
||||||
NewVersionEvent (result);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
web_client.DownloadStringAsync (uri);
|
web_client.DownloadStringAsync (uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool UpdateRequired (string running_version_string, string latest_version_string)
|
||||||
|
{
|
||||||
|
if (running_version_string == null)
|
||||||
|
throw new ArgumentNullException ("running_version_string");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace (running_version_string))
|
||||||
|
throw new ArgumentException ("running_version_string");
|
||||||
|
|
||||||
|
if (latest_version_string == null)
|
||||||
|
throw new ArgumentNullException ("latest_version_string");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace (latest_version_string))
|
||||||
|
throw new ArgumentException ("latest_version_string");
|
||||||
|
|
||||||
|
int running_major;
|
||||||
|
int running_minor;
|
||||||
|
int running_build;
|
||||||
|
try {
|
||||||
|
string[] running_split = running_version_string.Split ('.');
|
||||||
|
running_major = int.Parse (running_split [0]);
|
||||||
|
running_minor = int.Parse (running_split [1]);
|
||||||
|
running_build = int.Parse (running_split [2]);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new FormatException ("running_version_string", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int latest_major;
|
||||||
|
int latest_minor;
|
||||||
|
int latest_build;
|
||||||
|
try {
|
||||||
|
string[] latest_split = latest_version_string.Split ('.');
|
||||||
|
latest_major = int.Parse (latest_split [0]);
|
||||||
|
latest_minor = int.Parse (latest_split [1]);
|
||||||
|
latest_build = int.Parse (latest_split [2]);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new FormatException ("latest_version_string", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool higher_major = latest_major > running_major;
|
||||||
|
bool higher_minor = latest_major == running_major && latest_minor > running_minor;
|
||||||
|
bool higher_build = latest_major == running_major && latest_minor == running_minor && latest_build > running_build;
|
||||||
|
|
||||||
|
return higher_major || higher_minor || higher_build;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
2
SparkleShare/Windows/.gitignore
vendored
Normal file
2
SparkleShare/Windows/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
*.dotCover
|
17
SparkleShare/Windows/SparkleShare.sln.DotSettings
Normal file
17
SparkleShare/Windows/SparkleShare.sln.DotSettings
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBeMadeStatic_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_REMOVE</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_CATCH_ON_NEW_LINE/@EntryValue">False</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_ARRAY_ACCESS_BRACKETS/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_EMPTY_METHOD_CALL_PARENTHESES/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_EMPTY_METHOD_PARENTHESES/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_METHOD_CALL_PARENTHESES/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_METHOD_PARENTHESES/@EntryValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></s:String></wpf:ResourceDictionary>
|
Loading…
Reference in a new issue