public void SetInitViewModel(IMainViewModel MainViewModel)
        {
            Debug.Assert(MainViewModel is MainViewModel);

            ViewModel        = (MainViewModel as MainViewModel).ListViewModel;
            this.DataContext = ViewModel;
        }
Пример #2
0
 public MainList()
 {
     this.InitializeComponent();
     viewModel   = new MainListViewModel();
     DataContext = viewModel;
     Loaded     += OnLoaded;
 }
Пример #3
0
        public ActionResult Index(int?counter)
        {
            var model = new MainListViewModel();

            var animals = _animals.GetAll();

            foreach (var animal in animals)
            {
                var animalID = animal.Id;

                animal.UglyComments = _uglyComments.GetAll(animalID);
                animal.NewComment   = new UglyCommentModel {
                    AnimalId = animalID
                };
            }

            if (counter.HasValue && counter != 0 && counter != 1)
            {
                model.PageCounter = counter.Value;

                model.Animals = animals.Skip(3 * (counter.Value - 1)).Take(3).ToList();

                return(View(model));
            }

            model.PageCounter = 1;
            model.Animals     = animals.Take(3).ToList();

            return(View(model));
        }
Пример #4
0
        public MainListPage()
        {
            InitializeComponent();


            viewModel = new MainListViewModel(this, GetListContent(), GetListTemplate());

            this.BindingContext = viewModel;

            viewModel.ClickPickerEvent -= ViewModel_ClickPickerEvent;
            viewModel.ClickPickerEvent += ViewModel_ClickPickerEvent;
        }
Пример #5
0
        private void CancelExecute()
        {
            MainList view = new MainList(this.View.Owner);

            view.ProductList.ItemsSource = (this.View.Owner.DataContext as MainWindowViewModel).ProductRepository.GetAll();
            MainListViewModel vm = new MainListViewModel(view);

            vm.MainVM        = this.View.Owner.DataContext as MainWindowViewModel;
            view.DataContext = vm;
            View.Owner.MainContent.Content = view;
            (View.Owner.DataContext as MainWindowViewModel).Filter.Execute(this);
        }
Пример #6
0
        private void Picker_SelectedIndexChanged(object sender, EventArgs e)
        {
            MainListViewModel view = this.BindingContext as MainListViewModel;

            if (null != view)
            {
                if (null != view.SelectedLang && null != view.GoCommand && view._isInit)
                {
                    view.GoCommand.Execute(new MainListModel {
                        Name = "ChangeLanguageFinish"
                    });
                }
            }
        }
Пример #7
0
        public MainListView()
        {
            Debug.WriteLine("Start MainListView()");

            InitializeComponent();

            NavigationPage.SetHasNavigationBar(this, true);

            vm = new MainListViewModel(DateTime.Now.Date);

            BindingContext = vm;

            list.ItemTapped += (sender, e) => {
                Debug.WriteLine("Start - MainListView.ItemTapped");
                // do something with e.Item

                Navigation.PushAsync(new DetailsView(((ListView)sender).SelectedItem));

                ((ListView)sender).SelectedItem = null;                 // de-select the row
                Debug.WriteLine("End - MainListView.ItemTapped");
            };

            list.Refreshing += (sender, e) =>
            {
                Debug.WriteLine("Start - MainListView.Refreshing");


                list.EndRefresh();

                Debug.WriteLine("Einde - MainListView.Refreshing");
            };

            vm.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                Debug.WriteLine("Start vm.PropertyChanged(" + e.PropertyName + ")");

                if (e.PropertyName.Equals("CurrentWeek"))
                {
                    this.list.ItemsSource    = vm.CurrentWeek;
                    this.list.RowHeight      = vm.RowHeight;
                    this.ThisWeekButton.Text = vm.DisplayCurrentSaterday;
                }
                else if (e.PropertyName.Equals("RowHeight"))
                {
                    this.list.RowHeight   = vm.RowHeight;
                    this.list.ItemsSource = vm.CurrentWeek;
                }
            };
        }
        public MainWindow(Customer customer) : this()
        {
            MainWindowViewModel mainvm = new MainWindowViewModel(this, customer);

            this.DataContext = mainvm;

            MainList          view = new MainList(this);
            MainListViewModel vm   = new MainListViewModel(view);

            vm.MainVM           = this.DataContext as MainWindowViewModel;
            view.DataContext    = vm;
            MainContent.Content = view;

            if (customer.Role == Role.Admin)
            {
                this.Cart.Visibility      = Visibility.Collapsed;
                this.AdminMenu.Visibility = Visibility.Visible;
            }

            var desc = DependencyPropertyDescriptor.FromProperty(ContentControl.ContentProperty, typeof(ContentPresenter));

            desc.AddValueChanged(MainContent, MainContent_DataContextChanged);
        }
Пример #9
0
 public MainListView()
 {
     DataContext = new MainListViewModel();
     InitializeComponent();
 }
Пример #10
0
        private void ConfirmExecute()
        {
            StringBuilder errorMessage = new StringBuilder("");
            Order         formedOrder  = Customer.Order.FirstOrDefault(order => order.State == State.Created);

            if (formedOrder != null)
            {
                if (View.Address.Text.Length > 0)
                {
                    formedOrder.Address = View.Address.Text;
                }
                else
                {
                    errorMessage.Append("Поле адреса не может быть пустым!\n");
                }
                if (View.Phone.IsMaskFull)
                {
                    formedOrder.Phone = View.Phone.Text;
                }
                else
                {
                    errorMessage.Append("Поле номера телефона заполнено некорректно!\n");
                }
                if (View.Order.Items.Count == 0)
                {
                    errorMessage.Append("Заказ не может быть пустым!\n");
                }
                if (errorMessage.Length == 0)
                {
                    foreach (var ordered in formedOrder.Ordered)
                    {
                        if (ProductRepository.GetById(ordered.Product.Id) == null)
                        {
                            MessageBox.Show($"Товар {ordered.Product.Name} был изменен. Он будет удален из корзины.");
                            View.Order.ItemsSource = View.Order.ItemsSource.Cast <Ordered>().Where(ord => ord != ordered);
                            Customer.Order.First(order => order.State == State.Created).Ordered.Remove(ordered);
                            UpdateTotal();
                            return;
                        }
                    }

                    formedOrder.CustomerId = formedOrder.Customer.Id;
                    formedOrder.State      = State.Formed;
                    formedOrder.Date       = DateTime.Now;
                    OrderRepository.Add((Order)formedOrder.Clone());
                    OrderRepository.SaveChanges();

                    MainList          view = new MainList(View.Owner);
                    MainListViewModel vm   = new MainListViewModel(view);
                    vm.MainVM        = View.Owner.DataContext as MainWindowViewModel;
                    view.DataContext = vm;
                    View.Owner.MainContent.Content = view;
                    (View.Owner.DataContext as MainWindowViewModel).Customer.Order.Add(new Order()
                    {
                        State = State.Created, Customer = this.Customer
                    });
                    MessageBox.Show("Заказ успешно сформирован. Ожидайте подтверждения.");
                }
                else
                {
                    MessageBox.Show(errorMessage.ToString());
                }
            }
            else
            {
                MessageBox.Show("Ошибка");
            }
        }