48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.IO;
|
|
using Elwig.Helpers;
|
|
|
|
namespace Elwig {
|
|
public partial class App : Application {
|
|
|
|
public static bool IsPrintingReady => Documents.Html.IsReady && Documents.Pdf.IsReady;
|
|
public static System.Windows.Threading.Dispatcher MainDispatcher { get; private set; }
|
|
|
|
public App() : base() {
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
|
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Elwig"));
|
|
MainDispatcher = Dispatcher;
|
|
}
|
|
|
|
protected override void OnStartup(StartupEventArgs evt) {
|
|
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
|
Utils.RunBackground("PDF Initialization", () => Documents.Pdf.Init(PrintingReadyChanged));
|
|
base.OnStartup(evt);
|
|
}
|
|
|
|
protected override void OnExit(ExitEventArgs evt) {
|
|
Utils.RunBackground("PDF Close", () => Documents.Pdf.Close());
|
|
base.OnExit(evt);
|
|
}
|
|
|
|
private void PrintingReadyChanged() {
|
|
Dispatcher.BeginInvoke(OnPrintingReadyChanged, new EventArgs());
|
|
}
|
|
|
|
protected void OnPrintingReadyChanged(EventArgs evt) {
|
|
foreach (Window w in Windows) {
|
|
foreach (var b in Utils.FindVisualChilds<Button>(w).Where(b => "Print".Equals(b.Tag))) {
|
|
b.IsEnabled = IsPrintingReady;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|