Rename solution directory to Elwig
This commit is contained in:
47
Elwig/App.xaml.cs
Normal file
47
Elwig/App.xaml.cs
Normal file
@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user