Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thoemmi committed Dec 3, 2013
2 parents c5b4098 + 29096b2 commit 64482cb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Solutionizer/Infrastructure/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public UpdateManager(ISettings settings) {
}

public async Task CheckForUpdatesAsync() {
_log.Debug("Checking for updates.");
IReadOnlyCollection<ReleaseInfo> newReleases;
try {
newReleases = await _reader.GetReleaseInfosAsync();
Expand All @@ -50,7 +51,10 @@ public async Task CheckForUpdatesAsync() {
_releases.ForEach(r => r.IsNew = r.Version > _currentVersion);
SaveReleases();
if (_releases.Any(r => r.IsNew)) {
_log.Debug("{0} new updates detected.", _releases.Count(r => r.IsNew));
OnUpdatesAvailable();
} else {
_log.Debug("No updates detected.");
}
}

Expand Down
1 change: 1 addition & 0 deletions Solutionizer/Services/ISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface ISettings : INotifyPropertyChanged {
bool ShowLaunchElevatedButton { get; set; }
bool DontBuildReferencedProjects { get; set; }
bool ShowProjectCount { get; set; }
bool AutoUpdateCheck { get; set; }
bool IncludePrereleaseUpdates { get; set; }
string LastUpdateCheckETag { get; set; }
SolutionTargetLocation SolutionTargetLocation { get; set; }
Expand Down
12 changes: 12 additions & 0 deletions Solutionizer/Services/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Settings : PropertyChangedBase, ISettings {
private bool _showLaunchElevatedButton;
private bool _showProjectCount;
private string _lastUpdateCheckETag;
private bool _autoUpdateCheck = true;
private bool _includePrereleaseUpdates;
private string _someOtherProperty;
private SolutionTargetLocation _solutionTargetLocation;
Expand Down Expand Up @@ -211,6 +212,17 @@ public string SomeOtherProperty {
}
}

public bool AutoUpdateCheck {
get { return _autoUpdateCheck; }
set {
if (_autoUpdateCheck != value) {
_autoUpdateCheck = value;
NotifyOfPropertyChange(() => AutoUpdateCheck);
IsDirty = true;
}
}
}

public bool IncludePrereleaseUpdates {
get { return _includePrereleaseUpdates; }
set {
Expand Down
14 changes: 14 additions & 0 deletions Solutionizer/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public sealed class SettingsViewModel : DialogViewModel, IOnLoadedHandler, IWith
private VisualStudioVersion _visualStudioVersion;
private bool _showLaunchElevatedButton;
private bool _showProjectCount;
private bool _autoUpdateCheck;
private bool _includePrereleaseUpdates;
private SolutionTargetLocation _solutionTargetLocation;
private string _customTargetFolder;
Expand Down Expand Up @@ -53,6 +54,7 @@ public void OnLoaded() {
SolutionTargetLocation = _settings.SolutionTargetLocation;
CustomTargetFolder = _settings.CustomTargetFolder;
CustomTargetSubfolder = _settings.CustomTargetSubfolder;
AutoUpdateCheck = _settings.AutoUpdateCheck;
}

public bool ScanOnStartup {
Expand Down Expand Up @@ -155,6 +157,16 @@ public bool ShowProjectCount {
}
}

public bool AutoUpdateCheck {
get { return _autoUpdateCheck; }
set {
if (_autoUpdateCheck != value) {
_autoUpdateCheck = value;
NotifyOfPropertyChange(() => AutoUpdateCheck);
}
}
}

public bool IncludePrereleaseUpdates {
get { return _includePrereleaseUpdates; }
set {
Expand Down Expand Up @@ -238,6 +250,7 @@ public void Ok() {
_settings.VisualStudioVersion = VisualStudioVersion;
_settings.ShowLaunchElevatedButton = ShowLaunchElevatedButton;
_settings.ShowProjectCount = ShowProjectCount;
_settings.AutoUpdateCheck = AutoUpdateCheck;
_settings.IncludePrereleaseUpdates = IncludePrereleaseUpdates;
_settings.SolutionTargetLocation = SolutionTargetLocation;
_settings.CustomTargetFolder = CustomTargetFolder;
Expand All @@ -259,6 +272,7 @@ public bool CanOk {
VisualStudioVersion != _settings.VisualStudioVersion ||
ShowLaunchElevatedButton != _settings.ShowLaunchElevatedButton ||
ShowProjectCount != _settings.ShowProjectCount ||
AutoUpdateCheck != _settings.AutoUpdateCheck ||
IncludePrereleaseUpdates != _settings.IncludePrereleaseUpdates ||
SolutionTargetLocation != _settings.SolutionTargetLocation ||
CustomTargetFolder != _settings.CustomTargetFolder ||
Expand Down
19 changes: 17 additions & 2 deletions Solutionizer/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
Expand All @@ -25,6 +26,7 @@ public sealed class ShellViewModel : PropertyChangedBase, IShell, IOnLoadedHandl
private readonly ICommand _showSettingsCommand;
private readonly ICommand _showAboutCommand;
private readonly ICommand _selectRootPathCommand;
private readonly Timer _updateTimer;
private string _statusMessage;

public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutManager flyoutManager, IUpdateManager updateManager, IViewModelFactory viewModelFactory) {
Expand All @@ -39,9 +41,11 @@ public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutM
(sender, args) => AreUpdatesAvailable = _updateManager.Releases != null && _updateManager.Releases.Any(r => r.IsNew && (_settings.IncludePrereleaseUpdates || !r.IsPrerelease));

_showUpdatesCommand = new RelayCommand<bool>(checkForUpdates => _flyoutManager.ShowFlyout(_viewModelFactory.CreateUpdateViewModel(checkForUpdates)));
_showSettingsCommand = new RelayCommand(() => _flyoutManager.ShowFlyout(_viewModelFactory.CreateSettingsViewModel()));
_showSettingsCommand = new RelayCommand(OnShowSettings);
_showAboutCommand = new RelayCommand(() => _flyoutManager.ShowFlyout(_viewModelFactory.CreateAboutViewModel()));
_selectRootPathCommand = new RelayCommand(SelectRootPath);

_updateTimer = new Timer(_ => _updateManager.CheckForUpdatesAsync(), null, -1, -1);
}

public string RootPath {
Expand Down Expand Up @@ -103,7 +107,18 @@ public void OnLoaded() {
LoadProjects(_settings.RootPath);
}

Task.Run(() => _updateManager.CheckForUpdatesAsync());
if (_settings.AutoUpdateCheck) {
_updateTimer.Change(0, 1000 * 60 * 60);
}
}

private async void OnShowSettings() {
await _flyoutManager.ShowFlyout(_viewModelFactory.CreateSettingsViewModel());
if (_settings.AutoUpdateCheck) {
_updateTimer.Change(0, 1000 * 60 * 60);
} else {
_updateTimer.Change(-1, -1);
}
}

public void SelectRootPath() {
Expand Down
16 changes: 11 additions & 5 deletions Solutionizer/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
IsChecked="{Binding DontBuildReferencedProjects}"
IsEnabled="{Binding IncludeReferencedProjects}"
Margin="20 0 0 8"
Content="Exclude referenced projects from build configurations."
Content="Exclude referenced projects from build configurations"
ToolTip="If checked, referenced projects won't be build&#x0a;automatically in the resulting solution."/>

<StackPanel
Expand Down Expand Up @@ -175,19 +175,19 @@
<CheckBox
IsChecked="{Binding IsFlatMode}"
Margin="0 0 0 8"
Content="Show projects as flat list."
Content="Show projects as flat list"
ToolTip="If checked, the projects will be presented&#x0a;in a flat list instead of a tree view."/>

<CheckBox
IsChecked="{Binding ShowLaunchElevatedButton}"
Margin="0 0 0 8"
Content="Show &quot;Launch Elevated&quot; button."
Content="Show &quot;Launch Elevated&quot; button"
ToolTip="This button allows to open the created solution&#x0a;inside an elevated instance of Visual Studio."/>

<CheckBox
IsChecked="{Binding ShowProjectCount}"
Margin="0 0 0 8"
Content="Show number of contained projects behind the directory name."
Content="Show number of contained projects behind the directory name"
ToolTip="If checked, the number of contained projects&#x0a;will be displayed behind folders."/>

<TextBlock
Expand All @@ -200,10 +200,16 @@
Content="Scan projects on start-up"
ToolTip="If checked, the last used folder will be scanned for projects."/>

<CheckBox
IsChecked="{Binding AutoUpdateCheck}"
Margin="0 0 0 8"
Content="Automatically check for updates periodically"
ToolTip="If checked, Solutionizer will check for updates once per hour."/>

<CheckBox
IsChecked="{Binding IncludePrereleaseUpdates}"
Margin="0 0 0 8"
Content="Include pre-release versions in checks for updates."
Content="Include pre-release versions in checks for updates"
ToolTip="If checked, auto-update will also check for pre-release versions."/>

</StackPanel>
Expand Down

0 comments on commit 64482cb

Please sign in to comment.