Mercurial > silverbladetech
changeset 60:fc62c971a117
upload to blog
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Sat, 21 Apr 2012 21:19:39 +0100 |
parents | 3591c26bd63e |
children | 9de81c9ad319 |
files | SilverlightValidation/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml SilverlightValidation/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml.cs SilverlightValidation/SilverlightGlimpse/Controls/ExceptionsViewer.xaml SilverlightValidation/SilverlightGlimpse/Controls/ExceptionsViewer.xaml.cs SilverlightValidation/SilverlightGlimpse/Controls/GlimpseViewer.xaml SilverlightValidation/SilverlightGlimpse/Controls/GlimpseViewer.xaml.cs SilverlightValidation/SilverlightGlimpse/Controls/LoadExceptionViewer.xaml SilverlightValidation/SilverlightGlimpse/Controls/LoadExceptionViewer.xaml.cs SilverlightValidation/SilverlightGlimpse/Libs/FloatableWindow.dll SilverlightValidation/SilverlightGlimpse/Libs/FloatableWindow.pdb SilverlightValidation/SilverlightGlimpse/Libs/System.Windows.Controls.dll SilverlightValidation/SilverlightGlimpse/Models/BrokenBinding.cs SilverlightValidation/SilverlightGlimpse/Models/ExceptionWrapper.cs SilverlightValidation/SilverlightGlimpse/Properties/AppManifest.xml SilverlightValidation/SilverlightGlimpse/Properties/AssemblyInfo.cs SilverlightValidation/SilverlightGlimpse/Services/GlimpseService.cs SilverlightValidation/SilverlightGlimpse/SilverlightGlimpse.csproj SilverlightValidation/SilverlightGlimpse/SilverlightGlimpse.sln SilverlightValidation/SilverlightValidation.Web/ClientBin/SilverlightValidation.xap SilverlightValidation/SilverlightValidation.Web/SilverlightValidation.Web.csproj SilverlightValidation/SilverlightValidation/App.xaml SilverlightValidation/SilverlightValidation/Data/Factory.cs SilverlightValidation/SilverlightValidation/Diagrams/Form.cd SilverlightValidation/SilverlightValidation/Diagrams/List.cd SilverlightValidation/SilverlightValidation/SilverlightValidation.csproj SilverlightValidation/SilverlightValidation/ViewModels/UserListViewModel.cs SilverlightValidation/SilverlightValidation/ViewModels/UserViewModel.cs SilverlightValidation/SilverlightValidation/Views/UserListView.xaml SilverlightValidation/SilverlightValidation/Views/UserView.xaml SilverlightValidation/SilverlightValidation/Views/UserView.xaml.cs |
diffstat | 30 files changed, 66 insertions(+), 1090 deletions(-) [+] |
line wrap: on
line diff
--- a/SilverlightValidation/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -<UserControl x:Class="SilverlightGlimpse.Controls.BrokenBindingsViewer" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Loaded="BrokenBindings_Loaded"> - <Grid x:Name="LayoutRoot" Background="White"> - <ScrollViewer> - <ItemsControl x:Name="icBrokenBindings" /> - </ScrollViewer> - </Grid> -</UserControl>
--- a/SilverlightValidation/SilverlightGlimpse/Controls/BrokenBindingsViewer.xaml.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -using System.Reflection; -using System.Windows.Data; -using SilverlightGlimpse.Models; -using System.Windows; -using System.Diagnostics; -using System.Windows.Media; -using SilverlightGlimpse.Services; - -namespace SilverlightGlimpse.Controls -{ - public partial class BrokenBindingsViewer - { - public BrokenBindingsViewer() - { - InitializeComponent(); - } - - private void BrokenBindings_Loaded(object sender, RoutedEventArgs e) - { - this.icBrokenBindings.Items.Clear(); - LoadBrokenBindings(GlimpseService.CreateInstance.RootVisual); - } - - private void LoadBrokenBindings(UIElement uiElement) - { - var frameworkElement = uiElement as FrameworkElement; - - if (frameworkElement != null) - { - foreach (var fieldInfo in frameworkElement.GetType().GetFields(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static)) - { - if (object.ReferenceEquals(fieldInfo.FieldType, typeof(DependencyProperty))) - { - var bindingExpression = frameworkElement.GetBindingExpression((DependencyProperty)fieldInfo.GetValue(null)); - - if (bindingExpression != null && bindingExpression.ParentBinding.Source == null && bindingExpression.ParentBinding.RelativeSource == null) - { - var isInherited = false; - - if (frameworkElement.DataContext != null && !string.IsNullOrEmpty(bindingExpression.ParentBinding.Path.Path)) - { - foreach (var propertyInfo in frameworkElement.DataContext.GetType().GetProperties(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Instance)) - { - if (string.Compare(propertyInfo.Name, bindingExpression.ParentBinding.Path.Path) == 0) - { - isInherited = true; - break; // TODO: might not be correct. Was : Exit For - } - } - } - - if (isInherited) - { - break; // TODO: might not be correct. Was : Exit For - } - - //this code handles empty bindings on the Button controls - //I'll have to look into why the Button has an empty or unresolved binding - if (string.IsNullOrEmpty(frameworkElement.Name) - && frameworkElement.GetType().Name == "TextBlock" - && fieldInfo.Name == "TextProperty" - && string.IsNullOrEmpty(bindingExpression.ParentBinding.Path.Path)) - { - break; // TODO: might not be correct. Was : Exit For - } - - BrokenBinding objBrokenBinding = new BrokenBinding( - frameworkElement.Name, - frameworkElement.GetType().Name, - fieldInfo.Name, - bindingExpression.ParentBinding.Path.Path); - this.icBrokenBindings.Items.Add(objBrokenBinding); - Debug.WriteLine("Broken Binding - ", objBrokenBinding.ToString()); - } - } - } - - int children = VisualTreeHelper.GetChildrenCount(frameworkElement); - - for (int j = 0; j <= children - 1; j++) - { - FrameworkElement child = VisualTreeHelper.GetChild(frameworkElement, j) as FrameworkElement; - - if (child != null) - { - LoadBrokenBindings(child); - } - } - } - } - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Controls/ExceptionsViewer.xaml Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -<UserControl x:Class="SilverlightGlimpse.Controls.ExceptionsViewer" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Loaded="ExceptionsViewer_Loaded"> - <Grid x:Name="LayoutRoot" Background="White"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="250" /> - <ColumnDefinition Width="*" /> - </Grid.ColumnDefinitions> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="*" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - - <TextBlock Grid.ColumnSpan="2" - Margin="3.5" - VerticalAlignment="Center" - FontSize="18" - Foreground="Red" - Text="Exceptions Viewer" /> - - <ListBox x:Name="lbExceptions" - Grid.Row="1" - Margin="3.5" - ItemsSource="{Binding}" - SelectionChanged="lbExceptions_SelectionChanged" /> - - <ScrollViewer Grid.Row="1" - Grid.Column="1" - Margin="3.5" - DataContext="{Binding ElementName=lbExceptions, - Path=SelectedItem}"> - <Grid> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - - <Rectangle Fill="BlanchedAlmond" /> - <TextBlock x:Name="tbAction" - FontSize="14" - Text="Action" - TextDecorations="Underline" /> - <TextBlock Grid.Row="1" - FontSize="11" - Text="{Binding Path=Action}" - TextWrapping="Wrap" - Visibility="{Binding ElementName=tbAction, - Path=Visibility}" /> - - <Rectangle Grid.Row="2" Fill="BlanchedAlmond" /> - <TextBlock Grid.Row="2" - Margin="0,7,0,0" - FontSize="14" - Text="Control Name" - TextDecorations="Underline" - Visibility="{Binding ElementName=tbAction, - Path=Visibility}" /> - <TextBlock Grid.Row="3" - FontSize="11" - Text="{Binding Path=ControlName}" - TextWrapping="Wrap" - Visibility="{Binding ElementName=tbAction, - Path=Visibility}" /> - - <Rectangle Grid.Row="4" Fill="BlanchedAlmond" /> - <TextBlock Grid.Row="4" - Margin="0,7,0,0" - FontSize="14" - Text="Message" - TextDecorations="Underline" /> - <TextBlock Grid.Row="5" - FontSize="11" - Text="{Binding Path=Exception.Message}" - TextWrapping="Wrap" /> - - <Rectangle Grid.Row="6" Fill="BlanchedAlmond" /> - <TextBlock Grid.Row="6" - Margin="0,7,0,0" - FontSize="14" - Text="Stack Trace" - TextDecorations="Underline" /> - <TextBlock Grid.Row="7" - FontSize="11" - Text="{Binding Path=Exception.StackTrace}" - TextWrapping="Wrap" /> - - </Grid> - </ScrollViewer> - <Button Grid.Row="2" - Grid.Column="1" - Margin="11" - HorizontalAlignment="Right" - VerticalAlignment="Center" - Click="ClearExceptions_Click" - Content="Clear Exceptions" - Padding="7" /> - </Grid> -</UserControl>
--- a/SilverlightValidation/SilverlightGlimpse/Controls/ExceptionsViewer.xaml.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -using System; -using System.Windows; -using SilverlightGlimpse.Models; -using System.Windows.Controls; -using SilverlightGlimpse.Services; - -namespace SilverlightGlimpse.Controls -{ - public partial class ExceptionsViewer - { - public ExceptionsViewer() - { - InitializeComponent(); - } - - private void ClearExceptions_Click(object sender, RoutedEventArgs e) - { - GlimpseService.CreateInstance.HostExceptions.Clear(); - } - - private void ExceptionsViewer_Loaded(object sender, RoutedEventArgs e) - { - this.DataContext = GlimpseService.CreateInstance.HostExceptions; - if (GlimpseService.CreateInstance.HostExceptions.Count > 0) - this.lbExceptions.SelectedIndex = 0; - } - - private void lbExceptions_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (this.lbExceptions.SelectedItem != null && this.lbExceptions.SelectedItem is ExceptionWrapper) - { - if (((ExceptionWrapper)this.lbExceptions.SelectedItem).IsValidationException) - this.tbAction.Visibility = Visibility.Visible; - else - this.tbAction.Visibility = Visibility.Collapsed; - } - } - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Controls/GlimpseViewer.xaml Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -<UserControl x:Class="SilverlightGlimpse.Controls.GlimpseViewer" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" - xmlns:localc="clr-namespace:SilverlightGlimpse.Controls"> - <Grid x:Name="LayoutRoot" Background="Khaki"> - <Grid.Resources> - <SolidColorBrush x:Name="noExceptionsBrush" Color="LightGreen" /> - <SolidColorBrush x:Name="hasExceptionsBrush" Color="Red" /> - </Grid.Resources> - <Grid x:Name="layoutInstrumentPanel"> - <StackPanel Orientation="Horizontal"> - <Grid Margin="7"> - <Ellipse x:Name="elpValidationExceptions" - Width="40" - Height="40" - Fill="LightGreen" - Stroke="Brown" - StrokeThickness="2" /> - <TextBlock x:Name="tbValidationExceptions" - HorizontalAlignment="Center" - VerticalAlignment="Center" - FontSize="12" - FontWeight="Bold" - Text="0" - ToolTipService.ToolTip="Binding Exception Count" /> - </Grid> - <Grid Margin="7"> - <Ellipse x:Name="elpUnhandledExceptions" - Width="40" - Height="40" - Fill="LightGreen" - Stroke="Brown" - StrokeThickness="2" /> - <TextBlock x:Name="tbUnhandledExceptions" - HorizontalAlignment="Center" - VerticalAlignment="Center" - FontSize="12" - FontWeight="Bold" - Text="0" - ToolTipService.ToolTip="Unhandled Exception Count" /> - </Grid> - <Button x:Name="btnExpand" - Margin="7" - VerticalAlignment="Center" - Click="btnExpand_Click" - Content="Expand" /> - </StackPanel> - </Grid> - <Grid x:Name="layoutViewer" Visibility="Collapsed"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="*" /> - </Grid.RowDefinitions> - <TextBlock Margin="3.5" - VerticalAlignment="Center" - FontSize="18" - Foreground="DarkGreen" - Text="Glimpse Viewer" /> - <Button x:Name="btnContract" - Margin="7" - HorizontalAlignment="Right" - VerticalAlignment="Center" - Click="btnContract_Click" - Content="Contract" /> - <c:TabControl Grid.Row="1" - Width="690" - Height="390" - Background="Khaki" - SelectedIndex="2"> - <c:TabItem Header="Exceptions"> - <localc:ExceptionsViewer /> - </c:TabItem> - <c:TabItem Header="Bindings with no Source"> - <localc:BrokenBindingsViewer /> - </c:TabItem> - </c:TabControl> - </Grid> - </Grid> - -</UserControl>
--- a/SilverlightValidation/SilverlightGlimpse/Controls/GlimpseViewer.xaml.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -using System.Collections.Specialized; -using System.Windows; - -using SilverlightGlimpse.Models; -using SilverlightGlimpse.Services; - -namespace SilverlightGlimpse.Controls -{ - public partial class GlimpseViewer - { - public GlimpseViewer() - { - InitializeComponent(); - this.DataContext = GlimpseService.CreateInstance; - GlimpseService.CreateInstance.HostExceptions.CollectionChanged += HostExceptions_CollectionChanged; - } - - private void btnContract_Click(object sender, System.Windows.RoutedEventArgs e) - { - this.layoutViewer.Visibility = Visibility.Collapsed; - } - - private void btnExpand_Click(object sender, System.Windows.RoutedEventArgs e) - { - this.layoutViewer.Visibility = Visibility.Visible; - } - - private void HostExceptions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - int unhandledExceptionCount = 0; - int validationExceptionCount = 0; - - foreach (ExceptionWrapper ew in GlimpseService.CreateInstance.HostExceptions) - { - if (ew.IsValidationException) - validationExceptionCount++; - else - unhandledExceptionCount++; - } - - this.tbValidationExceptions.Text = validationExceptionCount.ToString(); - - this.elpValidationExceptions.Fill = validationExceptionCount == 0 - ? this.noExceptionsBrush - : this.hasExceptionsBrush; - - this.tbUnhandledExceptions.Text = unhandledExceptionCount.ToString(); - - this.elpUnhandledExceptions.Fill = unhandledExceptionCount == 0 - ? this.noExceptionsBrush - : this.hasExceptionsBrush; - } - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Controls/LoadExceptionViewer.xaml Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -<UserControl x:Class="SilverlightGlimpse.Controls.LoadExceptionViewer" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - <Border Width="700" - Height="375" - Margin="11" - Background="LightYellow" - BorderBrush="Red" - BorderThickness="2" - CornerRadius="20" - Padding="11"> - <Grid x:Name="LayoutRoot"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="200" /> - <ColumnDefinition Width="*" /> - </Grid.ColumnDefinitions> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="*" /> - </Grid.RowDefinitions> - <TextBlock Grid.ColumnSpan="2" - Margin="3.5" - VerticalAlignment="Center" - FontSize="18" - Foreground="Red" - Text="Exception Viewer" /> - - <ListBox x:Name="lbExceptions" - Grid.Row="1" - Margin="3.5" - DisplayMemberPath="Message" /> - - <TextBlock x:Name="txtSourceLocation" - Grid.ColumnSpan="2" - HorizontalAlignment="Right" - VerticalAlignment="Center" - FontSize="14" /> - <ScrollViewer Grid.Row="1" - Grid.Column="1" - Margin="3.5" - Background="White" - DataContext="{Binding ElementName=lbExceptions, - Path=SelectedItem}"> - <Grid> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - <Rectangle Fill="BlanchedAlmond" /> - <TextBlock FontSize="14" - Text="Message" - TextDecorations="Underline" /> - <TextBlock Grid.Row="1" - FontSize="11" - Text="{Binding Path=Message}" - TextWrapping="Wrap" /> - - <Rectangle Grid.Row="2" Fill="BlanchedAlmond" /> - <TextBlock Grid.Row="2" - Margin="0,11,0,0" - FontSize="14" - Text="Stack Trace" - TextDecorations="Underline" /> - <TextBlock Grid.Row="3" - FontSize="11" - Text="{Binding Path=StackTrace}" - TextWrapping="Wrap" /> - - </Grid> - </ScrollViewer> - </Grid> - </Border> - -</UserControl> -
--- a/SilverlightValidation/SilverlightGlimpse/Controls/LoadExceptionViewer.xaml.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -using System; - -namespace SilverlightGlimpse.Controls -{ - public partial class LoadExceptionViewer - { - public LoadExceptionViewer() - { - InitializeComponent(); - } - - public LoadExceptionViewer(Exception e, string sourceLocation) : this() - { - this.txtSourceLocation.Text = string.Concat("Source Location: ", sourceLocation); - - Exception ex = e; - - while (ex != null) - { - this.lbExceptions.Items.Add(ex); - ex = ex.InnerException; - } - - if (this.lbExceptions.Items.Count > 0) - { - this.lbExceptions.SelectedIndex = 0; - } - } - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Models/BrokenBinding.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -using System; - -namespace SilverlightGlimpse.Models -{ - public class BrokenBinding - { - #region Fields - - private string _controlName = string.Empty; - private string _controlTypeName = string.Empty; - private string _path = string.Empty; - private string _propertyName = string.Empty; - - #endregion - - #region Constructor - - public BrokenBinding(string controlName, string controlTypeName, string propertyName, string path) - { - _controlName = controlName; - _controlTypeName = controlTypeName; - _propertyName = propertyName; - _path = path; - } - - #endregion - - #region Properties - - public string ControlName { get { return string.IsNullOrEmpty(_controlName) ? "(none)" : _controlName; } } - public string ControlTypeName { get { return _controlTypeName; } } - public string Path { get { return _path; } } - public string PropertyName { get { return _propertyName; } } - - #endregion - - #region Methods - - public override string ToString() - { - return string.Format( - "Control Name: {0}, Type: {1}, Property: {2}, Path: {3}", - this.ControlName, - this.ControlTypeName, - this.PropertyName, - this.Path); - } - - #endregion - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Models/ExceptionWrapper.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -using System; -using System.Windows.Controls; - -namespace SilverlightGlimpse.Models -{ - public class ExceptionWrapper - { - #region Fields - - private bool _isValidationException = false; - private ValidationErrorEventAction _enumAction = ValidationErrorEventAction.Added; - private Exception _exception; - private string _controlName = string.Empty; - - #endregion - - #region Constructor - - public ExceptionWrapper(Exception e) - { - _exception = e; - } - - #endregion - - #region Properties - - public ExceptionWrapper(ValidationErrorEventAction enumAction, string controlName, Exception validationException) - { - _enumAction = enumAction; - _controlName = controlName; - _exception = validationException; - _isValidationException = true; - } - - public ValidationErrorEventAction Action { get { return _enumAction; } } - public string ControlName { get { return _controlName; } } - public Exception Exception { get { return _exception; } } - public bool IsValidationException { get { return _isValidationException; } } - - #endregion - - #region Methods - - public override string ToString() - { - return _isValidationException - ? string.Format("({0}) - {1}", this.Action, Exception.Message) - : Exception.Message; - } - - #endregion - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/Properties/AppManifest.xml Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" -> - <Deployment.Parts> - </Deployment.Parts> -</Deployment>
--- a/SilverlightValidation/SilverlightGlimpse/Properties/AssemblyInfo.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SilverlightGlimpse")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SilverlightGlimpse")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("52ef33ca-e923-41ef-a7c8-98ec475bc956")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]
--- a/SilverlightValidation/SilverlightGlimpse/Services/GlimpseService.cs Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Windows; -using System.Windows.Controls; -using SilverlightGlimpse.Controls; -using SilverlightGlimpse.Models; -using System.Windows.Media; - -namespace SilverlightGlimpse.Services -{ - public class GlimpseService - { - #region Fields - - private static GlimpseService _instance; - - #endregion - - #region Private constructor - - private GlimpseService() - { - } - - #endregion - - #region Properties - - public static GlimpseService CreateInstance - { - get { return (_instance == null) ? _instance = new GlimpseService() : _instance; } - } - - internal Application App { get; private set; } - internal ChildWindow GlimpseWindow { get; set;} - internal string HostApplicationName { get; set; } - internal ObservableCollection<ExceptionWrapper> HostExceptions { get; private set; } - internal FrameworkElement RootVisual { get; private set; } - - #endregion - - #region Creation and Loading - - public void DisplayLoadFailure(Application app, Exception ex, string hostApplicationName) - { - Debug.WriteLine("{0} had exception. {1}", this.HostApplicationName, ex.ToString()); - App = app; - App.UnhandledException += Application_UnhandledException; - RootVisual = new LoadExceptionViewer(ex, hostApplicationName); - RootVisual.BindingValidationError += HostRootVisual_BindingValidationError; - } - - public void Load(Application app, string hostApplicationName) - { - this.App = app; - this.RootVisual = App.RootVisual as FrameworkElement; - this.HostApplicationName = hostApplicationName; - - RootVisual.BindingValidationError += HostRootVisual_BindingValidationError; - App.UnhandledException += Application_UnhandledException; - - var window = new ChildWindow() - { - Title = this.HostApplicationName, - Content = new GlimpseViewer() - }; - window.Show(); - } - #endregion - - #region Events handlers - - private void HostRootVisual_BindingValidationError(object sender, ValidationErrorEventArgs e) - { - string controlName = "(none)"; - Control control = e.OriginalSource as Control; - - if (control != null && !string.IsNullOrEmpty(control.Name)) - { - controlName = control.Name; - } - - Exception ex = e.Error.Exception; - - while (ex != null) - { - this.HostExceptions.Add(new ExceptionWrapper(e.Action, controlName, e.Error.Exception)); - ex = ex.InnerException; - } - } - - private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - Debug.WriteLine("{0} had exception. {1}", this.HostApplicationName, e.ExceptionObject.ToString()); - - Exception ex = e.ExceptionObject; - - while (ex != null) - { - this.HostExceptions.Add(new ExceptionWrapper(ex)); - ex = ex.InnerException; - } - - e.Handled = true; - } - - #endregion - } -} \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/SilverlightGlimpse.csproj Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{BB51026B-2864-4389-AACA-0BBDF1926E46}</ProjectGuid> - <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>SilverlightGlimpse</RootNamespace> - <AssemblyName>SilverlightGlimpse</AssemblyName> - <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> - <TargetFrameworkVersion>v5.0</TargetFrameworkVersion> - <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion> - <SilverlightApplication>true</SilverlightApplication> - <SupportedCultures> - </SupportedCultures> - <XapOutputs>true</XapOutputs> - <GenerateSilverlightManifest>true</GenerateSilverlightManifest> - <XapFilename>SilverlightGlimpse.xap</XapFilename> - <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate> - <SilverlightAppEntry>SilverlightGlimpse.App</SilverlightAppEntry> - <TestPageFileName>SilverlightGlimpseTestPage.html</TestPageFileName> - <CreateTestPage>true</CreateTestPage> - <ValidateXaml>true</ValidateXaml> - <EnableOutOfBrowser>false</EnableOutOfBrowser> - <OutOfBrowserSettingsFile>Properties\OutOfBrowserSettings.xml</OutOfBrowserSettingsFile> - <UsePlatformExtensions>false</UsePlatformExtensions> - <ThrowErrorsInValidation>true</ThrowErrorsInValidation> - <LinkedServerProject> - </LinkedServerProject> - </PropertyGroup> - <!-- This property group is only here to support building this project using the - MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs - to set the TargetFrameworkVersion to v3.5 --> - <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'"> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>Bin\Debug</OutputPath> - <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants> - <NoStdLib>true</NoStdLib> - <NoConfig>true</NoConfig> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>Bin\Release</OutputPath> - <DefineConstants>TRACE;SILVERLIGHT</DefineConstants> - <NoStdLib>true</NoStdLib> - <NoConfig>true</NoConfig> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <ItemGroup> - <Reference Include="mscorlib" /> - <Reference Include="System.Windows" /> - <Reference Include="system" /> - <Reference Include="System.Core" /> - <Reference Include="System.Net" /> - <Reference Include="System.Windows.Controls, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> - <Reference Include="System.Xml" /> - <Reference Include="System.Windows.Browser" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Controls\BrokenBindingsViewer.xaml.cs"> - <DependentUpon>BrokenBindingsViewer.xaml</DependentUpon> - </Compile> - <Compile Include="Controls\GlimpseViewer.xaml.cs"> - <DependentUpon>GlimpseViewer.xaml</DependentUpon> - </Compile> - <Compile Include="Controls\LoadExceptionViewer.xaml.cs"> - <DependentUpon>LoadExceptionViewer.xaml</DependentUpon> - </Compile> - <Compile Include="Controls\ExceptionsViewer.xaml.cs"> - <DependentUpon>ExceptionsViewer.xaml</DependentUpon> - </Compile> - <Compile Include="Models\BrokenBinding.cs" /> - <Compile Include="Models\ExceptionWrapper.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Services\GlimpseService.cs" /> - </ItemGroup> - <ItemGroup> - <Page Include="Controls\BrokenBindingsViewer.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> - <Page Include="Controls\GlimpseViewer.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> - <Page Include="Controls\LoadExceptionViewer.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> - <Page Include="Controls\ExceptionsViewer.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> - </ItemGroup> - <ItemGroup> - <None Include="Properties\AppManifest.xml" /> - </ItemGroup> - <ItemGroup> - <Content Include="Libs\FloatableWindow.dll" /> - <Content Include="Libs\System.Windows.Controls.dll" /> - </ItemGroup> - <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <ProjectExtensions> - <VisualStudio> - <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}"> - <SilverlightProjectProperties /> - </FlavorProperties> - </VisualStudio> - </ProjectExtensions> -</Project> \ No newline at end of file
--- a/SilverlightValidation/SilverlightGlimpse/SilverlightGlimpse.sln Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightGlimpse", "SilverlightGlimpse.csproj", "{BB51026B-2864-4389-AACA-0BBDF1926E46}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB51026B-2864-4389-AACA-0BBDF1926E46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB51026B-2864-4389-AACA-0BBDF1926E46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB51026B-2864-4389-AACA-0BBDF1926E46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB51026B-2864-4389-AACA-0BBDF1926E46}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal
Binary file SilverlightValidation/SilverlightValidation.Web/ClientBin/SilverlightValidation.xap has changed
--- a/SilverlightValidation/SilverlightValidation.Web/SilverlightValidation.Web.csproj Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation.Web/SilverlightValidation.Web.csproj Sat Apr 21 21:19:39 2012 +0100 @@ -66,7 +66,12 @@ <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <Content Include="ClientBin\System.ComponentModel.DataAnnotations.zip" /> + </ItemGroup> + <ItemGroup> + <Content Include="ClientBin\System.Windows.Data.zip" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <ProjectExtensions>
--- a/SilverlightValidation/SilverlightValidation/App.xaml Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/App.xaml Sat Apr 21 21:19:39 2012 +0100 @@ -68,7 +68,7 @@ <Border Margin="1,1,-1,-1" Background="#352A2E31" CornerRadius="2" /> - <Border Background="#FFF3AB00" CornerRadius="2" /> + <Border Background="#FFDC000C" CornerRadius="2" /> <Border CornerRadius="2"> <TextBlock MaxWidth="250" Margin="8,4,8,4" @@ -222,7 +222,7 @@ IsHitTestVisible="False" Opacity="0" /> <Border x:Name="ValidationErrorElement" - BorderBrush="#FFF3AB00" + BorderBrush="#FFDC000C" BorderThickness="1" CornerRadius="1" Visibility="Collapsed"> @@ -259,7 +259,7 @@ Background="Transparent"> <Path Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" - Fill="#FFF3AB00" /> + Fill="#FFDC000C" /> <Path Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" /> @@ -571,7 +571,7 @@ </Grid> <Popup x:Name="Popup" /> <Border x:Name="ValidationErrorElement" - BorderBrush="#FFF3AB00" + BorderBrush="#FFDC000C" BorderThickness="1" CornerRadius="1" Visibility="Collapsed"> @@ -606,7 +606,7 @@ Background="Transparent"> <Path Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" - Fill="#FFF3AB00" /> + Fill="#FFDC000C" /> <Path Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" /> @@ -637,7 +637,7 @@ <DataTemplate> <Border x:Name="Header" Margin="-1,-1,-1,0" - Background="#FFF3AB00" + Background="#FFDC000C" CornerRadius="2"> <StackPanel Margin="6,2,6,4" VerticalAlignment="Top" @@ -652,7 +652,7 @@ </Ellipse.Fill> <Ellipse.Stroke> <LinearGradientBrush StartPoint="0.505,0.65" EndPoint="0.5,0.058"> - <GradientStop Offset="0" Color="#FFF3AB00" /> + <GradientStop Offset="0" Color="#FFDC000C" /> <GradientStop Offset="0.991" Color="#FFFF9298" /> </LinearGradientBrush> </Ellipse.Stroke> @@ -947,7 +947,7 @@ IsHitTestVisible="False" Opacity="0" /> <Border x:Name="ValidationErrorElement" - BorderBrush="#FFF3AB00" + BorderBrush="#FFDC000C" BorderThickness="1" CornerRadius="1" Visibility="Collapsed"> @@ -982,7 +982,7 @@ Background="Transparent"> <Path Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" - Fill="#FFF3AB00" /> + Fill="#FFDC000C" /> <Path Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff" />
--- a/SilverlightValidation/SilverlightValidation/Data/Factory.cs Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/Data/Factory.cs Sat Apr 21 21:19:39 2012 +0100 @@ -11,9 +11,9 @@ return new List<UserModel>(5) { new UserModel() { Username = "StevenH", Password = "Password1", Email = "steven@hotmail.com", DateOfBirth = new DateTime(1977, 09, 01), Description = ""}, - new UserModel() { Username = "RichardJ", Password = "12N456a", Email = "dicky@gmail.com", DateOfBirth = new DateTime(1983, 03, 13), Description = "Rebel"}, + new UserModel() { Username = "RichardJ", Password = "12N456a", Email = "dicky@gmail.com", DateOfBirth = new DateTime(1983, 03, 13), Description = "Loves .Net!"}, new UserModel() { Username = "BobbyP", Password = "pa33Word", Email = "bob@yahoo.co.uk", DateOfBirth = new DateTime(1992, 08, 30), Description = ""}, - new UserModel() { Username = "DavidM", Password = "poIu789", Email = "daveyboy@marsh.com", DateOfBirth = new DateTime(1965, 06, 21), Description = "Renegade"}, + new UserModel() { Username = "DavidM", Password = "poIu789", Email = "daveyboy@marsh.com", DateOfBirth = new DateTime(1965, 06, 21), Description = "Java fan boy"}, new UserModel() { Username = "JessieJ", Password = "jlkJh567", Email = "jj@apple.co.uk", DateOfBirth = new DateTime(1990, 10, 15), Description = ""} }; }
--- a/SilverlightValidation/SilverlightValidation/Diagrams/Form.cd Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ClassDiagram MajorVersion="1" MinorVersion="1"> - <Class Name="SilverlightValidation.RelayCommand" Collapsed="true" BaseTypeListCollapsed="true"> - <Position X="6.75" Y="5.5" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAAAIEACAAQAAECAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> - <FileName>RelayCommand.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" Collapsed="true" /> - </Class> - <Class Name="SilverlightValidation.ViewModelBase"> - <Position X="1.75" Y="0.5" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAACAABQAAABAAAAAgAAgAAAAACIAAAAAAARAAA=</HashCode> - <FileName>ViewModelBase.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.UserModel" BaseTypeListCollapsed="true"> - <Position X="9.25" Y="0.5" Width="1.5" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAEACAAAAAAAAABA=</HashCode> - <FileName>UserModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" Collapsed="true" /> - </Class> - <Class Name="SilverlightValidation.UserModelValidator"> - <Position X="6.75" Y="3.75" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAA=</HashCode> - <FileName>UserModelValidator.cs</FileName> - </TypeIdentifier> - </Class> - <Class Name="SilverlightValidation.UserViewModel"> - <Position X="4.25" Y="0.5" Width="2" /> - <TypeIdentifier> - <HashCode>UAAAoIIABCIgAAAAEYAAGAAAAAAQABAKQAAAAAAAIAA=</HashCode> - <FileName>UserViewModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Interface Name="SilverlightValidation.IUserModel"> - <Position X="6.75" Y="0.5" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAAACAAAAAAAAAAA=</HashCode> - <FileName>UserModel.cs</FileName> - </TypeIdentifier> - </Interface> - <Interface Name="SilverlightValidation.ICloneable<T>"> - <Position X="6.75" Y="2.5" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA=</HashCode> - <FileName>UserModel.cs</FileName> - </TypeIdentifier> - </Interface> - <Font Name="Segoe UI" Size="9" /> -</ClassDiagram> \ No newline at end of file
--- a/SilverlightValidation/SilverlightValidation/Diagrams/List.cd Sat Apr 21 19:20:28 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ClassDiagram MajorVersion="1" MinorVersion="1"> - <Class Name="SilverlightValidation.UserListViewModel"> - <Position X="8.25" Y="0.75" Width="2" /> - <TypeIdentifier> - <HashCode>QAAAIAIAAAIAAAAAAAAAEAAAAAAAABAIQAAAAAAAAAA=</HashCode> - <FileName>UserListViewModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.ViewModelBase"> - <Position X="5.5" Y="0.75" Width="2.25" /> - <TypeIdentifier> - <HashCode>AAAAAAACAABQAAABAAAAAgAAgAAAAACIAAAAAAARAAA=</HashCode> - <FileName>ViewModelBase.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.UserViewModel"> - <Position X="3" Y="0.75" Width="2" /> - <TypeIdentifier> - <HashCode>UAAAoIIADCIgAAAAEYAAGAAAAAAQABAKQEAAAAAgIAA=</HashCode> - <FileName>UserViewModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.UserModel" BaseTypeListCollapsed="true"> - <Position X="5.5" Y="4.75" Width="2.25" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAEACAAAAAAAAABA=</HashCode> - <FileName>UserModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" Collapsed="true" /> - </Class> - <Interface Name="SilverlightValidation.IUserModel"> - <Position X="8.25" Y="4.75" Width="1.5" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAAACAAAAAAAAAAA=</HashCode> - <FileName>UserModel.cs</FileName> - </TypeIdentifier> - </Interface> - <Font Name="Segoe UI" Size="9" /> -</ClassDiagram> \ No newline at end of file
--- a/SilverlightValidation/SilverlightValidation/SilverlightValidation.csproj Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/SilverlightValidation.csproj Sat Apr 21 21:19:39 2012 +0100 @@ -27,7 +27,7 @@ <ValidateXaml>true</ValidateXaml> <EnableOutOfBrowser>false</EnableOutOfBrowser> <OutOfBrowserSettingsFile>Properties\OutOfBrowserSettings.xml</OutOfBrowserSettingsFile> - <UsePlatformExtensions>false</UsePlatformExtensions> + <UsePlatformExtensions>true</UsePlatformExtensions> <ThrowErrorsInValidation>true</ThrowErrorsInValidation> <LinkedServerProject> </LinkedServerProject> @@ -98,6 +98,7 @@ <Compile Include="Data\Factory.cs" /> <Compile Include="Interfaces\ICloneable.cs" /> <Compile Include="Interfaces\IUserModel.cs" /> + <Compile Include="Messages\UserViewResponseMessage.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Commands\RelayCommand.cs" /> <Compile Include="ViewModels\UserListViewModel.cs" /> @@ -127,13 +128,10 @@ </Page> </ItemGroup> <ItemGroup> - <None Include="Diagrams\List.cd" /> - <None Include="Diagrams\Form.cd" /> + <None Include="Diagrams\Overview.cd" /> <None Include="Properties\AppManifest.xml" /> </ItemGroup> - <ItemGroup> - <Folder Include="Messages\" /> - </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets.
--- a/SilverlightValidation/SilverlightValidation/ViewModels/UserListViewModel.cs Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/ViewModels/UserListViewModel.cs Sat Apr 21 21:19:39 2012 +0100 @@ -5,11 +5,15 @@ using SilverlightValidation.Models; using SilverlightValidation.Validators; using SilverlightValidation.Views; +using GalaSoft.MvvmLight.Messaging; +using SilverlightValidation.Messages; namespace SilverlightValidation.ViewModels { public class UserListViewModel { + UserView window; + public UserListViewModel(IList<UserModel> models, UserModelValidator validator) { Data = new ObservableCollection<UserViewModel>(); @@ -19,6 +23,15 @@ AddCommand = new RelayCommand(AddCommandExecute); DeleteCommand = new RelayCommand(DeleteCommandExecute); + + Messenger.Default.Register<UserViewResponseMessage>(this, UserViewResponseMessageReceived); + } + + private void UserViewResponseMessageReceived(UserViewResponseMessage userViewResponseMessage) + { + if (userViewResponseMessage.UserViewModel != null) + Data.Add(userViewResponseMessage.UserViewModel); + window.Close(); } #region Properties @@ -36,10 +49,7 @@ private void AddCommandExecute(object obj) { - // rather than hard code the view here - // you could raise a notification using - // PRISM EventAggregator or MVVMLight Messenger - var window = new UserView(); + window = new UserView(); window.Show(); }
--- a/SilverlightValidation/SilverlightValidation/ViewModels/UserViewModel.cs Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/ViewModels/UserViewModel.cs Sat Apr 21 21:19:39 2012 +0100 @@ -8,10 +8,12 @@ using SilverlightValidation.Validators; using SilverlightValidation.Models; using SilverlightValidation.Commands; +using GalaSoft.MvvmLight.Messaging; +using SilverlightValidation.Messages; namespace SilverlightValidation.ViewModels { - public class UserViewModel : ViewModelBase, IUserModel, IChangeTracking, IEditableObject + public class UserViewModel : ViewModelBase, IUserModel, IEditableObject { #region Fields @@ -39,11 +41,11 @@ private void SetProperties(IUserModel source) { - Username = source.Username; - Password = source.Password; - Email = source.Email; - DateOfBirth = source.DateOfBirth; - Description = source.Description; + _data.Username = source.Username; + _data.Password = source.Password; + _data.Email = source.Email; + _data.DateOfBirth = source.DateOfBirth; + _data.Description = source.Description; } #endregion @@ -159,35 +161,35 @@ private void OkCommandExecute(object obj) { - SetProperties(_data); + RefreshToViewErrors(); if (IsChanged && !HasErrors) { - AcceptChanges(); + // save here + Messenger.Default.Send<UserViewResponseMessage>( + new UserViewResponseMessage() { UserViewModel = this }); } } + // in case user hasn't touched the form + private void RefreshToViewErrors() + { + Username = _data.Username; + Password = _data.Password; + Email = _data.Email; + DateOfBirth = _data.DateOfBirth; + } + private void CancelCommandExecute(object obj) { - CancelChanges(); + Messenger.Default.Send<UserViewResponseMessage>( + new UserViewResponseMessage() { UserViewModel = null }); } #endregion - #region IChangeTrack plus Cancel - - public void AcceptChanges() + private void ResetFormData() { - MessageBox.Show("Saving..."); - SetProperties(_backup); - - ClearAllErrors(); - IsChanged = false; - } - - public void CancelChanges() - { - if (!IsChanged) return; SetProperties(_backup); ClearAllErrors(); IsChanged = false; @@ -195,33 +197,27 @@ public bool IsChanged { get; private set; } - #endregion - - #region + #region IEditableObject for datagrid private bool inEdit; public void BeginEdit() { if (inEdit) return; inEdit = true; - SetProperties(_backup); } public void CancelEdit() { if (!inEdit) return; inEdit = false; - CancelChanges(); + ResetFormData(); } public void EndEdit() { if (!inEdit) return; - inEdit = false; - SetProperties(_backup); } #endregion - } }
--- a/SilverlightValidation/SilverlightValidation/Views/UserListView.xaml Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/Views/UserListView.xaml Sat Apr 21 21:19:39 2012 +0100 @@ -16,7 +16,6 @@ <RowDefinition Height="30" /> <RowDefinition Height="40" /> <RowDefinition Height="300" /> - <RowDefinition Height="50" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> @@ -42,8 +41,9 @@ Grid.Column="1" AutoGenerateColumns="False" ItemsSource="{Binding Data}" - SelectionMode="Single" - SelectedItem="{Binding SelectedItem, Mode=TwoWay}"> + SelectedItem="{Binding SelectedItem, + Mode=TwoWay}" + SelectionMode="Single"> <controls:DataGrid.Columns> <controls:DataGridTextColumn Width="125" Binding="{Binding Username,
--- a/SilverlightValidation/SilverlightValidation/Views/UserView.xaml Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/Views/UserView.xaml Sat Apr 21 21:19:39 2012 +0100 @@ -39,7 +39,6 @@ <TextBox x:Name="tbUsername" Grid.Row="1" Grid.Column="2" - LostFocus="tbUsername_LostFocus" Style="{StaticResource TextBoxStyle}" Text="{Binding Username, Mode=TwoWay, @@ -60,7 +59,6 @@ <PasswordBox x:Name="tbPassword" Grid.Row="2" Grid.Column="2" - LostFocus="tbPassword_LostFocus" Password="{Binding Password, Mode=TwoWay, ValidatesOnNotifyDataErrors=True, @@ -81,7 +79,6 @@ <TextBox x:Name="tbEmail" Grid.Row="3" Grid.Column="2" - LostFocus="tbEmail_LostFocus" Style="{StaticResource TextBoxStyle}" Text="{Binding Email, Mode=TwoWay, @@ -103,7 +100,6 @@ Grid.Row="4" Grid.Column="2" KeyDown="DatePicker_KeyDown" - LostFocus="dpDateOfBirth_LostFocus" SelectedDate="{Binding DateOfBirth, Mode=TwoWay, ValidatesOnNotifyDataErrors=True,
--- a/SilverlightValidation/SilverlightValidation/Views/UserView.xaml.cs Sat Apr 21 19:20:28 2012 +0100 +++ b/SilverlightValidation/SilverlightValidation/Views/UserView.xaml.cs Sat Apr 21 21:19:39 2012 +0100 @@ -1,18 +1,14 @@ -using System.Windows; -using System.Windows.Browser; -using System.Windows.Controls; -using System.Windows.Data; +using System.Windows.Browser; using System.Windows.Input; -using SilverlightValidation.ViewModels; using SilverlightValidation.Models; using SilverlightValidation.Validators; +using SilverlightValidation.ViewModels; namespace SilverlightValidation.Views { public partial class UserView { private UserViewModel vm; - private UserListViewModel Parent { get; set; } public UserView() { @@ -23,38 +19,10 @@ this.DataContext = vm; } - private static void UpdateTextBoxSource(object sender) - { - BindingExpression be = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty); - be.UpdateSource(); - } - private void DatePicker_KeyDown(object sender, KeyEventArgs e) { if (e.Key != Key.Tab) e.Handled = true; } - - private void tbUsername_LostFocus(object sender, RoutedEventArgs e) - { - UpdateTextBoxSource(sender); - } - - private void tbPassword_LostFocus(object sender, RoutedEventArgs e) - { - BindingExpression be = ((PasswordBox)sender).GetBindingExpression(PasswordBox.PasswordProperty); - be.UpdateSource(); - } - - private void tbEmail_LostFocus(object sender, RoutedEventArgs e) - { - UpdateTextBoxSource(sender); - } - - private void dpDateOfBirth_LostFocus(object sender, RoutedEventArgs e) - { - BindingExpression be = ((DatePicker)sender).GetBindingExpression(DatePicker.SelectedDateProperty); - be.UpdateSource(); - } } } \ No newline at end of file