优化了ModulePage界面添加了点内容

This commit is contained in:
muqing 2024-07-26 18:50:25 +08:00
parent 1dec11200a
commit a670df127b
11 changed files with 219 additions and 49 deletions

View File

@ -50,7 +50,6 @@ Global
{39825A39-612C-4260-8079-FA021D04783F}.Debug|x64.ActiveCfg = Debug|x64
{39825A39-612C-4260-8079-FA021D04783F}.Debug|x64.Build.0 = Debug|x64
{39825A39-612C-4260-8079-FA021D04783F}.Debug|x86.ActiveCfg = Debug|x86
{39825A39-612C-4260-8079-FA021D04783F}.Debug|x86.Build.0 = Debug|x86
{39825A39-612C-4260-8079-FA021D04783F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39825A39-612C-4260-8079-FA021D04783F}.Release|Any CPU.Build.0 = Release|Any CPU
{39825A39-612C-4260-8079-FA021D04783F}.Release|arm64.ActiveCfg = Release|arm64

View File

@ -13,6 +13,7 @@ using RustTools.Services;
using RustTools.ViewModels;
using RustTools.Views;
using System.Threading;
using RustTools.muqing;
namespace RustTools;
@ -52,7 +53,6 @@ public partial class App : Application
{
Exit(); //关闭系统
}
Host = Microsoft.Extensions.Hosting.Host.
CreateDefaultBuilder().
UseContentRoot(AppContext.BaseDirectory).

View File

@ -2,8 +2,8 @@
x:Class="RustTools.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RustTools"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:RustTools"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowex="using:WinUIEx"
MinWidth="500"
@ -11,6 +11,6 @@
PersistenceId="MainWindow"
mc:Ignorable="d">
<Window.SystemBackdrop>
<MicaBackdrop/>
<MicaBackdrop />
</Window.SystemBackdrop>
</windowex:WindowEx>

View File

@ -1,5 +1,5 @@
using RustTools.Helpers;
using RustTools.muqing;
using Windows.UI.ViewManagement;
namespace RustTools;
@ -13,7 +13,6 @@ public sealed partial class MainWindow : WindowEx
public MainWindow()
{
InitializeComponent();
//AppWindow.SetIcon("Assets/tool.png");
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
Content = null;
@ -23,6 +22,16 @@ public sealed partial class MainWindow : WindowEx
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
settings = new UISettings();
settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event
//gj.sc(Directory.GetCurrentDirectory());
if(wj.cz(wj.FILE.UUID))
{
gj.sc(wj.dqwb(wj.FILE.UUID));
}
else
{
wj.xrwb("win.uuid", gj.GetUUID());
}
}
// this handles updating the caption button colors correctly when indows system theme is changed

View File

