添加vs code 支持
This commit is contained in:
parent
49c0f93b84
commit
a1f19d5d86
|
@ -52,10 +52,10 @@ public partial class App : Microsoft.UI.Xaml.Application
|
|||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (!Directory.Exists(wj.CD))
|
||||
{
|
||||
Directory.CreateDirectory(wj.CD);
|
||||
}
|
||||
//if (!Directory.Exists(wj.CD))
|
||||
//{
|
||||
// Directory.CreateDirectory(wj.CD);
|
||||
//}
|
||||
// 注册激活事件处理程序
|
||||
Host = Microsoft.Extensions.Hosting.Host.
|
||||
CreateDefaultBuilder().
|
||||
|
|
6
RustTools/Assets/image/folder.svg
Normal file
6
RustTools/Assets/image/folder.svg
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg t="1723031837806" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11589" width="50" height="50" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path d="M409.6 409.6h460.8c56.32 0 102.4 46.08 102.4 102.4v307.2c0 56.32-46.08 102.4-102.4 102.4H409.6c-56.32 0-102.4-46.08-102.4-102.4v-307.2c0-56.32 46.08-102.4 102.4-102.4z" fill="#5AC8FA" p-id="11590"></path>
|
||||
<path d="M153.6 153.6c-30.72 0-51.2 25.6-51.2 51.2v614.4c0 30.72 20.48 51.2 51.2 51.2h716.8c30.72 0 51.2-20.48 51.2-51.2V307.2c0-30.72-25.6-51.2-51.2-51.2h-337.92c-25.6 0-51.2-10.24-71.68-30.72L404.48 168.96c-10.24-10.24-25.6-15.36-35.84-15.36H153.6z m0-51.2h215.04c25.6 0 51.2 10.24 71.68 30.72l56.32 56.32c10.24 10.24 20.48 15.36 35.84 15.36H870.4c56.32 0 102.4 46.08 102.4 102.4v512c0 56.32-46.08 102.4-102.4 102.4H153.6c-56.32 0-102.4-46.08-102.4-102.4V204.8c0-56.32 46.08-102.4 102.4-102.4z" fill="" p-id="11591"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
5
RustTools/Assets/image/rwmod.svg
Normal file
5
RustTools/Assets/image/rwmod.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg t="1723033128339" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="17871" width="50" height="50">
|
||||
<path d="M332.799002 686.081014m-332.799002 0a332.799002 332.799002 0 1 0 665.598003 0 332.799002 332.799002 0 1 0-665.598003 0Z" fill="#CCE4F2" p-id="17872"></path>
|
||||
<path d="M883.19735 1024h-639.99808A141.055577 141.055577 0 0 1 102.399693 883.200422v-742.397772A141.055577 141.055577 0 0 1 243.19927 0.003072h516.350451a89.087733 89.087733 0 0 1 63.231811 25.599923l189.695431 189.695431A38.399885 38.399885 0 0 1 1023.996928 243.202342v639.99808a141.055577 141.055577 0 0 1-140.799578 140.799578zM243.19927 76.802842A63.999808 63.999808 0 0 0 179.199462 140.80265v742.397772A63.999808 63.999808 0 0 0 243.19927 947.20023h639.99808a63.999808 63.999808 0 0 0 63.999808-63.999808V259.074295l-179.199462-179.199463a12.799962 12.799962 0 0 0-8.447975-3.07199z" fill="#434260" p-id="17873"></path>
|
||||
<path d="M251.391246 399.105875h40.959877L332.799002 513.281532c5.119985 15.103955 9.727971 30.463909 15.103954 45.823863h1.535996c5.119985-15.359954 9.471972-30.719908 14.847955-45.823863l40.959877-114.175657h41.215877v226.047322h-32.511903v-111.871665c0-20.223939 2.815992-49.407852 4.607986-70.143789l-18.175945 51.199846-39.423882 107.775677h-22.015934l-39.679881-107.775677-17.919946-51.199846c1.535995 20.479939 4.351987 49.663851 4.351987 70.143789v111.871665H251.391246zM483.838548 512.001536c0-72.703782 40.191879-116.479651 98.303706-116.479651s98.559704 43.519869 98.559704 116.479651-40.703878 117.247648-98.559704 117.247648S483.838548 583.93732 483.838548 512.001536z m160.25552 0c0-53.24784-25.599923-85.247744-61.951814-85.247744S520.446439 458.241697 520.446439 512.001536s24.319927 86.78374 61.695815 86.78374S644.094068 563.201382 644.094068 512.001536zM716.79785 399.105875h58.623824c69.375792 0 109.055673 38.399885 109.055673 112.127663s-39.679881 113.919658-106.495681 113.919659H716.79785z m56.319831 196.863409c48.383855 0 74.495777-28.671914 74.495776-84.735746s-25.599923-83.19975-74.495776-83.19975h-20.479939v167.935496z" fill="#434260" p-id="17874"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
|
@ -17,8 +17,6 @@ public sealed partial class MainWindow : WindowEx
|
|||
{
|
||||
InitializeComponent();
|
||||
gj.SetBackTheme(this);
|
||||
//gj.sc("lujing"+ AppContext.BaseDirectory);
|
||||
//Resources
|
||||
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
||||
//AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico"));
|
||||
Content = null;
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>RustTools</RootNamespace>
|
||||
<Platform>x64</Platform>
|
||||
<Platforms>x86;x64;arm64</Platforms>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -29,20 +31,7 @@
|
|||
<AppInstallerUri>C:\\RustTools</AppInstallerUri>
|
||||
<AppxPackageDir>D:\RustTools</AppxPackageDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\image\image_106.svg" />
|
||||
<None Remove="Styles\ItemView.xaml" />
|
||||
<None Remove="Styles\TitleSubtitleControlStyle.xaml" />
|
||||
<None Remove="Views\ConcernPage.xaml" />
|
||||
<None Remove="Views\HomePage.xaml" />
|
||||
<None Remove="Views\ModulePage.xaml" />
|
||||
<None Remove="Views\RankingPage.xaml" />
|
||||
<None Remove="Views\UserPage.xaml" />
|
||||
<None Remove="WindowUI\ImportModule.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Remove="Themes\Generic.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
|
@ -58,19 +47,18 @@
|
|||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="WinUIEx" Version="2.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
<Content Include="Assets\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\ModulePage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Update="Styles\TitleSubtitleControlStyle.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<None Update="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<Page Update="Styles\ItemView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
@ -95,6 +83,7 @@
|
|||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:RustTools">
|
||||
|
||||
<Style TargetType="local2:CustomControl1" xmlns:local2="using:RustTools.Styles">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="local2:CustomControl1">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -1,9 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using RustTools.muqing;
|
||||
using RustTools.Views;
|
||||
|
||||
namespace RustTools.ViewModels;
|
||||
/// <summary>
|
||||
|
@ -11,8 +16,71 @@ namespace RustTools.ViewModels;
|
|||
/// </summary>
|
||||
public class ModuleViewModel : ObservableRecipient
|
||||
{
|
||||
|
||||
public ObservableCollection<DataObject> ListMod = new();
|
||||
public ModuleViewModel()
|
||||
{
|
||||
|
||||
var iniHelper = new IniHelper();
|
||||
iniHelper.Load(IniHelper.FILE.Config);
|
||||
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
||||
if (v == string.Empty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var subfolders = Directory.GetDirectories(v);
|
||||
foreach (var item in subfolders)
|
||||
{
|
||||
var info = new DirectoryInfo(item);
|
||||
ListMod.Add(new DataObject(info));
|
||||
}
|
||||
var files = Directory.GetFiles(v);
|
||||
foreach (var item in files)
|
||||
{
|
||||
var info = new FileInfo(item);
|
||||
if (info.Name.EndsWith(".rwmod"))
|
||||
{
|
||||
ListMod.Add(new DataObject(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void Button_Rwmod(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
var menuItem = sender as MenuFlyoutItem;
|
||||
if (menuItem != null)
|
||||
{
|
||||
if (menuItem.DataContext is DataObject folderItem)
|
||||
{
|
||||
var filepath = Path.Combine(Path.GetDirectoryName(folderItem.Dri), folderItem.Name + ".rwmod");
|
||||
if (File.Exists(filepath))
|
||||
{
|
||||
var show = await new ContentDialog()
|
||||
{
|
||||
XamlRoot = menuItem.XamlRoot,
|
||||
Title = "警告",
|
||||
Content = "已经存在必须覆盖",
|
||||
PrimaryButtonText = "确定",
|
||||
SecondaryButtonText = "取消"
|
||||
}.ShowAsync();
|
||||
if (show == ContentDialogResult.Primary)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 压缩zip
|
||||
var v = wj.ZipExample(folderItem.Dri, folderItem.Name + ".rwmod");
|
||||
if (v!=string.Empty)
|
||||
{
|
||||
ListMod.Remove(new DataObject(new FileInfo(filepath)));
|
||||
ListMod.Insert(0,new DataObject(new FileInfo(v)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,15 @@ public sealed partial class HomePage : Page
|
|||
Pictures.Add(item);
|
||||
}
|
||||
}
|
||||
ViewModel.random();
|
||||
ViewModel.Latest();
|
||||
InitializeComponent();
|
||||
ListA.ItemClick += ListAClick;
|
||||
ListB.ItemClick += ListAClick;
|
||||
//为了节省流量测试的时候不加载这些
|
||||
if (false)
|
||||
{
|
||||
ViewModel.random();
|
||||
ViewModel.Latest();
|
||||
}
|
||||
}
|
||||
|
||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
|
|
|
@ -16,10 +16,15 @@
|
|||
Click="Button_Click_RwmodItem"
|
||||
CornerRadius="9">
|
||||
<Grid
|
||||
Width="160"
|
||||
Height="190"
|
||||
Width="130"
|
||||
Height="160"
|
||||
Padding="9">
|
||||
<FontIcon Glyph="" />
|
||||
<Image
|
||||
Width="50"
|
||||
Height="50"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="/Assets/image/rwmod.svg" />
|
||||
<Button
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
|
@ -28,31 +33,55 @@
|
|||
<FontIcon Glyph="" />
|
||||
</Button>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom">
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Name}" />
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" Text="{Binding Info}" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="{Binding Name}"
|
||||
TextWrapping="NoWrap" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding Info}"
|
||||
TextWrapping="NoWrap" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
<!-- 文件夹 -->
|
||||
<DataTemplate x:Key="FolderItem">
|
||||
<Button Background="{ThemeResource SystemColorWindowColor}" CornerRadius="9">
|
||||
<Button
|
||||
Background="{ThemeResource SystemColorWindowColor}"
|
||||
CornerRadius="9"
|
||||
ToolTipService.ToolTip="{Binding Info}">
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Text="打开" />
|
||||
<MenuFlyoutItem Text="打包" />
|
||||
<MenuFlyoutItem Click="ViewModel.Button_Rwmod" Text="打包" />
|
||||
<MenuFlyoutItem Text="发布" />
|
||||
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
<Grid
|
||||
Width="160"
|
||||
Height="190"
|
||||
Width="130"
|
||||
Height="160"
|
||||
Padding="9">
|
||||
<FontIcon Glyph="" />
|
||||
<Image
|
||||
Width="50"
|
||||
Height="50"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{Binding Icon}" />
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom">
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Name}" />
|
||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" Text="{Binding Info}" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="{Binding Name}"
|
||||
TextWrapping="NoWrap" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding Info}"
|
||||
TextWrapping="NoWrap" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
|
@ -65,6 +94,7 @@
|
|||
Label="分享"
|
||||
ToolTipService.ToolTip="分享" />
|
||||
<AppBarButton
|
||||
Click="Button_Delete"
|
||||
Icon="Delete"
|
||||
Label="删除"
|
||||
ToolTipService.ToolTip="删除" />
|
||||
|
@ -74,16 +104,16 @@
|
|||
</CommandBarFlyout>
|
||||
</Page.Resources>
|
||||
<Grid Margin="16">
|
||||
|
||||
<GridView
|
||||
x:Name="BasicGridView"
|
||||
IsItemClickEnabled="False"
|
||||
ItemsSource="{x:Bind ListMod}"
|
||||
ItemsSource="{x:Bind ViewModel.ListMod}"
|
||||
SelectionMode="None">
|
||||
<GridView.ItemTemplateSelector>
|
||||
<local:MyItemTemplateSelector Template1="{StaticResource RwmodItem}" Template2="{StaticResource FolderItem}" />
|
||||
</GridView.ItemTemplateSelector>
|
||||
</GridView>
|
||||
<ContentDialog Name="AAAA" Title="aaaa" />
|
||||
</Grid>
|
||||
|
||||
</Page>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
@ -7,13 +8,14 @@ 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>
|
||||
/// 模组碎片
|
||||
/// 模组碎片
|
||||
/// </summary>
|
||||
public class DataObject
|
||||
{
|
||||
//路径
|
||||
public string Dri
|
||||
{
|
||||
get; set;
|
||||
|
@ -30,61 +32,67 @@ public class DataObject
|
|||
{
|
||||
get; set;
|
||||
}
|
||||
public DataObject()
|
||||
public string Icon
|
||||
{
|
||||
IsRwmod = true;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is DataObject other)
|
||||
{
|
||||
return Dri == other.Dri;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public DataObject(FileInfo fileInfo)
|
||||
{
|
||||
Name = fileInfo.Name;
|
||||
Name = Path.GetFileNameWithoutExtension(fileInfo.Name);
|
||||
//Name = fileInfo.Name;
|
||||
IsRwmod = true;
|
||||
Info = $"文件大小:{wj.FormatFileSize(fileInfo.Length)}";
|
||||
Info = $"大小:{wj.FormatFileSize(fileInfo.Length)}";
|
||||
Dri = fileInfo.FullName;
|
||||
}
|
||||
public DataObject(DirectoryInfo fileInfo)
|
||||
{
|
||||
Name = fileInfo.Name;
|
||||
IsRwmod = false;
|
||||
Info = $"创建时间:{fileInfo.CreationTime}";
|
||||
Info = $"{fileInfo.CreationTime}";
|
||||
Dri = fileInfo.FullName;
|
||||
Icon = File.Exists(Path.Combine(Dri, "icon.png")) ? Path.Combine(Dri, "icon.png") : "/Assets/image/folder.svg";
|
||||
var modinfo = Path.Combine(Dri, "mod-info.txt");
|
||||
if (File.Exists(modinfo))
|
||||
{
|
||||
var dictionary = gj.IniInfo(modinfo);
|
||||
if (dictionary.TryGetValue("mod", out var sectionValues))
|
||||
{
|
||||
gj.sc(sectionValues);
|
||||
Name =sectionValues.TryGetValue("title", out var value) ? value : Name;
|
||||
gj.sc(value);
|
||||
Info = sectionValues.TryGetValue("description", out var description) ? description : Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ... Methods ...
|
||||
}
|
||||
public sealed partial class ModulePage : Page
|
||||
{
|
||||
public ObservableCollection<DataObject> ListMod = new();
|
||||
public ModuleViewModel ViewModel { get; set; }
|
||||
public ModuleViewModel ViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public ModulePage()
|
||||
{
|
||||
ViewModel = App.GetService<ModuleViewModel>();
|
||||
InitializeComponent();
|
||||
var iniHelper = new IniHelper();
|
||||
iniHelper.Load(IniHelper.FILE.Config);
|
||||
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
||||
|
||||
var subfolders = Directory.GetDirectories(v);
|
||||
foreach (var item in subfolders)
|
||||
{
|
||||
var info = new DirectoryInfo(item);
|
||||
ListMod.Add(new DataObject(info));
|
||||
}
|
||||
var files = Directory.GetFiles(v);
|
||||
foreach (var item in files)
|
||||
{
|
||||
var info = new FileInfo(item);
|
||||
if (info.Name.EndsWith(".rwmod"))
|
||||
{
|
||||
ListMod.Add(new DataObject(info));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void ShowMenu(bool isTransient, GridViewItem dataTemplate)
|
||||
{
|
||||
FlyoutShowOptions myOption = new FlyoutShowOptions();
|
||||
myOption.ShowMode = isTransient ? FlyoutShowMode.Transient : FlyoutShowMode.Standard;
|
||||
CommandBarFlyout1.ShowAt(dataTemplate, myOption);
|
||||
}
|
||||
//private void ShowMenu(bool isTransient, GridViewItem dataTemplate)
|
||||
//{
|
||||
// FlyoutShowOptions myOption = new FlyoutShowOptions();
|
||||
// myOption.ShowMode = isTransient ? FlyoutShowMode.Transient : FlyoutShowMode.Standard;
|
||||
// CommandBarFlyout1.ShowAt(dataTemplate, myOption);
|
||||
//}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
@ -103,19 +111,23 @@ public sealed partial class ModulePage : Page
|
|||
}
|
||||
private void Button_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
MenuFlyoutItem menuItem = sender as MenuFlyoutItem;
|
||||
var menuItem = sender as ButtonBase;
|
||||
if (menuItem != null)
|
||||
{
|
||||
// 获取相关的文件夹项
|
||||
var folderItem = menuItem.DataContext as DataObject; // 假设你的文件夹项类型为 FolderItem
|
||||
if (folderItem != null)
|
||||
if (menuItem.DataContext is DataObject folderItem)
|
||||
{
|
||||
// 这里可以添加删除文件夹逻辑
|
||||
gj.sc("删除文件夹"+folderItem.Dri);
|
||||
if (Directory.Exists(folderItem.Dri))
|
||||
{
|
||||
// 删除文件夹
|
||||
Directory.Delete(folderItem.Dri, true);
|
||||
}
|
||||
else if (File.Exists(folderItem.Dri))
|
||||
{
|
||||
//删除文件
|
||||
File.Delete(folderItem.Dri);
|
||||
}
|
||||
ViewModel.ListMod.Remove(folderItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -124,10 +136,9 @@ public sealed partial class ModulePage : Page
|
|||
{
|
||||
ContentDialog dialog = new ContentDialog();
|
||||
dialog.XamlRoot = XamlRoot;
|
||||
dialog.Title = "解压";
|
||||
//dialog. = "你可以在本次解压中选择是否删除源文件";
|
||||
dialog.PrimaryButtonText = "确定";
|
||||
dialog.SecondaryButtonText = "取消";
|
||||
dialog.Title = "提示";
|
||||
dialog.PrimaryButtonText = "确定";
|
||||
dialog.SecondaryButtonText = "取消";
|
||||
dialog.Content = CreateCheckboxContent();
|
||||
var contentDialogResult = await dialog.ShowAsync();
|
||||
if (contentDialogResult == ContentDialogResult.Primary)
|
||||
|
@ -143,10 +154,8 @@ public sealed partial class ModulePage : Page
|
|||
if (checkbox.IsChecked == true)
|
||||
{
|
||||
File.Delete(dataItem.Dri);
|
||||
ListMod.Remove(dataItem);
|
||||
ViewModel.ListMod.Remove(dataItem);
|
||||
}
|
||||
gj.sc("确定");
|
||||
// 获取文件的名称(不包括扩展名)
|
||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(dataItem.Dri);
|
||||
var GetDirectoryName = Path.GetDirectoryName(dataItem.Dri);
|
||||
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
||||
|
@ -156,7 +165,7 @@ public sealed partial class ModulePage : Page
|
|||
gj.sc(v);
|
||||
if (v)
|
||||
{
|
||||
ListMod.Add(new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
ViewModel.ListMod.Add(new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,25 +176,24 @@ public sealed partial class ModulePage : Page
|
|||
|
||||
private FrameworkElement CreateCheckboxContent()
|
||||
{
|
||||
// 创建 CheckBox
|
||||
var checkbox = new CheckBox
|
||||
{
|
||||
Content = "删除源文件",
|
||||
IsChecked = false, // 默认未选中
|
||||
Content = "是否删除源文件",
|
||||
IsChecked = false,
|
||||
Margin = new Thickness(0, 16, 0, 0),
|
||||
|
||||
};
|
||||
var text = new TextBlock
|
||||
{
|
||||
Text = "你可以在本次解压中选择是否删除源文件",
|
||||
Text = "解压模组到目录",
|
||||
};
|
||||
|
||||
// 创建 StackPanel 作为容器
|
||||
var stackPanel = new StackPanel();
|
||||
stackPanel.Children.Add(text);
|
||||
stackPanel.Children.Add(checkbox);
|
||||
return stackPanel;
|
||||
}
|
||||
|
||||
}
|
||||
public class MyItemTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
|
|
|
@ -18,14 +18,15 @@ public sealed partial class SettingsPage : Page
|
|||
{
|
||||
None,
|
||||
}
|
||||
|
||||
public SettingsPage()
|
||||
{
|
||||
//this.windowEx = windowEx;
|
||||
ViewModel = App.GetService<SettingsViewModel>();
|
||||
InitializeComponent();
|
||||
Init();
|
||||
|
||||
//BackgroundRadioButtons
|
||||
}
|
||||
private async void Init()
|
||||
{
|
||||
var iniHelper = new IniHelper();
|
||||
iniHelper.Load(IniHelper.FILE.Config);
|
||||
var v = iniHelper.GetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop);
|
||||
|
@ -50,7 +51,7 @@ public sealed partial class SettingsPage : Page
|
|||
MapsFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl);
|
||||
}
|
||||
private bool Backone = false;
|
||||
private void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
private async void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (Backone)
|
||||
{
|
||||
|
@ -121,7 +122,7 @@ public sealed partial class SettingsPage : Page
|
|||
}
|
||||
}
|
||||
|
||||
private void SaveModAndMaps()
|
||||
private async void SaveModAndMaps()
|
||||
{
|
||||
var iniHelper = new IniHelper();
|
||||
iniHelper.Load(IniHelper.FILE.Config);
|
||||
|
@ -130,7 +131,7 @@ public sealed partial class SettingsPage : Page
|
|||
iniHelper.Save();
|
||||
}
|
||||
|
||||
private void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
||||
private async void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var a=(AutoSuggestBox) sender;
|
||||
var iniHelper = new IniHelper();
|
||||
|
|
|
@ -31,12 +31,14 @@
|
|||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture
|
||||
<Border
|
||||
Grid.Column="0"
|
||||
Width="86"
|
||||
Height="86"
|
||||
HorizontalContentAlignment="Right"
|
||||
ProfilePicture="/Assets/tool.png" />
|
||||
Background="BlanchedAlmond"
|
||||
CornerRadius="16">
|
||||
<Image Source="http://q1.qlogo.cn/g?b=qq&nk=2923268971&s=100" />
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Margin="16,0,0,0">
|
||||
<TextBlock
|
||||
Margin="0,9,0,0"
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace RustTools.WindowUI;
|
|||
public sealed partial class ImportModule : WindowEx
|
||||
{
|
||||
private readonly FileInfo? fileInfo;
|
||||
private readonly string ImpUrl= string.Empty;
|
||||
private string ImpUrl= string.Empty;
|
||||
public ImportModule(string file)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -21,8 +21,8 @@ public sealed partial class ImportModule : WindowEx
|
|||
}
|
||||
fileInfo = new FileInfo(file);
|
||||
var iniHelper = new IniHelper();
|
||||
|
||||
iniHelper.Load(IniHelper.FILE.Config);
|
||||
ImpUrl = string.Empty;
|
||||
if (file.EndsWith(".rwmod"))
|
||||
{
|
||||
var l = " | ";
|
||||
|
|
|
@ -12,24 +12,29 @@
|
|||
Closed="WindowEx_Closed"
|
||||
SizeChanged="WindowEx_SizeChanged"
|
||||
mc:Ignorable="d">
|
||||
<Grid x:Name="grid" Padding="16,36,16,10">
|
||||
<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">
|
||||
<StackPanel Grid.Row="0"
|
||||
Orientation="Horizontal">
|
||||
<Border
|
||||
Width="106"
|
||||
Height="106"
|
||||
CornerRadius="9">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="{Binding Mod.IconUrl}" Stretch="UniformToFill" />
|
||||
<ImageBrush ImageSource="{Binding Mod.IconUrl}"
|
||||
Stretch="UniformToFill"/>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<StackPanel Margin="16,3,9,3" Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource TitleLargeTextBlockStyle}" Text="{Binding Mod.Name}" />
|
||||
<StackPanel Margin="16,3,9,3"
|
||||
Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource TitleLargeTextBlockStyle}"
|
||||
Text="{Binding Mod.Name}"/>
|
||||
<TextBlock
|
||||
x:Name="title_b"
|
||||
Margin="0,3,0,0"
|
||||
|
@ -43,8 +48,10 @@
|
|||
</StackPanel>
|
||||
</StackPanel>
|
||||
<ScrollView Grid.Row="1">
|
||||
<StackPanel Margin="0,26,0,0" Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="介绍" />
|
||||
<StackPanel Margin="0,26,0,0"
|
||||
Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
Text="介绍"/>
|
||||
<TextBlock
|
||||
x:Name="DescriptionText"
|
||||
Padding="6,6,6,6"
|
||||
|
@ -66,7 +73,8 @@
|
|||
Visibility="Collapsed">
|
||||
<FlipView.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<Image Source="{x:Bind Mode=OneTime}" Stretch="Uniform" />
|
||||
<Image Source="{x:Bind Mode=OneTime}"
|
||||
Stretch="Uniform"/>
|
||||
</DataTemplate>
|
||||
</FlipView.ItemTemplate>
|
||||
</FlipView>
|
||||
|
@ -114,8 +122,10 @@
|
|||
Title="下载中"
|
||||
SecondaryButtonText="取消">
|
||||
<StackPanel>
|
||||
<TextBlock Name="DownloadDialogText" Text="下载完成后会自动导入到你配置的模组路径,请勿取消" />
|
||||
<ProgressBar Margin="0,6,0,0" IsIndeterminate="True" />
|
||||
<TextBlock Name="DownloadDialogText"
|
||||
Text="下载完成后会自动导入到你配置的模组路径,请勿取消"/>
|
||||
<ProgressBar Margin="0,6,0,0"
|
||||
IsIndeterminate="True"/>
|
||||
</StackPanel>
|
||||
</ContentDialog>
|
||||
</Grid>
|
||||
|
|
|
@ -35,7 +35,6 @@ public class IniHelper
|
|||
|
||||
public IniHelper()
|
||||
{
|
||||
_sections = new Dictionary<string, Dictionary<string, string>>();
|
||||
/*用法
|
||||
//IniHelper iniHelper = new IniHelper();
|
||||
// 设置配置数据 节 key value
|
||||
|
@ -62,12 +61,13 @@ public class IniHelper
|
|||
/// <exception cref="FileNotFoundException"></exception>
|
||||
public void Load(string a)
|
||||
{
|
||||
filePath = Path.Combine(wj.CD,a);
|
||||
|
||||
filePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, a);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
File.Create(filePath);
|
||||
{// 使用 File.Create 创建文件并立即关闭
|
||||
using var fs = File.Create(filePath);
|
||||
// 文件创建成功,但在这里不做任何操作 文件已经关闭
|
||||
return;
|
||||
//throw new FileNotFoundException("The specified file does not exist.", filePath);
|
||||
}
|
||||
if (filePath == null || filePath == string.Empty)
|
||||
{
|
||||
|
@ -107,8 +107,8 @@ public class IniHelper
|
|||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
if (filePath==null) {
|
||||
throw new FileNotFoundException("不存在或者filePath没有定义");
|
||||
if (filePath==null||filePath==string.Empty) {
|
||||
return;
|
||||
}
|
||||
|
||||
using var sw = new StreamWriter(filePath);
|
||||
|
|
|
@ -12,12 +12,16 @@ using Windows.UI.ViewManagement;
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
using Windows.UI;
|
||||
class gj
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
||||
#pragma warning disable IDE1006 // 命名样式
|
||||
public class gj
|
||||
{
|
||||
public static void sc(object? obj)
|
||||
{
|
||||
obj ??= "null";
|
||||
Debug.WriteLine(obj);
|
||||
Debug.WriteLine("Debug:" + obj);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,12 +29,10 @@ class gj
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var searcher = new ManagementObjectSearcher("select UUID from Win32_ComputerSystemProduct"))
|
||||
using var searcher = new ManagementObjectSearcher("select UUID from Win32_ComputerSystemProduct");
|
||||
foreach (var obj in searcher.Get().Cast<ManagementObject>())
|
||||
{
|
||||
foreach (ManagementObject obj in searcher.Get())
|
||||
{
|
||||
return obj["UUID"].ToString();
|
||||
}
|
||||
return obj["UUID"] != null ? (string)obj["UUID"] : "";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -38,7 +40,7 @@ class gj
|
|||
Console.WriteLine($"An error occurred while retrieving the UUID: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +87,7 @@ class gj
|
|||
|
||||
public static void SetBackColor(WindowEx windowEx)
|
||||
{
|
||||
UISettings uISettings = new UISettings();
|
||||
var uISettings = new UISettings();
|
||||
// 获取当前的背景颜色
|
||||
var backgroundColor = uISettings.GetColorValue(UIColorType.Background);
|
||||
|
||||
|
@ -178,6 +180,47 @@ class gj
|
|||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam);
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 简单的ini读取器
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, Dictionary<string, string>> IniInfo(string filePath)
|
||||
{
|
||||
|
||||
var sections=new Dictionary<string, Dictionary<string, string>>();
|
||||
using (var reader = new StreamReader(filePath))
|
||||
{
|
||||
string? line;
|
||||
string? currentSection = null;
|
||||
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
if (line.StartsWith("[") && line.EndsWith("]"))
|
||||
{
|
||||
// New section found
|
||||
currentSection = line.Trim('[', ']');
|
||||
sections[currentSection] = new Dictionary<string, string>();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(line) && currentSection != null)
|
||||
{
|
||||
// Key-value pair found
|
||||
var delimiterIndex = line.IndexOf(':');
|
||||
if (delimiterIndex > 0)
|
||||
{
|
||||
var key = line.Substring(0, delimiterIndex).Trim();
|
||||
var value = line.Substring(delimiterIndex + 1).Trim();
|
||||
sections[currentSection][key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
}
|
||||
|
||||
public enum BackTheme
|
||||
|
|
|
@ -3,17 +3,20 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO.Compression;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Streams;
|
||||
namespace RustTools.muqing;
|
||||
|
||||
class wj
|
||||
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
||||
#pragma warning disable IDE1006 // 命名样式
|
||||
public class wj
|
||||
{
|
||||
//存储主要文件的路径
|
||||
public static string CD = "C:\\RustTools";
|
||||
public static string CD = "";
|
||||
//缓存路径
|
||||
public const string Cache = "";
|
||||
|
||||
//不知道为什么会保存到这里的路径 废弃了 , 找到了新的文件夹路径
|
||||
//public const string CachePath= "C:/Users/账号/AppData/Local/VirtualStore/Windows/SysWOW64";
|
||||
//public const string CachePath= "C:/Users/19669/AppData/Local/VirtualStore/Windows/SysWOW64";
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件名字的路径
|
||||
|
@ -91,4 +94,44 @@ class wj
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 压缩zip
|
||||
/// </summary>
|
||||
/// <param name="folderPath"></param>
|
||||
/// <param name="zipFileName"></param>
|
||||
public static string ZipExample(string folderPath, string zipFileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
zipFileName = Path.Combine(Path.Combine(Path.GetDirectoryName(folderPath), zipFileName));
|
||||
// 创建一个新的 Zip 文件
|
||||
|
||||
using (FileStream fs = File.Create(zipFileName))
|
||||
{
|
||||
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Create, true))
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
string relativePath = file.Substring(folderPath.Length + 1);
|
||||
|
||||
ZipArchiveEntry entry = archive.CreateEntry(relativePath);
|
||||
using (FileStream sourceStream = File.OpenRead(file))
|
||||
using (Stream entryStream = entry.Open())
|
||||
{
|
||||
sourceStream.CopyTo(entryStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return zipFileName;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using RestSharp;
|
||||
namespace RustTools.muqing;
|
||||
|
||||
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
||||
class wl
|
||||
{
|
||||
public static string api = "https://rust.coldmint.top";
|
||||
|
@ -102,4 +104,5 @@ class wl
|
|||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user