private object ConvertToBoolean(IListViewModel list)
        {
            if (list == null)
                return false;

            return list.HasMoreItems ? true : false;
        }
        protected void Init(bool letUpdateList = true)
        {
            model = new ListModel <IEventModel>();

            List <IItemModelAdapter <IEventModel> > items = new List <IItemModelAdapter <IEventModel> >();

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(235235, "Ivanovo", DateTime.Now, "Ivanovo station. 5 min.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(945853, "Airport", DateTime.Now, "Airport station. 15 min.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(124590, "Lake", DateTime.Now, "Lake station. 5 min. Temporarily closed.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(744935, "Central station.", DateTime.Now, "Central station. 7 min.")));

            model.AddItems(items);

            var creator           = new EventViewModelCreator();
            var eventModelCreator = new EventModelAdapterCreator();

            var vm = new ListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel>(model, creator, eventModelCreator);

            vm.LetUpdate = letUpdateList;
            viewModel    = vm;

            itemsVM = viewModel.ItemsVM;

            airportVM = itemsVM.FirstOrDefault(itmVM => itmVM.DataViewModel.Name == "Airport");
        }
        public void Register(IListViewModel listViewModel)
        {
            var addListViewModel = listViewModel as IAdd;

            if (addListViewModel != null)
            {
                AddButton.ExecuteAction = addListViewModel.Add;
                AddButton.CanExecute = addListViewModel.CanAdd;
                addListViewModel.CanAddChanged += AddButton.RaiseCanExecuteChanged;
            }
            else
            {
                AddButton.CanExecute = () => false;
            }

            var saveListViewModel = listViewModel as ISave;

            if (saveListViewModel != null)
            {
                SaveButton.ExecuteAction = saveListViewModel.Save;
                SaveButton.CanExecute = saveListViewModel.CanSave;
                saveListViewModel.CanSaveChanged += SaveButton.RaiseCanExecuteChanged;
            }
            else
            {
                SaveButton.CanExecute = () => false;
            }
        }
Beispiel #4
0
        public void Initialize(IListViewModel viewModel)
        {
            if (IsInitialized)
            {
                throw new Exception("Error : Attempting to initialize an already initialized list selection binding.");
            }

            Owner = viewModel;
            Timer = new Timer()
            {
                AutoReset = false,
                Interval  = 100,
            };
            Timer.Elapsed        += OnTimerElapsed;
            SelectionChangedScope = new Scope();
            SelectionSubscription = new Subscription()
            {
                Event = Selection,
                Token = Selection.Subscribe(o => OnSelectionChanged(), ThreadOption.PublisherThread)
            };

            foreach (var item in Owner.Items)
            {
                item.IsSelected = item.Value?.Equals(Selection.Value) ?? false;
            }


            IsInitialized = true;
        }
        public Module1Controller(
            //IUnityContainer container,
            IRegionManager regionManager,
            IListViewModel list)
        {
            //_container = container;
            _regionManager = regionManager;

            _list = list;

            _list.Items = new ObservableCollection <ListItem>();

            _list.Items.Add(new ListItem {
                Id = 1, Name = "Item 1"
            });
            _list.Items.Add(new ListItem {
                Id = 2, Name = "Item 2"
            });
            _list.Items.Add(new ListItem {
                Id = 3, Name = "Item 3"
            });

            _regionManager.RegisterViewWithRegion(
                RegionNames.LeftRegion,
                () => _list.View);
        }
        private object ConvertToVisibility(IListViewModel list)
        {
            if (!list.HasMoreItems)
                return Visibility.Collapsed;

            return Visibility.Visible;
        }
Beispiel #7
0
 public ucListView()
 {
     InitializeComponent();
     m = new ListViewModel(this);
     UpdateListView();
     ucAddView.UpdateListViewArgs     += new EventHandler(UpdateListViewByAdd);
     ucDetailsView.UpdateListViewArgs += new EventHandler(UpdateListViewByAdd);
 }
        public ShopDetailViewModel(ShopModel model)
        {
            _model = model;
            ViewModelProductCreator creator = new ViewModelProductCreator();
            var shopModelCreator            = new ProductModelAdapterCreator();

            Products = new ListViewModel <ProductModel, ProductViewModel, ProductDetailViewModel>(_model, creator, shopModelCreator);
        }
        public void ProcessCanNotBeUpdatedWhileItEdit()
        {
            IListModel <IEventModel> model = new ListModel <IEventModel>();

            List <IItemModelAdapter <IEventModel> > items = new List <IItemModelAdapter <IEventModel> >();

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(235235, "Ivanovo", DateTime.Now, "Ivanovo station. 5 min.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(945853, "Airport", DateTime.Now, "Airport station. 15 min.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(124590, "Lake", DateTime.Now, "Lake station. 5 min. Temporarily closed.")));

            items.Add(new ItemModelAdapterForPassive <IEventModel>(new EventModel(744935, "Central station.", DateTime.Now, "Central station. 7 min.")));

            model.AddItems(items);

            var creator           = new EventViewModelCreator();
            var eventModelCreator = new EventModelAdapterCreator();

            var vmFirst = new ListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel>(model, creator, eventModelCreator);

            vmFirst.LetUpdate = false;
            IListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel> viewModelFirst = vmFirst;

            var itemsVMFirst = viewModelFirst.ItemsVM;

            var vmSecond = new ListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel>(model, creator, eventModelCreator);

            vmSecond.LetUpdate = false;
            IListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel> viewModelSecond = vmSecond;

            var itemsVMSecond = viewModelSecond.ItemsVM;


            viewModelFirst.EditListCommand.Execute(null);

            viewModelSecond.EditListCommand.Execute(null);

            viewModelSecond.AddItemCommand.Execute(null);

            viewModelSecond.CurrentVM.DataViewModel.Id          = 5374623654;
            viewModelSecond.CurrentVM.DataViewModel.Name        = "XX century";
            viewModelSecond.CurrentVM.DataViewModel.Description = "station was built in XX century.";

            viewModelSecond.CurrentVM.SaveCommand.Execute(null);

            viewModelSecond.SaveListCommand.Execute(null);

            Assert.IsNull(itemsVMFirst.FirstOrDefault(ev => ev.DataViewModel.Name == "XX century"));

            Assert.IsTrue(itemsVMFirst.Count == 4);
        }
Beispiel #10
0
        /// <summary>
        /// Initializes this list view model item in the context of the specified owner.
        /// </summary>
        /// <param name="owner"></param>
        public void Initialize(IListViewModel owner)
        {
            owner.AssertParameterNotNull(nameof(owner));

            if (IsInitialized)
            {
                throw new Exception("Error : Attempting to initialize a list view model item instance that has already been initialized.");
            }

            Owner         = owner;
            FallbackIcon  = Owner.IconManager.GetIconForType <T>();
            IsInitialized = true;
        }
Beispiel #11
0
 private void OnNavigating(object sender, NavigatingCancelEventArgs e)
 {
     if (e.NavigationMode.Equals(NavigationMode.Back))
     {
         if (e.Content != null && e.Content is Page)
         {
             Page           content = (Page)e.Content;
             IListViewModel context = content.DataContext as IListViewModel;
             if (context != null)
             {
                 context.RefreshDataSource();
             }
         }
     }
 }
        public static RouteValueDictionary GetRouteValueDictionaryForList(this UrlHelper urlHelper, IListViewModel model, string sortColumn = "", string direction = "")
        {
            var dictionary = new RouteValueDictionary
                                 {
                                     {"page", model.CurrentPageNumber},
                                     {"sort", string.IsNullOrEmpty(sortColumn) ? model.SortColumn : sortColumn},
                                     {"direction", string.IsNullOrEmpty(direction) ? (model.SortDirection == ListSortDirection.Ascending ? "asc" : "desc") : direction}
                                 };
            foreach (var filter in model.GetFilters())
            {
                dictionary.Add(filter.UrlFilterName, filter.Value);
            }

            return dictionary;
        }
Beispiel #13
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (this.isNewInstance)
            {
                if (NavigationContext.QueryString.ContainsKey("id"))
                {
                    IListViewModel selected = mainDataModel.GetListDataByID(
                        NavigationContext.QueryString["id"]);

                    this.viewmodel = selected;
                    this.DataContext = this.viewmodel;
                    await this.viewmodel.OnSelectedAsync(this, this.Progress);
                    NotifyCommands();
                }

                this.isNewInstance = false;
            }
        }
        public void UnRegister(IListViewModel listViewModel)
        {
            var addListViewModel = listViewModel as IAdd;

            if (addListViewModel != null)
            {
                AddButton.ExecuteAction = null;
                AddButton.CanExecute = null;
                addListViewModel.CanAddChanged -= AddButton.RaiseCanExecuteChanged;
            }

            var saveListViewModel = listViewModel as ISave;

            if (saveListViewModel != null)
            {
                SaveButton.ExecuteAction = null;
                SaveButton.CanExecute = null;
                saveListViewModel.CanSaveChanged -= SaveButton.RaiseCanExecuteChanged;
            }
        }
