コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <param name="creator"></param>
 /// <param name="itemModelCreator"></param>
 /// <param name="updateInterval">интервал обновления в секундах</param>
 public ListViewModelWithTimer(IListModel <DataModelType> model,
                               IViewModelCreator <DataModelType, DataViewModelType, DataDetailViewModelType> creator,
                               IItemModelAdapterCreator <DataModelType> itemModelCreator, int updateInterval = 5) :
     base(model, creator, itemModelCreator)
 {
     timer          = new System.Windows.Threading.DispatcherTimer();
     timer.Tick    += Timer_Tick;
     timer.Interval = new TimeSpan(0, 0, updateInterval);
     timer.Start();
 }
コード例 #2
0
        public ListViewModel(IListModel <DataModelType> model,
                             IViewModelCreator <DataModelType, DataViewModelType, DataDetailViewModelType> creator,
                             IItemModelAdapterCreator <DataModelType> itemModelCreator)
        {
            if (creator == null)
            {
                throw new ArgumentNullException("creator can't be null");
            }
            _creator = creator;

            if (itemModelCreator == null)
            {
                throw new ArgumentNullException("itemModelCreator can't be null");
            }
            _itemModelCreator = itemModelCreator;

            if (model == null)
            {
                throw new ArgumentNullException("model can't be null");
            }

            _model          = model;
            _model.Updated += OnUpdate;
            var itemViewModels = GetItemViewModels(_model.GetItems());

            UpdateList(itemViewModels);

            AddItemCommand    = new AddItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);
            DeleteItemCommand = new DeleteItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);
            EditListCommand   = new EditListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);
            SaveListCommand   = new SaveListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);
            SelectItemCommand = new SelectItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);
            UpdateListCommand = new UpdateListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this);

            addedAndDelatedItems = new Dictionary <IItemModelAdapter <DataModelType>, ChangeStatus>();

            IsSaved = true;
        }