2024-08-09 07:05:40 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2025-01-16 06:27:07 +00:00
|
|
|
|
using System.Diagnostics;
|
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.Input;
|
2025-01-21 11:26:04 +00:00
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using RustTools.muqing;
|
|
|
|
|
using WinRT.Interop;
|
2025-01-21 11:26:04 +00:00
|
|
|
|
using WinUIEditor;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
namespace RustTools.Editor;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class EditorWin : WindowEx
|
|
|
|
|
{
|
2025-01-16 07:23:37 +00:00
|
|
|
|
public static ObservableCollection<TabViewItem> TabViewList = new();
|
2024-08-09 07:05:40 +00:00
|
|
|
|
//Ŀ¼<C4BF>б<EFBFBD>
|
2025-01-16 06:27:07 +00:00
|
|
|
|
public ObservableCollection<FileItem> DataSource = new();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
public EditorWin(string path)
|
2024-08-08 09:29:19 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
}
|
2025-01-16 06:27:07 +00:00
|
|
|
|
//Debug.WriteLine(path);
|
|
|
|
|
var directoryInfo = new DirectoryInfo(path);
|
2024-08-15 01:40:33 +00:00
|
|
|
|
Title = directoryInfo.Name;
|
2024-08-09 07:05:40 +00:00
|
|
|
|
TitleText.Text = directoryInfo.Name;
|
2025-01-16 06:27:07 +00:00
|
|
|
|
DataSource = EditorLoad.GetData(directoryInfo.FullName);
|
|
|
|
|
treeView.ItemsSource = DataSource;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
Closed += EditorWin_Closed;
|
2025-01-21 11:26:04 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>TabView<65>ĸ߶<C4B8>
|
|
|
|
|
gridedit.SizeChanged += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
tabview.Height = gridedit.ActualHeight - 10;
|
|
|
|
|
};
|
2025-01-16 07:23:37 +00:00
|
|
|
|
|
2025-01-21 11:26:04 +00:00
|
|
|
|
tabview.TabItemsSource = TabViewList;
|
|
|
|
|
treeView.AddTabItem += TreeView_AddTabItem;
|
2024-08-11 11:16:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 11:26:04 +00:00
|
|
|
|
private void TreeView_AddTabItem(TabViewItem obj,CodeEditorControl codeEditorControl){
|
|
|
|
|
tabview.SelectedItem = obj;
|
|
|
|
|
var title = obj.Header.ToString();
|
|
|
|
|
codeEditorControl.Editor.UpdateUI += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7>п<EFBFBD><D0BF>Գ<EFBFBD><D4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼
|
|
|
|
|
var a = codeEditorControl.Editor.CanUndo();
|
|
|
|
|
|
|
|
|
|
if (a)
|
|
|
|
|
{
|
|
|
|
|
obj.Header = $"{title} *";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
obj.Header = title;
|
|
|
|
|
}
|
|
|
|
|
Debug.WriteLine($"UpdateUI :" + a);
|
|
|
|
|
};
|
|
|
|
|
}
|
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;
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
if (ClosedDialog != null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// <20><>ʾһ<CABE><D2BB><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>֪<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2>ܹر<DCB9>
|
|
|
|
|
ClosedDialog = new ContentDialog
|
|
|
|
|
{
|
|
|
|
|
XamlRoot = page.XamlRoot,
|
|
|
|
|
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();
|
2024-08-08 09:29:19 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
else if (result == ContentDialogResult.Secondary)
|
|
|
|
|
{
|
2024-08-08 09:29:19 +00:00
|
|
|
|
|
2024-08-15 01:40:33 +00:00
|
|
|
|
IsSave = true;
|
|
|
|
|
Application.Current.Exit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ClosedDialog = null;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|
2025-01-16 11:22:27 +00:00
|
|
|
|
// <20>ر<EFBFBD>ѡ<EFBFBD>
|
|
|
|
|
private void MyTabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Tab is TabViewItem tab)
|
|
|
|
|
{
|
|
|
|
|
TabViewList.Remove(tab);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-08 09:29:19 +00:00
|
|
|
|
}
|