SHARE
TWEET

Untitled

a guest Nov 29th, 2014 216 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows;
  7. using System.Windows.Input;
  8. using TestMVVM.Commands;
  9. using TestMVVM.Model;
  10. using TestMVVM.Notifications;
  11.  
  12. namespace TestMVVM.ViewModels
  13. {
  14.     class BoreViewModel : PropertyChangedNotification
  15.     {
  16.  
  17.         #region Fields for binding
  18.         public Byte BoreNumber
  19.         {
  20.             get { return GetValue(() => BoreNumber); }
  21.             set { SetValue(() => BoreNumber, value); }
  22.         }
  23.         public String TypeDrilling
  24.         {
  25.             get { return GetValue(() => TypeDrilling); }
  26.             set { SetValue(() => TypeDrilling, value); }
  27.         }
  28.         public String Description
  29.         {
  30.             get { return GetValue(() => Description); }
  31.             set { SetValue(() => Description, value); }
  32.         }
  33.         public DateTime DateBoreBegin
  34.         {
  35.             get { return GetValue(() => DateBoreBegin); }
  36.             set { SetValue(() => DateBoreBegin, value); }
  37.         }
  38.         public DateTime DateBoreEnd
  39.         {
  40.             get { return GetValue(() => DateBoreEnd); }
  41.             set { SetValue(() => DateBoreEnd, value); }
  42.         }
  43.  
  44.         public ObservableCollection<DiameterViewModel> FirstDiameters
  45.         {
  46.             get { return GetValue(() => FirstDiameters); }
  47.             set { SetValue(() => FirstDiameters, value); }
  48.         }
  49.         public ObservableCollection<DiameterViewModel> SecondDiameters
  50.         {
  51.             get { return GetValue(() => SecondDiameters); }
  52.             set { SetValue(() => SecondDiameters, value); }
  53.         }
  54.  
  55.         public ObservableCollection<LayerViewModel> Layers
  56.         {
  57.             get { return GetValue(() => Layers); }
  58.             set { SetValue(() => Layers, value); }
  59.         }
  60.         #endregion
  61.  
  62.         #region Commands
  63.         public RelayCommand EditBoreCommand { get; set; }
  64.  
  65.         public void EditBore(object parameter)
  66.         {
  67.             OuterEditCommand.Execute(this);
  68.         }
  69.  
  70.         public bool CanEditBore(object parameter)
  71.         {
  72.             return true;
  73.         }
  74.  
  75.         ICommand OuterEditCommand;
  76.         #endregion
  77.  
  78.         public BoreViewModel(BoreInfo bore, ICommand editCommand)
  79.         {
  80.             BoreNumber = bore.BoreNumber;
  81.             TypeDrilling = bore.TypeDrilling;
  82.             Description = bore.TypeDrilling;
  83.             DateBoreBegin = bore.DateBoreBegin;
  84.             DateBoreEnd = bore.DateBoreEnd;
  85.  
  86.             FirstDiameters = new ObservableCollection<DiameterViewModel>();
  87.             foreach (var frDiameter in bore.FirstDiameters)
  88.                 FirstDiameters.Add(new DiameterViewModel(frDiameter));
  89.            
  90.             SecondDiameters = new ObservableCollection<DiameterViewModel>();
  91.             foreach (var scDiameter in bore.SecondDiameters)
  92.                 SecondDiameters.Add(new DiameterViewModel(scDiameter));
  93.            
  94.             Layers = new ObservableCollection<LayerViewModel>();
  95.             foreach (var layer in bore.Layers)
  96.                 Layers.Add(new LayerViewModel(layer));
  97.  
  98.             OuterEditCommand = editCommand;
  99.             EditBoreCommand = new RelayCommand(EditBore, CanEditBore);
  100.         }
  101.     }
  102. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top