示例#1
0
        private void EditListExecute(object obj)
        {
            List <IWidget> list = new List <IWidget>();

            foreach (var item in _VMItems)
            {
                //Fore Undo
                ListBaseWidgetViewModel listVM = item as ListBaseWidgetViewModel;
                listVM.StoreOldItems();

                list.Add(listVM.IWidget);
            }
            if (list.Count <= 0)
            {
                return;
            }

            EditListWindow win = new EditListWindow(list, _IsItemsSame);

            win.Owner = Application.Current.MainWindow;

            bool?bRValue = win.ShowDialog();

            if ((bool)bRValue)
            {
                Naver.Compass.InfoStructure.CompositeCommand cmds = new Naver.Compass.InfoStructure.CompositeCommand();
                foreach (var item in _VMItems)
                {
                    ListBaseWidgetViewModel listVM = item as ListBaseWidgetViewModel;
                    listVM.LoadList();

                    //Undo
                    EditListCommand cmd = new EditListCommand(listVM, listVM.OldItems, listVM.IWidget.Items);
                    cmds.AddCommand(cmd);
                    listVM.ClearOldItems();
                }
                CurrentUndoManager.Push(cmds);

                RefreshItemsList(true);
            }
        }
        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;
        }