Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
🐟 杂项更新&Mod搜寻器显示下载量等信息
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiYu-233 committed Jun 2, 2024
1 parent 34cede9 commit 63a6499
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 69 deletions.
10 changes: 10 additions & 0 deletions YMCL.Main/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
<ui:FontIcon Glyph="&#xE70A;" />
</MenuItem.Icon>
</MenuItem>
<MenuItem
x:Name="ResizeWindow"
Click="ResizeWindow_Click"
DockPanel.Dock="Top"
FontFamily="{DynamicResource Font}"
Header="{x:Static properties:MainLang.ResizeWindow}">
<MenuItem.Icon>
<ui:FontIcon Glyph="&#xE70A;" />
</MenuItem.Icon>
</MenuItem>
<MenuItem
x:Name="ShowTasks"
Click="ShowTasks_Click"
Expand Down
8 changes: 8 additions & 0 deletions YMCL.Main/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ private void App_DispatcherUnhandledException(object sender, System.Windows.Thre
}
}
#region NotifyIcon
private void ResizeWindow_Click(object sender, RoutedEventArgs e)
{
var setting = JsonConvert.DeserializeObject<Public.Class.Setting>(File.ReadAllText(Const.SettingDataPath));
setting.MainWidth = 1050;
setting.MainHeight = 600;
File.WriteAllText(Const.SettingDataPath, JsonConvert.SerializeObject(setting, Formatting.Indented));
Method.RestartApp();
}
private void ShowWindow_Click(object sender, RoutedEventArgs e)
{
Const.Window.main.WindowState = WindowState.Normal;
Expand Down
9 changes: 9 additions & 0 deletions YMCL.Main/Public/Class/Sundry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ public enum InfoType
}
}
}
public class ModListViewEntry()
{
public string Name { get; set; }
public string Summary { get; set; }
public string DownloadCount { get; set; }
public string DateModified { get; set; }
public string Source { get; set; }
public string IconUrl { get; set; }
}
}
9 changes: 9 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,7 @@
<data name="SettingTransfer" xml:space="preserve">
<value>Settings Migrated</value>
</data>
<data name="ResizeWindow" xml:space="preserve">
<value>Adjust Window</value>
</data>
</root>
3 changes: 3 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.ja-JP.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,7 @@
<data name="SettingTransfer" xml:space="preserve">
<value>設定が移行されました</value>
</data>
<data name="ResizeWindow" xml:space="preserve">
<value>ウィンドウを調整します</value>
</data>
</root>
3 changes: 3 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,7 @@
<data name="SettingTransfer" xml:space="preserve">
<value>设置迁移</value>
</data>
<data name="ResizeWindow" xml:space="preserve">
<value>调整窗口</value>
</data>
</root>
3 changes: 3 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,7 @@
<data name="SettingTransfer" xml:space="preserve">
<value>Настройки перенесены</value>
</data>
<data name="ResizeWindow" xml:space="preserve">
<value>Отрегулируйте окно</value>
</data>
</root>
3 changes: 3 additions & 0 deletions YMCL.Main/Public/Lang/MainLang.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,7 @@
<data name="SettingTransfer" xml:space="preserve">
<value>設定遷移</value>
</data>
<data name="ResizeWindow" xml:space="preserve">
<value>調整視窗</value>
</data>
</root>
19 changes: 19 additions & 0 deletions YMCL.Main/Public/Method.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Security.Principal;
using System.Windows;
using MessageBoxIcon = Panuon.WPF.UI.MessageBoxIcon;
using System.Globalization;

namespace YMCL.Main.Public
{
Expand Down Expand Up @@ -276,5 +277,23 @@ public static string MsToTime(double ms)//转换为分秒格式

return $"{minuteStr}:{secondStr}";
}
public static string FormatNumberWithWanYi(string numberStr)
{
// 先转换为decimal,确保精度
decimal number = decimal.Parse(numberStr, CultureInfo.InvariantCulture);

if (number < 10000) // 小于万位,直接返回
{
return number.ToString("N0", CultureInfo.InvariantCulture);
}
else if (number < 100000000) // 小于亿位,转换为万位
{
return (number / 10000).ToString("N2") + "万";
}
else // 大于等于亿位,转换为亿位
{
return (number / 100000000).ToString("N2") + "亿";
}
}
}
}
11 changes: 10 additions & 1 deletion YMCL.Main/Views/Main/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@
<TextBlock />
<Button
x:Name="btnMinimize"
Margin="0,0,30,0"
Margin="0,0,57,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="btnMinimize_Click"
Content="{DynamicResource Minimize}"
Cursor="Hand"
Style="{DynamicResource IconButtonsStyle}" />
<Button
x:Name="btnMaximize"
Margin="0,0,30,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="btnMaximize_Click"
Content="{DynamicResource Maximize}"
Cursor="Hand"
Style="{DynamicResource IconButtonsStyle}" />
<Button
x:Name="btnClose"
Margin="0,0,3,0"
Expand Down
12 changes: 12 additions & 0 deletions YMCL.Main/Views/Main/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,17 @@ private void WindowX_Drop(object sender, System.Windows.DragEventArgs e)
{
Const.Window.main.DropMethod(e);
}

