修复BUG
This commit is contained in:
parent
582f4f2652
commit
bf54ae4dd0
|
@ -7,6 +7,8 @@
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
<Platforms>x86;x64;arm64</Platforms>
|
<Platforms>x86;x64;arm64</Platforms>
|
||||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||||
|
|
||||||
|
<!--<WindowsPackageType>None</WindowsPackageType>-->
|
||||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
|
@ -22,9 +22,26 @@
|
||||||
<StackPanel Grid.Row="0" Margin="0,0,0,9">
|
<StackPanel Grid.Row="0" Margin="0,0,0,9">
|
||||||
<AutoSuggestBox
|
<AutoSuggestBox
|
||||||
x:Name="search"
|
x:Name="search"
|
||||||
|
KeyDown="searchBox_KeyDown"
|
||||||
|
PlaceholderText="(Ctrl+J 显示建议列表)"
|
||||||
QueryIcon="Find"
|
QueryIcon="Find"
|
||||||
|
QuerySubmitted="search_QuerySubmitted"
|
||||||
SuggestionChosen="AutoSuggestBox_SuggestionChosen"
|
SuggestionChosen="AutoSuggestBox_SuggestionChosen"
|
||||||
TextChanged="search_TextChanged" />
|
TextChanged="search_TextChanged"
|
||||||
|
TextMemberPath="key">
|
||||||
|
<AutoSuggestBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock VerticalAlignment="Center" Text="{Binding key}" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="9,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding value}" />
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
</AutoSuggestBox.ItemTemplate>
|
||||||
|
</AutoSuggestBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Grid Grid.Row="1" Grid.Column="0">
|
<Grid Grid.Row="1" Grid.Column="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|
|
@ -9,6 +9,7 @@ using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using Microsoft.UI.Input;
|
||||||
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;
|
||||||
|
@ -21,7 +22,11 @@ using Newtonsoft.Json.Linq;
|
||||||
using RustTools.DataList;
|
using RustTools.DataList;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
using RustTools.ViewModels;
|
using RustTools.ViewModels;
|
||||||
|
using Windows.ApplicationModel.Core;
|
||||||
|
using Windows.System;
|
||||||
|
using Windows.UI.Core;
|
||||||
using static System.Collections.Specialized.BitVector32;
|
using static System.Collections.Specialized.BitVector32;
|
||||||
|
using static IniHelper;
|
||||||
using static RustTools.DataList.DataBaseManifest;
|
using static RustTools.DataList.DataBaseManifest;
|
||||||
|
|
||||||
// To learn more about WinUI, the WinUI project structure,
|
// To learn more about WinUI, the WinUI project structure,
|
||||||
|
@ -33,7 +38,7 @@ namespace RustTools.Views;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class CodeTablePage : Page
|
public sealed partial class CodeTablePage : Page
|
||||||
{
|
{
|
||||||
public ObservableCollection<CodeTable>? codeList = new();
|
public ObservableCollection<CodeTable> codeList = new();
|
||||||
public CodeTableViewModel ViewModel { get; set; }
|
public CodeTableViewModel ViewModel { get; set; }
|
||||||
public List<DataBaseManifest.Section.SectionData> section = new();
|
public List<DataBaseManifest.Section.SectionData> section = new();
|
||||||
public CodeTablePage()
|
public CodeTablePage()
|
||||||
|
@ -93,9 +98,9 @@ public sealed partial class CodeTablePage : Page
|
||||||
|
|
||||||
//var textBlock = new TextBlock();
|
//var textBlock = new TextBlock();
|
||||||
//textBlock.IsTextSelectionEnabled
|
//textBlock.IsTextSelectionEnabled
|
||||||
|
|
||||||
|
// 注册 KeyDown 事件处理程序
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void keyListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void keyListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -128,8 +133,9 @@ public sealed partial class CodeTablePage : Page
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnNavigatedFrom(e);
|
base.OnNavigatedFrom(e);
|
||||||
codeList?.Clear();
|
codeList.Clear();
|
||||||
codeList = null;
|
//section.Clear();
|
||||||
|
//valueList.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,24 +160,31 @@ public sealed partial class CodeTablePage : Page
|
||||||
|
|
||||||
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
||||||
{
|
{
|
||||||
var str = args.SelectedItem.ToString();
|
//gj.sc("AutoSuggestBox_SuggestionChosen "+sender);
|
||||||
search.Text = str;
|
//if (args.SelectedItem is not Search_List str) { return; }
|
||||||
if (str == null) { return; }
|
//search.Text = str.key;
|
||||||
var a=str.Split(' ');
|
//List<CodeTable_Data> itemsSource = new();
|
||||||
List<CodeTable_Data> itemsSource = new();
|
//foreach (var item in valueList)
|
||||||
|
//{
|
||||||
foreach (var item in valueList)
|
// if (item.code.Contains(str.key) || item.translate.Contains(str.value))
|
||||||
{
|
// {
|
||||||
if (item.code.Contains(a[0]) || item.translate.Contains(a[1]))
|
// itemsSource.Add(item);
|
||||||
{
|
// }
|
||||||
itemsSource.Add(item);
|
//}
|
||||||
gj.sc(item.code);
|
//valueListView.ItemsSource=itemsSource;
|
||||||
}
|
|
||||||
}
|
|
||||||
gj.sc(itemsSource.Count);
|
|
||||||
valueListView.ItemsSource=itemsSource;
|
|
||||||
//valueListView.ItemsSource=search.ItemsSource;
|
//valueListView.ItemsSource=search.ItemsSource;
|
||||||
}
|
}
|
||||||
|
class Search_List
|
||||||
|
{
|
||||||
|
public string key
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public string value
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<CodeTable_Data> valueList = new ();
|
private List<CodeTable_Data> valueList = new ();
|
||||||
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||||
|
@ -184,27 +197,57 @@ public sealed partial class CodeTablePage : Page
|
||||||
// only listen to changes caused by user entering text.
|
// only listen to changes caused by user entering text.
|
||||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||||
{
|
{
|
||||||
var suitableItems = new List<string>();
|
var suitableItems = new List<Search_List>();
|
||||||
var splitText = sender.Text.ToLower().Split(" ");
|
var splitText = sender.Text.ToString();
|
||||||
if (valueListView.ItemsSource is not List<CodeTable_Data> itemsSource) { return; }
|
if (valueListView.ItemsSource is not List<CodeTable_Data> itemsSource) { return; }
|
||||||
|
var i = 0;
|
||||||
foreach (var cat in itemsSource)
|
foreach (var cat in itemsSource)
|
||||||
{
|
{
|
||||||
var found = splitText.All((key) =>
|
if (cat.code.Contains(splitText) || cat.translate.Contains(splitText))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key)) { return false; }
|
suitableItems.Add(new Search_List
|
||||||
return cat.code.Contains(key)||cat.translate.Contains(key);
|
{
|
||||||
});
|
key=cat.code,value=cat.translate
|
||||||
if (found)
|
});
|
||||||
{
|
}
|
||||||
suitableItems.Add(cat.code+" "+cat.translate);
|
//限制搜索的最大显示
|
||||||
|
if (++i > 30)
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (suitableItems.Count == 0)
|
|
||||||
{
|
|
||||||
suitableItems.Add("No results found");
|
|
||||||
}
|
}
|
||||||
sender.ItemsSource = suitableItems;
|
sender.ItemsSource = suitableItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||||
|
{
|
||||||
|
List<CodeTable_Data> itemsSource = new();
|
||||||
|
foreach (var item in valueList)
|
||||||
|
{
|
||||||
|
if (item.code.Contains(sender.Text) || item.translate.Contains(sender.Text))
|
||||||
|
{
|
||||||
|
itemsSource.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valueListView.ItemsSource = itemsSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void searchBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
// 检查是否按下了 Ctrl 键
|
||||||
|
var isCtrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control) == CoreVirtualKeyStates.Down;
|
||||||
|
|
||||||
|
// 检查是否按下了 J 键
|
||||||
|
if (e.Key == VirtualKey.J && isCtrlPressed)
|
||||||
|
{
|
||||||
|
// 在这里执行当 Ctrl+J 被按下时的操作
|
||||||
|
var a = search.ItemsSource as List<Search_List>;
|
||||||
|
search.ItemsSource = null;
|
||||||
|
search.ItemsSource = a;
|
||||||
|
//Debug.WriteLine("Ctrl+J pressed "+ a?.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public sealed partial class HomePage : Page
|
||||||
ListA.ItemClick += ListAClick;
|
ListA.ItemClick += ListAClick;
|
||||||
ListB.ItemClick += ListAClick;
|
ListB.ItemClick += ListAClick;
|
||||||
//为了节省流量测试的时候不加载这些
|
//为了节省流量测试的时候不加载这些
|
||||||
if (false)
|
if (true)
|
||||||
{
|
{
|
||||||
ViewModel.random();
|
ViewModel.random();
|
||||||
ViewModel.Latest();
|
ViewModel.Latest();
|
||||||
|
|
|
@ -142,12 +142,14 @@ public sealed partial class ModulePage : Page
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ContentDialog dialog = new ContentDialog();
|
ContentDialog dialog = new ContentDialog
|
||||||
dialog.XamlRoot = XamlRoot;
|
{
|
||||||
dialog.Title = "提示";
|
XamlRoot = XamlRoot,
|
||||||
dialog.PrimaryButtonText = "确定";
|
Title = "提示",
|
||||||
dialog.SecondaryButtonText = "取消";
|
PrimaryButtonText = "确定",
|
||||||
dialog.Content = CreateCheckboxContent();
|
SecondaryButtonText = "取消",
|
||||||
|
Content = CreateCheckboxContent()
|
||||||
|
};
|
||||||
var contentDialogResult = await dialog.ShowAsync();
|
var contentDialogResult = await dialog.ShowAsync();
|
||||||
if (contentDialogResult == ContentDialogResult.Primary)
|
if (contentDialogResult == ContentDialogResult.Primary)
|
||||||
{
|
{
|
||||||
|
@ -159,21 +161,23 @@ public sealed partial class ModulePage : Page
|
||||||
if (container != null && container.DataContext is DataObject dataItem)
|
if (container != null && container.DataContext is DataObject dataItem)
|
||||||
{
|
{
|
||||||
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
||||||
if (checkbox.IsChecked == true)
|
|
||||||
{
|
|
||||||
File.Delete(dataItem.Dri);
|
|
||||||
ViewModel.ListMod.Remove(dataItem);
|
|
||||||
}
|
|
||||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(dataItem.Dri);
|
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(dataItem.Dri);
|
||||||
var GetDirectoryName = Path.GetDirectoryName(dataItem.Dri);
|
var GetDirectoryName = Path.GetDirectoryName(dataItem.Dri);
|
||||||
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
||||||
{
|
{
|
||||||
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
||||||
var v = wj.UnzipFile(dataItem.Dri, targetDirectory);
|
var v = wj.UnzipFile(dataItem.Dri, targetDirectory);
|
||||||
gj.sc(v);
|
gj.sc("解压成功:"+v);
|
||||||
|
if (checkbox?.IsChecked == true)
|
||||||
|
{
|
||||||
|
File.Delete(dataItem.Dri);
|
||||||
|
ViewModel.ListMod.Remove(dataItem);
|
||||||
|
}
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
ViewModel.ListMod.Add(new DataObject(new DirectoryInfo(targetDirectory)));
|
ViewModel.ListMod.Remove(new DataObject(new DirectoryInfo(targetDirectory)));
|
||||||
|
ViewModel.ListMod.Insert(0,new DataObject(new DirectoryInfo(targetDirectory)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user