Beispiel #1
0
        internal static void Show_AddIngredientsView(Dishes dish)
        {
            Show_WaitView("Cargando las lista de productos");

            //TODO select all products from db
            List <Products> products;

            using (var db = App.DbFactory.Open())
            {
                products = db.Select <Products>();
            }

            Current.Dispatcher.Invoke(() => {
                ParentView.Current.ProductCatalogBtn.IsEnabled = false;
                ParentView.Current.DishesCatalogBtn.IsEnabled  = false;
                ParentView.Current.ConfigurationBtn.IsEnabled  = false;
                var oldView = Current.Transition.Content as UserControl;
                var view    = new AddIngredientsView(dish, products);
                Current.Transition.Content = view;
                ViewLoaded?.Invoke(view);
                App.Log.Message($"AddIngredientsView. Dish: {dish.ToString()}\nProducts: {products.Serialize(LibreR.Models.Enums.Serializer.OneLine)}", "VIEW-LOADED");
                if (!(oldView is WaitView))
                {
                    ViewUnloaded?.Invoke(oldView);
                }
            });
        }
Beispiel #2
0
        internal static void Show_DishesView()
        {
            Show_WaitView("Cargando el catálogo de platillos");

            //TODO select all dishes from db
            List <Dishes> dishes;

            using (var db = App.DbFactory.Open())
            {
                dishes = db.Select <Dishes>();
            }

            Current.Dispatcher.Invoke(() => {
                ParentView.Current.ProductCatalogBtn.IsEnabled = true;
                ParentView.Current.DishesCatalogBtn.IsEnabled  = true;
                ParentView.Current.ConfigurationBtn.IsEnabled  = true;
                var oldView = Current.Transition.Content as UserControl;
                var view    = new DishesView(dishes);
                Current.Transition.Content = view;
                ViewLoaded?.Invoke(view);
                App.Log.Message($"DishesView", "VIEW-LOADED");
                if (!(oldView is WaitView))
                {
                    ViewUnloaded?.Invoke(oldView);
                }
            });
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UIViewController"/> class.
        /// </summary>
        public UIViewController()
        {
            if (CatelEnvironment.IsInDesignMode)
            {
                return;
            }

            var viewModelType = GetViewModelType();

            if (viewModelType is null)
            {
                Log.Debug("GetViewModelType() returned null, using the ViewModelLocator to resolve the view model");

                viewModelType = _viewModelLocator.ResolveViewModel(GetType());
                if (viewModelType is null)
                {
                    const string error = "The view model of the view could not be resolved. Use either the GetViewModelType() method or IViewModelLocator";
                    Log.Error(error);
                    throw new NotSupportedException(error);
                }
            }

            _logic = new PageLogic(this, viewModelType);
            _logic.TargetViewPropertyChanged += (sender, e) =>
            {
                OnPropertyChanged(e);

                PropertyChanged?.Invoke(this, e);
            };

            _logic.ViewModelChanged += (sender, e) => RaiseViewModelChanged();

            _logic.ViewModelPropertyChanged += (sender, e) =>
            {
                OnViewModelPropertyChanged(e);

                ViewModelPropertyChanged?.Invoke(this, e);
            };

            _logic.DetermineViewModelInstance += (sender, e) =>
            {
                e.ViewModel = GetViewModelInstance(e.DataContext);
            };

            _logic.DetermineViewModelType += (sender, e) =>
            {
                e.ViewModelType = GetViewModelType(e.DataContext);
            };

            _logic.ViewLoading   += (sender, e) => ViewLoading?.Invoke(this);
            _logic.ViewLoaded    += (sender, e) => ViewLoaded?.Invoke(this);
            _logic.ViewUnloading += (sender, e) => ViewUnloading?.Invoke(this);
            _logic.ViewUnloaded  += (sender, e) => ViewUnloaded?.Invoke(this);
        }
Beispiel #4
0
 internal static void Show_MessageView(string message, Action affirmativeAction = null, string ABtnContent = null, Action negativeAction = null, string BBtnContent = null, FontAwesomeIcon icon = FontAwesomeIcon.None)
 {
     Current.Dispatcher.Invoke(() => {
         ParentView.Current.ProductCatalogBtn.IsEnabled = false;
         ParentView.Current.DishesCatalogBtn.IsEnabled  = false;
         ParentView.Current.ConfigurationBtn.IsEnabled  = false;
         var oldView = Current.Transition.Content as UserControl;
         var view    = new MessageView(message, affirmativeAction, ABtnContent, negativeAction, BBtnContent, icon);
         Current.Transition.Content = view;
         ViewLoaded?.Invoke(view);
         App.Log.Message($"MessageView, Icon: {icon}, Message: {message}", "VIEW-LOADED");
         if (!(oldView is WaitView))
         {
             ViewUnloaded?.Invoke(oldView);
         }
     });
 }
Beispiel #5
0
 internal static void Show_MainView()
 {
     Current.Dispatcher.Invoke(() => {
         ParentView.Current.ProductCatalogBtn.IsEnabled = true;
         ParentView.Current.DishesCatalogBtn.IsEnabled  = true;
         ParentView.Current.ConfigurationBtn.IsEnabled  = true;
         var oldView = Current.Transition.Content as UserControl;
         var view    = new MainView();
         Current.Transition.Content = view;
         ViewLoaded?.Invoke(view);
         App.Log.Message($"MainView", "VIEW-LOADED");
         if (!(oldView is WaitView))
         {
             ViewUnloaded?.Invoke(oldView);
         }
     });
 }
Beispiel #6
0
 internal static void Show_AddDishPhoto(Dishes dish)
 {
     Current.Dispatcher.Invoke(() => {
         ParentView.Current.ProductCatalogBtn.IsEnabled = false;
         ParentView.Current.DishesCatalogBtn.IsEnabled  = false;
         ParentView.Current.ConfigurationBtn.IsEnabled  = false;
         var oldView = Current.Transition.Content as UserControl;
         var view    = new AddDishPhotoView(dish);
         Current.Transition.Content = view;
         ViewLoaded?.Invoke(view);
         App.Log.Message($"AddDishPhotoView. Dish: {dish.ToString()}", "VIEW-LOADED");
         if (!(oldView is WaitView))
         {
             ViewUnloaded?.Invoke(oldView);
         }
     });
 }
Beispiel #7
0
 internal static void Show_NewProductView(Products product = null)
 {
     Current.Dispatcher.Invoke(() => {
         ParentView.Current.ProductCatalogBtn.IsEnabled = false;
         ParentView.Current.DishesCatalogBtn.IsEnabled  = false;
         ParentView.Current.ConfigurationBtn.IsEnabled  = false;
         var oldView = Current.Transition.Content as UserControl;
         var view    = new NewProductView(product);
         Current.Transition.Content = view;
         ViewLoaded?.Invoke(view);
         App.Log.Message($"NewProductView, Product: {product.Serialize(LibreR.Models.Enums.Serializer.OneLine)}", "VIEW-LOADED");
         if (!(oldView is WaitView))
         {
             ViewUnloaded?.Invoke(oldView);
         }
     });
 }
Beispiel #8
0
 private void RaiseViewUnloaded()
 {
     ViewUnloaded?.Invoke(this, new ViewStackPartEventArgs(_viewInfo.View));
 }