Пример #1
0
        private void ShowError(string messageId, string message)
        {
            messageId = messageId.Replace(Environment.NewLine, string.Empty);// remove newlines to ease persistence

            if (!m_suppressedMessages.Contains(messageId))
            {
                if (Application.Current.MainWindow != null &&
                    Application.Current.MainWindow.IsLoaded)
                {
                    var dlg = new ErrorDialog();

                    var vm = new ErrorDialogViewModel();
                    vm.Message = message;
                    dlg.DataContext = vm;
                    dlg.Owner = Application.Current.MainWindow;
                    dlg.ShowDialog();

                    if (vm.SuppressMessage)
                    {
                        m_suppressedMessages.Add(messageId);
                    }
                }
            }
        }
Пример #2
0
        private void ShowError(string messageId, string message)
        {
            messageId = messageId.Replace(Environment.NewLine, string.Empty);// remove newlines to ease persistence

            if (!m_suppressedMessages.Contains(messageId))
            {
                // If this is called from another thread we will not be able to access
                // Application.Current.MainWindow so invoke back to UI thread
                Application.Current.Dispatcher.BeginInvokeIfRequired(() =>
                {
                    if (Application.Current.MainWindow != null &&
                        Application.Current.MainWindow.IsLoaded)
                    {
                        var dlg = new ErrorDialog();

                        var vm = new ErrorDialogViewModel();
                        vm.Message = message;
                        dlg.DataContext = vm;
                        dlg.Owner = Application.Current.MainWindow;
                        dlg.ShowDialog();

                        if (vm.SuppressMessage)
                        {
                            m_suppressedMessages.Add(messageId);
                        }
                    }
                });
            }
        }