public VentanaDialogoBoton Mostrar(MensajeException mensaje) { if (mensaje.EsError) { return(Mostrar(null, mensaje.Mensaje, "Error", VentanaDialogoTipoVentana.Error)); } else { VentanaDialogoTipoVentana tipoventana = VentanaDialogoTipoVentana.Error; if (mensaje.Tipo == MensajeException.TipoMensaje.Advertencia) { tipoventana = VentanaDialogoTipoVentana.Advertencia; } else if (mensaje.Tipo == MensajeException.TipoMensaje.AdvertenciaAlta) { tipoventana = VentanaDialogoTipoVentana.AdvertenciaAlta; } else if (mensaje.Tipo == MensajeException.TipoMensaje.ErrorSimple) { tipoventana = VentanaDialogoTipoVentana.ErrorSimple; } else if (mensaje.Tipo == MensajeException.TipoMensaje.Informacion) { tipoventana = VentanaDialogoTipoVentana.Informacion; } else if (mensaje.Tipo == MensajeException.TipoMensaje.Mensaje) { tipoventana = VentanaDialogoTipoVentana.Mensaje; } else if (mensaje.Tipo == MensajeException.TipoMensaje.Pregunta) { tipoventana = VentanaDialogoTipoVentana.Pregunta; } else if (mensaje.Tipo == MensajeException.TipoMensaje.PreguntaAdvertencia) { tipoventana = VentanaDialogoTipoVentana.PreguntaAdvertencia; } return(Mostrar(null, mensaje.Mensaje, "Mensaje", tipoventana)); } }
public VentanaDialogoBoton Mostrar(Exception exception, String mensaje, String titulo, VentanaDialogoTipoVentana tipoVentana) { try { txt_Mensaje.Text = mensaje; Title = titulo; btn_botonCancelar.Visibility = System.Windows.Visibility.Hidden; btn_botonEnviarSoporte.Visibility = System.Windows.Visibility.Hidden; if (tipoVentana == VentanaDialogoTipoVentana.Advertencia) { img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\advertencia.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.AdvertenciaAlta) { img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\advertencia3.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.Error) { if (exception != null) { this.exception = exception; Log.EscribirLog("Exception name: " + exception.GetType().Name + " - Message: " + exception.Message + " - StackTrace: " + exception.StackTrace); } else { Log.EscribirLog("Exception: " + mensaje); } btn_botonEnviarSoporte.Visibility = System.Windows.Visibility.Visible; img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\error.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.Informacion) { img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\informacion.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.Mensaje) { img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\mensaje.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.Pregunta) { btn_botonAceptar.Text = "Si"; btn_botonCancelar.Text = "No"; btn_botonCancelar.Visibility = System.Windows.Visibility.Visible; img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\pregunta.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.PreguntaAdvertencia) { btn_botonAceptar.Text = "Si"; btn_botonCancelar.Text = "No"; btn_botonCancelar.Visibility = System.Windows.Visibility.Visible; img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\advertencia2.png")); } else if (tipoVentana == VentanaDialogoTipoVentana.ErrorSimple) { img_Imagen.Source = HerramientasWindow.BitmapAImageSource(new Bitmap(@"Imagenes\Iconos\Sistema\Dialogos\error.png")); } try { this.Icon = img_Imagen.Source; ShowDialog(); } catch (System.Windows.Media.Animation.AnimationException anim) { } VentanaDialogoBoton respuesta = VentanaDialogoBoton.Cancelar; if (botonRespuesta == 0) { if (tipoVentana == VentanaDialogoTipoVentana.Pregunta || tipoVentana == VentanaDialogoTipoVentana.PreguntaAdvertencia) { respuesta = VentanaDialogoBoton.No; } else { respuesta = VentanaDialogoBoton.Cancelar; } } else if (botonRespuesta == 1) { if (tipoVentana == VentanaDialogoTipoVentana.Pregunta || tipoVentana == VentanaDialogoTipoVentana.PreguntaAdvertencia) { respuesta = VentanaDialogoBoton.Si; } else { respuesta = VentanaDialogoBoton.Aceptar; } } return(respuesta); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return(VentanaDialogoBoton.Cancelar); } }