예제 #1
0
        /// <summary>
        /// Static constructor
        /// </summary>
        static DefaultDialogManager()
        {
            DefaultDialogManager.Lock = new object();

            if (Application.Current is null)
            {
                System.Diagnostics.Trace.WriteLine($"ERROR: The {nameof(DefaultDialogManager)} could not be initialized because {nameof(Application)}.{nameof(Application.Current)} is null. This can happen when running unit tests.");
                return;
            }

            // Attach to the applications activated event, so that an reference to its main window can be obtained once it is available.
            Application.Current.Activated += DefaultDialogManager.HandleApplicationActivated;

            // Try to get a reference to the applications main window regardless of the activation event (it could have been fired already).
            DefaultDialogManager.MainWindow = DefaultDialogManager.GetMainWindow();
        }
예제 #2
0
 /// <summary>
 /// Handler for the current applications <see cref="Application.Activated"/> event.
 /// </summary>
 private static void HandleApplicationActivated(object sender, EventArgs args)
 {
     // Try to get a reference to the applications main window.
     DefaultDialogManager.MainWindow = DefaultDialogManager.GetMainWindow();
 }