Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            var a = this;

            this.ViewModel = Mvx.IocConstruct <ProductStatisticViewModel>();
            base.ViewDidLoad();

            //var textEmail = new UITextField { Placeholder = "Username", BorderStyle = UITextBorderStyle.RoundedRect };
            //var textPassword = new UITextField { Placeholder = "Your password", BorderStyle = UITextBorderStyle.RoundedRect, SecureTextEntry = true };
            var loginButton = new UIButton(new CGRect(100, 100, 100, 100));

            loginButton.SetTitle("фуд", UIControlState.Normal);
            loginButton.BackgroundColor = UIColor.Black;


            var set = this.CreateBindingSet <ProductStatisticView, ProductStatisticViewModel>();

            set.Bind(loginButton).For(l => l.TitleLabel).To(vm => vm.StartDateValue);
            set.Bind(loginButton).To("SetStartTime");
            set.Apply();

            Add(loginButton);

            //var table = new TemplateTableViewController<ProductCell
            //                                       , ProductStatisticViewModel>
            //                (ViewModel
            //                , nameof(FoodStatisticValueConverter).Replace("ValueConverter", ""));

            //View.AddSubview(table.View);
        }
        /// <summary>
        /// 再利用リストを初期化する
        /// </summary>
        private void SetUpAvailableViews()
        {
            if (_convertViews == null || _convertViews.Count == 0)
            {
                _convertViews = new List <RecordDetailView> ();

                for (var i = 0; i < 4; i++)
                {
                    var fragment = new RecordDetailView();

                    RecordDetailViewModel viewModel;
                    if (_viewModelList.Count < i + 1)
                    {
                        viewModel = Mvx.IocConstruct <RecordDetailViewModel> ();
                    }
                    else
                    {
                        viewModel = _viewModelList [i];
                    }

                    fragment.ViewModel = viewModel;

                    _convertViews.Add(fragment);
                }
            }
        }
Exemplo n.º 3
0
        private VehicleViewModel CreateVehicleVM(VehicleLocationUpdate locationUpdate)
        {
            try
            {
                var vehicleVM = Mvx.IocConstruct <VehicleViewModel>();
                vehicleVM.Model           = locationUpdate.Vehicle;
                vehicleVM.MarkerSize      = _markerSize;
                vehicleVM.AnimateMovement = this.IsAnimationEnabled(this.Zoom);
                vehicleVM.IsTitleVisible  = this.IsVehicleTitleMarkerVisible(this.Zoom);

                if (_selectedVehicle != null)
                {
                    vehicleVM.SelectionState = MapMarkerSelectionStates.SelectionNotSelected;
                }
                else
                {
                    vehicleVM.SelectionState = MapMarkerSelectionStates.NoSelection;
                }

                return(vehicleVM);
            }
            catch (Exception e)
            {
                Insights.Report(e);
                return(null);
            }
        }
Exemplo n.º 4
0
        private void LoadItemTabs()
        {
            if (this.ViewModel.Items.Count == 0)
            {
                var newsFeedViewModel = Mvx.IocConstruct <NewsFeedViewModel>();
                newsFeedViewModel.Init(new Core.Model.SqlNewsFeed()
                {
                    Name     = AppResources.NoData,
                    Index    = 0,
                    IconPath = null
                });
                this.CreateTabFor(newsFeedViewModel);
                this.ViewModel.Items.Add(newsFeedViewModel);
            }

            var viewControllers = this.ViewModel.Items.Select(this.CreateTabFor);

            this.ViewControllers             = viewControllers.ToArray();
            this.CustomizableViewControllers = new UIViewController[] { };

            if (this.ViewControllers?.Any() == true)
            {
                this.SelectedViewController = this.ViewControllers[0];
            }
        }
Exemplo n.º 5
0
        public async Task ShowRepositoryDetails(Repository repository)
        {
            var detailsPage = Mvx.IocConstruct <RepositoryDetailsView>();

            detailsPage.SetUpRepository(repository);
            await App.Current.MainPage.Navigation.PushAsync(detailsPage);
        }
        private void CreateOrderViewModel(OrderSalepoint order)
        {
            var orderVM = Mvx.IocConstruct <SalepointOrderListItemViewModel>();

            orderVM.Order = order;
            this.Orders.Add(orderVM);
        }
