mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
Code Cleanup of MainWindow
This commit is contained in:
parent
f8df14dc61
commit
a2b811972f
3 changed files with 120 additions and 127 deletions
|
|
@ -33,7 +33,7 @@
|
||||||
<Style TargetType="{x:Type DockPanel}">
|
<Style TargetType="{x:Type DockPanel}">
|
||||||
<Setter Property="Background" Value="#4F4F4F"/>
|
<Setter Property="Background" Value="#4F4F4F"/>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding ElementName=Main, Path=BetaVersion}" Value="True">
|
<DataTrigger Binding="{Binding AppInstance.BetaVersion}" Value="True">
|
||||||
<Setter Property="Background" Value="#378CFB"/>
|
<Setter Property="Background" Value="#378CFB"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
|
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
|
||||||
<Setter Property="Content" Value="{DynamicResource MainWindow_VersionLabel}"/>
|
<Setter Property="Content" Value="{DynamicResource MainWindow_VersionLabel}"/>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding ElementName=Main, Path=BetaVersion}" Value="True">
|
<DataTrigger Binding="{Binding AppInstance.BetaVersion}" Value="True">
|
||||||
<Setter Property="Content" Value="{DynamicResource MainWindow_BetaVersionLabel}"/>
|
<Setter Property="Content" Value="{DynamicResource MainWindow_BetaVersionLabel}"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
|
|
@ -60,17 +60,17 @@
|
||||||
</Label.Style>
|
</Label.Style>
|
||||||
</Label>
|
</Label>
|
||||||
<Label Margin="5,0,0,0" Background="Transparent" Foreground="White" FontSize="12" Content="{Binding Source={x:Static local:App.Instance}, Path=Version}" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
<Label Margin="5,0,0,0" Background="Transparent" Foreground="White" FontSize="12" Content="{Binding Source={x:Static local:App.Instance}, Path=Version}" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||||
<Button Margin="5" Click="ASMPatchNotes_Click" ToolTip="{DynamicResource ServerSettings_PatchNotesTooltip}" Style="{StaticResource ButtonStyle1}">
|
<Button Margin="5" Click="PatchNotes_Click" ToolTip="{DynamicResource ServerSettings_PatchNotesTooltip}" Style="{StaticResource ButtonStyle1}">
|
||||||
<Image Source="{com:Icon Path=/Ark Server Manager;component/Art/ChangeNotes.ico,Size=32}"/>
|
<Image Source="{com:Icon Path=/Ark Server Manager;component/Art/ChangeNotes.ico,Size=32}"/>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Margin="5,0,0,0" Background="#00AA00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" ContentStringFormat="{DynamicResource MainWindow_UpdateToLabelFormat}" Content="{Binding LatestASMVersion}" Click="Upgrade_Click" VerticalAlignment="Center" >
|
<Button Margin="5,0,0,0" Background="#00AA00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" ContentStringFormat="{DynamicResource MainWindow_UpdateToLabelFormat}" Content="{Binding LatestServerManagerVersion}" Click="Upgrade_Click" VerticalAlignment="Center" >
|
||||||
<Button.Style>
|
<Button.Style>
|
||||||
<Style TargetType="{x:Type Button}">
|
<Style TargetType="{x:Type Button}">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding NewASMAvailable}" Value="True">
|
<DataTrigger Binding="{Binding NewServerManagerAvailable}" Value="True">
|
||||||
<Setter Property="Visibility" Value="Visible"/>
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
<DataTrigger Binding="{Binding NewASMAvailable}" Value="False">
|
<DataTrigger Binding="{Binding NewServerManagerAvailable}" Value="False">
|
||||||
<Setter Property="Visibility" Value="Collapsed"/>
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
|
|
@ -277,7 +277,7 @@
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Validation.ErrorTemplate>
|
</Validation.ErrorTemplate>
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
<Binding Path="CurrentConfig.MachinePublicIP" ElementName="Main">
|
<Binding Path="Config.MachinePublicIP" ElementName="Main">
|
||||||
<Binding.ValidationRules>
|
<Binding.ValidationRules>
|
||||||
<cvr:IpValidationRule ValidatesOnTargetUpdated="true" />
|
<cvr:IpValidationRule ValidatesOnTargetUpdated="true" />
|
||||||
</Binding.ValidationRules>
|
</Binding.ValidationRules>
|
||||||
|
|
@ -310,7 +310,7 @@
|
||||||
<MultiDataTrigger>
|
<MultiDataTrigger>
|
||||||
<MultiDataTrigger.Conditions>
|
<MultiDataTrigger.Conditions>
|
||||||
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
|
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
|
||||||
<Condition Binding="{Binding CurrentConfig.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
|
<Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
|
||||||
</MultiDataTrigger.Conditions>
|
</MultiDataTrigger.Conditions>
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
|
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
|
||||||
|
|
@ -318,7 +318,7 @@
|
||||||
<MultiDataTrigger>
|
<MultiDataTrigger>
|
||||||
<MultiDataTrigger.Conditions>
|
<MultiDataTrigger.Conditions>
|
||||||
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
|
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
|
||||||
<Condition Binding="{Binding CurrentConfig.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
|
<Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
|
||||||
</MultiDataTrigger.Conditions>
|
</MultiDataTrigger.Conditions>
|
||||||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
|
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
|
||||||
</MultiDataTrigger>
|
</MultiDataTrigger>
|
||||||
|
|
@ -329,7 +329,7 @@
|
||||||
<MultiDataTrigger>
|
<MultiDataTrigger>
|
||||||
<MultiDataTrigger.Conditions>
|
<MultiDataTrigger.Conditions>
|
||||||
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
|
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
|
||||||
<Condition Binding="{Binding CurrentConfig.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
|
<Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
|
||||||
</MultiDataTrigger.Conditions>
|
</MultiDataTrigger.Conditions>
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
|
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
|
||||||
|
|
@ -337,7 +337,7 @@
|
||||||
<MultiDataTrigger>
|
<MultiDataTrigger>
|
||||||
<MultiDataTrigger.Conditions>
|
<MultiDataTrigger.Conditions>
|
||||||
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
|
<Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
|
||||||
<Condition Binding="{Binding CurrentConfig.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
|
<Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
|
||||||
</MultiDataTrigger.Conditions>
|
</MultiDataTrigger.Conditions>
|
||||||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
|
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
|
||||||
</MultiDataTrigger>
|
</MultiDataTrigger>
|
||||||
|
|
|
||||||
|
|
@ -27,45 +27,74 @@ namespace ServerManagerTool
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public static MainWindow Instance
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||||
private readonly ActionQueue versionChecker;
|
private readonly ActionQueue versionChecker;
|
||||||
private readonly ActionQueue scheduledTaskChecker;
|
private readonly ActionQueue scheduledTaskChecker;
|
||||||
|
|
||||||
public static readonly DependencyProperty BetaVersionProperty = DependencyProperty.Register(nameof(BetaVersion), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow));
|
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty CurrentConfigProperty = DependencyProperty.Register(nameof(CurrentConfig), typeof(Config), typeof(MainWindow));
|
|
||||||
public static readonly DependencyProperty ServerManagerProperty = DependencyProperty.Register(nameof(ServerManager), typeof(ServerManager), typeof(MainWindow), new PropertyMetadata(null));
|
public static readonly DependencyProperty ServerManagerProperty = DependencyProperty.Register(nameof(ServerManager), typeof(ServerManager), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty LatestASMVersionProperty = DependencyProperty.Register(nameof(LatestASMVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
|
||||||
public static readonly DependencyProperty NewASMAvailableProperty = DependencyProperty.Register(nameof(NewASMAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
|
||||||
public static readonly DependencyProperty AutoBackupStateProperty = DependencyProperty.Register(nameof(AutoBackupState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
public static readonly DependencyProperty AutoBackupStateProperty = DependencyProperty.Register(nameof(AutoBackupState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
||||||
public static readonly DependencyProperty AutoBackupStateStringProperty = DependencyProperty.Register(nameof(AutoBackupStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoBackupStateStringProperty = DependencyProperty.Register(nameof(AutoBackupStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty AutoBackupNextRunTimeProperty = DependencyProperty.Register(nameof(AutoBackupNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoBackupNextRunTimeProperty = DependencyProperty.Register(nameof(AutoBackupNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
||||||
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
|
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
|
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
||||||
|
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
|
|
||||||
public bool BetaVersion
|
public MainWindow()
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(BetaVersionProperty); }
|
this.AppInstance = App.Instance;
|
||||||
set { SetValue(BetaVersionProperty, value); }
|
this.Config = Config.Default;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||||
|
|
||||||
|
this.ServerManager = ServerManager.Instance;
|
||||||
|
|
||||||
|
this.DataContext = this;
|
||||||
|
this.versionChecker = new ActionQueue();
|
||||||
|
this.scheduledTaskChecker = new ActionQueue();
|
||||||
|
|
||||||
|
IsAdministrator = SecurityUtils.IsAdministrator();
|
||||||
|
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
||||||
|
{
|
||||||
|
this.Title = App.Instance.Title;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (IsAdministrator)
|
||||||
|
{
|
||||||
|
this.Title = _globalizer.GetResourceString("MainWindow_TitleWithAdmin");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Left = Config.Default.MainWindow_Left;
|
||||||
|
this.Top = Config.Default.MainWindow_Top;
|
||||||
|
this.Height = Config.Default.MainWindow_Height;
|
||||||
|
this.Width = Config.Default.MainWindow_Width;
|
||||||
|
this.WindowState = Config.Default.MainWindow_WindowState;
|
||||||
|
|
||||||
|
// hook into the language change event
|
||||||
|
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIpValid
|
public App AppInstance
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(IsIpValidProperty); }
|
get { return GetValue(AppInstanceProperty) as App; }
|
||||||
set { SetValue(IsIpValidProperty, value); }
|
set { SetValue(AppInstanceProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Config CurrentConfig
|
public Config Config
|
||||||
{
|
{
|
||||||
get { return GetValue(CurrentConfigProperty) as Config; }
|
get { return GetValue(ConfigProperty) as Config; }
|
||||||
set { SetValue(CurrentConfigProperty, value); }
|
set { SetValue(ConfigProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerManager ServerManager
|
public ServerManager ServerManager
|
||||||
|
|
@ -74,18 +103,6 @@ namespace ServerManagerTool
|
||||||
set { SetValue(ServerManagerProperty, value); }
|
set { SetValue(ServerManagerProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Version LatestASMVersion
|
|
||||||
{
|
|
||||||
get { return (Version)GetValue(LatestASMVersionProperty); }
|
|
||||||
set { SetValue(LatestASMVersionProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool NewASMAvailable
|
|
||||||
{
|
|
||||||
get { return (bool)GetValue(NewASMAvailableProperty); }
|
|
||||||
set { SetValue(NewASMAvailableProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Microsoft.Win32.TaskScheduler.TaskState AutoBackupState
|
public Microsoft.Win32.TaskScheduler.TaskState AutoBackupState
|
||||||
{
|
{
|
||||||
get { return (Microsoft.Win32.TaskScheduler.TaskState)GetValue(AutoBackupStateProperty); }
|
get { return (Microsoft.Win32.TaskScheduler.TaskState)GetValue(AutoBackupStateProperty); }
|
||||||
|
|
@ -128,46 +145,22 @@ namespace ServerManagerTool
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow()
|
public bool IsIpValid
|
||||||
{
|
{
|
||||||
this.BetaVersion = App.Instance.BetaVersion;
|
get { return (bool)GetValue(IsIpValidProperty); }
|
||||||
this.CurrentConfig = Config.Default;
|
set { SetValue(IsIpValidProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
InitializeComponent();
|
public Version LatestServerManagerVersion
|
||||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
{
|
||||||
|
get { return (Version)GetValue(LatestServerManagerVersionProperty); }
|
||||||
|
set { SetValue(LatestServerManagerVersionProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow.Instance = this;
|
public bool NewServerManagerAvailable
|
||||||
this.ServerManager = ServerManager.Instance;
|
{
|
||||||
|
get { return (bool)GetValue(NewServerManagerAvailableProperty); }
|
||||||
this.DataContext = this;
|
set { SetValue(NewServerManagerAvailableProperty, value); }
|
||||||
this.versionChecker = new ActionQueue();
|
|
||||||
this.scheduledTaskChecker = new ActionQueue();
|
|
||||||
|
|
||||||
IsAdministrator = SecurityUtils.IsAdministrator();
|
|
||||||
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
|
||||||
{
|
|
||||||
this.Title = $"{App.Instance.Title}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (IsAdministrator)
|
|
||||||
{
|
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_TitleWithAdmin");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Left = Config.Default.MainWindow_Left;
|
|
||||||
this.Top = Config.Default.MainWindow_Top;
|
|
||||||
this.Height = Config.Default.MainWindow_Height;
|
|
||||||
this.Width = Config.Default.MainWindow_Width;
|
|
||||||
this.WindowState = Config.Default.MainWindow_WindowState;
|
|
||||||
|
|
||||||
// hook into the language change event
|
|
||||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -263,10 +256,10 @@ namespace ServerManagerTool
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ASMPatchNotes_Click(object sender, RoutedEventArgs e)
|
private void PatchNotes_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var url = string.Empty;
|
var url = string.Empty;
|
||||||
if (BetaVersion)
|
if (AppInstance.BetaVersion)
|
||||||
url = Config.Default.ServerManagerVersionBetaFeedUrl;
|
url = Config.Default.ServerManagerVersionBetaFeedUrl;
|
||||||
else
|
else
|
||||||
url = Config.Default.ServerManagerVersionFeedUrl;
|
url = Config.Default.ServerManagerVersionFeedUrl;
|
||||||
|
|
@ -280,7 +273,7 @@ namespace ServerManagerTool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (BetaVersion)
|
if (AppInstance.BetaVersion)
|
||||||
url = Config.Default.LatestASMBetaPatchNotesUrl;
|
url = Config.Default.LatestASMBetaPatchNotesUrl;
|
||||||
else
|
else
|
||||||
url = Config.Default.LatestASMPatchNotesUrl;
|
url = Config.Default.LatestASMPatchNotesUrl;
|
||||||
|
|
@ -424,7 +417,7 @@ namespace ServerManagerTool
|
||||||
|
|
||||||
private async void Upgrade_Click(object sender, RoutedEventArgs e)
|
private async void Upgrade_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var result = MessageBox.Show(String.Format(_globalizer.GetResourceString("MainWindow_Upgrade_Label"), this.LatestASMVersion), _globalizer.GetResourceString("MainWindow_Upgrade_Title"), MessageBoxButton.YesNo, MessageBoxImage.Question);
|
var result = MessageBox.Show(String.Format(_globalizer.GetResourceString("MainWindow_Upgrade_Label"), this.LatestServerManagerVersion), _globalizer.GetResourceString("MainWindow_Upgrade_Title"), MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
if(result == MessageBoxResult.Yes)
|
if(result == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -640,8 +633,8 @@ namespace ServerManagerTool
|
||||||
var appVersion = new Version();
|
var appVersion = new Version();
|
||||||
Version.TryParse(App.Instance.Version, out appVersion);
|
Version.TryParse(App.Instance.Version, out appVersion);
|
||||||
|
|
||||||
this.LatestASMVersion = newVersion;
|
this.LatestServerManagerVersion = newVersion;
|
||||||
this.NewASMAvailable = appVersion < newVersion;
|
this.NewServerManagerAvailable = appVersion < newVersion;
|
||||||
|
|
||||||
Logger.Info($"{nameof(CheckForUpdates)} performed");
|
Logger.Info($"{nameof(CheckForUpdates)} performed");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,47 @@ namespace ServerManagerTool
|
||||||
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
||||||
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
|
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
this.AppInstance = App.Instance;
|
||||||
|
this.Config = Config.Default;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||||
|
|
||||||
|
this.ServerManager = ServerManager.Instance;
|
||||||
|
|
||||||
|
this.DataContext = this;
|
||||||
|
this.versionChecker = new ActionQueue();
|
||||||
|
this.scheduledTaskChecker = new ActionQueue();
|
||||||
|
|
||||||
|
IsAdministrator = SecurityUtils.IsAdministrator();
|
||||||
|
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
||||||
|
{
|
||||||
|
this.Title = App.Instance.Title;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (IsAdministrator)
|
||||||
|
{
|
||||||
|
this.Title = _globalizer.GetResourceString("MainWindow_TitleWithAdmin");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Left = Config.Default.MainWindow_Left;
|
||||||
|
this.Top = Config.Default.MainWindow_Top;
|
||||||
|
this.Height = Config.Default.MainWindow_Height;
|
||||||
|
this.Width = Config.Default.MainWindow_Width;
|
||||||
|
this.WindowState = Config.Default.MainWindow_WindowState;
|
||||||
|
|
||||||
|
// hook into the language change event
|
||||||
|
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
||||||
|
}
|
||||||
|
|
||||||
public App AppInstance
|
public App AppInstance
|
||||||
{
|
{
|
||||||
get { return GetValue(AppInstanceProperty) as App; }
|
get { return GetValue(AppInstanceProperty) as App; }
|
||||||
|
|
@ -122,47 +163,6 @@ namespace ServerManagerTool
|
||||||
set { SetValue(NewServerManagerAvailableProperty, value); }
|
set { SetValue(NewServerManagerAvailableProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
this.AppInstance = App.Instance;
|
|
||||||
this.Config = Config.Default;
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
|
||||||
|
|
||||||
this.ServerManager = ServerManager.Instance;
|
|
||||||
|
|
||||||
this.DataContext = this;
|
|
||||||
this.versionChecker = new ActionQueue();
|
|
||||||
this.scheduledTaskChecker = new ActionQueue();
|
|
||||||
|
|
||||||
IsAdministrator = SecurityUtils.IsAdministrator();
|
|
||||||
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
|
||||||
{
|
|
||||||
this.Title = App.Instance.Title;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (IsAdministrator)
|
|
||||||
{
|
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_TitleWithAdmin");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Left = Config.Default.MainWindow_Left;
|
|
||||||
this.Top = Config.Default.MainWindow_Top;
|
|
||||||
this.Height = Config.Default.MainWindow_Height;
|
|
||||||
this.Width = Config.Default.MainWindow_Width;
|
|
||||||
this.WindowState = Config.Default.MainWindow_WindowState;
|
|
||||||
|
|
||||||
// hook into the language change event
|
|
||||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue