Revision 81c5c310 trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | ||
---|---|---|
169 | 169 |
Proxy.SetFromSettings(settings); |
170 | 170 |
|
171 | 171 |
StatusMessage = Settings.Accounts.Count==0 |
172 |
? "No Accounts added. Please add an account"
|
|
172 |
? "No Accounts added\r\nPlease add an account"
|
|
173 | 173 |
: "Starting"; |
174 | 174 |
|
175 | 175 |
_accounts.CollectionChanged += (sender, e) => |
... | ... | |
178 | 178 |
NotifyOfPropertyChange(() => HasAccounts); |
179 | 179 |
}; |
180 | 180 |
|
181 |
Assembly assembly = Assembly.GetExecutingAssembly(); |
|
182 |
var fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); |
|
183 |
VersionMessage = String.Format("Pithos+ {0}", fileVersion.FileVersion); |
|
184 |
|
|
181 |
SetVersionMessage(); |
|
185 | 182 |
} |
186 | 183 |
catch (Exception exc) |
187 | 184 |
{ |
... | ... | |
191 | 188 |
|
192 | 189 |
} |
193 | 190 |
|
191 |
private void SetVersionMessage() |
|
192 |
{ |
|
193 |
Assembly assembly = Assembly.GetExecutingAssembly(); |
|
194 |
var fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); |
|
195 |
VersionMessage = String.Format("Pithos+ {0}", fileVersion.FileVersion); |
|
196 |
} |
|
194 | 197 |
|
195 |
protected override void OnActivate() |
|
198 |
public void OnStatusAction() |
|
199 |
{ |
|
200 |
if (Accounts.Count==0) |
|
201 |
{ |
|
202 |
ShowPreferences("AccountTab"); |
|
203 |
} |
|
204 |
} |
|
205 |
protected override void OnActivate() |
|
196 | 206 |
{ |
197 | 207 |
base.OnActivate(); |
198 | 208 |
|
199 |
_sparkle = new Sparkle(Settings.UpdateUrl); |
|
200 |
_sparkle.updateDetected += OnUpgradeDetected; |
|
201 |
_sparkle.ShowDiagnosticWindow = Settings.UpdateDiagnostics; |
|
209 |
InitializeSparkle(); |
|
202 | 210 |
|
203 |
//Must delay opening the upgrade window
|
|
211 |
//Must delay opening the upgrade window
|
|
204 | 212 |
//to avoid Windows Messages sent by the TaskbarIcon |
205 | 213 |
TaskEx.Delay(5000).ContinueWith(_=> |
206 | 214 |
Execute.OnUIThread(()=> _sparkle.StartLoop(true,Settings.UpdateForceCheck,Settings.UpdateCheckInterval))); |
... | ... | |
209 | 217 |
StartMonitoring(); |
210 | 218 |
} |
211 | 219 |
|
212 |
private void OnUpgradeDetected(object sender, UpdateDetectedEventArgs e) |
|
220 |
|
|
221 |
private void OnCheckFinished(object sender, bool updaterequired) |
|
213 | 222 |
{ |
223 |
|
|
224 |
Log.InfoFormat("Upgrade check finished. Need Upgrade: {0}", updaterequired); |
|
225 |
if (_manualUpgradeCheck) |
|
226 |
{ |
|
227 |
_manualUpgradeCheck = false; |
|
228 |
if (!updaterequired) |
|
229 |
//Sparkle raises events on a background thread |
|
230 |
Execute.OnUIThread(()=> |
|
231 |
ShowBalloonFor(new Notification{Title="Pithos+ is up to date",Message="You have the latest Pitsos+ version. No update is required"})); |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
private void OnUpgradeDetected(object sender, UpdateDetectedEventArgs e) |
|
236 |
{ |
|
214 | 237 |
Log.InfoFormat("Update detected {0}",e.LatestVersion); |
215 | 238 |
} |
216 | 239 |
|
217 | 240 |
public void CheckForUpgrade() |
218 | 241 |
{ |
242 |
ShowBalloonFor(new Notification{Title="Checking for upgrades",Message="Contacting the server to retrieve the latest Pithos+ version."}); |
|
219 | 243 |
Log.Error("Test Error message"); |
220 | 244 |
_sparkle.StopLoop(); |
245 |
_sparkle.updateDetected -= OnUpgradeDetected; |
|
246 |
_sparkle.checkLoopFinished -= OnCheckFinished; |
|
221 | 247 |
_sparkle.Dispose(); |
222 |
_sparkle=new Sparkle(Settings.UpdateUrl); |
|
248 |
|
|
249 |
_manualUpgradeCheck = true; |
|
250 |
InitializeSparkle(); |
|
223 | 251 |
_sparkle.StartLoop(true,true,Settings.UpdateCheckInterval); |
224 | 252 |
} |
225 | 253 |
|
254 |
private void InitializeSparkle() |
|
255 |
{ |
|
256 |
_sparkle = new Sparkle(Settings.UpdateUrl); |
|
257 |
_sparkle.updateDetected += OnUpgradeDetected; |
|
258 |
_sparkle.checkLoopFinished += OnCheckFinished; |
|
259 |
_sparkle.ShowDiagnosticWindow = Settings.UpdateDiagnostics; |
|
260 |
} |
|
261 |
|
|
226 | 262 |
private async void StartMonitoring() |
227 | 263 |
{ |
228 | 264 |
try |
... | ... | |
905 | 941 |
|
906 | 942 |
private bool _pollStarted; |
907 | 943 |
private Sparkle _sparkle; |
944 |
private bool _manualUpgradeCheck; |
|
908 | 945 |
|
909 | 946 |
//SMELL: Doing so much work for notifications in the shell is wrong |
910 | 947 |
//The notifications should be moved to their own view/viewmodel pair |
... | ... | |
961 | 998 |
if (String.IsNullOrWhiteSpace(notification.Message) && String.IsNullOrWhiteSpace(notification.Title)) |
962 | 999 |
return; |
963 | 1000 |
|
964 |
ShowBalloonFor(notification); |
|
1001 |
if (notification.Level <= TraceLevel.Warning) |
|
1002 |
ShowBalloonFor(notification); |
|
965 | 1003 |
} |
966 | 1004 |
|
967 | 1005 |
private void ShowBalloonFor(Notification notification) |
... | ... | |
974 | 1012 |
BalloonIcon icon; |
975 | 1013 |
switch (notification.Level) |
976 | 1014 |
{ |
977 |
case TraceLevel.Info: |
|
978 |
case TraceLevel.Verbose: |
|
1015 |
case TraceLevel.Verbose: |
|
979 | 1016 |
return; |
1017 |
case TraceLevel.Info: |
|
1018 |
icon = BalloonIcon.Info; |
|
1019 |
break; |
|
980 | 1020 |
case TraceLevel.Error: |
981 | 1021 |
icon = BalloonIcon.Error; |
982 | 1022 |
break; |
Also available in: Unified diff