private void btnMaximize_Click(object sender, RoutedEventArgs e)
{
if (WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
}
else
{
WindowState = WindowState.Maximized;
}
}
}
}
65 changes: 53 additions & 12 deletions YMCL.Main/Views/Main/Pages/Download/Pages/Mods/Mods.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,69 @@
<DataTemplate>
<DockPanel Margin="-8,3,10,3">
<ui:ClippingBorder
Width="32"
Height="32"
Width="40"
Height="40"
Background="Wheat"
CornerRadius="5">
CornerRadius="5" Margin="0,0,3,0">
<Image
Width="32"
Height="32"
Width="NaN"
Height="NaN"
Source="{Binding IconUrl}" />
</ui:ClippingBorder>
<Grid Margin="6.5,1,0,1">
<TextBlock><Run
<DockPanel Margin="6.5,1,0,1">
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap"><Run
FontFamily="MiSans Medium"
FontSize="14"
Text="{Binding Name}" /><Run Text=" " /></TextBlock>
<TextBlock
Margin="1,17,0,0"
FontSize="12"
Foreground="#E48A8A8A"><Run
Margin="1,0,0,0"
VerticalAlignment="Top"
DockPanel.Dock="Top"
FontSize="13"
Foreground="#E48A8A8A"
TextWrapping="Wrap"><Run
FontFamily="MiSans Medium"
FontSize="11"
FontSize="12"
Text="{Binding Summary}" /><Run Text=" " /></TextBlock>
</Grid>
<Grid Margin="1,2,0,0">
<DockPanel>
<ui:FontIcon
FontSize="12"
Foreground="{DynamicResource Gray}"
Glyph="&#xEBD3;" />
<TextBlock
Margin="2,0,0,0"
FontFamily="MiSans Medium"
FontSize="12"
Foreground="{DynamicResource Gray}"
Text="{Binding DownloadCount}" />
</DockPanel>
<DockPanel Margin="130,0,0,0">
<ui:FontIcon
FontSize="12"
Foreground="{DynamicResource Gray}"
Glyph="&#xE898;" />
<TextBlock
Margin="2,0,0,0"
FontFamily="MiSans Medium"
FontSize="12"
Foreground="{DynamicResource Gray}"
Text="{Binding DateModified}" />
</DockPanel>
<DockPanel Margin="300,0,0,0">
<ui:FontIcon
FontSize="12"
Foreground="{DynamicResource Gray}"
Glyph="&#xF6FA;" />
<TextBlock
Margin="2,0,0,0"
FontFamily="MiSans Medium"
FontSize="12"
Foreground="{DynamicResource Gray}"
Text="{Binding Source}" />
</DockPanel>
</Grid>
</DockPanel>
</DockPanel>
</DataTemplate>
</ui:ListView.ItemTemplate>
Expand Down
20 changes: 4 additions & 16 deletions YMCL.Main/Views/Main/Pages/Download/Pages/Mods/Mods.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
using MinecraftLaunch.Classes.Enums;
using MinecraftLaunch.Classes.Models.Download;
using MinecraftLaunch.Components.Fetcher;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using YMCL.Main.Public;
using YMCL.Main.Public.Control.ModFileExpander;
using ListView = iNKORE.UI.WPF.Modern.Controls.ListView;
Expand Down Expand Up @@ -58,7 +46,7 @@ public Mods()
{
InitializeComponent();
}
private async void ModSearchBox_QuerySubmitted(iNKORE.UI.WPF.Modern.Controls.AutoSuggestBox sender, iNKORE.UI.WPF.Modern.Controls.AutoSuggestBoxQuerySubmittedEventArgs args)
private async void ModSearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
ModsListView.Items.Clear();
ModSearchBox.IsEnabled = false;
Expand All @@ -77,7 +65,7 @@ private async void ModSearchBox_QuerySubmitted(iNKORE.UI.WPF.Modern.Controls.Aut
ModSearchBox.IsEnabled = true;
entries.ForEach(entry =>
{
ModsListView.Items.Add(entry);
ModsListView.Items.Add(new Public.Class.ModListViewEntry() { Name = entry.Name, Summary = entry.Summary, DownloadCount = Method.FormatNumberWithWanYi(entry.DownloadCount.ToString()), DateModified = entry.DateModified.ToString(), Source = "CurseForge", IconUrl = entry.IconUrl });
});
}

Expand All @@ -102,7 +90,7 @@ private void ModsListView_SelectionChanged(object sender, SelectionChangedEventA
{
var expander = new ModFileExpander(mcVersion);
expander.Margin = new Thickness(0, 0, 0, 10);
expander.Name = $"mod_{mcVersion.Replace(".","_")}";
expander.Name = $"mod_{mcVersion.Replace(".", "_")}";
expander.ModFileListView.SelectionChanged += ModFileListView_SelectionChanged;
ModDetailsVersionPanel.Children.Add(expander);
foreach (var file in item.Files)
Expand All @@ -121,7 +109,7 @@ private void ModFileListView_SelectionChanged(object sender, SelectionChangedEve
var item = control.SelectedItem as CurseFileEntry;
if (item != null)
{

}
}

Expand Down
Loading

0 comments on commit 63a6499

Please sign in to comment.