加入登陆的UI

This commit is contained in:
muqing 2024-08-15 09:40:33 +08:00
parent 02f8e1c036
commit 91659543fa
43 changed files with 421 additions and 361 deletions

View File

@ -1,9 +1,4 @@
using System; using RustTools.muqing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RustTools.muqing;
namespace RustTools.ApiFox; namespace RustTools.ApiFox;
@ -40,7 +35,7 @@ class mod
public static async Task<string> getInfo(string account, string modId) public static async Task<string> getInfo(string account, string modId)
{ {
var v = await wl.postAsync("/php/mod.php?action=getInfo", new string[][]{ var v = await wl.postAsync("/php/mod.php?action=getInfo", new string[][]{
new string[] { "account", account }, new string[] { "account", account },
new string[] { "modId", modId} new string[] { "modId", modId}

View File

@ -2,17 +2,16 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using RustTools.Activation;
using RustTools.Contracts.Services; using RustTools.Contracts.Services;
using RustTools.Models; using RustTools.Models;
using RustTools.muqing;
using RustTools.Services; using RustTools.Services;
using RustTools.ViewModels; using RustTools.ViewModels;
using RustTools.Views; using RustTools.Views;
using RustTools.muqing;
using RustTools.Activation;
using RustTools.WindowUI; using RustTools.WindowUI;
using Windows.ApplicationModel.Activation; using Windows.ApplicationModel.Activation;
using Microsoft.Windows.AppLifecycle;
using WinUIEx;
namespace RustTools; namespace RustTools;
@ -41,7 +40,10 @@ public partial class App : Microsoft.UI.Xaml.Application
} }
public static UIElement? AppTitlebar { get; set; } public static UIElement? AppTitlebar
{
get; set;
}
public static WindowEx? MainWindow; public static WindowEx? MainWindow;
public App() public App()
@ -123,7 +125,7 @@ public partial class App : Microsoft.UI.Xaml.Application
if (storageFile != null) if (storageFile != null)
{ {
gj.sc(storageFile.Path); gj.sc(storageFile.Path);
var importModule=new ImportModule(storageFile.Path); var importModule = new ImportModule(storageFile.Path);
importModule.Activate(); importModule.Activate();
// 读取或处理文件内容 // 读取或处理文件内容
} }

View File

@ -1,6 +1,4 @@
using System; using Newtonsoft.Json;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
public class CommunityList public class CommunityList
{ {

View File

@ -1,11 +1,4 @@
using System; namespace RustTools.DataList;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace RustTools.DataList;
public class HomeBanner public class HomeBanner
{ {

View File

@ -1,5 +1,4 @@
using System; using Newtonsoft.Json;
using Newtonsoft.Json;
public class ModInfo public class ModInfo
{ {

View File

@ -1,6 +1,4 @@
using System; using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
public class ModListResponse public class ModListResponse

View File

@ -1,10 +1,4 @@
using System; namespace RustTools.DataList;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RustTools.DataList;
public class MovingInfo public class MovingInfo
{ {
public class Data public class Data

View File

@ -1,12 +1,4 @@
using System; using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Payments;
namespace RustTools.Editor; namespace RustTools.Editor;
public class EditorLoad public class EditorLoad
@ -67,7 +59,8 @@ public class EditorLoad
// Type = ExplorerItem.ExplorerItemType.Folder, // Type = ExplorerItem.ExplorerItemType.Folder,
//}; //};
//LoadDirectory(directoryInfos,rootItem); //LoadDirectory(directoryInfos,rootItem);
foreach (var file in directoryInfos.GetDirectories()) { foreach (var file in directoryInfos.GetDirectories())
{
var explorerItem = new ExplorerItem() var explorerItem = new ExplorerItem()
{ {
Name = file.Name, Name = file.Name,

View File

@ -1,18 +1,15 @@
 
using Microsoft.UI.Xaml.Controls; using System.Diagnostics;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using RustTools.muqing; using RustTools.muqing;
using Windows.ApplicationModel.DataTransfer; using Windows.ApplicationModel.DataTransfer;
using Microsoft.UI.Xaml.Input;
using Windows.Storage; using Windows.Storage;
using RustTools.Helpers;
using Microsoft.UI.Xaml.Media;
using Windows.Foundation;
using System.Diagnostics;
namespace RustTools.Editor; namespace RustTools.Editor;
public class EditorTreeView: TreeView public class EditorTreeView : TreeView
{ {
public EditorTreeView() public EditorTreeView()
{ {
@ -34,7 +31,8 @@ public class EditorTreeView: TreeView
e.Data.SetData("path", firstItem.Dir); e.Data.SetData("path", firstItem.Dir);
e.Data.RequestedOperation = DataPackageOperation.Move; // Use Copy to avoid moving items e.Data.RequestedOperation = DataPackageOperation.Move; // Use Copy to avoid moving items
} }
private void EditorTreeView_DragItemsCompleted(TreeView sender, TreeViewDragItemsCompletedEventArgs e) { private void EditorTreeView_DragItemsCompleted(TreeView sender, TreeViewDragItemsCompletedEventArgs e)
{
// 获取拖拽的项 // 获取拖拽的项
var items = e.Items.Cast<ExplorerItem>().ToList(); var items = e.Items.Cast<ExplorerItem>().ToList();
@ -114,9 +112,9 @@ public class EditorTreeView: TreeView
var storageItems = await e.DataView.GetStorageItemsAsync(); var storageItems = await e.DataView.GetStorageItemsAsync();
// 获取目标文件夹,即拖放的位置 // 获取目标文件夹,即拖放的位置
// 获取目标位置 // 获取目标位置
var treeView = sender as TreeView; var treeView = sender as TreeView;
var data = await e.DataView.GetDataAsync("path"); var data = await e.DataView.GetDataAsync("path");
gj.sc(data); gj.sc(data);
@ -125,7 +123,7 @@ public class EditorTreeView: TreeView
if (item is StorageFolder folder) if (item is StorageFolder folder)
{ {
// 移动文件夹 // 移动文件夹
gj.sc(folder.Path+"-->"); gj.sc(folder.Path + "-->");
//var newFolder = await folder.MoveAsync(targetFolder, folder.Name, NameCollisionOption.ReplaceExisting); //var newFolder = await folder.MoveAsync(targetFolder, folder.Name, NameCollisionOption.ReplaceExisting);
} }
else if (item is StorageFile file) else if (item is StorageFile file)

View File

@ -1,18 +1,10 @@
using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Metadata;
using Microsoft.UI; using Microsoft.UI;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Input;
using RustTools.muqing; using RustTools.muqing;
using Windows.ApplicationModel.DataTransfer;
using WinRT.Interop; using WinRT.Interop;
namespace RustTools.Editor; namespace RustTools.Editor;
/// <summary> /// <summary>
@ -22,7 +14,7 @@ public sealed partial class EditorWin : WindowEx
{ {
private readonly ObservableCollection<TabViewItem> TabViewList = new(); private readonly ObservableCollection<TabViewItem> TabViewList = new();
//目录列表 //目录列表
public ObservableCollection<ExplorerItem> DataSource=new (); public ObservableCollection<ExplorerItem> DataSource = new();
public EditorWin() public EditorWin()
{ {
InitializeComponent(); InitializeComponent();
@ -42,7 +34,7 @@ public sealed partial class EditorWin : WindowEx
//Closed += EditorWin_Closed; //Closed += EditorWin_Closed;
var directoryInfo = new DirectoryInfo("D:\\steam\\steamapps\\common\\Rusted Warfare\\mods\\units\\赤道·联合进攻0.9补丁版0.2"); var directoryInfo = new DirectoryInfo("D:\\steam\\steamapps\\common\\Rusted Warfare\\mods\\units\\赤道·联合进攻0.9补丁版0.2");
DataSource = new EditorLoad().GetData(directoryInfo.FullName); DataSource = new EditorLoad().GetData(directoryInfo.FullName);
Title=directoryInfo.Name; Title = directoryInfo.Name;
TitleText.Text = directoryInfo.Name; TitleText.Text = directoryInfo.Name;
Closed += EditorWin_Closed; Closed += EditorWin_Closed;
} }
@ -59,35 +51,36 @@ public sealed partial class EditorWin : WindowEx
// 防止窗口关闭 // 防止窗口关闭
e.Handled = true; e.Handled = true;
} }
if (ClosedDialog != null) { if (ClosedDialog != null)
{
return; return;
} }
// 显示一个对话框,告知用户窗口不能关闭 // 显示一个对话框,告知用户窗口不能关闭
ClosedDialog = new ContentDialog ClosedDialog = new ContentDialog
{ {
XamlRoot = page.XamlRoot, XamlRoot = page.XamlRoot,
Title = "警告", Title = "警告",
Content = "你还有未保存的文件在编译器中。", Content = "你还有未保存的文件在编译器中。",
PrimaryButtonText = "保存关闭", PrimaryButtonText = "保存关闭",
PrimaryButtonStyle = Application.Current.Resources["AccentButtonStyle"] as Style, PrimaryButtonStyle = Application.Current.Resources["AccentButtonStyle"] as Style,
SecondaryButtonText = "直接关闭", SecondaryButtonText = "直接关闭",
CloseButtonText = "取消" CloseButtonText = "取消"
}; };
var result = await ClosedDialog.ShowAsync(); var result = await ClosedDialog.ShowAsync();
if (result == ContentDialogResult.Primary) if (result == ContentDialogResult.Primary)
{ {
IsSave = true; IsSave = true;
Application.Current.Exit(); Application.Current.Exit();
return; return;
} }
else if (result == ContentDialogResult.Secondary) else if (result == ContentDialogResult.Secondary)
{ {
IsSave = true; IsSave = true;
Application.Current.Exit(); Application.Current.Exit();
return; return;
} }
ClosedDialog = null; ClosedDialog = null;
} }
private Microsoft.UI.Windowing.AppWindow GetAppWindowForCurrentWindow() private Microsoft.UI.Windowing.AppWindow GetAppWindowForCurrentWindow()

View File

@ -1,12 +1,7 @@
using System; using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace RustTools.Editor; namespace RustTools.Editor;
public class ExplorerItemTemplateSelector : DataTemplateSelector public class ExplorerItemTemplateSelector : DataTemplateSelector
@ -40,7 +35,7 @@ public class ExplorerItem : INotifyPropertyChanged
} }
public string? Dir public string? Dir
{ {
get;set; get; set;
} }
private ObservableCollection<ExplorerItem>? m_children; private ObservableCollection<ExplorerItem>? m_children;
public ObservableCollection<ExplorerItem> Children public ObservableCollection<ExplorerItem> Children

View File

@ -1,6 +1,4 @@
using RustTools.Helpers; using Windows.Storage;
using Windows.Storage;
using Windows.Storage.Streams; using Windows.Storage.Streams;
namespace RustTools.Helpers; namespace RustTools.Helpers;

View File

@ -2,7 +2,6 @@
using Microsoft.UI; using Microsoft.UI;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Windows.UI; using Windows.UI;
using Windows.UI.ViewManagement; using Windows.UI.ViewManagement;

View File

@ -1,9 +1,5 @@
using System.Resources; using RustTools.Helpers;
using Microsoft.UI.Xaml;
using RustTools.Helpers;
using RustTools.muqing; using RustTools.muqing;
using RustTools.WindowUI;
using Windows.Storage;
using Windows.UI.ViewManagement; using Windows.UI.ViewManagement;
namespace RustTools; namespace RustTools;

View File

@ -62,12 +62,26 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Themes\ButtonIcon.xaml" />
<None Remove="Themes\LoginPage.xaml" />
<None Remove="Themes\NullPage.xaml" /> <None Remove="Themes\NullPage.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Update="Themes\LoginPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\NullPage.xaml"> <Page Update="Themes\NullPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup>
<CustomAdditionalCompileInputs Remove="Themes\ButtonIcon.xaml" />
</ItemGroup>
<ItemGroup>
<Resource Remove="Themes\ButtonIcon.xaml" />
</ItemGroup>
</Project> </Project>

View File

@ -3,8 +3,6 @@
using RustTools.Contracts.Services; using RustTools.Contracts.Services;
using RustTools.Helpers; using RustTools.Helpers;
using RustTools.Models; using RustTools.Models;
using Windows.ApplicationModel;
using Windows.Storage; using Windows.Storage;
namespace RustTools.Services; namespace RustTools.Services;

View File

@ -1,18 +1,5 @@
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace RustTools.Styles; namespace RustTools.Styles;
public sealed class TitleSubtitleControl : Control public sealed class TitleSubtitleControl : Control
@ -24,16 +11,9 @@ public sealed class TitleSubtitleControl : Control
public string TitleText public string TitleText
{ {
get get => (string)GetValue(TitleTextProperty);
{ set => SetValue(TitleTextProperty, value);
return (string)GetValue(TitleTextProperty);
}
set
{
SetValue(TitleTextProperty, value);
}
} }
public static readonly DependencyProperty TitleTextProperty = public static readonly DependencyProperty TitleTextProperty =
DependencyProperty.Register("TitleText", typeof(string), typeof(TitleSubtitleControl), new PropertyMetadata("")); DependencyProperty.Register("TitleText", typeof(string), typeof(TitleSubtitleControl), new PropertyMetadata(""));

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="RustTools.Themes.ButtonIcon"
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:local="using:RustTools.Themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="using:RustTools.ViewModels"
d:DataContext="{d:DesignInstance Type=viewmodels:ButtonViewModel}"
mc:Ignorable="d">
<Button
Name="button"
Padding="9"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
CornerRadius="9">
<FontIcon Glyph="{x:Bind Glyph, Mode=OneWay}" />
</Button>
</UserControl>

View File

@ -0,0 +1,31 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace RustTools.Themes;
public sealed partial class ButtonIcon : UserControl
{
public ButtonIcon()
{
this.InitializeComponent();
DefaultStyleKey = typeof(ButtonIcon);
}
public string Glyph
{
get => (string)GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
public static readonly DependencyProperty GlyphProperty =
DependencyProperty.Register("Glyph", typeof(string), typeof(ButtonIcon), new PropertyMetadata("\uE70A")); // ÉèÖÃĬÈÏÖµ
public event RoutedEventHandler Click
{
add
{
button.Click += value;
}
remove
{
button.Click -= value;
}
}
}

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="RustTools.Themes.LoginPage"
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:local="using:RustTools.Themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Border
Margin="16"
Padding="26"
Background="{StaticResource CardStrokeColorDefault}"
CornerRadius="13">
<Grid MinWidth="350" HorizontalAlignment="Center">
<StackPanel x:Name="login_view">
<TextBlock HorizontalAlignment="Center" Text="登陆" />
<StackPanel>
<TextBox
Margin="0,16,0,16"
InputScope="AlphanumericPin"
PlaceholderText="账号" />
<PasswordBox Margin="0,0,0,16" PlaceholderText="密码" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Width="100"
Margin="16"
Click="login_Click"
Content="登陆"
Style="{StaticResource AccentButtonStyle}" />
<Button
Margin="0,0,0,0"
Click="enroll_Click"
Content="注册" />
</StackPanel>
<CheckBox>
<CheckBox.Content>
<StackPanel Orientation="Horizontal" ToolTipService.ToolTip="虽然没什么用但是这是常规的">
<TextBlock VerticalAlignment="Center" Text="我同意" />
<HyperlinkButton
x:Name="hlbTerms"
Content="《服务协议》"
NavigateUri="https://rust.coldmint.top/resources/agreement/service_agreement.html" />
<TextBlock VerticalAlignment="Center" Text="与" />
<HyperlinkButton
x:Name="hlbPrivacy"
Content="《隐私政策》"
NavigateUri="https://rust.coldmint.top/resources/agreement/privacy_policy.html" />
</StackPanel>
</CheckBox.Content>
</CheckBox>
</StackPanel>
<StackPanel x:Name="enroll_view" Visibility="Collapsed">
<local:ButtonIcon
x:Name="Back_Button"
Click="Back_Click"
Glyph="&#xE72B;" />
<TextBlock HorizontalAlignment="Center" Text="注册" />
<StackPanel>
<TextBox
Margin="0,16,0,16"
InputScope="AlphanumericPin"
PlaceholderText="账号" />
<TextBox
Margin="0,0,0,16"
InputScope="NameOrPhoneNumber"
PlaceholderText="用户名/昵称" />
<PasswordBox Margin="0,0,0,16" PlaceholderText="密码" />
<PasswordBox Margin="0,0,0,16" PlaceholderText="确认密码" />
<TextBox
Margin="0,0,0,16"
InputScope="EmailNameOrAddress"
PlaceholderText="邮箱" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="0,0,0,0" Content="注册" />
</StackPanel>
</StackPanel>
</Grid>
</Border>
</UserControl>

View File

@ -0,0 +1,91 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
namespace RustTools.Themes;
public sealed partial class LoginPage : UserControl
{
public LoginPage()
{
InitializeComponent();
DefaultStyleKey = typeof(LoginPage);
}
/// <summary>
/// 返回到登陆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Back_Click(object sender, RoutedEventArgs e)
{
var storyboard = CreateFadeTransitionStoryboard(enroll_view,login_view);
storyboard.Begin();
}
/// <summary>
/// 切换到注册
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void enroll_Click(object sender, RoutedEventArgs e)
{
var storyboard = CreateFadeTransitionStoryboard(login_view, enroll_view);
storyboard.Begin();
}
private void FadeOutStoryboard_Completed(object? sender, object e)
{
// 确保动画完成后执行切换
if (login_view.Visibility == Visibility.Visible)
{
login_view.Visibility = Visibility.Collapsed;
enroll_view.Visibility = Visibility.Visible;
}
else
{
enroll_view.Visibility = Visibility.Collapsed;
login_view.Visibility = Visibility.Visible;
}
}
private Storyboard CreateFadeTransitionStoryboard(FrameworkElement fromElement, FrameworkElement toElement)
{
var storyboard = new Storyboard();
// 淡出动画
var fadeOutAnimation = new DoubleAnimation
{
From = 1,
To = 0,
Duration = new Duration(TimeSpan.FromSeconds(0.5))
};
Storyboard.SetTarget(fadeOutAnimation, fromElement);
Storyboard.SetTargetProperty(fadeOutAnimation, "Opacity");
storyboard.Children.Add(fadeOutAnimation);
storyboard.Completed += (a, b) =>
{
fromElement.Visibility = Visibility.Collapsed;
toElement.Visibility = Visibility.Visible;
// 淡入动画
var storyboard1 = new Storyboard();
var fadeInAnimation = new DoubleAnimation
{
From = 0,
To = 1,
Duration = new Duration(TimeSpan.FromSeconds(0.5))
};
Storyboard.SetTarget(fadeInAnimation, toElement);
Storyboard.SetTargetProperty(fadeInAnimation, "Opacity");
storyboard1.Children.Add(fadeInAnimation);
storyboard1.Begin();
};
return storyboard;
}
private void login_Click(object sender, RoutedEventArgs e)
{
}
}

View File

@ -1,18 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using RustTools.Styles;
namespace RustTools.Themes; namespace RustTools.Themes;
public sealed partial class NullPage : UserControl public sealed partial class NullPage : UserControl
{ {
public NullPage() public NullPage()
{ {
this.InitializeComponent();
DefaultStyleKey = typeof(NullPage); DefaultStyleKey = typeof(NullPage);
} }
} }

View File

@ -0,0 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace RustTools.ViewModels
{
public class ButtonViewModel : ObservableObject
{
}
}

View File

@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json; using Newtonsoft.Json;
using RustTools.DataList; using RustTools.DataList;
using RustTools.muqing; using RustTools.muqing;
using Windows.System;
namespace RustTools.ViewModels; namespace RustTools.ViewModels;
@ -79,7 +78,7 @@ public partial class ConcernViewModel : ObservableRecipient
foreach (var item in response.data) foreach (var item in response.data)
{ {
//item.UserName //item.UserName
item.HeadIcon= item.HeadIcon.Replace("..", wl.api); item.HeadIcon = item.HeadIcon.Replace("..", wl.api);
communitylist.Add(item); communitylist.Add(item);
} }

View File

@ -1,8 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml.Media.Imaging;
using Newtonsoft.Json; using Newtonsoft.Json;
using RustTools.muqing;
namespace RustTools.ViewModels; namespace RustTools.ViewModels;
@ -39,7 +37,7 @@ public partial class HomePageViewModel : ObservableRecipient
public async void Latest() public async void Latest()
{ {
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(await ApiFox.mod.list(ApiFox.mod.latestTime,"6","")); var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(await ApiFox.mod.list(ApiFox.mod.latestTime, "6", ""));
if (modListResponse != null) if (modListResponse != null)
{ {
latestTimeList.Clear(); latestTimeList.Clear();

View File

@ -1,9 +1,4 @@
using System; using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
@ -14,7 +9,7 @@ namespace RustTools.ViewModels;
/// <summary> /// <summary>
/// 模组界面配置 /// 模组界面配置
/// </summary> /// </summary>
public class ModuleViewModel : ObservableRecipient public class ModuleViewModel : ObservableRecipient
{ {
public ObservableCollection<DataObject> ListMod = new(); public ObservableCollection<DataObject> ListMod = new();
@ -75,10 +70,10 @@ public class ModuleViewModel : ObservableRecipient
} }
// 压缩zip // 压缩zip
var v = wj.ZipExample(folderItem.Dri, folderItem.Name + ".rwmod"); var v = wj.ZipExample(folderItem.Dri, folderItem.Name + ".rwmod");
if (v!=string.Empty) if (v != string.Empty)
{ {
ListMod.Remove(new DataObject(new FileInfo(filepath))); ListMod.Remove(new DataObject(new FileInfo(filepath)));
ListMod.Insert(0,new DataObject(new FileInfo(v))); ListMod.Insert(0, new DataObject(new FileInfo(v)));
} }
} }
} }

View File

@ -1,8 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Net.Http.Json;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json; using Newtonsoft.Json;
using RustTools.muqing;
namespace RustTools.ViewModels; namespace RustTools.ViewModels;

View File

@ -10,10 +10,6 @@ using RustTools.Contracts.Services;
using RustTools.Helpers; using RustTools.Helpers;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.Storage;
using RustTools.muqing;
namespace RustTools.ViewModels; namespace RustTools.ViewModels;

View File

@ -1,20 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.muqing; using RustTools.muqing;
using RustTools.ViewModels; using RustTools.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure, // To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info. // and more about our project templates, see: http://aka.ms/winui-project-info.
@ -26,7 +13,10 @@ namespace RustTools.Views;
/// </summary> /// </summary>
public sealed partial class ConcernPage : Page public sealed partial class ConcernPage : Page
{ {
public ConcernViewModel ViewModels { get; set; } public ConcernViewModel ViewModels
{
get; set;
}
public ConcernPage() public ConcernPage()
{ {
ViewModels = App.GetService<ConcernViewModel>(); ViewModels = App.GetService<ConcernViewModel>();

View File

@ -1,11 +1,11 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Newtonsoft.Json; using Newtonsoft.Json;
using RustTools.DataList; using RustTools.DataList;
using RustTools.ViewModels; using RustTools.ViewModels;
using System.Text.RegularExpressions;
using RustTools.WindowUI; using RustTools.WindowUI;
namespace RustTools.Views; namespace RustTools.Views;
public sealed partial class HomePage : Page public sealed partial class HomePage : Page
@ -75,7 +75,7 @@ public sealed partial class HomePage : Page
} }
} }
private void RefreshRandom(object sender,RoutedEventArgs e) private void RefreshRandom(object sender, RoutedEventArgs e)
{ {
ViewModel.random(); ViewModel.random();
} }

View File

@ -1,15 +1,9 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media;
using RustTools.muqing; using RustTools.muqing;
using RustTools.ViewModels; using RustTools.ViewModels;
using static IniHelper;
using static System.Collections.Specialized.BitVector32;
namespace RustTools.Views; namespace RustTools.Views;
/// <summary> /// <summary>
/// 模组碎片 /// 模组碎片
@ -69,7 +63,7 @@ public class DataObject
if (dictionary.TryGetValue("mod", out var sectionValues)) if (dictionary.TryGetValue("mod", out var sectionValues))
{ {
gj.sc(sectionValues); gj.sc(sectionValues);
Name =sectionValues.TryGetValue("title", out var value) ? value : Name; Name = sectionValues.TryGetValue("title", out var value) ? value : Name;
gj.sc(value); gj.sc(value);
Info = sectionValues.TryGetValue("description", out var description) ? description : Info; Info = sectionValues.TryGetValue("description", out var description) ? description : Info;
} }

View File

@ -1,21 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels; using RustTools.ViewModels;
using Newtonsoft.Json;
using RustTools.muqing;
using System.Collections;
// To learn more about WinUI, the WinUI project structure, // To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info. // and more about our project templates, see: http://aka.ms/winui-project-info.
@ -33,9 +18,9 @@ public sealed partial class RankingPage : Page
public RankingPage() public RankingPage()
{ {
ViewModel=App.GetService<RankingViewModel>(); ViewModel = App.GetService<RankingViewModel>();
InitializeComponent(); InitializeComponent();
list.ItemClick +=HomePage.ListAClick; list.ItemClick += HomePage.ListAClick;
} }
@ -51,7 +36,7 @@ public sealed partial class RankingPage : Page
var menu = (MenuFlyoutItem)sender; var menu = (MenuFlyoutItem)sender;
if (menu != null && menu.Tag != null) if (menu != null && menu.Tag != null)
{ {
var tag =(string) menu.Tag; var tag = (string)menu.Tag;
ViewModel.ListTab(tag); ViewModel.ListTab(tag);
} }
} }

View File

@ -54,7 +54,7 @@ public sealed partial class SettingsPage : Page
private async void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e) private async void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (Backone) if (Backone)
{ {
if (App.MainWindow != null && sender is RadioButtons rb) if (App.MainWindow != null && sender is RadioButtons rb)
{ {
var colorName = rb.SelectedItem as string; var colorName = rb.SelectedItem as string;
@ -70,7 +70,7 @@ public sealed partial class SettingsPage : Page
{ {
Backone = true; Backone = true;
} }
} }
private async void AutoSuggestBox_Url(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) private async void AutoSuggestBox_Url(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{ {
@ -90,11 +90,12 @@ public sealed partial class SettingsPage : Page
await dialog.ShowAsync(); await dialog.ShowAsync();
} }
private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){ private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
sender.Hide(); sender.Hide();
var mod = new Mod(XamlRoot, (FileDri) => var mod = new Mod(XamlRoot, (FileDri) =>
{ {
gj.sc("找到了QWQ"+FileDri); gj.sc("找到了QWQ" + FileDri);
var a = Path.Combine(FileDri, "mods\\units"); var a = Path.Combine(FileDri, "mods\\units");
ModFileUrlText.Text = a; ModFileUrlText.Text = a;
var b = Path.Combine(FileDri, "mods\\maps"); var b = Path.Combine(FileDri, "mods\\maps");
@ -103,7 +104,8 @@ public sealed partial class SettingsPage : Page
}); });
} }
private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){ private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var openPicker = new FolderPicker(); var openPicker = new FolderPicker();
var window = App.MainWindow; var window = App.MainWindow;
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window); var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
@ -125,7 +127,7 @@ public sealed partial class SettingsPage : Page
private async void SaveModAndMaps() private async void SaveModAndMaps()
{ {
var iniHelper = new IniHelper(); var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config); iniHelper.Load(IniHelper.FILE.Config);
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, MapsFileUrlText.Text); iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, MapsFileUrlText.Text);
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, ModFileUrlText.Text); iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, ModFileUrlText.Text);
iniHelper.Save(); iniHelper.Save();
@ -133,37 +135,38 @@ public sealed partial class SettingsPage : Page
private async void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e) private async void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
{ {
var a=(AutoSuggestBox) sender; var a = (AutoSuggestBox)sender;
var iniHelper = new IniHelper(); var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config); iniHelper.Load(IniHelper.FILE.Config);
if (a.Name.Equals("MapsFileUrlText")) if (a.Name.Equals("MapsFileUrlText"))
{ {
var Url = MapsFileUrlText.Text; var Url = MapsFileUrlText.Text;
if (!Directory.Exists(Url)&&Url!=string.Empty) { if (!Directory.Exists(Url) && Url != string.Empty)
{
Url = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl); Url = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl);
MapsFileUrlText.Text= Url; MapsFileUrlText.Text = Url;
} }
if (Url != string.Empty) if (Url != string.Empty)
{ {
Url = Path.GetFullPath(Url); Url = Path.GetFullPath(Url);
} }
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl,Url); iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, Url);
MapsFileUrlText.Text = Url; MapsFileUrlText.Text = Url;
} }
else if(a.Name.Equals("ModFileUrlText")) else if (a.Name.Equals("ModFileUrlText"))
{ {
var Url = ModFileUrlText.Text; var Url = ModFileUrlText.Text;
if (!Directory.Exists(Url)&&Url!=string.Empty) if (!Directory.Exists(Url) && Url != string.Empty)
{ {
Url=iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl); Url = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
ModFileUrlText.Text = Url; ModFileUrlText.Text = Url;
} }
if (Url != string.Empty) if (Url != string.Empty)
{ {
Url = Path.GetFullPath(Url); Url = Path.GetFullPath(Url);
} }
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl,Url); iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, Url);
ModFileUrlText.Text = Url; ModFileUrlText.Text = Url;
} }
// 获取 AutoSuggestBox 的当前文本 // 获取 AutoSuggestBox 的当前文本
iniHelper.Save(); iniHelper.Save();

View File

@ -1,11 +1,9 @@
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using RustTools.Contracts.Services; using RustTools.Contracts.Services;
using RustTools.Helpers; using RustTools.Helpers;
using RustTools.muqing;
using RustTools.ViewModels; using RustTools.ViewModels;
using Windows.System; using Windows.System;
@ -22,13 +20,13 @@ public sealed partial class ShellPage : Page
public ShellPage(ShellViewModel viewModel) public ShellPage(ShellViewModel viewModel)
{ {
//< NavigationViewItem //< NavigationViewItem
// x: Uid = "Shell_Main" // x: Uid = "Shell_Main"
// helpers: NavigationHelper.NavigateTo = "RustTools.ViewModels.MainViewModel"> // helpers: NavigationHelper.NavigateTo = "RustTools.ViewModels.MainViewModel">
// < NavigationViewItem.Icon > // < NavigationViewItem.Icon >
// < FontIcon FontFamily = "{StaticResource SymbolThemeFontFamily}" Glyph = "&#xe7c3;" /> // < FontIcon FontFamily = "{StaticResource SymbolThemeFontFamily}" Glyph = "&#xe7c3;" />
// </ NavigationViewItem.Icon > // </ NavigationViewItem.Icon >
//</ NavigationViewItem > //</ NavigationViewItem >
ViewModel = viewModel; ViewModel = viewModel;
InitializeComponent(); InitializeComponent();
@ -43,7 +41,7 @@ public sealed partial class ShellPage : Page
App.MainWindow.SetTitleBar(AppTitleBar); App.MainWindow.SetTitleBar(AppTitleBar);
App.MainWindow.Activated += MainWindow_Activated; App.MainWindow.Activated += MainWindow_Activated;
App.MainWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico")); App.MainWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
AppTitleBarText.Text = "app_name".GetLocalized() +" " +"app_version".GetLocalized(); AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized();
} }
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)

View File

@ -7,51 +7,12 @@
xmlns:local="using:RustTools.Views" xmlns:local="using:RustTools.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:styles="using:RustTools.Styles" xmlns:styles="using:RustTools.Styles"
xmlns:themes="using:RustTools.Themes"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<Grid <themes:LoginPage x:Name="loginpage" />
MinWidth="350"
Margin="16"
HorizontalAlignment="Center">
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="登陆" />
<StackPanel>
<TextBox
Margin="0,16,0,16"
InputScope="AlphanumericPin"
PlaceholderText="账号" />
<PasswordBox Margin="0,0,0,16" PlaceholderText="密码" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Width="100"
Margin="16"
Content="登陆"
Style="{StaticResource AccentButtonStyle}" />
<Button Margin="0,0,0,0" Content="注册" />
</StackPanel>
<CheckBox>
<CheckBox.Content>
<StackPanel Orientation="Horizontal" ToolTipService.ToolTip="虽然没什么用但是这是常规的">
<TextBlock VerticalAlignment="Center" Text="我同意" />
<HyperlinkButton
x:Name="hlbTerms"
Content="《服务协议》"
NavigateUri="https://rust.coldmint.top/resources/agreement/service_agreement.html" />
<TextBlock VerticalAlignment="Center" Text="与" />
<HyperlinkButton
x:Name="hlbPrivacy"
Content="《隐私政策》"
NavigateUri="https://rust.coldmint.top/resources/agreement/privacy_policy.html" />
</StackPanel>
</CheckBox.Content>
</CheckBox>
</StackPanel>
</Grid>
<Grid Name="gridview" Visibility="Collapsed"> <Grid Name="gridview" Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="110" /> <RowDefinition Height="110" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />

View File

@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels; using RustTools.ViewModels;
// To learn more about WinUI, the WinUI project structure, // To learn more about WinUI, the WinUI project structure,
@ -24,10 +11,13 @@ namespace RustTools.Views;
/// </summary> /// </summary>
public sealed partial class UserPage : Page public sealed partial class UserPage : Page
{ {
public UserViewModel UserViewModel { get; set; } public UserViewModel UserViewModel
{
get; set;
}
public UserPage() public UserPage()
{ {
UserViewModel=App.GetService<UserViewModel>(); UserViewModel = App.GetService<UserViewModel>();
InitializeComponent(); InitializeComponent();
} }
} }

View File

@ -1,7 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using RustTools.muqing; using RustTools.muqing;
@ -10,33 +9,34 @@ namespace RustTools.WindowUI;
public sealed partial class ImportModule : WindowEx public sealed partial class ImportModule : WindowEx
{ {
private readonly FileInfo? fileInfo; private readonly FileInfo? fileInfo;
private string ImpUrl= string.Empty; private string ImpUrl = string.Empty;
public ImportModule(string file) public ImportModule(string file)
{ {
InitializeComponent(); InitializeComponent();
ExtendsContentIntoTitleBar = true; ExtendsContentIntoTitleBar = true;
if (file == string.Empty) { if (file == string.Empty)
{
Close(); Close();
return; return;
} }
fileInfo = new FileInfo(file); fileInfo = new FileInfo(file);
var iniHelper = new IniHelper(); var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config); iniHelper.Load(IniHelper.FILE.Config);
if (file.EndsWith(".rwmod")) if (file.EndsWith(".rwmod"))
{ {
var l = " | "; var l = " | ";
var formattedSize = wj.FormatFileSize(fileInfo.Length); var formattedSize = wj.FormatFileSize(fileInfo.Length);
MessageText.Text = "类型:模组" + l + "大小" + formattedSize; MessageText.Text = "类型:模组" + l + "大小" + formattedSize;
ImpUrl = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl); ImpUrl = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
InfoText.Text = string.Format("原位置 {0} --> {1} \n在处理的时候请不要关闭此窗口 导成功后会自动关闭 失败则会提示权限等错误问题", InfoText.Text = string.Format("原位置 {0} --> {1} \n在处理的时候请不要关闭此窗口 导成功后会自动关闭 失败则会提示权限等错误问题",
file, ImpUrl); file, ImpUrl);
} }
NameText.Text = NameText.Text =
fileInfo.Name; fileInfo.Name;
GridView.Loaded += GridView_Loaded; GridView.Loaded += GridView_Loaded;
// 添加 Loaded 事件处理程序 // 添加 Loaded 事件处理程序
} }
private void GridView_Loaded(object sender, RoutedEventArgs e) private void GridView_Loaded(object sender, RoutedEventArgs e)
@ -89,10 +89,10 @@ public sealed partial class ImportModule : WindowEx
{ {
return; return;
} }
var button=sender as Button; var button = sender as Button;
if (button == null) { return; } if (button == null) { return; }
button.IsEnabled=false; button.IsEnabled = false;
gj.sc(fileInfo.ToString()); gj.sc(fileInfo.ToString());
// 确保目标文件夹存在 // 确保目标文件夹存在
@ -100,7 +100,7 @@ public sealed partial class ImportModule : WindowEx
var destinationZipPath = Path.Combine(ImpUrl, fileInfo.Name); var destinationZipPath = Path.Combine(ImpUrl, fileInfo.Name);
await CopyFileWithProgressAsync( fileInfo.ToString() ,destinationZipPath, (percentage) => await CopyFileWithProgressAsync(fileInfo.ToString(), destinationZipPath, (percentage) =>
{ {
button.Content = $"{percentage:F2}%"; button.Content = $"{percentage:F2}%";
Debug.WriteLine($"复制进度: {percentage:F2}%"); Debug.WriteLine($"复制进度: {percentage:F2}%");

View File

@ -1,16 +1,11 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using RustTools.muqing;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.ObjectModel; using RustTools.muqing;
using Windows.ApplicationModel.Core;
using System.Diagnostics;
using Windows.UI.ViewManagement;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI;
using static RustTools.muqing.wl; using static RustTools.muqing.wl;
using System.Threading;
// To learn more about WinUI, the WinUI project structure, // To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info. // and more about our project templates, see: http://aka.ms/winui-project-info.
@ -124,13 +119,13 @@ public sealed partial class ModuleInfoWin : WindowEx
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl); var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
if (v == string.Empty) if (v == string.Empty)
{ {
var dialog=new ContentDialog() var dialog = new ContentDialog()
{ {
XamlRoot = grid.XamlRoot, XamlRoot = grid.XamlRoot,
Title="警告", Title = "警告",
Content="请在设置中配置好模组路径再来", Content = "请在设置中配置好模组路径再来",
SecondaryButtonText="取消" SecondaryButtonText = "取消"
}; };
await dialog.ShowAsync(); await dialog.ShowAsync();
return; return;
@ -156,7 +151,7 @@ public sealed partial class ModuleInfoWin : WindowEx
File.Delete(PathMod + ".rwmod"); File.Delete(PathMod + ".rwmod");
} }
//下载链接 保存文件的本地路径 //下载链接 保存文件的本地路径
await downloader.DownloadFileAsync(Mod.Link,PathMod, (totalBytesRead, totalBytes) => await downloader.DownloadFileAsync(Mod.Link, PathMod, (totalBytesRead, totalBytes) =>
{ {
DownloadDialogText.Text = $"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete."; DownloadDialogText.Text = $"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.";
//Debug.WriteLine($"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete."); //Debug.WriteLine($"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.");

View File

@ -1,8 +1,4 @@
using System; using Windows.Storage;
using System.Collections.Generic;
using System.IO;
using RustTools.muqing;
using Windows.Storage;
public class IniHelper public class IniHelper
{ {
@ -107,7 +103,8 @@ public class IniHelper
/// </summary> /// </summary>
public void Save() public void Save()
{ {
if (filePath==null||filePath==string.Empty) { if (filePath == null || filePath == string.Empty)
{
return; return;
} }

View File

@ -2,17 +2,14 @@
using System.Diagnostics; using System.Diagnostics;
namespace RustTools.muqing; namespace RustTools.muqing;
using System; using System;
using System.Diagnostics.Tracing;
using System.Management; using System.Management;
using System.Runtime.InteropServices;
using Microsoft.UI; using Microsoft.UI;
using Microsoft.UI.Composition.SystemBackdrops; using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media;
using Windows.UI.ViewManagement;
using System.Runtime.InteropServices;
using Windows.UI; using Windows.UI;
using System.Text.RegularExpressions; using Windows.UI.ViewManagement;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
#pragma warning disable IDE1006 // 命名样式 #pragma warning disable IDE1006 // 命名样式
@ -89,7 +86,7 @@ public class gj
private const int WAINACTIVE = 0x00; private const int WAINACTIVE = 0x00;
private const int WAACTIVE = 0x01; private const int WAACTIVE = 0x01;
private const int WMACTIVATE = 0x0006; private const int WMACTIVATE = 0x0006;
public static void UpdateTitleBar(WindowEx a,ElementTheme theme) public static void UpdateTitleBar(WindowEx a, ElementTheme theme)
{ {
if (a.ExtendsContentIntoTitleBar) if (a.ExtendsContentIntoTitleBar)
{ {
@ -166,8 +163,8 @@ public class gj
/// <returns></returns> /// <returns></returns>
public static Dictionary<string, Dictionary<string, string>> IniInfo(string filePath) public static Dictionary<string, Dictionary<string, string>> IniInfo(string filePath)
{ {
var sections=new Dictionary<string, Dictionary<string, string>>(); var sections = new Dictionary<string, Dictionary<string, string>>();
using (var reader = new StreamReader(filePath)) using (var reader = new StreamReader(filePath))
{ {
string? line; string? line;

View File

@ -1,16 +1,11 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection.Emit; using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.Win32; using Microsoft.Win32;
using Newtonsoft.Json.Linq;
using RustTools.muqing; using RustTools.muqing;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Microsoft.UI.Dispatching;
public class Mod public class Mod
{ {
@ -36,8 +31,8 @@ public class Mod
"androidstudioword","鸿图对战平台","xshell7" "androidstudioword","鸿图对战平台","xshell7"
}; };
//游戏位置 //游戏位置
public string FileDir =string.Empty; public string FileDir = string.Empty;
private readonly ContentDialog? dialog =null; private readonly ContentDialog? dialog = null;
//在MainPage的后台code里面添加这个申明 //在MainPage的后台code里面添加这个申明
public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal) public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal)
{ {
@ -57,7 +52,8 @@ public class Mod
Debug.WriteLine("开始执行文件搜索引擎"); Debug.WriteLine("开始执行文件搜索引擎");
//先找steam中的位置 //先找steam中的位置
steam(); steam();
if (FileDir == string.Empty) { if (FileDir == string.Empty)
{
//找不到执行搜索引擎 //找不到执行搜索引擎
gj.sc("找不到执行搜索引擎"); gj.sc("找不到执行搜索引擎");
dialog = new ContentDialog() dialog = new ContentDialog()
@ -75,7 +71,8 @@ public class Mod
await init(); await init();
// 使用 DispatcherQueue 将 UI 更新委托回 UI 线程 // 使用 DispatcherQueue 将 UI 更新委托回 UI 线程
_dispatcherQueue.TryEnqueue(() => { _dispatcherQueue.TryEnqueue(() =>
{
dialog.Closing -= Dialog_Closing; dialog.Closing -= Dialog_Closing;
dialog.Hide(); dialog.Hide();
action?.Invoke(FileDir); action?.Invoke(FileDir);
@ -100,7 +97,8 @@ public class Mod
} }
private void Dialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args){ private void Dialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
gj.sc(args.Result); gj.sc(args.Result);
if (args.Result != ContentDialogResult.Primary) if (args.Result != ContentDialogResult.Primary)
{ {

View File

@ -1,9 +1,5 @@
using System; using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Compression; using System.IO.Compression;
using Windows.Storage;
using Windows.Storage.Streams;
namespace RustTools.muqing; namespace RustTools.muqing;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
@ -26,17 +22,18 @@ public class wj
public const string UUID = "win.uuid"; public const string UUID = "win.uuid";
} }
public static bool xrwb(string name,string str) public static bool xrwb(string name, string str)
{ {
// 获取当前执行文件的目录 // 获取当前执行文件的目录
//var currentDirectory = Directory.GetCurrentDirectory(); //var currentDirectory = Directory.GetCurrentDirectory();
var filePath = Path.Combine(CD,name); var filePath = Path.Combine(CD, name);
try try
{ {
File.WriteAllText(filePath, str); File.WriteAllText(filePath, str);
return true; return true;
} }
catch (Exception ex) { catch (Exception ex)
{
Debug.WriteLine(ex.ToString()); Debug.WriteLine(ex.ToString());
} }
// 将 UUID 写入文件 // 将 UUID 写入文件
@ -51,7 +48,7 @@ public class wj
public static bool cz(string name) public static bool cz(string name)
{ {
return File.Exists(Path.Combine(CD,name)); return File.Exists(Path.Combine(CD, name));
} }
public static string FormatFileSize(long bytes) public static string FormatFileSize(long bytes)

View File

@ -1,6 +1,4 @@
using System.Text.RegularExpressions; using RestSharp;
using System.Threading;
using RestSharp;
namespace RustTools.muqing; namespace RustTools.muqing;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
@ -63,7 +61,7 @@ class wl
public class FileDownloader public class FileDownloader
{ {
private readonly HttpClient _httpClient=new(); private readonly HttpClient _httpClient = new();
private bool IsDelete = false; private bool IsDelete = false;
public FileDownloader() public FileDownloader()
{ {
@ -91,7 +89,7 @@ class wl
//if (IsDelete) { //if (IsDelete) {
// break; // break;
//} //}
await fileStream.WriteAsync(buffer, 0, bytesRead,cancellationToken); await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationToken);
totalBytesRead += bytesRead; totalBytesRead += bytesRead;
progress?.Invoke(totalBytesRead, totalBytes); progress?.Invoke(totalBytesRead, totalBytes);
} }