Mercurial > silverbladetech
changeset 78:dd6bcd2535b6
Working version
line wrap: on
line diff
--- 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 @@ -<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - x:Class="SilverlightGlimpse.Test.App" - > - <Application.Resources> - - </Application.Resources> +<Application x:Class="SilverlightGlimpse.Test.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> </Application>
--- 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
--- 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); } }
--- 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(
--- 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) {
--- 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<object> _canExecute; - private readonly Action<object> _execute; - - public RelayCommand(Action<object> execute, - Predicate<object> 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
--- 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<UserModel> CreateUserModels() - { - return new List<UserModel>(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"} - }; - } - } -}
--- 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<ClassDiagram MajorVersion="1" MinorVersion="1"> - <Class Name="SilverlightValidation.Models.UserModel"> - <Position X="2.5" Y="1.75" Width="1.5" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAEACAAAAAAAAABA=</HashCode> - <FileName>Models\UserModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.Validators.UserModelValidator" Collapsed="true"> - <Position X="2" Y="7.75" Width="2" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAA=</HashCode> - <FileName>Validators\UserModelValidator.cs</FileName> - </TypeIdentifier> - </Class> - <Class Name="SilverlightValidation.ViewModels.UserListViewModel"> - <Position X="6.25" Y="5.5" Width="2.75" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAECAAAAAAAAAAAAABAYABEACAAAAAA=</HashCode> - <FileName>ViewModels\UserListViewModel.cs</FileName> - </TypeIdentifier> - </Class> - <Class Name="SilverlightValidation.ViewModels.UserViewModel"> - <Position X="4.25" Y="1.75" Width="1.75" /> - <TypeIdentifier> - <HashCode>UAAAoIAADCIgAAAAMYAACAAAAAAQABAKQEAAAAAgIAA=</HashCode> - <FileName>ViewModels\UserViewModel.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.ViewModels.ViewModelBase"> - <Position X="6.25" Y="1.75" Width="2.75" /> - <TypeIdentifier> - <HashCode>AAAAAAACAABQAAABAAAAAgAAgAAAAACIAAAAAAARAAA=</HashCode> - <FileName>ViewModels\ViewModelBase.cs</FileName> - </TypeIdentifier> - <Lollipop Position="0.2" /> - </Class> - <Class Name="SilverlightValidation.Messages.UserViewResponseMessage"> - <Position X="9.25" Y="5" Width="2.25" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA=</HashCode> - <FileName>Messages\UserViewResponseMessage.cs</FileName> - </TypeIdentifier> - </Class> - <Interface Name="SilverlightValidation.Interfaces.ICloneable<T>"> - <Position X="2.5" Y="4.5" Width="1.5" /> - <TypeIdentifier> - <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA=</HashCode> - <FileName>Interfaces\ICloneable.cs</FileName> - </TypeIdentifier> - </Interface> - <Interface Name="SilverlightValidation.Interfaces.IUserModel"> - <Position X="2.5" Y="5.75" Width="1.5" /> - <TypeIdentifier> - <HashCode>AAAAAAAAACAgAAAAAQAAAAAAAAAQAAACAAAAAAAAAAA=</HashCode> - <FileName>Interfaces\IUserModel.cs</FileName> - </TypeIdentifier> - </Interface> - <Font Name="Segoe UI" Size="9" /> -</ClassDiagram> \ No newline at end of file
--- 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> - { - T Clone(); - } -}
--- 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; } - } -}
--- 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<UserModel> + public class UserModel : IUserModel { public string Username { get; set; } public string Email { get; set; }
--- 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 @@ <Compile Include="App.xaml.cs"> <DependentUpon>App.xaml</DependentUpon> </Compile> - <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" /> <Compile Include="Models\UserModel.cs" /> <Compile Include="Validators\UserModelValidator.cs" /> - <Compile Include="Views\UserListView.xaml.cs"> - <DependentUpon>UserListView.xaml</DependentUpon> - </Compile> <Compile Include="Views\UserView.xaml.cs"> <DependentUpon>UserView.xaml</DependentUpon> </Compile> @@ -113,17 +105,12 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </ApplicationDefinition> - <Page Include="Views\UserListView.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Views\UserView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> </ItemGroup> <ItemGroup> - <None Include="Diagrams\Overview.cd" /> <None Include="Properties\AppManifest.xml" /> </ItemGroup> <ItemGroup>
--- 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
--- 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<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) - { - Messenger.Default.Send<UserViewResponseMessage>( - 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 } }
--- 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 @@ -<c:ChildWindow x:Class="SilverlightValidation.Views.UserView" - 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:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" - Title="Add User" - Width="500" - Height="400"> +<UserControl x:Class="SilverlightValidation.Views.UserView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> <Grid x:Name="LayoutRoot" Background="White"> @@ -20,11 +16,11 @@ <RowDefinition Height="120" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> - <ColumnDefinition Width="30" /> + <ColumnDefinition Width="*" /> <ColumnDefinition Width="100" /> <ColumnDefinition Width="300" /> <ColumnDefinition Width="30" /> - <ColumnDefinition Width="30" /> + <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Grid.Row="1" @@ -44,8 +40,7 @@ <sdk:DescriptionViewer Grid.Row="1" Grid.Column="3" Width="20" - Description="Required" - Target="{Binding ElementName=tbUsername}" /> + Description="Required" /> <TextBlock Grid.Row="2" Grid.Column="1" @@ -64,8 +59,7 @@ <sdk:DescriptionViewer Grid.Row="2" Grid.Column="3" Width="20" - Description="Required" - Target="{Binding ElementName=tbPassword}" /> + Description="Required" /> <TextBlock Grid.Row="3" Grid.Column="1" @@ -84,8 +78,7 @@ <sdk:DescriptionViewer Grid.Row="3" Grid.Column="3" Width="20" - Description="Required" - Target="{Binding ElementName=tbEmail}" /> + Description="Required" /> <TextBlock Grid.Row="4" Grid.Column="1" @@ -104,8 +97,7 @@ <sdk:DescriptionViewer Grid.Row="4" Grid.Column="3" Width="20" - Description="Required" - Target="{Binding ElementName=dpDateOfBirth}" /> + Description="Required" /> <TextBlock x:Name="tbDescription" Grid.Row="5" @@ -116,23 +108,16 @@ <TextBox Grid.Row="5" Grid.Column="2" Style="{StaticResource TextBoxStyle}" - Text="{Binding DONEITGAIN}" /> + Text="{Binding IncorectBindingPath}" /> <StackPanel Grid.Row="6" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal"> <Button x:Name="btnThrowException" Width="120" - Margin="0,0,50,0" Click="btnThrowException_OnClick" Content="Throw Exception" Style="{StaticResource ButtonStyle}" /> - <Button Command="{Binding OkCommand}" - Content="OK" - Style="{StaticResource ButtonStyle}" /> - <Button Command="{Binding CancelCommand}" - Content="Cancel" - Style="{StaticResource ButtonStyle}" /> </StackPanel> <sdk:ValidationSummary Grid.Row="7" @@ -141,4 +126,4 @@ Style="{StaticResource ValidationSummaryStyle}" /> </Grid> -</c:ChildWindow> \ No newline at end of file +</UserControl> \ No newline at end of file
--- a/SilverlightGlimpse/SilverlightValidation/Views/UserView.xaml.cs Mon Apr 23 22:06:05 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Views/UserView.xaml.cs Mon Apr 23 22:43:53 2012 +0100 @@ -19,6 +19,9 @@ vm = new UserViewModel(UserModel.Create(), new UserModelValidator()); this.DataContext = vm; + + // uncomment this exception to view exception on startup + //ThrowNestedException(); } private void DatePicker_KeyDown(object sender, KeyEventArgs e) @@ -29,7 +32,13 @@ private void btnThrowException_OnClick(object sender, RoutedEventArgs e) { - throw new Exception("Exception from Child Window"); + ThrowNestedException(); + } + + private void ThrowNestedException() + { + throw new Exception("Oh dear we've hit an exception!", + new Exception("This is an inner exception")); } } } \ No newline at end of file