static NavAndMenuBar()
 {
     using (var scope = AppContainer.GlobalVariableContainer.BeginLifetimeScope())
     {
         _formsMessenger = scope.Resolve <IFormsMessenger>();
         _stateMachine   = scope.Resolve <IStateMachineBase>();
     }
 }
Exemplo n.º 2
0
        protected AnimalViewModelBase(IStateMachineBase stateMachine, IAnimalDataBase animalData) : base(stateMachine)
        {
            _animalData = animalData;

            // These commands are not currently used
            MakeNoiseCommand = new Command(() => { });
            MoveCommand      = new Command(() => { });
        }
        static PageViewModelBase()
        {
            using (var scope = AppContainer.GlobalVariableContainer.BeginLifetimeScope())
            {
                Messenger = scope.Resolve <IFormsMessenger>();

                // Request the same interface that was created at the local Xamarin.Forms setup.
                Machine = scope.Resolve <IStateMachineBase>();
            }
        }
Exemplo n.º 4
0
        protected PageViewModelBase(IStateMachineBase stateMachine, IProvidePageEvents pageEventProvider = null)
        {
            // Request the global interface type so the code is more share-able.
            Machine = stateMachine;

            // Also share the page event provider so that derivers know about OnAppearing,
            // OnDisappearing, etc.
            PageEventProvider = pageEventProvider;

            if (PageEventProvider?.GetEventBroadcaster != null)
            {
                FormsMessengerUtils.Subscribe <PageLifecycleMessage>(this, HandlePageLifecycleChanged);
            }
        }
Exemplo n.º 5
0
        public MainMenu(IStateMachineBase stateMachine)
        {
            _stateMachine = stateMachine;

            // Not really used
            BindingContext = this;

            VerticalOptions   = LayoutOptions.StartAndExpand;
            HorizontalOptions = LayoutOptions.CenterAndExpand;

            BackgroundColor = Colors.HEADER_AND_TOOLBAR_COLOR;
            Opacity         = MAIN_MENU_OPACITY;

            InputTransparent = ALLOW_EVENT_TUNNELING;

            LoadMenuFromStateMachine();
        }
        public App()
        {
            var appSetup = new FormsContainerSetup();

            AppContainer.GlobalVariableContainer = appSetup.CreateContainer();

            // NOTE: Dependency without injection
            _stateMachine = AppContainer.GlobalVariableContainer.Resolve <IStateMachineBase>();

            InitializeComponent();

            // MainPage = new MvvmAntipattern.MainPage();
            // MainPage = new TiredAndTrueMainPage { BindingContext = new TiredAndTrueMainViewModel() };

            // If the MainPage gets set too late, serious problems occur -- so this is just a precaution
            MainPage = new ContentPage();
        }
Exemplo n.º 7
0
        /// <remarks>
        /// Not used in the run-time app but can be called for unit testing.
        /// </remarks>
        public NavAndMenuBar(IStateMachineBase stateMachine)
        {
            _stateMachine = stateMachine;

            BackgroundColor = Colors.HEADER_AND_TOOLBAR_COLOR_DEEP;

            if (Device.RuntimePlatform.IsSameAs(Device.iOS))
            {
                Margin = IOS_MARGIN;
            }

            // Listen for the static page change
            AskToSetBackButtonVisiblity += SetBackButtonVisiblity;

            // These message are subscribed but never unsubscribed.
            // The menu is global static, so persists throughout the life of the app.
            // There is no reason to unsubscribe them under these circumstances.
            FormsMessengerUtils.Subscribe <MenuLoadedMessage>(this, OnMenuLoaded);
            FormsMessengerUtils.Subscribe <AppStateChangedMessage>(this, OnAppStateChanged);
        }
Exemplo n.º 8
0
        public App()
        {
            var appSetup = new FormsContainerSetup();

            AppContainer.GlobalVariableContainer = appSetup.CreateContainer();

            using (var scope = AppContainer.GlobalVariableContainer.BeginLifetimeScope())
            {
                _formsMessenger = scope.Resolve <IFormsMessenger>();
                _stateMachine   = scope.Resolve <IStateMachineBase>();
            }

            InitializeComponent();

            // MainPage = new MvvmAntipattern.MainPage();
            // MainPage = new TiredAndTrueMainPage { BindingContext = new TiredAndTrueMainViewModel() };

            // If the MainPage gets set too late, serious problems occur -- so this is just a precaution
            MainPage = new ContentPage();
        }
Exemplo n.º 9
0
        public MainMenu()
        {
            using (var scope = AppContainer.GlobalVariableContainer.BeginLifetimeScope())
            {
                _stateMachine   = scope.Resolve <IStateMachineBase>();
                _formsMessenger = scope.Resolve <IFormsMessenger>();
            }

            // Not really used
            BindingContext = this;

            VerticalOptions   = LayoutOptions.StartAndExpand;
            HorizontalOptions = LayoutOptions.CenterAndExpand;

            BackgroundColor = Colors.HEADER_AND_TOOLBAR_COLOR;
            Opacity         = MAIN_MENU_OPACITY;

            InputTransparent = ALLOW_EVENT_TUNNELING;

            LoadMenuFromStateMachine();
        }
 public BirdViewModel(IStateMachineBase stateMachine, IAnimalDataBase animalData) : base(stateMachine, animalData)
 {
 }
Exemplo n.º 11
0
 public AboutViewModel(IStateMachineBase stateMachine) : base(stateMachine)
 {
 }
Exemplo n.º 12
0
 public AboutViewModel(IStateMachineBase stateMachine, IProvidePageEvents pageEventProvider = null) : base(
         stateMachine, pageEventProvider)
 {
 }
Exemplo n.º 13
0
 public PreferencesViewModel(IStateMachineBase stateMachine) : base(stateMachine)
 {
 }
 protected PageViewModelBase(IStateMachineBase stateMachine)
 {
     // Request the global interface type so the code is more share-able.
     Machine = stateMachine;
 }