Skip to content

Commit ff6b3f8

Browse files
committed
v3.6.6.6
1 parent f397a8a commit ff6b3f8

File tree

9 files changed

+144
-92
lines changed

9 files changed

+144
-92
lines changed

MSL/App.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:hc="https://handyorg.github.io/handycontrol"
55
xmlns:langs="clr-namespace:MSL.langs"
66
xmlns:local="clr-namespace:MSL"
7+
xmlns:controls="clr-namespace:MSL.controls"
78
StartupUri="MainWindow.xaml">
89
<Application.Resources>
910
<ResourceDictionary>
@@ -52,6 +53,18 @@
5253
</Trigger>
5354
</Style.Triggers>
5455
</Style>
56+
<!-- 这个是自定义ListBox样式(放到Style.xaml后设计器会报错,强迫症很难受,只能放这里咯) -->
57+
<Style TargetType="{x:Type controls:MagicListBox}" BasedOn="{hc:StaticResource ListBoxBaseStyle}">
58+
<Setter Property="ItemsPanel">
59+
<Setter.Value>
60+
<ItemsPanelTemplate>
61+
<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>
62+
</ItemsPanelTemplate>
63+
</Setter.Value>
64+
</Setter>
65+
<Setter Property="ItemContainerStyle"
66+
Value="{StaticResource MagicListBoxItemStyle}"/>
67+
</Style>
5568
</ResourceDictionary>
5669
</Application.Resources>
5770
</Application>

MSL/controls/MagicControls.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ static MagicScrollViewer()
6767
DefaultStyleKeyProperty.OverrideMetadata(typeof(MagicScrollViewer), new FrameworkPropertyMetadata(typeof(MagicScrollViewer)));
6868
}
6969
}
70+
71+
public class MagicListBox : ListBox
72+
{
73+
static MagicListBox()
74+
{
75+
DefaultStyleKeyProperty.OverrideMetadata(typeof(MagicListBox), new FrameworkPropertyMetadata(typeof(MagicListBox)));
76+
}
77+
}
7078

