100 lines
2.9 KiB
C#
100 lines
2.9 KiB
C#
|
using System.ComponentModel;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
using Microsoft.UI;
|
|||
|
using Microsoft.UI.Windowing;
|
|||
|
using Microsoft.UI.Xaml;
|
|||
|
using Microsoft.UI.Xaml.Controls;
|
|||
|
using RustTools.muqing;
|
|||
|
using Windows.ApplicationModel.Core;
|
|||
|
using Windows.Foundation;
|
|||
|
using Windows.UI.Core.Preview;
|
|||
|
using Windows.UI.Popups;
|
|||
|
using Windows.UI.WindowManagement;
|
|||
|
using WinRT.Interop;
|
|||
|
namespace RustTools.Editor;
|
|||
|
/// <summary>
|
|||
|
/// <20>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
public sealed partial class EditorWin : WindowEx
|
|||
|
{
|
|||
|
|
|||
|
private Microsoft.UI.Windowing.AppWindow? app;
|
|||
|
public EditorWin()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
gj.SetBackTheme(this);
|
|||
|
ExtendsContentIntoTitleBar = true;
|
|||
|
var frame = App.AppTitlebar as FrameworkElement;
|
|||
|
if (frame != null)
|
|||
|
{
|
|||
|
gj.UpdateTitleBar(this, frame.ActualTheme);
|
|||
|
grid.RequestedTheme = frame.ActualTheme;
|
|||
|
}
|
|||
|
|
|||
|
//WindowManager.Get(this).IsMinimizable = false;
|
|||
|
//WindowManager.Get(this).IsMaximizable = false;
|
|||
|
//WindowManager.Get(this).IsResizable = false;
|
|||
|
//WindowManager.Get(this).IsAlwaysOnTop = false;
|
|||
|
//WindowManager.Get(this).IsTitleBarVisible = false;
|
|||
|
|
|||
|
|
|||
|
//app = GetAppWindowForCurrentWindow();
|
|||
|
//app.Closing += OnClosing;
|
|||
|
//Closed += EditorWin_Closed;
|
|||
|
|
|||
|
Closed += EditorWin_Closed;
|
|||
|
}
|
|||
|
|
|||
|
private async Task SaveDataAsync()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
//<2F>û<EFBFBD><C3BB><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
private bool IsSave = false;
|
|||
|
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
|
|||
|
{
|
|||
|
XamlRoot = grid.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();
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|