2024-08-09 07:05:40 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using System.ComponentModel;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection.Metadata;
|
2024-08-11 11:16:42 +00:00
|
|
|
|
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
using Microsoft.UI.Xaml.Documents;
|
|
|
|
|
using Microsoft.UI.Xaml.Input;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using RustTools.muqing;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
using Windows.ApplicationModel.DataTransfer;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using WinRT.Interop;
|
|
|
|
|
namespace RustTools.Editor;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class EditorWin : WindowEx
|
|
|
|
|
{
|
2024-08-11 11:16:42 +00:00
|
|
|
|
|
|
|
|
|
private readonly ObservableCollection<string> lineNumberList = new();
|
2024-08-09 07:05:40 +00:00
|
|
|
|
//Ŀ¼<C4BF>б<EFBFBD>
|
|
|
|
|
public ObservableCollection<ExplorerItem> DataSource=new ();
|
2024-08-08 09:29:19 +00:00
|
|
|
|
public EditorWin()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
gj.SetBackTheme(this);
|
|
|
|
|
ExtendsContentIntoTitleBar = true;
|
|
|
|
|
var frame = App.AppTitlebar as FrameworkElement;
|
|
|
|
|
if (frame != null)
|
|
|
|
|
{
|
|
|
|
|
gj.UpdateTitleBar(this, frame.ActualTheme);
|
2024-08-09 07:05:40 +00:00
|
|
|
|
page.RequestedTheme = frame.ActualTheme;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|
2024-08-11 11:16:42 +00:00
|
|
|
|
//new CodeEditorControl();
|
|
|
|
|
//new Editor.
|
2024-08-08 09:29:19 +00:00
|
|
|
|
//WindowManager.Get(this).IsMinimizable = false;
|
|
|
|
|
//app = GetAppWindowForCurrentWindow();
|
|
|
|
|
//app.Closing += OnClosing;
|
|
|
|
|
//Closed += EditorWin_Closed;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
var directoryInfo = new DirectoryInfo("D:\\steam\\steamapps\\common\\Rusted Warfare\\mods\\units\\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><CFBD><EFBFBD>0.9<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.2");
|
|
|
|
|
DataSource = new EditorLoad().GetData(directoryInfo.FullName);
|
|
|
|
|
Title=directoryInfo.Name;
|
|
|
|
|
TitleText.Text = directoryInfo.Name;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
Closed += EditorWin_Closed;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
var v = wj.dqwb("D:\\steam\\steamapps\\common\\Rusted Warfare\\mods\\units\\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><CFBD><EFBFBD>0.9<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.2\\<5C><>ʴ<EFBFBD>߹<EFBFBD><DFB9><EFBFBD>\\ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\\corrode_command.ini");
|
2024-08-11 11:16:42 +00:00
|
|
|
|
editor.Document.SetText(Microsoft.UI.Text.TextSetOptions.None,v);
|
2024-08-08 09:29:19 +00:00
|
|
|
|
|
2024-08-11 11:16:42 +00:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//listboxtext
|
|
|
|
|
gj.sc(editor.Document.Selection.CharacterFormat.Size);
|
|
|
|
|
TextLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void editor_TextChanged(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TextLine();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void TextLine()
|
|
|
|
|
{
|
|
|
|
|
lineNumberList.Clear();
|
|
|
|
|
editor.Document.GetText(Microsoft.UI.Text.TextGetOptions.NoHidden, out var a);
|
|
|
|
|
var lineCount = a.Split(new[] { "\r\n", "\n", "\r" }, StringSplitOptions.None).Length;
|
|
|
|
|
if (lineCount < 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (var i = 1; i <= lineCount; i++)
|
|
|
|
|
{
|
|
|
|
|
lineNumberList.Add((i).ToString());
|
|
|
|
|
}
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|
2024-08-09 07:05:40 +00:00
|
|
|
|
|
2024-08-08 09:29:19 +00:00
|
|
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
2024-08-11 11:16:42 +00:00
|
|
|
|
private bool IsSave = true;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
private ContentDialog? ClosedDialog;
|
|
|
|
|
private async void EditorWin_Closed(object sender, WindowEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (IsSave == false)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ֹ<EFBFBD><D6B9><EFBFBD>ڹر<DAB9>
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
if (ClosedDialog != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// <20><>ʾһ<CABE><D2BB><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>֪<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2>ܹر<DCB9>
|
|
|
|
|
ClosedDialog = new ContentDialog
|
|
|
|
|
{
|
2024-08-09 07:05:40 +00:00
|
|
|
|
XamlRoot = page.XamlRoot,
|
2024-08-08 09:29:19 +00:00
|
|
|
|
Title = "<22><><EFBFBD><EFBFBD>",
|
|
|
|
|
Content = "<22>㻹<EFBFBD><E3BBB9>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>",
|
|
|
|
|
PrimaryButtonText = "<22><><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>",
|
|
|
|
|
PrimaryButtonStyle = Application.Current.Resources["AccentButtonStyle"] as Style,
|
|
|
|
|
SecondaryButtonText = "ֱ<>ӹر<D3B9>",
|
|
|
|
|
CloseButtonText = "ȡ<><C8A1>"
|
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Microsoft.UI.Windowing.AppWindow GetAppWindowForCurrentWindow()
|
|
|
|
|
{
|
|
|
|
|
var hWnd = WindowNative.GetWindowHandle(this);
|
|
|
|
|
var myWndId = Win32Interop.GetWindowIdFromWindow(hWnd);
|
|
|
|
|
return Microsoft.UI.Windowing.AppWindow.GetFromWindowId(myWndId);
|
|
|
|
|
}
|
2024-08-09 07:05:40 +00:00
|
|
|
|
private void TreeView_ItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var invokedItem = args.InvokedItem;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ظ<EFBFBD>ѡ<EFBFBD><D1A1>
|
|
|
|
|
if (sender.SelectedItem is ExplorerItem selectedItem && invokedItem != null && selectedItem == invokedItem)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD>ֱ<EEA3AC>ӷ<EFBFBD><D3B7>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (invokedItem is not ExplorerItem explorerItem)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (explorerItem.Type == ExplorerItem.ExplorerItemType.Folder)
|
|
|
|
|
{
|
|
|
|
|
var directoryInfo = new DirectoryInfo(explorerItem.Dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TreeView_DragItemsStarting(TreeView sender, TreeViewDragItemsStartingEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel = true;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var items = args.Items.Cast<ExplorerItem>();
|
|
|
|
|
var v = items.ToList()[0];
|
|
|
|
|
args.Data.SetData("TreeViewItems", v.Dir);
|
|
|
|
|
args.Data.RequestedOperation = DataPackageOperation.Move;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>϶<EFBFBD><CFB6><EFBFBD>Ŀ<EFBFBD><C4BF>ͣ<EFBFBD><CDA3> TreeView <20><>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD>ṩ<EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void TreeView_DragOver(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> "TreeViewItems" <20><><EFBFBD><EFBFBD>
|
|
|
|
|
gj.sc("aaaaaa");
|
|
|
|
|
if (e.DataView.Contains("TreeViewItems"))
|
|
|
|
|
{
|
|
|
|
|
e.AcceptedOperation = DataPackageOperation.Move; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ϸ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gj.sc("No");
|
|
|
|
|
e.AcceptedOperation = DataPackageOperation.None; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϷŲ<CFB7><C5B2><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>µ<EFBFBD>λ<EFBFBD>á<EFBFBD>
|
|
|
|
|
private async void TreeView_Drop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
gj.sc(e);
|
|
|
|
|
// <20><>ȡ<EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (e.DataView.Contains("TreeViewItems"))
|
|
|
|
|
{
|
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
|
|
|
|
if (await e.DataView.GetDataAsync("TreeViewItems") is string Dir)
|
|
|
|
|
{
|
|
|
|
|
gj.sc(Dir);
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD> TreeViewItem
|
|
|
|
|
var treeView = sender as TreeView;
|
|
|
|
|
ExplorerItem v = treeView.DataContext is ExplorerItem;
|
|
|
|
|
//var dropPosition = e.GetPosition(treeView);
|
|
|
|
|
//data.Name
|
|
|
|
|
gj.sc(v.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IList<object> initialSelectedItems;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>shift<66><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ״̬
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void treeView_KeyDown(object sender, KeyRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Shift<66><74>
|
|
|
|
|
if (e.Key == Windows.System.VirtualKey.Shift)
|
|
|
|
|
{
|
|
|
|
|
gj.sc(e.Key);
|
|
|
|
|
// <20><><EFBFBD>ö<EFBFBD>ѡģʽ
|
|
|
|
|
treeView.SelectionMode = TreeViewSelectionMode.Multiple;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void treeView_KeyUp(object sender, KeyRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɿ<EFBFBD><C9BF><EFBFBD>Shift<66><74>
|
|
|
|
|
if (e.Key == Windows.System.VirtualKey.Shift)
|
|
|
|
|
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ѡģʽ<C4A3><CABD>ѡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>Ŀ
|
|
|
|
|
var selectedItems = treeView.SelectedItems.ToList();
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
{
|
|
|
|
|
treeView.SelectedItems.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
gj.sc("ȡ<><C8A1>");
|
|
|
|
|
// ȡ<><C8A1><EFBFBD><EFBFBD>ѡģʽ
|
|
|
|
|
treeView.SelectionMode = TreeViewSelectionMode.Single;
|
|
|
|
|
//treeView.SelectedItems.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
sender.TabItems.Remove(args.Tab);
|
|
|
|
|
}
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|