Beispiel #15
0
        public static RouteValueDictionary GetRouteValueDictionaryForList(this UrlHelper urlHelper, IListViewModel model, string sortColumn = "", string direction = "")
        {
            var dictionary = new RouteValueDictionary
            {
                { "page", model.CurrentPageNumber },
                { "sort", string.IsNullOrEmpty(sortColumn) ? model.SortColumn : sortColumn },
                { "direction", string.IsNullOrEmpty(direction) ? (model.SortDirection == ListSortDirection.Ascending ? "asc" : "desc") : direction }
            };

            foreach (var filter in model.GetFilters())
            {
                dictionary.Add(filter.UrlFilterName, filter.Value);
            }

            return(dictionary);
        }
 private object ConvertToOpacity(IListViewModel list)
 {
     return list.HasMoreItems ? 1 : 0;
 }
Beispiel #17
0
        public PivotViewModel(MainDataModel main)
        {
            this.articles = main.Articles;
            this.bookmarks = main.Bookmarks;
            this.forums = main.Forums;
            this.favorites = main.Pinned;

            itemsSource = new IListViewModel[]
            {
                this.bookmarks,
                this.favorites,
                this.forums,
                this.articles
            };
        }
 public CarsController(IRepository<Car> rep, IListViewModel<Car> model, IRepository<Order> orderRep)
 {
     CarRepository = rep;
     listViewModel = model;
     OrderRepository = orderRep;
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ShopModel FishAndMeatShop = new ShopModel("FishAndMeat", "Oswin St, 3", "Very, very good");


            List <IItemModelAdapter <ProductModel> > fishAndMeatItems = new List <IItemModelAdapter <ProductModel> >();

            fishAndMeatItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Milk", 5, 4.56)));

            fishAndMeatItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Mushroom", 5, 9.88)));

            fishAndMeatItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Chicken", 2, 6.17)));

            fishAndMeatItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Soup", 3, 2.34)));

            fishAndMeatItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Cheese", 7, 3.96)));

            FishAndMeatShop.AddItems(fishAndMeatItems);



            ShopModel PenAndAppleShop = new ShopModel("PenAndApple", "Rushworth St, 34", "Super shop");


            List <IItemModelAdapter <ProductModel> > PenAndAppleItems = new List <IItemModelAdapter <ProductModel> >();

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Milk", 10, 5.56)));

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Wieners", 4, 4.38)));

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Chicken", 3, 5.22)));

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Fish", 2, 4.55)));

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Bread", 5, 1.24)));

            PenAndAppleItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Сhips", 3, 4.21)));

            PenAndAppleShop.AddItems(PenAndAppleItems);



            ShopModel GoodFoodShop = new ShopModel("GoodFood", "Scott Lidgett Cres, 24", "Sale everytime");


            List <IItemModelAdapter <ProductModel> > goodFoodItems = new List <IItemModelAdapter <ProductModel> >();

            goodFoodItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Milk", 4, 3.55)));

            goodFoodItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Mushroom", 5, 9.88)));

            goodFoodItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Wine", 2, 3.23)));

            goodFoodItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Soup", 5, 3.88)));

            goodFoodItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Bread", 3, 4.66)));

            GoodFoodShop.AddItems(goodFoodItems);



            ShopModel _7DaysShop = new ShopModel("7Days", "Plough Way, 55", "Open everytime");


            List <IItemModelAdapter <ProductModel> > _7DaysShopItems = new List <IItemModelAdapter <ProductModel> >();

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Milk", 2, 4.55)));

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Wieners", 10, 5.32)));

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Chicken", 2, 5.66)));

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Сhips", 5, 2.10)));

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Soup", 4, 5.24)));

            _7DaysShopItems.Add(new ItemModelAdapterForPassive <ProductModel>(new ProductModel("Cheese", 2, 4.33)));

            _7DaysShop.AddItems(_7DaysShopItems);


            IListModel <ShopModel> shopsModel = new ListModel <ShopModel>();

            List <IItemModelAdapter <ShopModel> > shops = new List <IItemModelAdapter <ShopModel> >();

            shops.Add(new ItemModelAdapterForPassive <ShopModel>(FishAndMeatShop));

            shops.Add(new ItemModelAdapterForPassive <ShopModel>(PenAndAppleShop));

            shops.Add(new ItemModelAdapterForPassive <ShopModel>(GoodFoodShop));

            shops.Add(new ItemModelAdapterForPassive <ShopModel>(_7DaysShop));

            shopsModel.AddItems(shops);


            var shopCreator      = new ViewModelShopCreator();
            var shopModelCreator = new ShopModelAdapterCreator();

            var vmList = new ListViewModelWithTimer <ShopModel, ShopViewModel, ShopDetailViewModel>(shopsModel, shopCreator, shopModelCreator, 10);

            //var vmList = new ListViewModel<ShopModel, ShopViewModel, ShopDetailViewModel>(shopsModel, shopCreator, shopModelCreator);
            vmList.LetUpdate = true;
            ShopsTop         = vmList;

            vmList           = new ListViewModelWithTimer <ShopModel, ShopViewModel, ShopDetailViewModel>(shopsModel, shopCreator, shopModelCreator, 10);
            vmList.LetUpdate = true;
            ShopsBottom      = vmList;

            this.DataContext = this;
        }
 public HomeController(IRepository<Car> rep, IListViewModel<Car> model)
 {
     CarRepository = rep;
     listViewModel = model;
 }