Exemplo n.º 7
0
        IMvxImprovedConfig IGenericRegistration <IMvxImprovedConfig> .Register <Service, Implimentation>()
        {
            bool donothing     = false;
            var  makeDecorator = drh.ServiceRegisteredCallback(typeof(Service), skipRegistration =>
            {
                donothing = skipRegistration;
                return(typeof(Implimentation));
            });

            return(ss.PP(new FakedConfig((s, d, c) =>
            {
                if (donothing)
                {
                    return;            // AsDecorator was called
                }
                Func <Service> create = () => Mvx.IocConstruct <Implimentation>();
                Func <Service> impl = s ? () => (Service)ResolveAsSingleton(create, typeof(Service), typeof(Implimentation)) : create;
                if (c)
                {
                    AddCollectable(impl);
                }
                else
                {
                    Mvx.RegisterType(impl);
                }
            }, () => makeDecorator())));
        }
Exemplo n.º 8
0
        public IMvxImprovedDynConfig Register(Type service, Type impl)
        {
            bool donothing     = false;
            var  makeDecorator = drh.ServiceRegisteredCallback(service, skipRegistration =>
            {
                donothing = skipRegistration;
                return(impl);
            });

            return(ss.PP(new FakedConfig((s, d, c) =>
            {
                if (donothing)
                {
                    return;            // AsDecorator was called
                }
                if (s)
                {
                    basic.Register(service, () => ResolveAsSingleton(() => Mvx.IocConstruct(impl), service, impl));
                }
                else
                {
                    basic.Register(service, impl);
                }
            }, () => makeDecorator())));
        }
Exemplo n.º 9
0
        protected override IMvxAndroidViewPresenter CreateViewPresenter()
        {
            var presenter = Mvx.IocConstruct <DroidPresenter>();

            Mvx.RegisterSingleton <IMvxAndroidViewPresenter>(presenter);
            return(presenter);
        }
Exemplo n.º 10
0
        public async Task <TResult> Navigate <TViewModel, TResult>()
            where TViewModel : IMvxViewModelResult <TResult>
            where TResult : class
        {
            var args = new NavigateEventArgs(typeof(TViewModel));

            OnBeforeNavigate(this, args);

            var viewModel = (IMvxViewModelResult <TResult>)Mvx.IocConstruct <TViewModel>();
            var request   = new MvxViewModelInstanceRequest(viewModel);

            var tcs = new TaskCompletionSource <TResult>();

            viewModel.SetClose(tcs);

            _viewDispatcher.ShowViewModel(request);

            OnAfterNavigate(this, args);

            try
            {
                return(await tcs.Task);
            }
            catch
            {
                return(default(TResult));
            }
        }
 public ConferenceDetailTabViewModel()
 {
     ConferenceDetailViewModel         = Mvx.IocConstruct <ConferenceDetailViewModel>();
     ConferenceDetailSessionsViewModel = Mvx.IocConstruct <ConferenceDetailSessionsViewModel>();
     ConferenceDetailScheduleViewModel = Mvx.IocConstruct <ConferenceDetailScheduleViewModel>();
     ConferenceDetailLocation          = Mvx.IocConstruct <ConferenceDetailLocationViewModel>();
 }
Exemplo n.º 12
0
        private void UpdateImageFrame()
        {
            if (this.ViewModel.CurrentMap == null)
            {
                return;
            }

            var image = Mvx.IocConstruct <ImageLoader>().LoadImage(this.ViewModel.CurrentMap.ImagePath);

            if (image == null)
            {
                return;
            }

            var containerFrameSize = this.MapContainer.Frame.Size;
            var imageSize          = image.Size;

            var scale              = Math.Min(containerFrameSize.Width / imageSize.Width, containerFrameSize.Height / imageSize.Height);
            var imageFrameSize     = new CGSize(imageSize.Width * scale, imageSize.Height * scale);
            var imageFramePosition = new CGPoint((containerFrameSize.Width - imageFrameSize.Width) / 2, (containerFrameSize.Height - imageFrameSize.Height) / 2);

            this.MapImage.Frame = new CGRect(imageFramePosition, imageFrameSize);

            this.MapImage.Image = image;
        }
        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);
            }

            try
            {
                CallCustomInitMethods(viewModel, parameterValues);
                if (savedState != null)
                {
                    CallReloadStateMethods(viewModel, savedState);
                }
                viewModel.Start();
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap("Problem initialising viewModel of type {0}", viewModelType.Name);
            }

            return(viewModel);
        }
