init
This commit is contained in:
71
DataPRO/Modules/DatabaseImporter/DatabaseImport/App/App.cs
Normal file
71
DataPRO/Modules/DatabaseImporter/DatabaseImport/App/App.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
private static ISO13499FileDb _isoDb;
|
||||
public ISO13499FileDb IsoDb
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != _isoDb) return _isoDb;
|
||||
_isoDb = new ISO13499FileDb();
|
||||
_isoDb.RefreshAllData();
|
||||
return _isoDb;
|
||||
}
|
||||
}
|
||||
// Delegate for SetAppBusy and SetAppAvailable
|
||||
private delegate void SetAppBusyAvailableDelegate();
|
||||
|
||||
// WaitCursor for SetAppBusy and SetAppAvailable
|
||||
private WaitCursor _wc;
|
||||
|
||||
private static readonly object WaitCursorLock = new object();
|
||||
// // Apply WaitCursor and disable application
|
||||
// // recommend use before a try statement
|
||||
public void SetAppBusy()
|
||||
{
|
||||
//Can We access
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new SetAppBusyAvailableDelegate(SetAppBusy));
|
||||
return;
|
||||
}
|
||||
if (null == MainWindow) return;
|
||||
lock (WaitCursorLock)
|
||||
{
|
||||
if (null != _wc) { _wc.Dispose(); }
|
||||
//Init WaitCursor
|
||||
_wc = new WaitCursor();
|
||||
//Enable App
|
||||
MainWindow.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply normal cursor and enable application
|
||||
// recommend use in a finally statement
|
||||
public void SetAppAvailable()
|
||||
{
|
||||
//Can We access
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new SetAppBusyAvailableDelegate(SetAppAvailable));
|
||||
return;
|
||||
}
|
||||
if (null == MainWindow) return;
|
||||
lock (WaitCursorLock)
|
||||
{
|
||||
//Dispose WaitCursor
|
||||
if (null != _wc) { _wc.Dispose(); _wc = null; }
|
||||
|
||||
//Enable App
|
||||
MainWindow.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user