7179
/* MagicGrowlPanel 用处不多不大,暂时弃用
7280
public class MagicGrowlPanel : Control

MSL/controls/Styles.xaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,35 @@
331331
</Setter>
332332
</Style>
333333

334+
<Style x:Key="MagicListBoxItemStyle" TargetType="ListBoxItem">
335+
<Setter Property="Template">
336+
<Setter.Value>
337+
<ControlTemplate TargetType="ListBoxItem">
338+
<Border x:Name="Bd"
339+
CornerRadius="7"
340+
BorderBrush="{DynamicResource BorderBrush}"
341+
BorderThickness="1"
342+
Padding="10">
343+
<ContentPresenter />
344+
</Border>
345+
<ControlTemplate.Triggers>
346+
<Trigger Property="IsSelected" Value="True">
347+
<Setter TargetName="Bd"
348+
Property="BorderBrush"
349+
Value="{DynamicResource DarkPrimaryBrush}"/>
350+
</Trigger>
351+
<Trigger Property="IsMouseOver" Value="True">
352+
<Setter TargetName="Bd"
353+
Property="Background"
354+
Value="{DynamicResource SideMenuBrush}"/>
355+
</Trigger>
356+
</ControlTemplate.Triggers>
357+
</ControlTemplate>
358+
</Setter.Value>
359+
</Setter>
360+
<Setter Property="Margin" Value="5"/>
361+
</Style>
362+
334363
<Style TargetType="Page" x:Key="AnimationPage">
335364
<Setter Property="RenderTransform">
336365
<Setter.Value>

MSL/forms/ServerRunner.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
</StackPanel>
227227
<ListView x:Name="pluginslist" hc:Empty.ShowEmpty="true" BorderThickness="0" Margin="0,35,0,0" Background="{DynamicResource BackgroundBrush}" FontSize="14">
228228
<ListView.ContextMenu>
229-
<ContextMenu FontSize="14">
229+
<ContextMenu>
230230
<MenuItem Click="reFresh_Click" Header="刷新"/>
231231
<MenuItem x:Name="addPlugin" Click="addPlugin_Click" Header="添加插件"/>
232232
<MenuItem x:Name="disPlugin" Click="disPlugin_Click" Header="禁用/启用所选插件"/>
@@ -276,7 +276,7 @@
276276
</StackPanel>
277277
<ListView x:Name="modslist" hc:Empty.ShowEmpty="true" BorderThickness="0" Margin="0,35,0,0" Background="{DynamicResource BackgroundBrush}" FontSize="14">
278278
<ListView.ContextMenu>
279-
<ContextMenu FontSize="14">
279+
<ContextMenu>
280280
<MenuItem Click="reFresh_Click" Header="刷新"/>
281281
<MenuItem x:Name="addMod" Click="addMod_Click" Header="添加模组"/>
282282
<MenuItem x:Name="disMod" Click="disMod_Click" Header="禁用/启用所选模组"/>

MSL/forms/ServerRunner.xaml.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
9797
LoadingCircle loadingCircle = new LoadingCircle();
9898
MainGrid.Children.Add(loadingCircle);
9999
MainGrid.RegisterName("loadingBar", loadingCircle);
100-
await Task.Delay(100);
101-
LoadingInfoEvent();
100+
await Task.Delay(50);
101+
if (!await LoadingInfoEvent())
102+
return;
102103
GetFastCmd();
103104
LoadedInfoEvent();
104-
await Task.Delay(100);
105+
await Task.Delay(50);
105106
MainGrid.Children.Remove(loadingCircle);
106107
MainGrid.UnregisterName("loadingBar");
107108
TabCtrl.SelectedIndex = FirstStartTab;
@@ -182,7 +183,7 @@ private void DisposeRes()
182183
GC.Collect(); // collect finalized objects
183184
}
184185

185-
private void LoadingInfoEvent()
186+
private async Task<bool> LoadingInfoEvent()
186187
{
187188
if (File.Exists(@"MSL\config.json"))
188189
{
@@ -228,6 +229,21 @@ private void LoadingInfoEvent()
228229
//Get Server-Information
229230
JObject jsonObject = JObject.Parse(File.ReadAllText(@"MSL\ServerList.json", Encoding.UTF8));
230231
JObject _json = (JObject)jsonObject[RserverID.ToString()];
232+
try
233+
{
234+
if (_json["name"] == null || _json["java"] == null || _json["base"] == null || _json["core"] == null || _json["memory"] == null || _json["args"] == null)
235+
{
236+
await MagicShow.ShowMsgDialogAsync("加载服务器信息时出现错误!", "错误");
237+
Close();
238+
return false;
239+
}
240+
}
241+
catch
242+
{
243+
await MagicShow.ShowMsgDialogAsync("加载服务器信息时出现错误!", "错误");
244+
Close();
245+
return false;
246+
}
231247
Rservername = _json["name"].ToString();
232248
Rserverjava = _json["java"].ToString();
233249
Rserverbase = _json["base"].ToString();
@@ -349,6 +365,7 @@ private void LoadingInfoEvent()
349365
jsonObject[RserverID.ToString()].Replace(_json);
350366
File.WriteAllText(@"MSL\ServerList.json", Convert.ToString(jsonObject), Encoding.UTF8);
351367
}
368+
return true;
352369
}//窗体加载后,运行此方法,主要为改变UI、检测服务器是否完整
353370

354371
private void LoadedInfoEvent()

MSL/pages/ServerList.xaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,62 @@
2323
<Button Content="下载资源" x:Name="DlModBtn" Margin="0,0,10,0" hc:IconElement.Geometry="{StaticResource DownloadGeometry}" Click="DlModBtn_Click"/>
2424
<Button Content="下载服务端" x:Name="DlServerCoreBtn" hc:IconElement.Geometry="{StaticResource DownloadGeometry}" Click="DlServerCoreBtn_Click"/>
2525
</StackPanel>
26+
<controls:MagicListBox Grid.Row="1" x:Name="serverList" hc:Empty.ShowEmpty="true" MouseDoubleClick="serverList_MouseDoubleClick" SelectionMode="Single" SelectionChanged="serverList_SelectionChanged" Background="Transparent">
27+
<controls:MagicListBox.ItemTemplate>
28+
<DataTemplate>
29+
<Grid Width="auto" Background="Transparent">
30+
<Grid.RowDefinitions>
31+
<RowDefinition Height="Auto"/>
32+
<RowDefinition Height="*"/>
33+
</Grid.RowDefinitions>
34+
<Label Style="{StaticResource BorderTitle}">
35+
<TextBlock>
36+
<Run Text="#"/><Run Text="{Binding ServerID}"/>
37+
<Run Text="{Binding ServerName}"/>
38+
</TextBlock>
39+
</Label>
40+
<hc:UniformSpacingPanel Grid.Row="1" Orientation="Vertical" Spacing="10">
41+
<hc:UniformSpacingPanel Spacing="5" Orientation="Horizontal">
42+
<Image Height="28" Width="28" Name="imageName" Source="{Binding ServerIcon, Converter={StaticResource ImagePathConverter}}" HorizontalAlignment="Left"/>
43+
<Label Content="{Binding ServerState}">
44+
<Label.Style>
45+
<Style TargetType="Label" BasedOn="{StaticResource {x:Type Label}}">
46+
<Setter Property="Foreground" Value="White"/>
47+
<Setter Property="Background" Value="{DynamicResource DarkDangerBrush}"/>
48+
<Style.Triggers>
49+
<DataTrigger Binding="{Binding ServerState}" Value="运行中">
50+
<Setter Property="Background" Value="{DynamicResource DarkSuccessBrush}"/>
51+
</DataTrigger>
52+
<DataTrigger Binding="{Binding ServerState}" Value="已开服">
53+
<Setter Property="Background" Value="{DynamicResource DarkSuccessBrush}"/>
54+
</DataTrigger>
55+
</Style.Triggers>
56+
</Style>
57+
</Label.Style>
58+
</Label>
59+
</hc:UniformSpacingPanel>
60+
<hc:UniformSpacingPanel Spacing="5" Orientation="Horizontal">
61+
<Button Style="{StaticResource ButtonPrimary}" Content="开启服务器" hc:IconElement.Geometry="{StaticResource CheckedGeometry}" hc:IconElement.Width="16" HorizontalAlignment="Left" Click="startServerBtn_Click"/>
62+
<Button hc:IconElement.Geometry="{StaticResource ConfigGeometry}" hc:IconElement.Height="16" HorizontalAlignment="Left" hc:Poptip.Content="服务器设置" hc:Poptip.HorizontalOffset="40" hc:Poptip.Placement="Left" Click="setServerBtn_Click"/>
63+
<Button hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" hc:IconElement.Height="16" HorizontalAlignment="Left" hc:Poptip.Content="删除该服务器" hc:Poptip.HorizontalOffset="40" hc:Poptip.Placement="Left" Click="delServerBtn_Click"/>
64+
</hc:UniformSpacingPanel>
65+
</hc:UniformSpacingPanel>
66+
</Grid>
67+
</DataTemplate>
68+
</controls:MagicListBox.ItemTemplate>
69+
<controls:MagicListBox.ContextMenu>
70+
<ContextMenu>
71+
<MenuItem Click="refreshList_Click" Header="{Binding [Page_ServerList_Refresh], Source={x:Static langs:LanguageManager.Instance}}"/>
72+
<MenuItem x:Name="startServerBtn" Click="startServer_Click" Header="{Binding [Page_ServerList_LaunchServer], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
73+
<MenuItem x:Name="startWithCmd" Click="startWithCmd_Click" Header="{Binding [Page_ServerList_UseCMDLaunch], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
74+
<MenuItem x:Name="setServer" Click="setServer_Click" Header="{Binding [Page_ServerList_Setting], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
75+
<MenuItem x:Name="setModorPlugin" Click="setModorPlugin_Click" Header="{Binding [Page_ServerList_ManageModsOrPlugins], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
76+
<MenuItem x:Name="openServerDir" Click="openServerDir_Click" Header="{Binding [Page_ServerList_OpenDir], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
77+
<MenuItem x:Name="delServer" Click="delServer_Click" Header="{Binding [Page_ServerList_Delete], Source={x:Static langs:LanguageManager.Instance}}" IsEnabled="False"/>
78+
</ContextMenu>
79+
</controls:MagicListBox.ContextMenu>
80+
</controls:MagicListBox>
81+
<!--
2682
<Border Grid.Row="1" CornerRadius="10" BorderThickness="0" Background="{DynamicResource BackgroundBrush}">
2783
<ListView x:Name="serverList" hc:Empty.ShowEmpty="true" MouseDoubleClick="serverList_MouseDoubleClick" FontSize="16" SelectionMode="Single" SelectionChanged="serverList_SelectionChanged" Background="Transparent" BorderThickness="0">
2884
<ListView.ContextMenu>
@@ -72,6 +128,7 @@
72128
</ListView.View>
73129
</ListView>
74130
</Border>
131+
-->
75132
<Button Grid.Row="1" x:Name="addServer" Margin="20" HorizontalAlignment="Right" VerticalAlignment="Bottom" hc:IconElement.Geometry="{StaticResource AddGeometry}" hc:IconElement.Height="16" Style="{StaticResource ButtonPrimary}" hc:BorderElement.CornerRadius="30" Height="48" Width="48" Click="addServer_Click"/>
76133
</Grid>
77134
</controls:MagicCard>

MSL/pages/ServerList.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private void startServerBtn_Click(object sender, RoutedEventArgs e)
335335
Button btn = sender as Button;
336336
if (btn != null)
337337
{
338-
ListViewItem item = FindAncestor<ListViewItem>(btn);
338+
ListBoxItem item = FindAncestor<ListBoxItem>(btn);
339339
if (item != null)
340340
{
341341
item.IsSelected = true;
@@ -348,7 +348,7 @@ private void setServerBtn_Click(object sender, RoutedEventArgs e)
348348
Button btn = sender as Button;
349349
if (btn != null)
350350
{
351-
ListViewItem item = FindAncestor<ListViewItem>(btn);
351+
ListBoxItem item = FindAncestor<ListBoxItem>(btn);
352352
if (item != null)
353353
{
354354
item.IsSelected = true;
@@ -361,7 +361,7 @@ private void delServerBtn_Click(object sender, RoutedEventArgs e)
361361
Button btn = sender as Button;
362362
if (btn != null)
363363
{
364-
ListViewItem item = FindAncestor<ListViewItem>(btn);
364+
ListBoxItem item = FindAncestor<ListBoxItem>(btn);
365365
if (item != null)
366366
{
367367
item.IsSelected = true;

MSL/pages/frpProviders/MSLFrp/MSLFrp.xaml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,45 +94,17 @@
9494
<ColumnDefinition Width="5*"/>
9595
<ColumnDefinition Width="4*"/>
9696
</Grid.ColumnDefinitions>
97-
<ListBox Grid.Column="0" x:Name="NodeList" SelectionMode="Single" SelectionChanged="NodeList_SelectionChanged">
98-
<ListBox.ItemsPanel>
99-
<ItemsPanelTemplate>
100-
<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>
101-
</ItemsPanelTemplate>
102-
</ListBox.ItemsPanel>
103-
<ListBox.ItemContainerStyle>
104-
<Style TargetType="ListBoxItem">
105-
<Setter Property="Template">
106-
<Setter.Value>
107-
<ControlTemplate TargetType="ListBoxItem">
108-
<Border x:Name="Bd" CornerRadius="7" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Padding="10">
109-
<ContentPresenter />
110-
</Border>
111-
<ControlTemplate.Triggers>
112-
<Trigger Property="IsSelected" Value="True">
113-
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
114-
</Trigger>
115-
<Trigger Property="IsMouseOver" Value="True">
116-
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource SideMenuBrush}"/>
117-
</Trigger>
118-
</ControlTemplate.Triggers>
119-
</ControlTemplate>
120-
</Setter.Value>
121-
</Setter>
122-
<Setter Property="Margin" Value="5"/>
123-
</Style>
124-
</ListBox.ItemContainerStyle>
125-
126-
<ListBox.ItemTemplate>
97+
<controls:MagicListBox Grid.Column="0" x:Name="NodeList" SelectionMode="Single" SelectionChanged="NodeList_SelectionChanged">
98+
<controls:MagicListBox.ItemTemplate>
12799
<DataTemplate>
128100
<Grid Width="160" Background="Transparent">
129101
<Grid.RowDefinitions>
130102
<RowDefinition Height="Auto"/>
131103
<RowDefinition Height="*"/>
132104
</Grid.RowDefinitions>
133105
<Label Style="{StaticResource BorderTitle}">
134-
<TextBlock>
135-
<Run Text="#"/><Run Text="{Binding ID}"/>
106+
<TextBlock><Run Text="#"/>
107+
<Run Text="{Binding ID}"/>
136108
<Run Text="{Binding Name}"/>
137109
</TextBlock>
138110
</Label>
@@ -173,8 +145,9 @@
173145
</hc:UniformSpacingPanel>
174146
</Grid>
175147
</DataTemplate>
176-
</ListBox.ItemTemplate>
177-
</ListBox>
148+
</controls:MagicListBox.ItemTemplate>
149+
</controls:MagicListBox>
150+
178151
<!--
179152
<ListBox x:Name="NodeList" Grid.Row="1" MinWidth="300" SelectionMode="Single" hc:Empty.ShowEmpty="true" SelectionChanged="NodeList_SelectionChanged">
180153
<ListBox.ItemTemplate>

0 commit comments

Comments
 (0)