@ -9,11 +9,14 @@
- **代码库**: [访问Muqing的个人项目](https://git.coldmint.top/muqing)
- **QQ**: 1966944300
Muqing专注于多平台开发包括但不限于
其他项目
- **WIn_RustTools**: [C#项目](https://git.coldmint.top/muqing/WIn_RustTools) - 专为桌面端设计的Rust辅助工具。
- **AndroidStudioDemo**: [Java项目](https://git.coldmint.top/muqing/AndroidStudioDemo) - 集成了Android各类小功能与界面测试的开源合集。
- **Cloud_music**: [Java项目](https://git.coldmint.top/muqing/Cloud_music) - 基于网易云SDK的开源音乐播放器。
- **new_Edit**(存档): [Java项目](https://git.coldmint.top/muqing/new_Edit) - 一款面向游戏的辅助编辑器原型。
### 为何开发电脑版
对于为什么开发电脑版,有的人觉得是多此一举,觉得手机版就够用了,没有电脑等等。
其实开发电脑版是作者对于铁锈的热爱开发的,请大家多多支持,开发不易。
## 反馈
我们目前没有写反馈的接口和功能 你可以加群 点击链接加入群聊【铁锈助手】https://qm.qq.com/q/dUfOK04pj2 在此反馈

View File

@ -50,6 +50,7 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="RestClient" Version="3.1024.23771" />
<PackageReference Include="RestSharp" Version="111.4.0" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="WinUIEx" Version="2.3.2" />
</ItemGroup>

View File

@ -50,27 +50,29 @@ public sealed partial class HomePage : Page
private void ListAClick(object sender, ItemClickEventArgs e)
{
if (e.ClickedItem is not ModData item) { return; }
var newWindow = new ModulePage(item.Id);
newWindow.Activate();
//// 获取点击的列表项的数据
//// 假设 RandomItem 是您的数据模型中的一个类
//// 获取被点击的项
//// 创建一个新的Window实例
//var window = new Window
//{
// // 将NewPage设置为新Window的内容
// Content = new ModulePage(item?.Id),
// // 设置新Window的一些属性如标题和大小
// Title =item?.Name,
//};
//window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
////window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/创意工坊.svg"));
//// 显示新Window
//window.Show();
// 查找已存在的 ModulePage如果存在则激活它
var existingWindow = ModulePage.ModulePageList.FirstOrDefault(window => window.Mod.Id == item.Id);
if (existingWindow != null)
{
// 如果窗口已经存在,则激活它
existingWindow.Activate();
}
else
{
// 如果窗口不存在,则创建新窗口并添加到列表中
var newWindow = new ModulePage(item.Id);
//newWindow.Activated += (s, args) =>
//{
// // 当窗口被激活时,确保它在列表中
// if (!ModulePage.ModulePageList.Contains(newWindow))
// {
// ModulePage.ModulePageList.Add(newWindow);
// }
//};
newWindow.Activate();
ModulePage.ModulePageList.Add(newWindow);
}
}
private void RefreshRandom(object sender,RoutedEventArgs e)

View File

@ -1,24 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<Window
<windowex:WindowEx
x:Class="RustTools.Views.ModulePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:RustTools.DataList"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowex="using:WinUIEx"
Title="模组信息"
MinWidth="650"
MinHeight="500"
Closed="WindowEx_Closed"
SizeChanged="WindowEx_SizeChanged"
mc:Ignorable="d">
<Window.SystemBackdrop>
<DesktopAcrylicBackdrop />
</Window.SystemBackdrop>
<Grid x:Name="grid">
<StackPanel
Grid.Row="1"
Height="126"
Margin="16,16,16,16"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Orientation="Horizontal">
<Grid x:Name="grid" Padding="16,36,16,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions />
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Border
Width="106"
Height="106"
@ -41,5 +45,49 @@
Text="加载中" />
</StackPanel>
</StackPanel>
<ScrollView Grid.Row="1">
<StackPanel Margin="0,26,0,0" Orientation="Vertical">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="介绍" />
<TextBlock
x:Name="DescriptionText"
Padding="6,6,6,6"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding Mod.Description}"
TextWrapping="Wrap" />
<TextBlock
x:Name="fliptext"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="截图"
Visibility="Collapsed" />
<FlipView
x:Name="flipview"
MaxWidth="600"
MaxHeight="360"
Margin="6,6,6,6"
HorizontalAlignment="Left"
ItemsSource="{x:Bind ScreenshotsList}"
Visibility="Collapsed">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Image Source="{x:Bind Mode=OneTime}" Stretch="Uniform" />
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
</StackPanel>
</ScrollView>
<CommandBar
Grid.Row="3"
VerticalAlignment="Bottom"
Background="Transparent"
DefaultLabelPosition="Right"
IsOpen="False">
<CommandBar.PrimaryCommands>
<AppBarButton Icon="ReportHacked" Label="举报" />
<AppBarSeparator />
<AppBarButton Icon="Like" Label="支持" />
<AppBarSeparator />
<AppBarButton Icon="Download" Label="下载" />
</CommandBar.PrimaryCommands>
</CommandBar>
</Grid>
</Window>
</windowex:WindowEx>

View File

@ -16,6 +16,7 @@ using RustTools.muqing;
using Newtonsoft.Json;
using RustTools.DataList;
using RustTools.Core.Helpers;
using System.Collections.ObjectModel;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@ -26,12 +27,15 @@ namespace RustTools.Views;
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ModulePage : Window
public sealed partial class ModulePage : WindowEx
{
public ModInfo.Data Mod { get; set; }
public static List<ModulePage> ModulePageList = new();
public ObservableCollection<string> ScreenshotsList =new();
public ModInfo.Data Mod { get; set; } = new();
public ModulePage(string v)
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
init(v);
}
private async void init(string v)
@ -51,12 +55,49 @@ public sealed partial class ModulePage : Window
{
Mod.IconUrl = Mod.IconUrl.Replace("..", wl.api);
}
gj.sc(Mod.Name);
Title = Mod.Name;
var l = " | ";
title_b.Text = "单位数" + Mod.UnitNumber + l + Mod.DownloadNumber + "次下载" + l + "版本名称" + Mod.VersionName;
title_c.Text = "发布时间:" + Mod.CreationTime + " 最近更新:" + Mod.UpdateTime;
var ScrList = Mod.Screenshots.Split(",");
foreach (var s in ScrList)
{
gj.sc(s);
if (string.IsNullOrEmpty(s))
{
continue;
}
ScreenshotsList.Add(s.Replace("..", wl.api));
}
if (ScreenshotsList.Count > 0)
{
fliptext.Visibility = Visibility.Visible;
flipview.Visibility = Visibility.Visible;
}
else
{
fliptext.Visibility = Visibility.Collapsed;
flipview.Visibility = Visibility.Collapsed;
}
grid.DataContext = this; // 设置数据上下文
}
}
private void WindowEx_SizeChanged(object sender, WindowSizeChangedEventArgs args)
{
gj.sc(Width);
DescriptionText.Width = Width-50;
}
private void WindowEx_Closed(object sender, WindowEventArgs args)
{
// 当窗口关闭时,从列表中移除
ModulePageList.Remove(this);
}
}

View File

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;

using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RustTools.muqing;
using System;
using System.Management;
class gj
{
public static void sc(object obj)
@ -14,4 +10,25 @@ class gj
obj ??= "null";
Debug.WriteLine(obj);
}
public static string GetUUID()
{
try
{
using (var searcher = new ManagementObjectSearcher("select UUID from Win32_ComputerSystemProduct"))
{
foreach (ManagementObject obj in searcher.Get())
{
return obj["UUID"].ToString();
}
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred while retrieving the UUID: {ex.Message}");
}
return null;
}
}

50
RustTools/muqing/wj.cs Normal file
View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace RustTools.muqing;
class wj
{
//存储主要文件的路径
public static string CD = "D:\\抓包";
//缓存路径
public static string? Cache;
/// <summary>
/// 存储文件名字的路径
/// </summary>
public class FILE
{
public static string UUID = "win.uuid";
}
public static bool xrwb(string name,string str)
{
// 获取当前执行文件的目录
//var currentDirectory = Directory.GetCurrentDirectory();
var filePath = Path.Combine(CD,name);
try
{
File.WriteAllText(filePath, str);
return true;
}
catch (Exception ex) {
Debug.WriteLine(ex.ToString());
}
// 将 UUID 写入文件
return false;
}
public static string dqwb(string name)
{
return File.ReadAllText(Path.Combine(CD, name));
}
public static bool cz(string name)
{
return File.Exists(Path.Combine(CD,name));
}
}