Exemplo n.º 1
0
        private static void WindowProc(object obj)
        {
            var    args = (WindowArgs)obj;
            Window localWindow;
            var    finalResult = new PresentationResult();

            Runspace.DefaultRunspace = args.ShellRunspace;
            // trap initialization errors
            try
            {
                localWindow = NewWindow(args.WindowXaml, args.OwnerHandle);
            }
            catch (Exception ex)
            {
                // set initialization exception
                args.InitException = ex;
                args.InitHandle.Set();
                return;
            }

            // initialization complete
            // set the dispatcher
            args.AsyncResult.SetWindow(localWindow);

            args.InitHandle.Set();

            if (args.Initialize != null)
            {
                args.Initialize(localWindow);
            }

            // trap runtime exceptions
            try
            {
                finalResult.DialogResult = localWindow.ShowDialog().Value;
                finalResult.WindowTag    = localWindow.Tag;
            }
            catch (Exception ex)
            {
                // set the runtime exception to be rethrown by the stop method
                args.AsyncResult.SetException(ex);
                return;
            }
            // set the dialog result
            args.AsyncResult.SetComplete(finalResult);
        }
Exemplo n.º 2
0
 public bool Equals(PresentationResult obj)
 {
    return obj.DialogResult == DialogResult && obj.WindowTag == WindowTag;
 }
Exemplo n.º 3
0
      private static void WindowProc(object obj)
      {
         WindowArgs Args = (WindowArgs)obj;
         Window LocalWindow;
         PresentationResult FinalResult = new PresentationResult();

         Runspace.DefaultRunspace = Args.ShellRunspace;
         // trap initialization errors
         try
         {
            LocalWindow = NewWindow(Args.WindowXaml, Args.OwnerHandle);
         }
         catch (Exception ex)
         {
            // set initialization exception
            Args.InitException = ex;
            Args.InitHandle.Set();
            return;
         }

         // initialization complete
         // set the dispatcher
         Args.AsyncResult.SetWindow(LocalWindow);

         Args.InitHandle.Set();

         if (Args.Initialize != null)
         {
            Args.Initialize(LocalWindow);
         }

         // trap runtime exceptions
         try
         {
            FinalResult.DialogResult = LocalWindow.ShowDialog().Value;
            FinalResult.WindowTag = LocalWindow.Tag;
         }
         catch (Exception ex)
         {
            // set the runtime exception to be rethrown by the stop method
            Args.AsyncResult.SetException(ex);
            return;
         }
         // set the dialog result
         Args.AsyncResult.SetComplete(FinalResult);
      }
Exemplo n.º 4
0
 /// <summary> used to set the result when the window is closed</summary>
 internal void SetComplete(PresentationResult result)
 {
    DialogResult = result;
    Completed = true;
    DoneHandle.Set();
 }
Exemplo n.º 5
0
        private static void WindowProc(object obj)
        {
            var args = (WindowArgs)obj;
            Window localWindow;
            var finalResult = new PresentationResult();

            Runspace.DefaultRunspace = args.ShellRunspace;
            // trap initialization errors
            try
            {
                localWindow = NewWindow(args.WindowXaml, args.OwnerHandle);
            }
            catch (Exception ex)
            {
                // set initialization exception
                args.InitException = ex;
                args.InitHandle.Set();
                return;
            }

            // initialization complete
            // set the dispatcher
            args.AsyncResult.SetWindow(localWindow);

            args.InitHandle.Set();

            if (args.Initialize != null)
            {
                args.Initialize(localWindow);
            }

            // trap runtime exceptions
            try
            {
                finalResult.DialogResult = localWindow.ShowDialog().Value;
                finalResult.WindowTag = localWindow.Tag;
            }
            catch (Exception ex)
            {
                // set the runtime exception to be rethrown by the stop method
                args.AsyncResult.SetException(ex);
                return;
            }
            // set the dialog result
            args.AsyncResult.SetComplete(finalResult);
        }
Exemplo n.º 6
0
 public bool Equals(PresentationResult obj)
 {
     return(obj.DialogResult == DialogResult && obj.WindowTag == WindowTag);
 }
Exemplo n.º 7
0
 /// <summary> used to set the result when the window is closed</summary>
 internal void SetComplete(PresentationResult result)
 {
     DialogResult = result;
     Completed    = true;
     DoneHandle.Set();
 }