Skip to content

Commit 2d63ce1

Browse files
committed
Silent update
- See #282
1 parent a8cfa4d commit 2d63ce1

6 files changed

Lines changed: 51 additions & 2 deletions

File tree

SimpleDnsCrypt/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
<setting name="TrayMode" serializeAs="String">
7272
<value>True</value>
7373
</setting>
74+
<setting name="AutoUpdateSilent" serializeAs="String">
75+
<value>False</value>
76+
</setting>
7477
</SimpleDnsCrypt.Properties.Settings>
7578
</userSettings>
7679
</configuration>

SimpleDnsCrypt/Properties/Settings.Designer.cs

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SimpleDnsCrypt/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@
4747
<Setting Name="TrayMode" Type="System.Boolean" Scope="User">
4848
<Value Profile="(Default)">True</Value>
4949
</Setting>
50+
<Setting Name="AutoUpdateSilent" Type="System.Boolean" Scope="User">
51+
<Value Profile="(Default)">False</Value>
52+
</Setting>
5053
</Settings>
5154
</SettingsFile>

SimpleDnsCrypt/ViewModels/LoaderViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,21 @@ private async void InitializeApplication()
8888
{
8989
ProgressText = LocalizationEx.GetUiString("loader_starting_update", Thread.CurrentThread.CurrentCulture);
9090
await Task.Delay(200).ConfigureAwait(false);
91-
Process.Start(installer);
91+
if (Properties.Settings.Default.AutoUpdate)
92+
{
93+
// auto install
94+
const string arguments = "/qb /passive /norestart";
95+
var startInfo = new ProcessStartInfo(installer)
96+
{
97+
Arguments = arguments,
98+
UseShellExecute = false
99+
};
100+
Process.Start(startInfo);
101+
}
102+
else
103+
{
104+
Process.Start(installer);
105+
}
92106
Process.GetCurrentProcess().Kill();
93107
}
94108
else

SimpleDnsCrypt/ViewModels/SettingsViewModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class SettingsViewModel : Screen
1717
private bool _isAddressBlacklistTabVisible;
1818
private bool _isAddressBlockLogTabVisible;
1919
private bool _isAutoUpdateEnabled;
20+
private bool _isAutoUpdateSilentEnabled;
2021

2122
private UpdateType _selectedUpdateType;
2223

@@ -37,6 +38,7 @@ public SettingsViewModel(IWindowManager windowManager, IEventAggregator events)
3738
_isAddressBlacklistTabVisible = Properties.Settings.Default.IsAddressBlacklistTabVisible;
3839
_isAddressBlockLogTabVisible = Properties.Settings.Default.IsAddressBlockLogTabVisible;
3940
_isAutoUpdateEnabled = Properties.Settings.Default.AutoUpdate;
41+
_isAutoUpdateSilentEnabled = Properties.Settings.Default.AutoUpdateSilent;
4042
_selectedUpdateType = (UpdateType)Properties.Settings.Default.MinUpdateType;
4143
}
4244

@@ -140,5 +142,16 @@ public bool IsAutoUpdateEnabled
140142
NotifyOfPropertyChange(() => IsAutoUpdateEnabled);
141143
}
142144
}
145+
146+
public bool IsAutoUpdateSilentEnabled
147+
{
148+
get => _isAutoUpdateSilentEnabled;
149+
set
150+
{
151+
_isAutoUpdateSilentEnabled = value;
152+
Properties.Settings.Default.AutoUpdateSilent = _isAutoUpdateSilentEnabled;
153+
NotifyOfPropertyChange(() => IsAutoUpdateSilentEnabled);
154+
}
155+
}
143156
}
144157
}

SimpleDnsCrypt/Views/SettingsView.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
Margin="5"
8585
Content="{lex:Loc Key=settings_update_auto}"
8686
Cursor="Hand" Foreground="#FF575757" />
87+
<CheckBox IsChecked="{Binding IsAutoUpdateSilentEnabled}"
88+
Margin="5"
89+
Content="Silently install new versions"
90+
Cursor="Hand" Foreground="#FF575757" />
8791
<StackPanel Margin="5,0,0,0" Orientation="Horizontal">
8892
<TextBlock Foreground="#FF575757" Text="{lex:Loc Key=settings_update_channel}" VerticalAlignment="Center" />
8993
<ComboBox VerticalContentAlignment="Center" IsEnabled="False"

0 commit comments

Comments
 (0)