Exemplo n.º 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // setup the application
            Setup.Instance.EnsureInitialized(ApplicationContext);
            Mvx.Resolve <ITopActivity>().Activity = this;

            // ensure location plugin is available
            Cirrious.MvvmCross.Plugins.Location.PluginLoader.Instance.EnsureLoaded();

            // create the view model
            _locationViewModel = Mvx.IocConstruct <LocationViewModel>();

            // create the UI
            SetContentView(Resource.Layout.Main);

            // get the controls
            _latText     = this.FindViewById <TextView>(Resource.Id.LatText);
            _lngText     = this.FindViewById <TextView>(Resource.Id.LngText);
            _startedText = this.FindViewById <TextView>(Resource.Id.StartedText);
            _errorText   = this.FindViewById <TextView>(Resource.Id.ErrorText);
            _button      = this.FindViewById <Button>(Resource.Id.ToggleButton);

            // bind to click
            _button.Click += ButtonOnClick;

            // update all UI
            UpdateError();
            UpdateStarted();
            UpdateLocation();

            // subscribe for future changes
            _locationViewModel.PropertyChanged += LocationViewModelOnPropertyChanged;
        }
Exemplo n.º 15
0
        private void AddOrderViewModel(OrderCarrier order)
        {
            var orderVM = Mvx.IocConstruct <FloatingPendingOrderViewModel>();

            orderVM.Order = order;
            this.Orders.Add(orderVM);
        }
Exemplo n.º 16
0
        public void ShowHideModalView(ModalViewContext context)
        {
            if (PresentedViewController != null)
            {
                DisposeModalView();
            }

            if (context != null)
            {
                var view = default(IModalView);

                switch (context.ViewKind)
                {
                case ModalViewKind.FullscreenImage:
                    view = new ImageFullscreenView {
                        ImageURL = context.DataContext as string
                    };
                    break;

                case ModalViewKind.Browser:
                    var viewModel = Mvx.IocConstruct <BrowserViewModel>();
                    viewModel.Init(new BrowserViewModel.Parameters {
                        URL = context.DataContext as string
                    });
                    view = new ModalNavView(new BrowserView {
                        ViewModel = viewModel
                    });
                    break;
                }

                view.ToHide += OnModalViewToHide;

                PresentViewController((UIViewController)view, true, null);
            }
        }
Exemplo n.º 17
0
        public MainViewModel(ICartService cartService, IGlobalEventor eventor)
        {
            _eventor     = eventor;
            _cartService = cartService;

            ProductsGridViewModel = Mvx.IocConstruct <ProductsGridViewModel>();
            CartViewModel         = Mvx.IocConstruct <CartViewModel>();
        }
Exemplo n.º 18
0
        private VehicleForecastViewModel CreateFromVehicle(Vehicle vehicle)
        {
            var vm = Mvx.IocConstruct <VehicleForecastViewModel>();

            vm.InitWithData(vehicle, this.Route, false);

            return(vm);
        }
Exemplo n.º 19
0
        private ILocationTracker InitializeLocationTracker()
        {
            ILocationTracker tracker = Mvx.IocConstruct <LocationTracker>();

            tracker.Start(3, 2, false);

            return(tracker);
        }
Exemplo n.º 20
0
 public MainTabViewModel()
 {
     PostsVM      = Mvx.IocConstruct <PostsViewModel> ();
     SearchVM     = Mvx.IocConstruct <SearchViewModel> ();
     CameraVM     = Mvx.IocConstruct <CameraViewModel> ();
     FavouritesVM = Mvx.IocConstruct <FavouritesViewModel> ();
     ProfileVM    = Mvx.IocConstruct <CurrentUserProfileViewModel> ();
 }
