Ejemplo n.º 1
0
 private void Save()
 {
     if (_dishesCollection.Any(d => d.Title.ToLower() == Title.ToLower()))
     {
         MessageBox.Show("Блюдо с таким именем уже существует");
     }
     else
     {
         if (!String.IsNullOrEmpty(NewTag))
         {
             AddTag();
         }
         if (!String.IsNullOrEmpty(NewIngredient))
         {
             AddIngredient();
         }
         _dishesCollection.Add(_currentDish);
         _currentDish = new Dish();
         Tags         = new LazyObservableCollection <Tag>(_currentDish.Tags);
         Ingredients  = new LazyObservableCollection <Ingredient>(_currentDish.Ingredients);
         InvokePropertyChanged(nameof(Title));
         NewIngredient = String.Empty;
         InvokePropertyChanged(nameof(Ingredients));
         NewTag = String.Empty;
         InvokePropertyChanged(nameof(Tags));
         InvokePropertyChanged(nameof(IsCanSave));
     }
 }
Ejemplo n.º 2
0
        public static ListViewAdapter <T> Build(ListView list, LazyObservableCollection <T> lazyObservableCollection, Func <T, View> getView, LayoutInflater layoutInflater)
        {
            var adapter = new ListViewAdapter <T>(list, lazyObservableCollection, getView, layoutInflater);

#pragma warning disable 4014
            lazyObservableCollection.LoadItemsAsync();
#pragma warning restore 4014

            return(adapter);
        }
Ejemplo n.º 3
0
        private ListViewAdapter(ListView list, LazyObservableCollection <T> lazyObservableCollection, Func <T, View> getView, LayoutInflater layoutInflater)
        {
            this.list = list;
            this.lazyObservableCollection = lazyObservableCollection;
            this.getView    = getView;
            this.footerView = layoutInflater.Inflate(Resource.Layout.ListViewBusyIndicatorFooter, null);
            list.Adapter    = this.lazyObservableCollection.GetAdapter(this.GetAdapter);

            this.InitializeCollection(this.lazyObservableCollection);
        }
Ejemplo n.º 4
0
 protected TreeViewItemViewModel(
     IStandarImageSourceFactory imageSourceFactory,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren) {
   _imageSourceFactory = imageSourceFactory;
   _parentViewModel = parentViewModel;
   _children = new LazyObservableCollection<TreeViewItemViewModel>(HardCodedSettings.MaxExpandedTreeViewItemCount,
                                                                   CreateLazyItemViewModel);
   if (lazyLoadChildren)
     _children.Add(DummyChild);
 }
 protected TreeViewItemViewModel(
     IStandarImageSourceFactory imageSourceFactory,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren)
 {
     _imageSourceFactory = imageSourceFactory;
       _parentViewModel = parentViewModel;
       _children = new LazyObservableCollection<TreeViewItemViewModel>(_initialItemCountLimit,
                                                               CreateLazyItemViewModel);
       if (lazyLoadChildren)
     _children.Add(_dummyChild);
 }
Ejemplo n.º 6
0
 protected TreeViewItemViewModel(
     IStandarImageSourceFactory imageSourceFactory,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren)
 {
     _imageSourceFactory = imageSourceFactory;
     _parentViewModel    = parentViewModel;
     _children           = new LazyObservableCollection <TreeViewItemViewModel>(HardCodedSettings.MaxExpandedTreeViewItemCount,
                                                                                CreateLazyItemViewModel);
     if (lazyLoadChildren)
     {
         _children.Add(DummyChild);
     }
 }
Ejemplo n.º 7
0
 public DishCreatorViewModel(ObservableCollection <Dish> dishesCollection, ObservableCollection <Tag> tags, ObservableCollection <Ingredient> ingredients)
 {
     _dishesCollection       = dishesCollection;
     AllTags                 = tags;
     AllIngredients          = ingredients;
     _currentDish            = new Dish();
     AddIngredientCommand    = new DelegateCommand(o => AddIngredient());
     AddTagCommand           = new DelegateCommand(o => AddTag());
     SaveCommand             = new DelegateCommand(o => Save());
     RemoveIngredientCommand = new DelegateCommand(o => RemoveIngredient(o as Ingredient));
     RemoveTagCommand        = new DelegateCommand(o => RemoveTag(o as Tag));
     Tags        = new LazyObservableCollection <Tag>(_currentDish.Tags);
     Ingredients = new LazyObservableCollection <Ingredient>(_currentDish.Ingredients);
 }
Ejemplo n.º 8
0
 protected TreeViewItemViewModel(
     IStandarImageSourceFactory imageSourceFactory,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren)
 {
     _imageSourceFactory = imageSourceFactory;
     _parentViewModel    = parentViewModel;
     _children           = new LazyObservableCollection <TreeViewItemViewModel>(_initialItemCountLimit,
                                                                                CreateLazyItemViewModel);
     if (lazyLoadChildren)
     {
         _children.Add(_dummyChild);
     }
 }