mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using ServerManagerTool.Common.Utils;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
using WPFSharp.Globalizer;
|
|
|
|
namespace ServerManagerTool
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ProgressWindow.xaml
|
|
/// </summary>
|
|
public partial class ProgressWindow : Window
|
|
{
|
|
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
|
private bool _allowClose = false;
|
|
|
|
public ProgressWindow(string windowTitle)
|
|
{
|
|
InitializeComponent();
|
|
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
|
|
|
if (!string.IsNullOrWhiteSpace(windowTitle))
|
|
Title = windowTitle;
|
|
Application.Current.Dispatcher.Invoke(() => MessageOutput.Cursor = System.Windows.Input.Cursors.Wait);
|
|
|
|
_allowClose = false;
|
|
this.DataContext = this;
|
|
}
|
|
|
|
public void AddMessage(string message, bool includeNewLine = true)
|
|
{
|
|
MessageOutput.AppendText(message);
|
|
if (includeNewLine)
|
|
MessageOutput.AppendText(Environment.NewLine);
|
|
MessageOutput.ScrollToEnd();
|
|
|
|
Debug.WriteLine(message);
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
Application.Current.Dispatcher.Invoke(() => MessageOutput.Cursor = null);
|
|
|
|
_allowClose = true;
|
|
}
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
if (!_allowClose)
|
|
e.Cancel = true;
|
|
}
|
|
}
|
|
}
|