Mercurial > silverbladetech
diff Chronosv2/source/Modules/Sample/ViewModels/EmpresaViewModel.cs @ 10:443821e55f06
Initial cleaned up add from Codeplex files
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Tue, 21 Feb 2012 17:25:44 +0700 |
parents | |
children | 09d18d6e5f40 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Chronosv2/source/Modules/Sample/ViewModels/EmpresaViewModel.cs Tue Feb 21 17:25:44 2012 +0700 @@ -0,0 +1,448 @@ +/* +The MIT License + +Copyright (c) 2009-2010. Carlos Guzmán Álvarez. http://chronoswpf.codeplex.com/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System.ComponentModel; +using Chronos.Modules.Navigation; +using Chronos.Modules.Sample.Models; +using Chronos.Presentation.Core.Windows; +using Chronos.Presentation.ViewModel; +using Chronos.Presentation.Core.Navigation; +using nRoute.Components; +using System.Collections.ObjectModel; + +namespace Chronos.Modules.Sample.ViewModels +{ + public sealed class EmpresaViewModel + : WorkspaceViewModel<EmpresaEntity> + { + #region · PropertyChangedEventArgs Cached Instances · + + private static readonly PropertyChangedEventArgs IdEmpresaChangedArgs = CreateArgs<EmpresaViewModel>(x => x.IdEmpresa); + private static readonly PropertyChangedEventArgs CifChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Cif); + private static readonly PropertyChangedEventArgs IdEpigrafeIaeChangedArgs = CreateArgs<EmpresaViewModel>(x => x.IdEpigrafeIae); + private static readonly PropertyChangedEventArgs IdCnaeChangedArgs = CreateArgs<EmpresaViewModel>(x => x.IdCnae); + private static readonly PropertyChangedEventArgs NombreChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Nombre); + private static readonly PropertyChangedEventArgs NombreComercialChangedArgs = CreateArgs<EmpresaViewModel>(x => x.NombreComercial); + private static readonly PropertyChangedEventArgs IdTipoViaChangedArgs = CreateArgs<EmpresaViewModel>(x => x.IdTipoVia); + private static readonly PropertyChangedEventArgs DireccionChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Direccion); + private static readonly PropertyChangedEventArgs NumeroBloqueChangedArgs = CreateArgs<EmpresaViewModel>(x => x.NumeroBloque); + private static readonly PropertyChangedEventArgs PisoChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Piso); + private static readonly PropertyChangedEventArgs PuertaChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Puerta); + private static readonly PropertyChangedEventArgs CodigoPostalChangedArgs = CreateArgs<EmpresaViewModel>(x => x.CodigoPostal); + private static readonly PropertyChangedEventArgs CiudadChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Ciudad); + private static readonly PropertyChangedEventArgs ProvinciaChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Provincia); + private static readonly PropertyChangedEventArgs PaisChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Pais); + private static readonly PropertyChangedEventArgs Telefono1ChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Telefono1); + private static readonly PropertyChangedEventArgs Telefono2ChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Telefono2); + private static readonly PropertyChangedEventArgs Fax1ChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Fax1); + private static readonly PropertyChangedEventArgs Fax2ChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Fax2); + private static readonly PropertyChangedEventArgs WwwChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Www); + private static readonly PropertyChangedEventArgs EmailChangedArgs = CreateArgs<EmpresaViewModel>(x => x.Email); + + #endregion + + #region · Model Data · + + public string IdEmpresa + { + get { return this.Entity.IdEmpresa; } + set + { + if (this.Entity.IdEmpresa != value) + { + this.Entity.IdEmpresa = value; + this.NotifyPropertyChanged(IdEmpresaChangedArgs); + } + } + } + + public string Cif + { + get { return this.Entity.Cif; } + set + { + if (this.Entity.Cif != value) + { + this.Entity.Cif = value; + this.NotifyPropertyChanged(CifChangedArgs); + } + } + } + + public string IdEpigrafeIae + { + get { return this.Entity.IdEpigrafeIae; } + set + { + if (this.Entity.IdEpigrafeIae != value) + { + this.Entity.IdEpigrafeIae = value; + this.NotifyPropertyChanged(IdEpigrafeIaeChangedArgs); + } + } + } + + public string IdCnae + { + get { return this.Entity.IdCnae; } + set + { + if (this.Entity.IdCnae != value) + { + this.Entity.IdCnae = value; + this.NotifyPropertyChanged(IdCnaeChangedArgs); + } + } + } + + public string Nombre + { + get { return this.Entity.Nombre; } + set + { + if (this.Entity.Nombre != value) + { + this.Entity.Nombre = value; + this.NotifyPropertyChanged(NombreChangedArgs); + } + } + } + + public string NombreComercial + { + get { return this.Entity.NombreComercial; } + set + { + if (this.Entity.NombreComercial != value) + { + this.Entity.NombreComercial = value; + this.NotifyPropertyChanged(NombreComercialChangedArgs); + } + } + } + + public string IdTipoVia + { + get { return this.Entity.IdTipoVia; } + set + { + if (this.Entity.IdTipoVia != value) + { + this.Entity.IdTipoVia = value; + this.NotifyPropertyChanged(IdTipoViaChangedArgs); + } + } + } + + public string Direccion + { + get { return this.Entity.Direccion; } + set + { + if (this.Entity.Direccion != value) + { + this.Entity.Direccion = value; + this.NotifyPropertyChanged(DireccionChangedArgs); + } + } + } + + public string NumeroBloque + { + get { return this.Entity.NumeroBloque; } + set + { + if (this.Entity.NumeroBloque != value) + { + this.Entity.NumeroBloque = value; + this.NotifyPropertyChanged(NumeroBloqueChangedArgs); + } + } + } + + public string Piso + { + get { return this.Entity.Piso; } + set + { + if (this.Entity.Piso != value) + { + this.Entity.Piso = value; + this.NotifyPropertyChanged(PisoChangedArgs); + } + } + } + + public string Puerta + { + get { return this.Entity.Puerta; } + set + { + if (this.Entity.Puerta != value) + { + this.Entity.Puerta = value; + this.NotifyPropertyChanged(PuertaChangedArgs); + } + } + } + + public string CodigoPostal + { + get { return this.Entity.CodigoPostal; } + set + { + if (this.Entity.CodigoPostal != value) + { + this.Entity.CodigoPostal = value; + this.NotifyPropertyChanged(CodigoPostalChangedArgs); + } + } + } + + public string Ciudad + { + get { return this.Entity.Ciudad; } + set + { + if (this.Entity.Ciudad != value) + { + this.Entity.Ciudad = value; + this.NotifyPropertyChanged(CiudadChangedArgs); + } + } + } + + public string Provincia + { + get { return this.Entity.Provincia; } + set + { + if (this.Entity.Provincia != value) + { + this.Entity.Provincia = value; + this.NotifyPropertyChanged(ProvinciaChangedArgs); + } + } + } + + public string Pais + { + get { return this.Entity.Pais; } + set + { + if (this.Entity.Pais != value) + { + this.Entity.Pais = value; + this.NotifyPropertyChanged(PaisChangedArgs); + } + } + } + + public string Telefono1 + { + get { return this.Entity.Telefono1; } + set + { + if (this.Entity.Telefono1 != value) + { + this.Entity.Telefono1 = value; + this.NotifyPropertyChanged(Telefono1ChangedArgs); + } + } + } + + public string Telefono2 + { + get { return this.Entity.Telefono2; } + set + { + if (this.Entity.Telefono2 != value) + { + this.Entity.Telefono2 = value; + this.NotifyPropertyChanged(Telefono2ChangedArgs); + } + } + } + + public string Fax1 + { + get { return this.Entity.Fax1; } + set + { + if (this.Entity.Fax1 != value) + { + this.Entity.Fax1 = value; + this.NotifyPropertyChanged(Fax1ChangedArgs); + } + } + } + + public string Fax2 + { + get { return this.Entity.Fax2; } + set + { + if (this.Entity.Fax2 != value) + { + this.Entity.Fax2 = value; + this.NotifyPropertyChanged(Fax2ChangedArgs); + } + } + } + + public string Www + { + get { return this.Entity.Www; } + set + { + if (this.Entity.Www != value) + { + this.Entity.Www = value; + this.NotifyPropertyChanged(WwwChangedArgs); + } + } + } + + public string Email + { + get { return this.Entity.Email; } + set + { + if (this.Entity.Email != value) + { + this.Entity.Email = value; + this.NotifyPropertyChanged(EmailChangedArgs); + } + } + } + + #endregion + + #region · Properties · + + /// <summary> + /// Gets the navigation URL + /// </summary> + /// <value></value> + public override string NavigationRoute + { + get { return NavigationRoutes.Companies; } + } + + #endregion + + #region · Constructors · + + public EmpresaViewModel() + : base() + { + } + + #endregion + + #region · Overriden Methods · + + protected override void OnInitialize(nRoute.Components.ParametersCollection requestParameters) + { + if (requestParameters.ContainsKey(NavigationParams.NavigationParamsKey)) + { + object[] rparams = requestParameters.GetValueOrDefault<object[]>(NavigationParams.NavigationParamsKey, null); + + if (rparams != null && rparams[0] is int) + { + int value = (int)rparams[0]; + } + } + } + + protected override void InitializePropertyStates() + { + this.PropertyStates.Add(e => e.IdEmpresa); + this.PropertyStates.Add(e => e.Nombre); + this.PropertyStates.Add(e => e.Cif); + this.PropertyStates.Add(e => e.IdEpigrafeIae); + this.PropertyStates.Add(e => e.IdCnae); + this.PropertyStates.Add(e => e.NombreComercial); + this.PropertyStates.Add(e => e.IdTipoVia); + this.PropertyStates.Add(e => e.Direccion); + this.PropertyStates.Add(e => e.NumeroBloque); + this.PropertyStates.Add(e => e.Piso); + this.PropertyStates.Add(e => e.Puerta); + this.PropertyStates.Add(e => e.CodigoPostal); + this.PropertyStates.Add(e => e.Ciudad); + this.PropertyStates.Add(e => e.Provincia); + this.PropertyStates.Add(e => e.Pais); + this.PropertyStates.Add(e => e.Telefono1); + this.PropertyStates.Add(e => e.Telefono2); + this.PropertyStates.Add(e => e.Fax1); + this.PropertyStates.Add(e => e.Fax2); + this.PropertyStates.Add(e => e.Www); + this.PropertyStates.Add(e => e.Email); + } + + protected override void OnViewModeChanged() + { + base.OnViewModeChanged(); + + if (this.PropertyStates.Count > 0) + { + bool editing = this.ViewMode == Chronos.Presentation.Core.Windows.ViewModeType.Add || + this.ViewMode == Chronos.Presentation.Core.Windows.ViewModeType.Edit; + + this.PropertyStates[x => x.IdEmpresa].IsEditable = this.ViewMode == ViewModeType.ViewOnly; + this.PropertyStates[x => x.Nombre].IsEditable = editing; + this.PropertyStates[x => x.Cif].IsEditable = editing; + this.PropertyStates[x => x.NombreComercial].IsEditable = editing; + this.PropertyStates[x => x.IdEpigrafeIae].IsEditable = editing; + this.PropertyStates[x => x.IdCnae].IsEditable = editing; + this.PropertyStates[x => x.NombreComercial].IsEditable = editing; + this.PropertyStates[x => x.IdTipoVia].IsEditable = editing; + this.PropertyStates[x => x.Direccion].IsEditable = editing; + this.PropertyStates[x => x.NumeroBloque].IsEditable = editing; + this.PropertyStates[x => x.Piso].IsEditable = editing; + this.PropertyStates[x => x.Puerta].IsEditable = editing; + this.PropertyStates[x => x.CodigoPostal].IsEditable = editing; + this.PropertyStates[x => x.Ciudad].IsEditable = editing; + this.PropertyStates[x => x.Provincia].IsEditable = editing; + this.PropertyStates[x => x.Pais].IsEditable = editing; + this.PropertyStates[x => x.Telefono1].IsEditable = editing; + this.PropertyStates[x => x.Telefono2].IsEditable = editing; + this.PropertyStates[x => x.Fax1].IsEditable = editing; + this.PropertyStates[x => x.Fax2].IsEditable = editing; + this.PropertyStates[x => x.Www].IsEditable = editing; + this.PropertyStates[x => x.Email].IsEditable = editing; + } + } + + #endregion + + #region · Command Actions · + + protected override void OnInquiryAction(InquiryActionResult<EmpresaEntity> result) + { + } + + #endregion + } +} \ No newline at end of file