2024-08-17 06:41:34 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Diagnostics.Metrics;
|
2024-08-17 06:41:34 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices.WindowsRuntime;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Xml.Linq;
|
2024-08-20 13:34:07 +00:00
|
|
|
|
using Microsoft.UI.Input;
|
2024-08-17 06:41:34 +00:00
|
|
|
|
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;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using RustTools.DataList;
|
|
|
|
|
using RustTools.muqing;
|
|
|
|
|
using RustTools.ViewModels;
|
2024-08-20 13:34:07 +00:00
|
|
|
|
using Windows.ApplicationModel.Core;
|
|
|
|
|
using Windows.System;
|
|
|
|
|
using Windows.UI.Core;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
using static System.Collections.Specialized.BitVector32;
|
2024-08-20 13:34:07 +00:00
|
|
|
|
using static IniHelper;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
using static RustTools.DataList.DataBaseManifest;
|
2024-08-17 06:41:34 +00:00
|
|
|
|
|
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
|
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
|
|
|
|
|
|
namespace RustTools.Views;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class CodeTablePage : Page
|
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
public ObservableCollection<CodeTable> codeList = new();
|
2024-08-19 14:30:11 +00:00
|
|
|
|
public CodeTableViewModel ViewModel { get; set; }
|
|
|
|
|
public List<DataBaseManifest.Section.SectionData> section = new();
|
2024-08-17 06:41:34 +00:00
|
|
|
|
public CodeTablePage()
|
|
|
|
|
{
|
2024-08-19 14:30:11 +00:00
|
|
|
|
ViewModel = App.GetService<CodeTableViewModel>();
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var path = Path.Combine(CodeDataPage.codetable.Dir, CodeDataPage.codetable.tables.code);
|
|
|
|
|
|
|
|
|
|
var codeTable_Code = JsonConvert.DeserializeObject<CodeTable_Code>(File.ReadAllText(path));
|
|
|
|
|
|
|
|
|
|
var v1 = File.ReadAllText(Path.Combine(CodeDataPage.codetable.Dir, CodeDataPage.codetable.tables.section));
|
|
|
|
|
section = JsonConvert.DeserializeObject<DataBaseManifest.Section>(v1).data;
|
|
|
|
|
//gj.sc(v1);
|
|
|
|
|
foreach (var item in codeTable_Code.data)
|
|
|
|
|
{
|
|
|
|
|
#pragma warning disable SYSLIB1045 // ת<><D7AA>Ϊ<EFBFBD><CEAA>GeneratedRegexAttribute<74><65><EFBFBD><EFBFBD>
|
|
|
|
|
foreach (var parts in Regex.Split(item.section, ","))
|
|
|
|
|
{
|
|
|
|
|
var FirstOrDefault = codeList.FirstOrDefault(any => any.Key == parts);
|
|
|
|
|
if (FirstOrDefault != null)
|
|
|
|
|
{
|
|
|
|
|
FirstOrDefault.Vaule.Add(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var sectionData = section.FirstOrDefault(any => any.code == parts);
|
|
|
|
|
var translate = "Null";
|
|
|
|
|
if (sectionData != null)
|
|
|
|
|
{
|
|
|
|
|
translate = sectionData.translate;
|
|
|
|
|
}
|
|
|
|
|
sectionData = null;
|
|
|
|
|
var codeTable1 = new CodeTable
|
|
|
|
|
{
|
|
|
|
|
Key = parts,
|
|
|
|
|
CnKey = translate,
|
|
|
|
|
Vaule = new List<CodeTable_Data>()
|
|
|
|
|
};
|
|
|
|
|
codeTable1.Vaule.Add(item);
|
|
|
|
|
codeList.Add(codeTable1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (codeList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//var firstEntry = codeList.FirstOrDefault();
|
|
|
|
|
keyListView.SelectedItem = codeList.FirstOrDefault(); // Ĭ<><C4AC>ѡ<EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(async () => { await Dialog.DialogWarn(ex.Message, XamlRoot); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//var textBlock = new TextBlock();
|
|
|
|
|
//textBlock.IsTextSelectionEnabled
|
|
|
|
|
|
2024-08-20 13:34:07 +00:00
|
|
|
|
// ע<><D7A2> KeyDown <20>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
2024-08-19 14:30:11 +00:00
|
|
|
|
private void keyListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
var addedItems = e.AddedItems;
|
|
|
|
|
foreach (var item in addedItems)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine($"Selected item: {item}");
|
|
|
|
|
if (item is CodeTable a)
|
|
|
|
|
{
|
|
|
|
|
gj.sc(a);
|
|
|
|
|
valueList = a.Vaule;
|
|
|
|
|
valueListView.ItemsSource = a.Vaule;
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>絼<EFBFBD><E7B5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ҳ<EFBFBD>桢<EFBFBD><E6A1A2><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// <20><>ȡ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//var removedItems = e.RemovedItems;
|
|
|
|
|
//foreach (var item in removedItems)
|
|
|
|
|
//{
|
|
|
|
|
// Debug.WriteLine($"Deselected item: {item}");
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>˳<EFBFBD><CBB3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ֹ<EFBFBD>ڴ<EFBFBD>й©
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedFrom(e);
|
2024-08-20 13:34:07 +00:00
|
|
|
|
codeList.Clear();
|
|
|
|
|
//section.Clear();
|
|
|
|
|
//valueList.Clear();
|
2024-08-19 14:30:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void List_ButtonIcon_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
if (button != null) {
|
|
|
|
|
if (button.DataContext is not CodeTable_Data codeTable_Data) { return; }
|
|
|
|
|
if (ToggleThemeTeachingTip1.IsOpen==false)
|
|
|
|
|
{
|
|
|
|
|
ToggleThemeTeachingTip1.Target = button;
|
|
|
|
|
ToggleThemeTeachingTip1.IsOpen = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ToggleThemeTeachingTip1.IsOpen = false;
|
|
|
|
|
}
|
|
|
|
|
ToastTextBlock.Text =codeTable_Data.demo;
|
|
|
|
|
gj.sc(codeTable_Data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
//gj.sc("AutoSuggestBox_SuggestionChosen "+sender);
|
|
|
|
|
//if (args.SelectedItem is not Search_List str) { return; }
|
|
|
|
|
//search.Text = str.key;
|
|
|
|
|
//List<CodeTable_Data> itemsSource = new();
|
|
|
|
|
//foreach (var item in valueList)
|
|
|
|
|
//{
|
|
|
|
|
// if (item.code.Contains(str.key) || item.translate.Contains(str.value))
|
|
|
|
|
// {
|
|
|
|
|
// itemsSource.Add(item);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//valueListView.ItemsSource=itemsSource;
|
|
|
|
|
//valueListView.ItemsSource=search.ItemsSource;
|
|
|
|
|
}
|
|
|
|
|
class Search_List
|
|
|
|
|
{
|
|
|
|
|
public string key
|
2024-08-19 14:30:11 +00:00
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
public string value
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<CodeTable_Data> valueList = new ();
|
|
|
|
|
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(search.Text))
|
|
|
|
|
{
|
|
|
|
|
valueListView.ItemsSource = valueList; return; }
|
|
|
|
|
// Since selecting an item will also change the text,
|
|
|
|
|
// only listen to changes caused by user entering text.
|
|
|
|
|
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
var suitableItems = new List<Search_List>();
|
|
|
|
|
var splitText = sender.Text.ToString();
|
2024-08-19 14:30:11 +00:00
|
|
|
|
if (valueListView.ItemsSource is not List<CodeTable_Data> itemsSource) { return; }
|
2024-08-20 13:34:07 +00:00
|
|
|
|
var i = 0;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
foreach (var cat in itemsSource)
|
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
if (cat.code.Contains(splitText) || cat.translate.Contains(splitText))
|
2024-08-19 14:30:11 +00:00
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
suitableItems.Add(new Search_List
|
|
|
|
|
{
|
|
|
|
|
key=cat.code,value=cat.translate
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if (++i > 30)
|
2024-08-19 14:30:11 +00:00
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
break;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-20 13:34:07 +00:00
|
|
|
|
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))
|
2024-08-19 14:30:11 +00:00
|
|
|
|
{
|
2024-08-20 13:34:07 +00:00
|
|
|
|
itemsSource.Add(item);
|
2024-08-19 14:30:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-20 13:34:07 +00:00
|
|
|
|
valueListView.ItemsSource = itemsSource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void searchBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ctrl <20><>
|
|
|
|
|
var isCtrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control) == CoreVirtualKeyStates.Down;
|
2024-08-19 14:30:11 +00:00
|
|
|
|
|
2024-08-20 13:34:07 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> J <20><>
|
|
|
|
|
if (e.Key == VirtualKey.J && isCtrlPressed)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD> Ctrl+J <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|
|
|
|
var a = search.ItemsSource as List<Search_List>;
|
|
|
|
|
search.ItemsSource = null;
|
|
|
|
|
search.ItemsSource = a;
|
|
|
|
|
//Debug.WriteLine("Ctrl+J pressed "+ a?.Count);
|
|
|
|
|
}
|
2024-08-17 06:41:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|