/// <summary> /// Исключения: /// System.ArgumentNullException: /// Параметр model имеет значение null. /// </summary> /// <param name="model"></param> public DetailItemViewModel(IItemModelAdapter <DataModelType> model, IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator, IItemModelAdapterCreator <DataModelType> itemModelCreator) { if (model == null) { throw new ArgumentNullException("model can't be null"); } if (viewModelCreator == null) { throw new ArgumentNullException("viewModelCreator can't be null"); } if (itemModelCreator == null) { throw new ArgumentNullException("itemModelCreator can't be null"); } _model = model; _model.Updated += OnUpdate; UpdateCommand = new UpdateItemCommand <DataModelType, DataDetailViewModelType>(this); EditCommand = new EditItemCommand <DataModelType, DataDetailViewModelType>(this); SaveCommand = new SaveItemCommand <DataModelType, DataDetailViewModelType>(this); Debug.Assert(_model.DataModel != null); _viewModelCreator = viewModelCreator; _itemModelCreator = itemModelCreator; DataViewModel = _viewModelCreator.CreateDataDetailViewModel(_model.DataModel); }
void SelectItemByModel(IItemModelAdapter <DataModelType> itemModel) { CurrentVM = _creator.CreateDetailViewModel(itemModel); Debug.Assert(StateCanChanged != null); StateCanChanged(this, new EventArgs()); }
public override IItemModelAdapter <IEventModel> CreateDeepCopyOfItemModel(IItemModelAdapter <IEventModel> model) { StationEvent stationEvent = (StationEvent)model.DataModel; var deepCopy = stationEvent.Copy(); var newModel = new ItemModelAdapterForPassive <IEventModel>(deepCopy); return(newModel); }
public IItemModelAdapter <ProductModel> CreateDeepCopyOfItemModel(IItemModelAdapter <ProductModel> model) { var oldDataModel = model.DataModel; var newDataModel = new ProductModel(oldDataModel.Name, oldDataModel.Count, oldDataModel.Price); var newModel = new ItemModelAdapterForPassive <ProductModel>(newDataModel); return(newModel); }
public IItemModelAdapter <ShopModel> CreateDeepCopyOfItemModel(IItemModelAdapter <ShopModel> model) { var oldDataModel = model.DataModel; var newDataModel = new ShopModel(oldDataModel.Name, oldDataModel.Address, oldDataModel.Description); var newModel = new ItemModelAdapterForPassive <ShopModel>(newDataModel); return(newModel); }
public DetailItemViewModelTimer(IItemModelAdapter <DataModelType> model, IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator, IItemModelAdapterCreator <DataModelType> itemModelCreator, int updateInterval = 5) : base(model, viewModelCreator, itemModelCreator) { timer = new System.Windows.Threading.DispatcherTimer(); timer.Tick += Timer_Tick; timer.Interval = new TimeSpan(0, 0, updateInterval); timer.Start(); }
public void Save(IItemModelAdapter <DataModelType> saveModel) { try { DataModel.Save(saveModel.DataModel); Updated?.Invoke(this, new ItemModelAdapterEventArgs <DataModelType>(this)); } catch (Exception ex) { log.Error(ex, "Save"); } }
void OnUpdate(object sender, ItemModelAdapterEventArgs <DataModelType> e) { if (!IsEditing) { if (!IsSaved) { _model = _realModel; IsSaved = true; } DataViewModel.Update(); NotifyPropertyChanged("DataViewModel"); } }
/// <summary> /// Исключения: /// System.ArgumentNullException: /// Параметр model имеет значение null. /// </summary> /// <param name="model"></param> public ItemViewModel(IItemModelAdapter <DataModelType> model, IDataViewModelCreator <DataModelType, DataViewModelType> creator) { if (model == null) { throw new ArgumentNullException("model can't be null"); } _model = model; if (creator == null) { throw new ArgumentNullException("creator can't be null"); } DataViewModel = creator.CreateDataViewModel(_model.DataModel); _model.Updated += OnUpdate; }
public void Edit() { if (CanEdit()) { Debug.Assert(_model != null, "_model is null!!"); _saveTempModel = _itemModelCreator.CreateDeepCopyOfItemModel(_model); _realModel = _model; _model = _saveTempModel; DataViewModel = _viewModelCreator.CreateDataDetailViewModel(_saveTempModel.DataModel); IsEditing = true; IsSaved = false; Debug.Assert(StateCanChanged != null); StateCanChanged(this, new EventArgs()); } }
public IItemViewModel <ProductModel, ProductViewModel> CreateItemViewModel(IItemModelAdapter <ProductModel> itemModel) { var dataViewModelCreator = new ProductDataViewModelCreator(); return(new ItemViewModel <ProductModel, ProductViewModel>(itemModel, dataViewModelCreator)); }
public IDetailItemViewModel <ProductModel, ProductDetailViewModel> CreateDetailViewModel(IItemModelAdapter <ProductModel> model) { if (_previosDetailViewModel != null) { _previosDetailViewModel.Dispose(); } _previosDetailViewModel = new DetailItemViewModelTimer <ProductModel, ProductDetailViewModel>(model, new ProductDataDetailViewModelCreator(), new ProductModelAdapterCreator()); return(_previosDetailViewModel); }
public IItemViewModel <ShopModel, ShopViewModel> CreateItemViewModel(IItemModelAdapter <ShopModel> itemModel) { var dataViewModelCreator = new ShopDataViewModelCreator(); return(new ItemViewModel <ShopModel, ShopViewModel>(itemModel, dataViewModelCreator)); }
public IItemViewModel <IEventModel, IEventViewModel> CreateItemViewModel(IItemModelAdapter <IEventModel> itemModel) { var dataViewModelCreator = new EventDataViewModelCreator(); return(new ItemViewModel <IEventModel, IEventViewModel>(itemModel, dataViewModelCreator)); }
public virtual IDetailItemViewModel <IEventModel, IDetailEventViewModel> CreateDetailViewModel(IItemModelAdapter <IEventModel> model) { return(new DetailItemViewModel <IEventModel, IDetailEventViewModel>(model, new EventDataDetailViewModelCreator(), new EventModelAdapterCreator())); }
public ItemModelAdapterEventArgs(IItemModelAdapter <DataModelType> _item) { Item = _item; }
public override IDetailItemViewModel <IEventModel, IDetailEventViewModel> CreateDetailViewModel(IItemModelAdapter <IEventModel> model) { return(new DetailItemViewModel <IEventModel, IDetailEventViewModel>(model, new DeliveryEventDataDetailViewModelCreator(), new DeliveryEventModelAdapterCreator())); }