/// <summary>
 /// This method opens a new ExceptionWindow with the
 /// passed exception object as datacontext.
 /// </summary>
 public override void OnUnhandledException(Exception e)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         var exceptionWindow         = new ExceptionWindow();
         exceptionWindow.DataContext = new ExceptionWindowVM(e);
         exceptionWindow.Show();
     }));
 }
Exemple #2
0
        /// <summary>
        /// --- Load example -> M System description - Click event ---
        /// Opens OpenFileDialog, M System description file and deserialize input.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event parameter.</param>
        private void mSystemDescriptionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter      = "XML Files (.xml)|*.xml";
                openFileDialog.Multiselect = false;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Check if selected file is really evolution file.
                    XDocument doc = XDocument.Load(openFileDialog.FileName);
                    if (doc.Element("root") == null)
                    {
                        throw new InvalidOperationException("Selected file is not an M System description file.");
                    }
                    v_MSystemObjectsPath = openFileDialog.FileName;

                    //XSD validation
                    if (v_ValidateUsingXSD)
                    {
                        string errorsAndWarnings;
                        if (!XmlValidator.Validate(v_MSystemObjectsPath, v_XSDPath, out errorsAndWarnings))
                        {
                            throw new ValidationFailed(errorsAndWarnings);
                        }
                    }

                    string errorMessage;
                    IDeserializedObjects deserializedObjects = Xmlizer.Deserialize(v_MSystemObjectsPath, out errorMessage);
                    if (deserializedObjects == null)
                    {
                        richTextBoxMSystem.Text = errorMessage;
                        return;
                    }
                    v_MSystemObjects = TypeUtil.Cast <DeserializedObjects>(deserializedObjects);
                    RestartSimulator();

                    richTextBoxMSystem.Text = v_Simulator.MSystemToString();
                    VisualizeLogging.LogMessageAndVisualize("Deserialization of M System description file was successful.");
                    VisualizeLogging.LogMessageAndVisualize(string.Format("File: {0}", openFileDialog.FileName));
                }
            }
            catch (Exception exception)
            {
                ExceptionWindow.Show(exception);
            }
        }
Exemple #3
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     ExceptionWindow.Show(new Exception("Dummy exception"));
 }
Exemple #4
0
 /// <summary>
 /// Handles unhandle application exception.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event parameter.</param>
 static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     ExceptionWindow.Show((Exception)e.ExceptionObject);
 }
Exemple #5
0
 /// <summary>
 /// Handles untrapper thread exception.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event parameter.</param>
 static void UnhandledThreadException(object sender, ThreadExceptionEventArgs e)
 {
     ExceptionWindow.Show(e.Exception);
 }