Exemplo n.º 21
0
        public IMvxScanningConfig RegisterAssembly(Assembly a)
        {
            // pls use classes not lambda closure hax
            FakedScanningConfig config = null;

            config = new FakedScanningConfig((s, d, c) =>
            {
                // assert !d && !c
                IEnumerable <Type> filtering = creatableTypes(a);
                foreach (var end in config.ending)
                {
                    filtering = filtering.EndingWith(end);
                }
                var scanned = new HashSet <MvxTypeExtensions.ServiceTypeAndImplementationTypePair>
                                  (filtering.AsInterfaces());
                if (d)
                {
                    foreach (var act in scanned.SelectMany(p => p.ServiceTypes.Select(v =>
                                                                                      drh.ServiceRegisteredCallback(v, skipRegistration =>
                    {
                        if (skipRegistration)
                        {
                            p.ServiceTypes.Remove(v);
                        }
                        return(p.ImplementationType);
                    })
                                                                                      )))
                    {
                        act();
                    }
                }
                else
                {
                    foreach (var t in scanned)
                    {
                        Func <Object> implimentation = () => Mvx.IocConstruct(t.ImplementationType);
                        var impl = s ? () => ResolveAsSingleton(implimentation) : implimentation;
                        if (c)
                        {
                            AddCollectable(impl);
                        }
                        else
                        {
                            Mvx.RegisterType(impl);
                        }
                    }
                }
                if (s)
                {
                    scanned.RegisterAsLazySingleton();
                }
                else
                {
                    scanned.RegisterAsDynamic();
                }
            });
            return((IMvxScanningConfig)ss.PP(config));
        }
Exemplo n.º 22
0
        protected async Task <MvxViewModelInstanceRequest> NavigationRouteRequest(string path, IMvxBundle presentationBundle = null)
        {
            KeyValuePair <Regex, Type> entry;

            if (!TryGetRoute(path, out entry))
            {
                return(null);
            }

            var regex           = entry.Key;
            var match           = regex.Match(path);
            var paramDict       = BuildParamDictionary(regex, match);
            var parameterValues = new MvxBundle(paramDict);

            var           viewModelType = entry.Value;
            IMvxViewModel viewModel;

            if (viewModelType.GetInterfaces().Contains(typeof(IMvxNavigationFacade)))
            {
                var facade = (IMvxNavigationFacade)Mvx.IocConstruct(viewModelType);

                try
                {
                    var facadeRequest = await facade.BuildViewModelRequest(path, paramDict);

                    viewModel = (IMvxViewModel)Mvx.IocConstruct(facadeRequest.ViewModelType);

                    if (facadeRequest == null)
                    {
                        Mvx.TaggedWarning("MvxNavigationService", "Facade did not return a valid MvxViewModelRequest.");
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    Mvx.TaggedError("MvxNavigationService",
                                    "Exception thrown while processing URL: {0} with RoutingFacade: {1}, {2}",
                                    path, viewModelType, ex);
                    return(null);
                }
            }
            else
            {
                try
                {
                    viewModel = (IMvxViewModel)Mvx.IocConstruct(viewModelType);
                }
                catch (Exception exception)
                {
                    throw exception.MvxWrap("Problem creating viewModel of type {0}", viewModelType.Name);
                }
            }

            return(new MvxViewModelInstanceRequest(viewModel)
            {
                ParameterValues = parameterValues.SafeGetData(), PresentationValues = presentationBundle?.SafeGetData()
            });
        }
Exemplo n.º 23
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            RegisterAppStart(Mvx.IocConstruct <CustomAppStart>());
        }
Exemplo n.º 24
0
 public HomeTab()
 {
     RecentConversationsViewModel = Mvx.IocConstruct <RecentConversationsViewModel>();
     CharacterListsViewModel      = Mvx.IocConstruct <CharacterListsViewModel>();
     Settings = new SettingsView {
         ViewModel = new SettingsViewModel(new SettingsImpl())
     };
     InitializeComponent();
 }
        public static void Register()
        {
            var success = WebRequest.RegisterPrefix(FB_PREFIX, Mvx.IocConstruct <FacebookWebRequest>());

            if (!success)
            {
                throw new Exception("Unable to register");
            }
        }