Beispiel #21
0
 private async Task<bool> ViewListAsync(IListViewModel list)
 {
     await list.OnSelectedAsync(this.page, this.progress);
     this.IsListActive = true;
     history.Push(list);
     CurrentDirectory = list;
     return false;
 }
Beispiel #22
0
        public PersonListView(IListViewModel <Domain.Person> viewModel)
        {
            ViewModel = viewModel;

            InitializeComponent();
        }
Beispiel #23
0
        internal void AdjustListView(IListViewModel list)
        {
            if (list == null)
                return;

            if (list.IsJumpList)
            {
                itemsViewSource.IsSourceGrouped = true;
            }
            else
            {
                itemsViewSource.IsSourceGrouped = false;
            }

            itemListView.SelectedItem = null;
            if (refreshListCommand != null)
                refreshListCommand.RaiseCanExecuteChanged();
        }
Beispiel #24
0
 public ViewTasksModel(IListViewModel listView)
 {
     this.ListView = listView;
 }
Beispiel #25
0
 void GoUp()
 {
     history.Pop();
     this.CurrentDirectory = null;
     this.CurrentDirectory = history.Peek();
 }
 public ProcessViewModel(IProcessModel model, EventViewModelCreator creator,
                         EventModelAdapterCreator eventModelCreator)
 {
     _model = model;
     Events = new ListViewModel <IEventModel, IEventViewModel, IDetailEventViewModel>(_model, creator, eventModelCreator);
 }