mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
1. Main window now stored the Left and Top positions.
2. Added global setting to set the start mode of the Main Window.
This commit is contained in:
parent
229ee09049
commit
34582ca91b
20 changed files with 286 additions and 58 deletions
|
|
@ -7,7 +7,8 @@
|
|||
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
|
||||
xmlns:globcntrls="clr-namespace:WPFSharp.Globalizer.Controls;assembly=WPFSharp.Globalizer"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="800">
|
||||
d:DesignWidth="800"
|
||||
x:Name="GlobalSettings">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
|
@ -47,8 +48,8 @@
|
|||
</ContentControl>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="3">
|
||||
|
||||
<Grid Margin="3" Background="{StaticResource BeigeGradient}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Visible">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
|
@ -74,6 +75,7 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
|
@ -90,10 +92,13 @@
|
|||
</DockPanel>
|
||||
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_RunAsAdministratorLabel}" IsChecked="{Binding CurrentConfig.RunAsAdministratorPrompt, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
<CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding CurrentConfig.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
|
||||
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding CurrentConfig.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding CurrentConfig.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeLabel}" VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding CurrentConfig.MainWindow_WindowState}" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding CurrentConfig.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding CurrentConfig.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding CurrentConfig.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Grid.Row="4" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_DataDirectoryLabel}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding CurrentConfig.DataDir, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using ServerManagerTool.Common;
|
|||
using ServerManagerTool.Common.Lib;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
@ -11,6 +12,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Xml;
|
||||
using WPFSharp.Globalizer;
|
||||
|
||||
|
|
@ -27,6 +29,7 @@ namespace ServerManagerTool
|
|||
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty CurrentConfigProperty = DependencyProperty.Register(nameof(CurrentConfig), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(List<WindowState>), typeof(GlobalSettingsControl), new PropertyMetadata(new List<WindowState>()));
|
||||
|
||||
public GlobalSettingsControl()
|
||||
{
|
||||
|
|
@ -36,6 +39,12 @@ namespace ServerManagerTool
|
|||
this.CommonConfig = CommonConfig.Default;
|
||||
this.DataContext = this;
|
||||
|
||||
this.WindowStates = new List<WindowState>();
|
||||
foreach (var windowState in Enum.GetValues(typeof(WindowState)))
|
||||
{
|
||||
this.WindowStates.Add((WindowState)windowState);
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
|
|
@ -66,6 +75,12 @@ namespace ServerManagerTool
|
|||
set { SetValue(IsAdministratorProperty, value); }
|
||||
}
|
||||
|
||||
public List<WindowState> WindowStates
|
||||
{
|
||||
get { return (List<WindowState>)GetValue(WindowStatesProperty); }
|
||||
set { SetValue(WindowStatesProperty, value); }
|
||||
}
|
||||
|
||||
private string GetDeployedVersion()
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
|
|
@ -278,6 +293,18 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
var comboBox = sender as ComboBox;
|
||||
if (comboBox == null)
|
||||
return;
|
||||
|
||||
if (comboBox.IsDropDownOpen)
|
||||
return;
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
CurrentConfig.CultureName = AvailableLanguages.Instance.SelectedLanguage;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
|
||||
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
||||
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
|
||||
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50"
|
||||
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged"
|
||||
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
|
||||
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" LocationChanged="Window_LocationChanged"
|
||||
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -159,8 +159,11 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
@ -204,6 +207,15 @@ namespace ServerManagerTool
|
|||
this.Activate();
|
||||
}
|
||||
|
||||
private void Window_LocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.WindowState == WindowState.Normal)
|
||||
{
|
||||
Config.Default.MainWindow_Left = Math.Max(0D, this.Left);
|
||||
Config.Default.MainWindow_Top = Math.Max(0D, this.Top);
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (this.WindowState != WindowState.Minimized)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue