117 lines
4.3 KiB
C#
117 lines
4.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace HashCalculator.GUI
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
var x = new ModXml(@"D:\Users\lanyi\Desktop\RA3Mods\ARSDK2\Mods\Armor Rush\DATA\mod.xml");
|
|
var xxx = Enumerable.Repeat(new { AssetId = "正在准备", Hash = "正在准备" }, 1);
|
|
x.ProcessDocument().ContinueWith(async txx =>
|
|
{
|
|
try
|
|
{
|
|
var xx = await txx.ConfigureAwait(true);
|
|
if (x.Errors.Any())
|
|
{
|
|
MessageBox.Show("Errors: \r\n" + x.Errors.Aggregate((x, y) => $"{x}\r\n{y}"));
|
|
}
|
|
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
DataGrid.ItemsSource = from y in xx
|
|
select new { AssetId = $"{y.Type}:{y.Name}", y.Hash };
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
DataGrid.ItemsSource = Enumerable.Repeat(new { AssetId = $"错误 {e}", Hash = e.ToString() }, 1);
|
|
});
|
|
}
|
|
}, TaskScheduler.Default);
|
|
|
|
/*_ = Task.Run(async () =>
|
|
{
|
|
var xxx = Enumerable.Repeat(new { AssetId = "正在准备", Hash = "正在准备" }, 1);
|
|
await Dispatcher.Invoke(async () =>
|
|
{
|
|
try
|
|
{
|
|
var xx = await x.ProcessDocument().ConfigureAwait(true);
|
|
DataGrid.ItemsSource = from y in xx
|
|
select new { AssetId = $"{y.Type}:{y.Name}", y.Hash };
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
DataGrid.ItemsSource = Enumerable.Repeat(new { AssetId = $"错误 {e}", Hash = e.ToString() }, 1);
|
|
}
|
|
|
|
}).ConfigureAwait(true);
|
|
});*/
|
|
}
|
|
|
|
private void OnMainInputTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
/*var mainInput = _viewModel.MainInput;
|
|
if (sender is InputBar)
|
|
{
|
|
var inputValue = mainInput.Text;
|
|
if(inputValue != null)
|
|
{
|
|
mainInput.Items = _suggestions.ProvideFileSystemSuggestions(inputValue)
|
|
.Prepend(new InputEntry(InputEntryType.Text, inputValue, inputValue));
|
|
}
|
|
}*/
|
|
}
|
|
|
|
private void OnBigInputTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
/*var mainInput = _viewModel.MainInput;
|
|
if (sender is InputBar)
|
|
{
|
|
var inputValue = mainInput.Text;
|
|
if (inputValue != null)
|
|
{
|
|
mainInput.Items = _suggestions.ProvideFileSystemSuggestions(inputValue)
|
|
.Prepend(new InputEntry(InputEntryType.Text, inputValue, inputValue));
|
|
}
|
|
}*/
|
|
}
|
|
|
|
private void OnAssetInputTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
/*var mainInput = _viewModel.MainInput;
|
|
if (sender is InputBar)
|
|
{
|
|
var inputValue = mainInput.Text;
|
|
if (inputValue != null)
|
|
{
|
|
mainInput.Items = _suggestions.ProvideFileSystemSuggestions(inputValue)
|
|
.Prepend(new InputEntry(InputEntryType.Text, inputValue, inputValue));
|
|
}
|
|
}*/
|
|
}
|
|
}
|
|
}
|