加入登陆的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 System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RustTools.muqing;
using RustTools.muqing;
namespace RustTools.ApiFox;

View File

@ -2,17 +2,16 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using RustTools.Activation;
using RustTools.Contracts.Services;
using RustTools.Models;
using RustTools.muqing;
using RustTools.Services;
using RustTools.ViewModels;
using RustTools.Views;
using RustTools.muqing;
using RustTools.Activation;
using RustTools.WindowUI;
using Windows.ApplicationModel.Activation;
using Microsoft.Windows.AppLifecycle;
using WinUIEx;
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 App()
@ -123,7 +125,7 @@ public partial class App : Microsoft.UI.Xaml.Application
if (storageFile != null)
{
gj.sc(storageFile.Path);
var importModule=new ImportModule(storageFile.Path);
var importModule = new ImportModule(storageFile.Path);
importModule.Activate();
// 读取或处理文件内容
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,4 @@
using System;
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;
using System.Collections.ObjectModel;
namespace RustTools.Editor;
public class EditorLoad
@ -67,7 +59,8 @@ public class EditorLoad
// Type = ExplorerItem.ExplorerItemType.Folder,
//};
//LoadDirectory(directoryInfos,rootItem);
foreach (var file in directoryInfos.GetDirectories()) {
foreach (var file in directoryInfos.GetDirectories())
{
var explorerItem = new ExplorerItem()
{
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.Controls;
using Microsoft.UI.Xaml.Input;
using RustTools.muqing;
using Windows.ApplicationModel.DataTransfer;
using Microsoft.UI.Xaml.Input;
using Windows.Storage;
using RustTools.Helpers;
using Microsoft.UI.Xaml.Media;
using Windows.Foundation;
using System.Diagnostics;
namespace RustTools.Editor;
public class EditorTreeView: TreeView
public class EditorTreeView : TreeView
{
public EditorTreeView()
{
@ -34,7 +31,8 @@ public class EditorTreeView: TreeView
e.Data.SetData("path", firstItem.Dir);
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();
@ -115,8 +113,8 @@ public class EditorTreeView: TreeView
// 获取目标文件夹,即拖放的位置
// 获取目标位置
var treeView = sender as TreeView;
// 获取目标位置
var treeView = sender as TreeView;
var data = await e.DataView.GetDataAsync("path");
gj.sc(data);
@ -125,7 +123,7 @@ public class EditorTreeView: TreeView
if (item is StorageFolder folder)
{
// 移动文件夹
gj.sc(folder.Path+"-->");
gj.sc(folder.Path + "-->");
//var newFolder = await folder.MoveAsync(targetFolder, folder.Name, NameCollisionOption.ReplaceExisting);
}
else if (item is StorageFile file)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,5 @@
using Microsoft.UI.Xaml;
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;
public sealed class TitleSubtitleControl : Control
@ -24,16 +11,9 @@ public sealed class TitleSubtitleControl : Control
public string TitleText
{
get
{
return (string)GetValue(TitleTextProperty);
}
set
{
SetValue(TitleTextProperty, value);
}
get => (string)GetValue(TitleTextProperty);
set => SetValue(TitleTextProperty, value);
}
public static readonly DependencyProperty TitleTextProperty =
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.Primitives;
using RustTools.Styles;
namespace RustTools.Themes;
public sealed partial class NullPage : UserControl
{
public NullPage()
{
this.InitializeComponent();
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 RustTools.DataList;
using RustTools.muqing;
using Windows.System;
namespace RustTools.ViewModels;
@ -79,7 +78,7 @@ public partial class ConcernViewModel : ObservableRecipient
foreach (var item in response.data)
{
//item.UserName
item.HeadIcon= item.HeadIcon.Replace("..", wl.api);
item.HeadIcon = item.HeadIcon.Replace("..", wl.api);
communitylist.Add(item);
}

View File

@ -1,8 +1,6 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml.Media.Imaging;
using Newtonsoft.Json;
using RustTools.muqing;
namespace RustTools.ViewModels;
@ -39,7 +37,7 @@ public partial class HomePageViewModel : ObservableRecipient
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)
{
latestTimeList.Clear();

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
@ -14,7 +9,7 @@ namespace RustTools.ViewModels;
/// <summary>
/// 模组界面配置
/// </summary>
public class ModuleViewModel : ObservableRecipient
public class ModuleViewModel : ObservableRecipient
{
public ObservableCollection<DataObject> ListMod = new();
@ -75,10 +70,10 @@ public class ModuleViewModel : ObservableRecipient
}
// 压缩zip
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.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.Net.Http.Json;
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
using RustTools.muqing;
namespace RustTools.ViewModels;

View File

@ -10,10 +10,6 @@ using RustTools.Contracts.Services;
using RustTools.Helpers;
using Windows.ApplicationModel;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.Storage;
using RustTools.muqing;
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.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.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@ -26,7 +13,10 @@ namespace RustTools.Views;
/// </summary>
public sealed partial class ConcernPage : Page
{
public ConcernViewModel ViewModels { get; set; }
public ConcernViewModel ViewModels
{
get; set;
}
public ConcernPage()
{
ViewModels = App.GetService<ConcernViewModel>();

View File

@ -1,11 +1,11 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Newtonsoft.Json;
using RustTools.DataList;
using RustTools.ViewModels;
using System.Text.RegularExpressions;
using RustTools.WindowUI;
namespace RustTools.Views;
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();
}

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.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Media;
using RustTools.muqing;
using RustTools.ViewModels;
using static IniHelper;
using static System.Collections.Specialized.BitVector32;
namespace RustTools.Views;
/// <summary>
/// 模组碎片
@ -69,7 +63,7 @@ public class DataObject
if (dictionary.TryGetValue("mod", out var 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);
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.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 Newtonsoft.Json;
using RustTools.muqing;
using System.Collections;
// To learn more about WinUI, the WinUI project structure,
// 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()
{
ViewModel=App.GetService<RankingViewModel>();
ViewModel = App.GetService<RankingViewModel>();
InitializeComponent();
list.ItemClick +=HomePage.ListAClick;
list.ItemClick += HomePage.ListAClick;
}
@ -51,7 +36,7 @@ public sealed partial class RankingPage : Page
var menu = (MenuFlyoutItem)sender;
if (menu != null && menu.Tag != null)
{
var tag =(string) menu.Tag;
var tag = (string)menu.Tag;
ViewModel.ListTab(tag);
}
}

View File

@ -90,11 +90,12 @@ public sealed partial class SettingsPage : Page
await dialog.ShowAsync();
}
private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
sender.Hide();
var mod = new Mod(XamlRoot, (FileDri) =>
{
gj.sc("找到了QWQ"+FileDri);
gj.sc("找到了QWQ" + FileDri);
var a = Path.Combine(FileDri, "mods\\units");
ModFileUrlText.Text = a;
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 window = App.MainWindow;
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
@ -125,7 +127,7 @@ public sealed partial class SettingsPage : Page
private async void SaveModAndMaps()
{
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.ModFileUrl, ModFileUrlText.Text);
iniHelper.Save();
@ -133,37 +135,38 @@ public sealed partial class SettingsPage : Page
private async void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
{
var a=(AutoSuggestBox) sender;
var a = (AutoSuggestBox)sender;
var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config);
iniHelper.Load(IniHelper.FILE.Config);
if (a.Name.Equals("MapsFileUrlText"))
{
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);
MapsFileUrlText.Text= Url;
MapsFileUrlText.Text = Url;
}
if (Url != string.Empty)
{
Url = Path.GetFullPath(Url);
}
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl,Url);
MapsFileUrlText.Text = Url;
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, Url);
MapsFileUrlText.Text = Url;
}
else if(a.Name.Equals("ModFileUrlText"))
else if (a.Name.Equals("ModFileUrlText"))
{
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;
}
if (Url != string.Empty)
{
Url = Path.GetFullPath(Url);
}
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl,Url);
ModFileUrlText.Text = Url;
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, Url);
ModFileUrlText.Text = Url;
}
// 获取 AutoSuggestBox 的当前文本
iniHelper.Save();

View File

@ -1,11 +1,9 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using RustTools.Contracts.Services;
using RustTools.Helpers;
using RustTools.muqing;
using RustTools.ViewModels;
using Windows.System;
@ -22,13 +20,13 @@ public sealed partial class ShellPage : Page
public ShellPage(ShellViewModel viewModel)
{
//< NavigationViewItem
// x: Uid = "Shell_Main"
// helpers: NavigationHelper.NavigateTo = "RustTools.ViewModels.MainViewModel">
// < NavigationViewItem.Icon >
// < FontIcon FontFamily = "{StaticResource SymbolThemeFontFamily}" Glyph = "&#xe7c3;" />
// </ NavigationViewItem.Icon >
//</ NavigationViewItem >
//< NavigationViewItem
// x: Uid = "Shell_Main"
// helpers: NavigationHelper.NavigateTo = "RustTools.ViewModels.MainViewModel">
// < NavigationViewItem.Icon >
// < FontIcon FontFamily = "{StaticResource SymbolThemeFontFamily}" Glyph = "&#xe7c3;" />
// </ NavigationViewItem.Icon >
//</ NavigationViewItem >
ViewModel = viewModel;
InitializeComponent();
@ -43,7 +41,7 @@ public sealed partial class ShellPage : Page
App.MainWindow.SetTitleBar(AppTitleBar);
App.MainWindow.Activated += MainWindow_Activated;
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)

View File

@ -7,51 +7,12 @@
xmlns:local="using:RustTools.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:styles="using:RustTools.Styles"
xmlns:themes="using:RustTools.Themes"
mc:Ignorable="d">
<Grid>
<Grid
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>
<themes:LoginPage x:Name="loginpage" />
<Grid Name="gridview" Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="110" />
<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.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels;
// To learn more about WinUI, the WinUI project structure,
@ -24,10 +11,13 @@ namespace RustTools.Views;
/// </summary>
public sealed partial class UserPage : Page
{
public UserViewModel UserViewModel { get; set; }
public UserViewModel UserViewModel
{
get; set;
}
public UserPage()
{
UserViewModel=App.GetService<UserViewModel>();
UserViewModel = App.GetService<UserViewModel>();
InitializeComponent();
}
}

View File

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.IO;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using RustTools.muqing;
@ -10,33 +9,34 @@ namespace RustTools.WindowUI;
public sealed partial class ImportModule : WindowEx
{
private readonly FileInfo? fileInfo;
private string ImpUrl= string.Empty;
private string ImpUrl = string.Empty;
public ImportModule(string file)
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
if (file == string.Empty) {
if (file == string.Empty)
{
Close();
return;
}
fileInfo = new FileInfo(file);
var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config);
if (file.EndsWith(".rwmod"))
{
var l = " | ";
var formattedSize = wj.FormatFileSize(fileInfo.Length);
MessageText.Text = "类型:模组" + l + "大小" + formattedSize;
ImpUrl = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
InfoText.Text = string.Format("原位置 {0} --> {1} \n在处理的时候请不要关闭此窗口 导成功后会自动关闭 失败则会提示权限等错误问题",
file, ImpUrl);
}
NameText.Text =
fileInfo.Name;
iniHelper.Load(IniHelper.FILE.Config);
if (file.EndsWith(".rwmod"))
{
var l = " | ";
var formattedSize = wj.FormatFileSize(fileInfo.Length);
MessageText.Text = "类型:模组" + l + "大小" + formattedSize;
ImpUrl = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
InfoText.Text = string.Format("原位置 {0} --> {1} \n在处理的时候请不要关闭此窗口 导成功后会自动关闭 失败则会提示权限等错误问题",
file, ImpUrl);
}
NameText.Text =
fileInfo.Name;
GridView.Loaded += GridView_Loaded;
// 添加 Loaded 事件处理程序
GridView.Loaded += GridView_Loaded;
// 添加 Loaded 事件处理程序
}
private void GridView_Loaded(object sender, RoutedEventArgs e)
@ -89,10 +89,10 @@ public sealed partial class ImportModule : WindowEx
{
return;
}
var button=sender as Button;
var button = sender as Button;
if (button == null) { return; }
button.IsEnabled=false;
button.IsEnabled = false;
gj.sc(fileInfo.ToString());
// 确保目标文件夹存在
@ -100,7 +100,7 @@ public sealed partial class ImportModule : WindowEx
var destinationZipPath = Path.Combine(ImpUrl, fileInfo.Name);
await CopyFileWithProgressAsync( fileInfo.ToString() ,destinationZipPath, (percentage) =>
await CopyFileWithProgressAsync(fileInfo.ToString(), destinationZipPath, (percentage) =>
{
button.Content = $"{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.Controls;
using RustTools.muqing;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using Windows.ApplicationModel.Core;
using System.Diagnostics;
using Windows.UI.ViewManagement;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI;
using RustTools.muqing;
using static RustTools.muqing.wl;
using System.Threading;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@ -124,12 +119,12 @@ public sealed partial class ModuleInfoWin : WindowEx
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
if (v == string.Empty)
{
var dialog=new ContentDialog()
var dialog = new ContentDialog()
{
XamlRoot = grid.XamlRoot,
Title="警告",
Content="请在设置中配置好模组路径再来",
SecondaryButtonText="取消"
Title = "警告",
Content = "请在设置中配置好模组路径再来",
SecondaryButtonText = "取消"
};
await dialog.ShowAsync();
@ -156,7 +151,7 @@ public sealed partial class ModuleInfoWin : WindowEx
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.";
//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 System.Collections.Generic;
using System.IO;
using RustTools.muqing;
using Windows.Storage;
using Windows.Storage;
public class IniHelper
{
@ -107,7 +103,8 @@ public class IniHelper
/// </summary>
public void Save()
{
if (filePath==null||filePath==string.Empty) {
if (filePath == null || filePath == string.Empty)
{
return;
}

View File

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

View File

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

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics;
using System.IO.Compression;
using Windows.Storage;
using Windows.Storage.Streams;
namespace RustTools.muqing;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
@ -26,17 +22,18 @@ public class wj
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 filePath = Path.Combine(CD,name);
var filePath = Path.Combine(CD, name);
try
{
File.WriteAllText(filePath, str);
return true;
}
catch (Exception ex) {
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
// 将 UUID 写入文件
@ -51,7 +48,7 @@ public class wj
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)

View File

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