# HG changeset patch # User Steven Hollidge # Date 1335217433 -3600 # Node ID dd6bcd2535b692a43a66b002661a3bbdce5377c7 # Parent 86ed4919b1262b9c3a8b4db59509cc79c825b12a Working version diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightGlimpse.Test/App.xaml --- a/SilverlightGlimpse/SilverlightGlimpse.Test/App.xaml Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightGlimpse.Test/App.xaml Mon Apr 23 22:43:53 2012 +0100 @@ -1,8 +1,4 @@ - - - - + diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightGlimpse.sln --- a/SilverlightGlimpse/SilverlightGlimpse.sln Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightGlimpse.sln Mon Apr 23 22:43:53 2012 +0100 @@ -3,6 +3,8 @@ # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightGlimpse", "SilverlightGlimpse\SilverlightGlimpse.csproj", "{BB51026B-2864-4389-AACA-0BBDF1926E46}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightGlimpse.Test", "SilverlightGlimpse.Test\SilverlightGlimpse.Test.csproj", "{212DBD25-6C98-45EB-9974-51D04D8B6549}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightValidation", "SilverlightValidation\SilverlightValidation.csproj", "{0C1CC1FC-915A-4428-8952-CDC79EABC3F4}" EndProject Global @@ -15,6 +17,10 @@ {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 + {212DBD25-6C98-45EB-9974-51D04D8B6549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {212DBD25-6C98-45EB-9974-51D04D8B6549}.Debug|Any CPU.Build.0 = Debug|Any CPU + {212DBD25-6C98-45EB-9974-51D04D8B6549}.Release|Any CPU.ActiveCfg = Release|Any CPU + {212DBD25-6C98-45EB-9974-51D04D8B6549}.Release|Any CPU.Build.0 = Release|Any CPU {0C1CC1FC-915A-4428-8952-CDC79EABC3F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0C1CC1FC-915A-4428-8952-CDC79EABC3F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {0C1CC1FC-915A-4428-8952-CDC79EABC3F4}.Release|Any CPU.ActiveCfg = Release|Any CPU diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightGlimpse/Controls/FloatableWindow/FloatableWindow.cs --- a/SilverlightGlimpse/SilverlightGlimpse/Controls/FloatableWindow/FloatableWindow.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightGlimpse/Controls/FloatableWindow/FloatableWindow.cs Mon Apr 23 22:43:53 2012 +0100 @@ -437,8 +437,8 @@ _parentLayoutRoot = value; var grid = _parentLayoutRoot as Grid; if (grid == null) return; - Grid.SetRowSpan(this, grid.RowDefinitions.Count); - Grid.SetColumnSpan(this, grid.ColumnDefinitions.Count); + if (grid.RowDefinitions.Count > 0) Grid.SetRowSpan(this, grid.RowDefinitions.Count); + if (grid.ColumnDefinitions.Count > 0) Grid.SetColumnSpan(this, grid.ColumnDefinitions.Count); } } diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightGlimpse/Services/BrokenBindingsService.cs --- a/SilverlightGlimpse/SilverlightGlimpse/Services/BrokenBindingsService.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightGlimpse/Services/BrokenBindingsService.cs Mon Apr 23 22:43:53 2012 +0100 @@ -50,7 +50,8 @@ continue; } - if (PropertyPathHelper.GetValue(fe, "Text").ToString() != string.Empty) + var value = PropertyPathHelper.GetValue(fe, "Text"); + if ((value!=null) && value.ToString() != string.Empty) continue; var brokenBinding = new BindingError( diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/App.xaml.cs --- a/SilverlightGlimpse/SilverlightValidation/App.xaml.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/App.xaml.cs Mon Apr 23 22:43:53 2012 +0100 @@ -20,8 +20,8 @@ const string appName = "Silverlight Glimpse"; try { - this.RootVisual = new Views.UserListView(); - Glimpse.Service.Load(this, appName, new TimeSpan(0,0,0,10)); + this.RootVisual = new Views.UserView(); + Glimpse.Service.Load(this, appName); } catch (Exception ex) { diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Commands/RelayCommand.cs --- a/SilverlightGlimpse/SilverlightValidation/Commands/RelayCommand.cs Mon Apr 23 22:06:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -using System; -using System.Windows.Input; - -namespace SilverlightValidation.Commands -{ - public class RelayCommand : ICommand - { - private readonly Predicate _canExecute; - private readonly Action _execute; - - public RelayCommand(Action execute, - Predicate canExecute = null) - { - if (execute == null) throw new ArgumentNullException("execute"); - - _execute = execute; - _canExecute = canExecute; - } - - #region ICommand Members - - public event EventHandler CanExecuteChanged = delegate { }; - - - public bool CanExecute(object parameter) - { - return _canExecute == null || _canExecute(parameter); - } - - - public void Execute(object parameter) - { - _execute(parameter); - } - - #endregion - - public void UpdateCanExecuteCommand() - { - CanExecuteChanged(this, new EventArgs()); - } - } -} \ No newline at end of file diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Data/Factory.cs --- a/SilverlightGlimpse/SilverlightValidation/Data/Factory.cs Mon Apr 23 22:06:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using SilverlightValidation.Models; - -namespace SilverlightValidation.Data -{ - public class Factory - { - public static IList CreateUserModels() - { - return new List(5) - { - new UserModel() { Username = "StevenH", Password = "Password1", Email = "steven@hotmail.com", DateOfBirth = new DateTime(1977, 09, 01), Description = "Great binding works"}, - 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 = "Adores fruit"}, - 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 = "StackOverflow deity"} - }; - } - } -} diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Diagrams/Overview.cd --- a/SilverlightGlimpse/SilverlightValidation/Diagrams/Overview.cd Mon Apr 23 22:06:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ - - - - - - AAAAAAAAACAgAAAAAQAAAAAAAAAQAEACAAAAAAAAABA= - Models\UserModel.cs - - - - - - - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAA= - Validators\UserModelValidator.cs - - - - - - AAAAAAAAAAAAAAECAAAAAAAAAAAAABAYABEACAAAAAA= - ViewModels\UserListViewModel.cs - - - - - - UAAAoIAADCIgAAAAMYAACAAAAAAQABAKQEAAAAAgIAA= - ViewModels\UserViewModel.cs - - - - - - - AAAAAAACAABQAAABAAAAAgAAgAAAAACIAAAAAAARAAA= - ViewModels\ViewModelBase.cs - - - - - - - AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA= - Messages\UserViewResponseMessage.cs - - - - - - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA= - Interfaces\ICloneable.cs - - - - - - AAAAAAAAACAgAAAAAQAAAAAAAAAQAAACAAAAAAAAAAA= - Interfaces\IUserModel.cs - - - - \ No newline at end of file diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Interfaces/ICloneable.cs --- a/SilverlightGlimpse/SilverlightValidation/Interfaces/ICloneable.cs Mon Apr 23 22:06:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -namespace SilverlightValidation.Interfaces -{ - public interface ICloneable - { - T Clone(); - } -} diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Messages/UserViewResponseMessage.cs --- a/SilverlightGlimpse/SilverlightValidation/Messages/UserViewResponseMessage.cs Mon Apr 23 22:06:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -using GalaSoft.MvvmLight.Messaging; -using SilverlightValidation.ViewModels; - -namespace SilverlightValidation.Messages -{ - public class UserViewResponseMessage : MessageBase - { - public UserViewModel UserViewModel { get; set; } - } -} diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Models/UserModel.cs --- a/SilverlightGlimpse/SilverlightValidation/Models/UserModel.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Models/UserModel.cs Mon Apr 23 22:43:53 2012 +0100 @@ -1,10 +1,9 @@ using System; -using System.ComponentModel; using SilverlightValidation.Interfaces; namespace SilverlightValidation.Models { - public class UserModel : IUserModel, ICloneable + public class UserModel : IUserModel { public string Username { get; set; } public string Email { get; set; } diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/SilverlightValidation.csproj --- a/SilverlightGlimpse/SilverlightValidation/SilverlightValidation.csproj Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/SilverlightValidation.csproj Mon Apr 23 22:43:53 2012 +0100 @@ -90,18 +90,10 @@ App.xaml - - - - - - - UserListView.xaml - UserView.xaml @@ -113,17 +105,12 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer - diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Validators/UserModelValidator.cs --- a/SilverlightGlimpse/SilverlightValidation/Validators/UserModelValidator.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Validators/UserModelValidator.cs Mon Apr 23 22:43:53 2012 +0100 @@ -1,5 +1,6 @@ using System; using FluentValidation; +using SilverlightValidation.Models; using SilverlightValidation.Interfaces; namespace SilverlightValidation.Validators diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/ViewModels/UserViewModel.cs --- a/SilverlightGlimpse/SilverlightValidation/ViewModels/UserViewModel.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/ViewModels/UserViewModel.cs Mon Apr 23 22:43:53 2012 +0100 @@ -1,25 +1,18 @@ using System; -using System.ComponentModel; using System.Linq; -using System.Windows; -using System.Windows.Input; using FluentValidation; using SilverlightValidation.Interfaces; using SilverlightValidation.Validators; using SilverlightValidation.Models; -using SilverlightValidation.Commands; -using GalaSoft.MvvmLight.Messaging; -using SilverlightValidation.Messages; namespace SilverlightValidation.ViewModels { - public class UserViewModel : ViewModelBase, IUserModel, IEditableObject + public class UserViewModel : ViewModelBase, IUserModel { #region Fields private readonly UserModelValidator _validator; private UserModel _data; - private UserModel _backup; #endregion @@ -29,23 +22,6 @@ { _validator = validator; _data = model; - _backup = model.Clone(); - - OkCommand = new RelayCommand(OkCommandExecute); - CancelCommand = new RelayCommand(CancelCommandExecute); - } - - #endregion - - #region Methods - - private void SetProperties(IUserModel source) - { - _data.Username = source.Username; - _data.Password = source.Password; - _data.Email = source.Email; - _data.DateOfBirth = source.DateOfBirth; - _data.Description = source.Description; } #endregion @@ -62,7 +38,6 @@ { _data.Username = value; RaisePropertyChanged(UsernameProperty); - IsChanged = true; } ClearError(UsernameProperty); @@ -82,7 +57,6 @@ { _data.Password = value; RaisePropertyChanged(PasswordProperty); - IsChanged = true; } ClearError(PasswordProperty); @@ -102,7 +76,6 @@ { _data.Email = value; RaisePropertyChanged(EmailProperty); - IsChanged = true; } ClearError(EmailProperty); @@ -122,7 +95,6 @@ { _data.DateOfBirth = value; RaisePropertyChanged(DateOfBirthProperty); - IsChanged = true; } ClearError(DateOfBirthProperty); @@ -142,7 +114,6 @@ { _data.Description = value; RaisePropertyChanged(DescriptionProperty); - IsChanged = true; } ClearError(DescriptionProperty); @@ -153,71 +124,5 @@ } #endregion - - #region Commands - - public ICommand OkCommand { get; set; } - public ICommand CancelCommand { get; set; } - - private void OkCommandExecute(object obj) - { - RefreshToViewErrors(); - - if (IsChanged && !HasErrors) - { - // save here - Messenger.Default.Send( - 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) - { - Messenger.Default.Send( - new UserViewResponseMessage() { UserViewModel = null }); - } - - #endregion - - private void ResetFormData() - { - SetProperties(_backup); - ClearAllErrors(); - IsChanged = false; - } - - public bool IsChanged { get; private set; } - - #region IEditableObject for datagrid - - private bool inEdit; - public void BeginEdit() - { - if (inEdit) return; - inEdit = true; - } - - public void CancelEdit() - { - if (!inEdit) return; - inEdit = false; - ResetFormData(); - } - - public void EndEdit() - { - if (!inEdit) return; - } - - #endregion } } diff -r 86ed4919b126 -r dd6bcd2535b6 SilverlightGlimpse/SilverlightValidation/Views/UserView.xaml --- a/SilverlightGlimpse/SilverlightValidation/Views/UserView.xaml Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Views/UserView.xaml Mon Apr 23 22:43:53 2012 +0100 @@ -1,11 +1,7 @@ - + @@ -20,11 +16,11 @@ - + - + + Description="Required" /> + Description="Required" /> + Description="Required" /> + Description="Required" /> + Text="{Binding IncorectBindingPath}" />