public HomeViewModel(IMvxNavigationService navigationService, IDatabaseUserService databaseUserService) : base(navigationService)
 {
     _databaseUserService       = databaseUserService;
     TaskListViewModel          = Mvx.IoCConstruct <TasksListViewModel>();
     AboutViewModel             = Mvx.IoCConstruct <AboutViewModel>();
     ShowTaskChangedViewCommand = new MvxAsyncCommand <ItemTask>(ShowTaskChanged);
 }
Exemplo n.º 2
0
        public override void ViewAppeared()
        {
            base.ViewAppeared();
            this.GetAccountProperties();
            OctoprintInstanceViewModel instance = Mvx.IoCConstruct <OctoprintInstanceViewModel>();

            instance.PrinterIP   = "192.168.1.34";
            instance.PrinterName = "Test";
            Instances.Add(instance);
        }
Exemplo n.º 3
0
        private void ConnectionIcon_Click(object sender, EventArgs e)
        {
            var t = SupportFragmentManager.BeginTransaction();
            PrinterConnectionFragment connection = new PrinterConnectionFragment()
            {
                ViewModel = Mvx.IoCConstruct <PrinterConnectionViewModel>()
            };

            t.Replace(Resource.Id.fragment_view, connection);
            t.Commit();
        }
 public static void EnsureViewModel <TViewModel>(IMvxView <TViewModel> mvxView) where TViewModel : class, IMvxViewModel
 {
     if (mvxView.ViewModel == null)
     {
         try {
             mvxView.ViewModel = Mvx.IoCConstruct <TViewModel>();
         }
         catch (Exception e) {
             Console.WriteLine(e);
         }
     }
 }
Exemplo n.º 5
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            var t = SupportFragmentManager.BeginTransaction();

            switch (item.ItemId)
            {
            case Resource.Id.navigation_print:
                PrintFragment connection = new PrintFragment()
                {
                    ViewModel = Mvx.IoCConstruct <PrintViewModel>()
                };
                t.Replace(Resource.Id.fragment_view, connection);
                t.Commit();
                return(true);

            case Resource.Id.navigation_control:
                PrinterConnectionFragment navigation = new PrinterConnectionFragment()
                {
                    ViewModel = Mvx.IoCConstruct <PrinterConnectionViewModel>()
                };
                t.Replace(Resource.Id.fragment_view, navigation);
                t.Commit();
                return(true);

            case Resource.Id.navigation_temperature:
                PrinterConnectionFragment temperature = new PrinterConnectionFragment()
                {
                    ViewModel = Mvx.IoCConstruct <PrinterConnectionViewModel>()
                };
                t.Replace(Resource.Id.fragment_view, temperature);
                t.Commit();
                return(true);

            case Resource.Id.navigation_terminal:
                PrinterConnectionFragment terminal = new PrinterConnectionFragment()
                {
                    ViewModel = Mvx.IoCConstruct <PrinterConnectionViewModel>()
                };
                t.Replace(Resource.Id.fragment_view, terminal);
                t.Commit();
                return(true);

            case Resource.Id.navigation_gcode:
                AccountFragment gcode = new AccountFragment()
                {
                    ViewModel = Mvx.IoCConstruct <AccountViewModel>()
                };
                t.Replace(Resource.Id.fragment_view, gcode);
                t.Commit();
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        public static void RegisterAsSingleton(this IEnumerable <ServiceTypeAndImplementationTypePair> pairs)
        {
            foreach (var pair in pairs)
            {
                if (!pair.ServiceTypes.Any())
                {
                    continue;
                }

                var instance = Mvx.IoCConstruct(pair.ImplementationType);
                foreach (var serviceType in pair.ServiceTypes)
                {
                    Mvx.RegisterSingleton(serviceType, instance);
                }
            }
        }
Exemplo n.º 7
0
        public virtual IMvxViewModel Load(Type viewModelType,
                                          IMvxBundle parameterValues,
                                          IMvxBundle savedState)
        {
            IMvxViewModel viewModel;

            try
            {
                viewModel = (IMvxViewModel)Mvx.IoCConstruct(viewModelType);
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap("Problem creating viewModel of type {0}", viewModelType.Name);
            }

            RunViewModelLifecycle(viewModel, parameterValues, savedState);

            return(viewModel);
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_tab);

            // Make tab menu
            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);

            // Put connection fragment
            PrinterConnectionFragment connection = new PrinterConnectionFragment()
            {
                ViewModel = Mvx.IoCConstruct <PrinterConnectionViewModel>()
            };
            var t = SupportFragmentManager.BeginTransaction();

            t.Add(Resource.Id.fragment_view, connection);
            t.Commit();

            ImageButton connectionIcon = FindViewById <ImageButton>(Resource.Id.connection_icon);

            connectionIcon.Click += ConnectionIcon_Click;
        }