Пример #1
0
        private static void DisplayMessageInternal(Window owner, string title, HResult hr, bool isTheHresultAWarning, string errorPreamble, Action postAction)
        {
            if (instance == null)
            {
                var dialog = new StatusDialog(owner, title, null, hr, null, errorPreamble, postAction);
                if (isTheHresultAWarning)
                {
                    dialog.SwitchToError(hr, true);
                }
                dialog.ShowDialog();
            }
            else
            {
                if (instance.additionalMessages == null)
                {
                    instance.additionalMessages = new Queue <MessageNode>();
                }

                var newMessage = new MessageNode
                {
                    Preamble         = errorPreamble ?? StringResources.UnknownErrorOccurred,
                    Result           = hr,
                    PostAction       = postAction,
                    IsWarningMessage = isTheHresultAWarning,
                };
                instance.additionalMessages.Enqueue(newMessage);
            }
        }
Пример #2
0
        protected override void OnClosed(EventArgs e)
        {
            instance = null;
            if (reportProgress != null)
            {
                reportProgress.Progress -= OnProgressReport;
                reportProgress           = null;
            }

            base.OnClosed(e);
        }
Пример #3
0
        private StatusDialog(Window owner, string title, BackgroundRequest request, HResult hr, string message, string errorPreamble, Action postAction)
        {
            instance = this;

            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.Owner                = owner;
            this.Title                = title;
            this.ErrorStatus          = new ErrorStatus();
            this.ErrorStatus.Preamble = message;
            this.ErrorStatus.SetStatus(ErrorSeverity.Info, null, null);

            this.request         = request;
            this.reportProgress  = request as IReportProgress;
            this.DataContext     = this;
            this.originalMessage = message;

            this.currentMessage = new MessageNode
            {
                Preamble   = errorPreamble ?? StringResources.UnknownErrorOccurred,
                PostAction = postAction
            };

            InitializeComponent();

            if (request != null)
            {
                request.Dispatched += OnRequestDispatched;

                if (reportProgress != null)
                {
                    reportProgress.Progress += OnProgressReport;
                }

                if (request.IsDispatchComplete)
                {
                    // We were asked to wait on a request that has already been dispatched.  Simulate notification
                    // of the dispatch.  Can't call it directly because Close() right now is bad news.
                    this.Dispatcher.BeginInvoke((Action)(() => { this.OnRequestDispatched(request, EventArgs.Empty); }), DispatcherPriority.Background);
                }
            }
            else
            {
                SwitchToError(hr, false);
            }

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopyExecuted));
        }
        private StatusDialog(Window owner, string title, BackgroundRequest request, HResult hr, string message, string errorPreamble, Action postAction)
        {
            instance = this;

            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.Owner = owner;
            this.Title = title;
            this.ErrorStatus = new ErrorStatus();
            this.ErrorStatus.Preamble = message;
            this.ErrorStatus.SetStatus(ErrorSeverity.Info, null, null);

            this.request = request;
            this.reportProgress = request as IReportProgress;
            this.DataContext = this;
            this.originalMessage = message;

            this.currentMessage = new MessageNode
            {
                Preamble = errorPreamble ?? StringResources.UnknownErrorOccurred,
                PostAction = postAction
            };

            InitializeComponent();

            if (request != null)
            {
                request.Dispatched += OnRequestDispatched;

                if (reportProgress != null)
                {
                    reportProgress.Progress += OnProgressReport;
                }

                if (request.IsDispatchComplete)
                {
                    // We were asked to wait on a request that has already been dispatched.  Simulate notification
                    // of the dispatch.  Can't call it directly because Close() right now is bad news.
                    this.Dispatcher.BeginInvoke((Action)(() => { this.OnRequestDispatched(request, EventArgs.Empty); }), DispatcherPriority.Background);
                }
            }
            else
            {
                SwitchToError(hr, false);
            }

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, OnCopyExecuted));
        }
        private static void DisplayMessageInternal(Window owner, string title, HResult hr, bool isTheHresultAWarning, string errorPreamble, Action postAction)
        {
            if (instance == null)
            {
                var dialog = new StatusDialog(owner, title, null, hr, null, errorPreamble, postAction);
                if (isTheHresultAWarning)
                {
                    dialog.SwitchToError(hr, true);
                }
                dialog.ShowDialog();
            }
            else
            {
                if (instance.additionalMessages == null)
                {
                    instance.additionalMessages = new Queue<MessageNode>();
                }

                var newMessage = new MessageNode
                {
                    Preamble = errorPreamble ?? StringResources.UnknownErrorOccurred,
                    Result = hr,
                    PostAction = postAction,
                    IsWarningMessage = isTheHresultAWarning,
                };
                instance.additionalMessages.Enqueue(newMessage);
            }
        }
        protected override void OnClosed(EventArgs e)
        {
            instance = null;
            if (reportProgress != null)
            {
                reportProgress.Progress -= OnProgressReport;
                reportProgress = null;
            }

            base.OnClosed(e);
        }