comparison SilverlightGlimpse/Controls/GlimpseViewer.xaml.cs @ 59:3591c26bd63e

MVVMLight added
author Steven Hollidge <stevenhollidge@hotmail.com>
date Sat, 21 Apr 2012 19:20:28 +0100
parents
children
comparison
equal deleted inserted replaced
58:241e2f22ed3c 59:3591c26bd63e
1 using System.Collections.Specialized;
2 using System.Windows;
3
4 using SilverlightGlimpse.Models;
5 using SilverlightGlimpse.Services;
6
7 namespace SilverlightGlimpse.Controls
8 {
9 public partial class GlimpseViewer
10 {
11 public GlimpseViewer()
12 {
13 InitializeComponent();
14 this.DataContext = GlimpseService.CreateInstance;
15 GlimpseService.CreateInstance.HostExceptions.CollectionChanged += HostExceptions_CollectionChanged;
16 }
17
18 private void btnContract_Click(object sender, System.Windows.RoutedEventArgs e)
19 {
20 this.layoutViewer.Visibility = Visibility.Collapsed;
21 }
22
23 private void btnExpand_Click(object sender, System.Windows.RoutedEventArgs e)
24 {
25 this.layoutViewer.Visibility = Visibility.Visible;
26 }
27
28 private void HostExceptions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
29 {
30 int unhandledExceptionCount = 0;
31 int validationExceptionCount = 0;
32
33 foreach (ExceptionWrapper ew in GlimpseService.CreateInstance.HostExceptions)
34 {
35 if (ew.IsValidationException)
36 validationExceptionCount++;
37 else
38 unhandledExceptionCount++;
39 }
40
41 this.tbValidationExceptions.Text = validationExceptionCount.ToString();
42
43 this.elpValidationExceptions.Fill = validationExceptionCount == 0
44 ? this.noExceptionsBrush
45 : this.hasExceptionsBrush;
46
47 this.tbUnhandledExceptions.Text = unhandledExceptionCount.ToString();
48
49 this.elpUnhandledExceptions.Fill = unhandledExceptionCount == 0
50 ? this.noExceptionsBrush
51 : this.hasExceptionsBrush;
52 }
53 }
54 }