Skip to content

Commit

Permalink
Silent update
Browse files Browse the repository at this point in the history
- See #282
  • Loading branch information
bitbeans committed Jun 17, 2018
1 parent a8cfa4d commit 2d63ce1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
3 changes: 3 additions & 0 deletions SimpleDnsCrypt/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<setting name="TrayMode" serializeAs="String">
<value>True</value>
</setting>
<setting name="AutoUpdateSilent" serializeAs="String">
<value>False</value>
</setting>
</SimpleDnsCrypt.Properties.Settings>
</userSettings>
</configuration>
14 changes: 13 additions & 1 deletion SimpleDnsCrypt/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions SimpleDnsCrypt/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@
<Setting Name="TrayMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="AutoUpdateSilent" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
16 changes: 15 additions & 1 deletion SimpleDnsCrypt/ViewModels/LoaderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,21 @@ private async void InitializeApplication()
{
ProgressText = LocalizationEx.GetUiString("loader_starting_update", Thread.CurrentThread.CurrentCulture);
await Task.Delay(200).ConfigureAwait(false);
Process.Start(installer);
if (Properties.Settings.Default.AutoUpdate)
{
// auto install
const string arguments = "/qb /passive /norestart";
var startInfo = new ProcessStartInfo(installer)
{
Arguments = arguments,
UseShellExecute = false
};
Process.Start(startInfo);
}
else
{
Process.Start(installer);
}
Process.GetCurrentProcess().Kill();
}
else
Expand Down
13 changes: 13 additions & 0 deletions SimpleDnsCrypt/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SettingsViewModel : Screen
private bool _isAddressBlacklistTabVisible;
private bool _isAddressBlockLogTabVisible;
private bool _isAutoUpdateEnabled;
private bool _isAutoUpdateSilentEnabled;

private UpdateType _selectedUpdateType;

Expand All @@ -37,6 +38,7 @@ public SettingsViewModel(IWindowManager windowManager, IEventAggregator events)
_isAddressBlacklistTabVisible = Properties.Settings.Default.IsAddressBlacklistTabVisible;
_isAddressBlockLogTabVisible = Properties.Settings.Default.IsAddressBlockLogTabVisible;
_isAutoUpdateEnabled = Properties.Settings.Default.AutoUpdate;
_isAutoUpdateSilentEnabled = Properties.Settings.Default.AutoUpdateSilent;
_selectedUpdateType = (UpdateType)Properties.Settings.Default.MinUpdateType;
}

Expand Down Expand Up @@ -140,5 +142,16 @@ public bool IsAutoUpdateEnabled
NotifyOfPropertyChange(() => IsAutoUpdateEnabled);
}
}

public bool IsAutoUpdateSilentEnabled
{
get => _isAutoUpdateSilentEnabled;
set
{
_isAutoUpdateSilentEnabled = value;
Properties.Settings.Default.AutoUpdateSilent = _isAutoUpdateSilentEnabled;
NotifyOfPropertyChange(() => IsAutoUpdateSilentEnabled);
}
}
}
}
4 changes: 4 additions & 0 deletions SimpleDnsCrypt/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
Margin="5"
Content="{lex:Loc Key=settings_update_auto}"
Cursor="Hand" Foreground="#FF575757" />
<CheckBox IsChecked="{Binding IsAutoUpdateSilentEnabled}"
Margin="5"
Content="Silently install new versions"
Cursor="Hand" Foreground="#FF575757" />
<StackPanel Margin="5,0,0,0" Orientation="Horizontal">
<TextBlock Foreground="#FF575757" Text="{lex:Loc Key=settings_update_channel}" VerticalAlignment="Center" />
<ComboBox VerticalContentAlignment="Center" IsEnabled="False"
Expand Down

0 comments on commit 2d63ce1

Please sign in to comment.