修
This commit is contained in:
parent
c3a41c0d4e
commit
5b907309e0
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace AnotherReplayReader
|
namespace AnotherReplayReader
|
||||||
@ -20,12 +21,15 @@ namespace AnotherReplayReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action<string> NewText;
|
public event Action<string>? NewText;
|
||||||
public Proxy DebugMessage
|
public Proxy DebugMessage
|
||||||
{
|
{
|
||||||
get => new Proxy();
|
get => new Proxy();
|
||||||
set => NewText?.Invoke(value.Payload);
|
set => NewText?.Invoke(value.Payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event Action? RequestedSave;
|
||||||
|
public void RequestSave() => RequestedSave?.Invoke();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Debug.xaml 的交互逻辑
|
/// Debug.xaml 的交互逻辑
|
||||||
@ -33,14 +37,31 @@ namespace AnotherReplayReader
|
|||||||
public sealed partial class Debug : Window
|
public sealed partial class Debug : Window
|
||||||
{
|
{
|
||||||
public static readonly DebugMessageWrapper Instance = new DebugMessageWrapper();
|
public static readonly DebugMessageWrapper Instance = new DebugMessageWrapper();
|
||||||
|
private static Debug? _window = null;
|
||||||
|
|
||||||
public Debug()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
Interlocked.CompareExchange(ref _window, new(), null);
|
||||||
Instance.NewText += t => Dispatcher.Invoke(() => _textBox.AppendText(t));
|
_window.InitializeComponent();
|
||||||
|
Instance.NewText += _window.AppendText;
|
||||||
|
Instance.RequestedSave += _window.ExportInMainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExport_Click(object sender, RoutedEventArgs e)
|
public static new void ShowDialog() => (_window as Window)?.ShowDialog();
|
||||||
|
|
||||||
|
private Debug() { }
|
||||||
|
|
||||||
|
private void OnExport_Click(object sender, RoutedEventArgs e) => Export(this);
|
||||||
|
|
||||||
|
private void OnClear_Click(object sender, RoutedEventArgs e) => _textBox.Clear();
|
||||||
|
|
||||||
|
private void AppendText(string s) => Dispatcher.Invoke(() => _textBox.AppendText(s));
|
||||||
|
|
||||||
|
private void ExportInMainWindow() => Export(Application.Current.MainWindow);
|
||||||
|
|
||||||
|
private void Export(Window owner)
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
var saveFileDialog = new SaveFileDialog
|
var saveFileDialog = new SaveFileDialog
|
||||||
{
|
{
|
||||||
@ -48,7 +69,7 @@ namespace AnotherReplayReader
|
|||||||
OverwritePrompt = true,
|
OverwritePrompt = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = saveFileDialog.ShowDialog(this);
|
var result = saveFileDialog.ShowDialog(owner);
|
||||||
if (result == true)
|
if (result == true)
|
||||||
{
|
{
|
||||||
using (var file = saveFileDialog.OpenFile())
|
using (var file = saveFileDialog.OpenFile())
|
||||||
@ -57,11 +78,7 @@ namespace AnotherReplayReader
|
|||||||
writer.Write(_textBox.Text);
|
writer.Write(_textBox.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
private void OnClear_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
_textBox.Clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,11 +492,7 @@ namespace AnotherReplayReader
|
|||||||
detailsWindow.ShowDialog();
|
detailsWindow.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDebugButton_Click(object sender, RoutedEventArgs e)
|
private void OnDebugButton_Click(object sender, RoutedEventArgs e) => Debug.ShowDialog();
|
||||||
{
|
|
||||||
var debug = new Debug();
|
|
||||||
debug.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPlayReplayButton_Click(object sender, RoutedEventArgs e)
|
private void OnPlayReplayButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user