2024-08-13 10:47:12 +00:00
|
|
|
|
using System;
|
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;
|
2024-08-13 10:47:12 +00:00
|
|
|
|
using System.Reflection;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
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-13 10:47:12 +00:00
|
|
|
|
private readonly ObservableCollection<TabViewItem> TabViewList = 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-11 11:16:42 +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-13 10:47:12 +00:00
|
|
|
|
private ContentDialog? ClosedDialog = null;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
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-13 10:47:12 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ѡ<><D1A1><EFBFBD>¼<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
private void TreeView_ItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs e)
|
2024-08-09 07:05:40 +00:00
|
|
|
|
{
|
2024-08-13 10:47:12 +00:00
|
|
|
|
|
2024-08-09 07:05:40 +00:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-13 10:47:12 +00:00
|
|
|
|
var invokedItem = e.InvokedItem;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-13 10:47:12 +00:00
|
|
|
|
|
|
|
|
|
private void TabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args)
|
2024-08-09 07:05:40 +00:00
|
|
|
|
{
|
2024-08-13 10:47:12 +00:00
|
|
|
|
TabViewList.Remove(args.Tab);
|
2024-08-09 07:05:40 +00:00
|
|
|
|
}
|
2024-08-13 10:47:12 +00:00
|
|
|
|
|
2024-08-09 07:05:40 +00:00
|
|
|
|
/// <summary>
|
2024-08-13 10:47:12 +00:00
|
|
|
|
/// ˫<><CBAB><EFBFBD>¼<EFBFBD>
|
2024-08-09 07:05:40 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-08-13 10:47:12 +00:00
|
|
|
|
private void treeView_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
|
2024-08-09 07:05:40 +00:00
|
|
|
|
{
|
2024-08-13 10:47:12 +00:00
|
|
|
|
gj.sc(e.OriginalSource);
|
|
|
|
|
var treeViewItem = e.OriginalSource as Grid;
|
|
|
|
|
if (treeViewItem == null) { return; }
|
|
|
|
|
if (treeViewItem.DataContext is not ExplorerItem explorerItem) { return; }
|
|
|
|
|
if (explorerItem.Type == ExplorerItem.ExplorerItemType.File)
|
2024-08-09 07:05:40 +00:00
|
|
|
|
{
|
2024-08-13 10:47:12 +00:00
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD> TabViewItem
|
|
|
|
|
var tabViewItemToFind = TabViewList.FirstOrDefault(item => (item as TabViewItem)?.Tag.ToString() == explorerItem.Dir) as TabViewItem;
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ TabViewItem <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
if (tabViewItemToFind != null)
|
2024-08-09 07:05:40 +00:00
|
|
|
|
{
|
2024-08-13 10:47:12 +00:00
|
|
|
|
tabview.SelectedIndex = TabViewList.IndexOf(tabViewItemToFind);
|
|
|
|
|
return;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
}
|
2024-08-13 10:47:12 +00:00
|
|
|
|
var fileInfo = new FileInfo(explorerItem.Dir);
|
|
|
|
|
//var name = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
|
|
|
|
var newItem = new TabViewItem()
|
|
|
|
|
{
|
|
|
|
|
Tag = explorerItem.Dir,
|
|
|
|
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>
|
|
|
|
|
Header = fileInfo.Name,
|
|
|
|
|
IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }
|
|
|
|
|
};
|
|
|
|
|
//if(tabview.TabItems.)
|
|
|
|
|
var v = wj.dqwb(explorerItem.Dir);
|
|
|
|
|
var textControlBox = new RichEditBox();
|
|
|
|
|
//textControlBox.Height = Height;
|
|
|
|
|
textControlBox.Document.SetText(Microsoft.UI.Text.TextSetOptions.None, v);
|
|
|
|
|
newItem.Content = textControlBox;
|
|
|
|
|
TabViewList.Insert(0, newItem);
|
|
|
|
|
tabview.SelectedIndex = 0;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|