Exemplo n.º 26
0
        public MainViewModel(IMvxMessenger messenger)
        {
            _messenger = messenger;

            _homeViewModel         = new Lazy <IMvxViewModel>(() => Mvx.IocConstruct <HomeViewModel>());
            _userViewModel         = new Lazy <IMvxViewModel>(() => Mvx.IocConstruct <UserViewModel>());
            _appointmentsViewModel = new Lazy <AppointmentsViewModel>(() => Mvx.IocConstruct <AppointmentsViewModel>());
            _treatmentViewModel    = new Lazy <TreatmentViewModel>(() => Mvx.IocConstruct <TreatmentViewModel>());
            _settingsViewModel     = new Lazy <SettingsViewModel>(() => Mvx.IocConstruct <SettingsViewModel>());
        }
        private MenuFeedViewModel CreateViewModelFromFeed(SqlMenuFeed feed)
        {
            var menuFeedViewModel = Mvx.IocConstruct <MenuFeedViewModel>();

            menuFeedViewModel.SetFeed(feed);

            menuFeedViewModel.MenuViewModel = this;

            return(menuFeedViewModel);
        }
        public CarrierSideViewViewModel(IRoutesService routesService, IMvxNavigationService navigationService)
        {
            this.routesService     = routesService;
            this.navigationService = navigationService;

            this.editRouteVM   = Mvx.IocConstruct <CarrierSideRouteEditViewModel>();
            this.activeRouteVM = Mvx.IocConstruct <CarrierSideActiveRouteViewModel>();

            this.routesService.ActiveRouteUpdated += onActiveRouteUpdated;
        }
Exemplo n.º 29
0
        public void Bind(IMvxViewModel viewModel, IMvxBundle parameterValues = null, IMvxBundle savedState = null)
        {
            var controllerAware = viewModel as IControllerAware;

            if (controllerAware != null)
            {
                var viewModelType = viewModel.GetType();
                var name          = viewModelType.FullName.Replace("ViewModel", "Controller");

                Type controllerType = GetControllerTypeForViewModel(_getCreateableTypes(), viewModel);

                if (controllerType == null)
                {
                    throw new ArgumentException(string.Format("Controller for view model {0} cannot be found.", viewModelType));
                }

                try
                {
                    var controller = (IMvxController)Mvx.IocConstruct(controllerType);
                    controllerAware.AttachController(controller);

                    var viewModelAware = controller as IViewModelAware;
                    if (viewModelAware != null)
                    {
                        viewModelAware.AttachViewModel(viewModel);
                    }

                    try
                    {
                        CallControllerInitMethods(controller, parameterValues);
                        if (savedState != null)
                        {
                            CallReloadStateMethods(controller, savedState);
                        }
                    }
                    catch (Exception ex)
                    {
                        MvxTrace.Error("MvxControllers: Problem initialising controller of type {0} - problem {1}",
                                       controllerType.Name, ex.ToLongString());

                        throw;
                    }

                    controller.WaitForInitialize();
                }
                catch (Exception ex)
                {
                    MvxTrace.Error("MvxControllers: Problem creating controller of type {0} - problem {1}",
                                   controllerType,
                                   ex.ToLongString());

                    throw;
                }
            }
        }
Exemplo n.º 30
0
        private async Task <IMvxViewModel> NavigateRoute(string path)
        {
            KeyValuePair <Regex, Type> entry;

            if (!TryGetRoute(path, out entry))
            {
                return(null);
            }

            var regex     = entry.Key;
            var match     = regex.Match(path);
            var paramDict = BuildParamDictionary(regex, match);

            var viewModelType           = entry.Value;
            MvxViewModelRequest request = null;
            IMvxViewModel       viewModel;

            if (viewModelType.GetInterfaces().Contains(typeof(IMvxNavigationFacade)))
            {
                var facade = (IMvxNavigationFacade)Mvx.IocConstruct(viewModelType);

                try
                {
                    var facadeRequest = await facade.BuildViewModelRequest(path, paramDict);

                    viewModel = (IMvxViewModel)Mvx.IocConstruct(facadeRequest.ViewModelType);

                    if (facadeRequest == null)
                    {
                        Mvx.TaggedWarning("MvxNavigationService", "Facade did not return a valid MvxViewModelRequest.");
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    Mvx.TaggedError("MvxNavigationService",
                                    "Exception thrown while processing URL: {0} with RoutingFacade: {1}, {2}",
                                    path, viewModelType, ex);
                    return(null);
                }
            }
            else
            {
                viewModel = (IMvxViewModel)Mvx.IocConstruct(viewModelType);
            }

            request = new MvxViewModelInstanceRequest(viewModel)
            {
                ParameterValues = new MvxBundle(paramDict).SafeGetData()
            };
            _viewDispatcher.ShowViewModel(request);

            return(viewModel);
        }