ソースを参照

Added auto update setting

flabbet 4 年 前
コミット
80f5a88d88

+ 6 - 2
PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
 using System.Windows;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Processes;
+using PixiEditor.Models.UserPreferences;
 using PixiEditor.UpdateModule;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main
@@ -74,7 +75,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
                     {
                         await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
                     }
-                    
+
                     UpdateReadyToInstall = true;
                     return true;
                 }
@@ -85,7 +86,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         private async void Owner_OnStartupEvent(object sender, EventArgs e)
         {
-            await CheckForUpdate();
+            if (PreferencesSettings.GetPreference<bool>("CheckUpdatesOnStartup"))
+            {
+                await CheckForUpdate();
+            }
         }
 
         private void RestartApplication(object parameter)

+ 15 - 0
PixiEditor/ViewModels/SubViewModels/UserPreferences/SettingsViewModel.cs

@@ -20,6 +20,21 @@ namespace PixiEditor.ViewModels.SubViewModels.UserPreferences
             }
         }
 
+        private bool checkUpdatesOnStartup = PreferencesSettings.GetPreference("CheckUpdatesOnStartup", true);
+
+        public bool CheckUpdatesOnStartup
+        {
+            get => checkUpdatesOnStartup;
+            set
+            {
+                checkUpdatesOnStartup = value;
+                string name = nameof(CheckUpdatesOnStartup);
+                RaisePropertyChanged(name);
+                PreferencesSettings.UpdatePreference(name, value);
+            }
+        }
+
+
         public SettingsViewModel(SettingsWindowViewModel owner)
             : base(owner)
         {

+ 8 - 2
PixiEditor/Views/Dialogs/SettingsWindow.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:PixiEditor.Views.Dialogs" xmlns:viewmodels="clr-namespace:PixiEditor.ViewModels" xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
         mc:Ignorable="d"
-        Title="SettingsWindow" Name="window" 
+        Title="Settings" Name="window" 
         Height="450" Width="800" WindowStyle="None" DataContext="{DynamicResource SettingsWindowViewModel}"
         BorderBrush="Black" BorderThickness="1">
     <Window.Resources>
@@ -33,7 +33,7 @@
         </Grid.RowDefinitions>
 
         <DockPanel Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Background="{StaticResource MainColor}">
-            <Label Foreground="White" FontSize="16">User preferences</Label>
+            <Label Foreground="White" FontSize="16">Settings</Label>
             <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Style="{StaticResource CloseButtonStyle}"
                     WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close"
                     Command="{x:Static SystemCommands.CloseWindowCommand}" />
@@ -56,6 +56,12 @@
             </Grid>
             <Grid Visibility="{Binding SelectedCategory, Converter={StaticResource EqualityBoolToVisibilityConverter},
             ConverterParameter='Updates'}">
+                <StackPanel Orientation="Vertical">
+                    <Label Style="{StaticResource Header1}" Content="Auto-updates"/>
+                    <StackPanel Orientation="Vertical" Margin="50 0 50 0">
+                        <CheckBox IsChecked="{Binding SettingsSubViewModel.CheckUpdatesOnStartup}" Content="Check updates on startup"/>
+                    </StackPanel>
+                </StackPanel>
             </Grid>
         </Grid>
     </Grid>