Example #1
0
        public static async Task NavigateToAsync <T>(this INavigationHelper helper, object parameter)
        {
            var viewType = typeof(T);
            var viewName = viewType.Name;

            await helper.NavigateToAsync(viewName, parameter);
        }
Example #2
0
 public LanguagePickerViewModel(IAnalyticsService analyticsService, INavigationHelper navigationHelper, LanguageService languageService)
     : base(analyticsService)
 {
     this.languageService = languageService;
     LanguageService.PreferredLanguageChanged += LanguageService_PreferredLanguageChanged;
     SetAppLanguageCommand = new AsyncCommand <LanguageViewModel>((x) => SetAppLanguage(x));
 }
Example #3
0
        public App(IAnalyticsService analyticsService, IMvpApiService mvpApiService, IAuthService authService, LanguageService languageService)
        {
            InitializeComponent();

            this.AnalyticsService = analyticsService;

            // We add exception handling here, because the MVP API is shared
            // through this app class with every page. Errors in it need to handled
            // generically through here as well.
            mvpApiService.AccessTokenExpired += MvpApiService_AccessTokenExpired;

            MvpApiService = mvpApiService;
            AuthService   = authService;

            if (Device.RuntimePlatform == Device.Android)
            {
                languageService.Initialize();
            }

            Resolver.SetResolver(new AutofacResolver(ContainerService.Container));
            Akavache.Registrations.Start(Constants.AppName);
            On <iOS>().SetHandleControlUpdatesOnMainThread(true);

            // Set the theme that the user has picked.
            Current.UserAppTheme = Settings.AppTheme;

            // Set our start page to the splash screen, as that is what we want
            // everyone to see first. It's glorious.
            NavigationHelper = Resolver.Resolve <INavigationHelper>();
            NavigationHelper.SetRootView(nameof(SplashScreenPage));
        }
 public CreateAccountViewModel(ILoginDataService loginDataService, INavigationHelper navigationHelper)
 {
     this.loginDataService    = loginDataService;
     this.navigationHelper    = navigationHelper;
     this.passwordsDoNotMatch = "The passwords you entered do not match.";
     CreateAccountCommand     = new AsyncCommand(() => CreateAccount(), CanCreate);
 }
Example #5
0
        public ThemePickerViewModel(IAnalyticsService analyticsService, IAuthService authService,
                                    IDialogService dialogService, INavigationHelper navigationHelper)
            : base(analyticsService, authService, dialogService, navigationHelper)
        {
            SetAppThemeCommand = new Command <AppThemeViewModel>((x) => SetAppTheme(x));

            AppThemes.FirstOrDefault(x => x.Key == Preferences.Get(Settings.AppTheme, Settings.AppThemeDefault)).IsSelected = true;
        }
Example #6
0
        public BaseViewModel(IAnalyticsService analyticsService, IAuthService authService, IDialogService dialogService, INavigationHelper navigationHelper)
        {
            AnalyticsService = analyticsService;
            AuthService      = authService;
            DialogService    = dialogService;
            NavigationHelper = navigationHelper;

            BackCommand = new AsyncCommand(() => Back());
        }
 public DeleteRequestViewModel(IDeleteRequestCommand command, INavigationHelper navigationHelper)
 {
     ConfirmDeleteCommand = new ActionCommand(() =>
     {
         command.Execute(Id);
         navigationHelper.RefreshMenu();
         navigationHelper.DestroyModal();
     });
 }
        public LoginViewModel(ILoginDataService loginDataService, INavigationHelper navigationHelper, IMessenger messenger)
        {
            this.loginDataService = loginDataService;
            this.navigationHelper = navigationHelper;
            this.messenger        = messenger;
            LoginCommand          = new AsyncCommand <string>(password => Login(password), CanLogin);
            CreateCommand         = new AsyncCommand(() => CreateAccount());

            this.messenger.Register <AppLoadedMessage>(this, async(message) => await this.AppLoaded(message).ConfigureAwait(false));
        }
Example #9
0
        public static async Task NavigateToAsync(this INavigationHelper helper, Page page)
        {
            var formsHelper = helper as FormsNavigationHelper;

            if (formsHelper == null)
            {
                throw new ArgumentException("This extension only works in Xamarin Forms");
            }

            await formsHelper.NavigateToAsync(page);
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 /// <param name="catalogNavigation">The catalog navigation.</param>
 public NavigationService(
     ILogger logger,
     INavigationHelper navigationHelper,
     ISearchHelper searchHelper,
     IVariationNavigationHelper catalogNavigation)
 {
     this.logger            = logger;
     this.navigationHelper  = navigationHelper;
     this.searchHelper      = searchHelper;
     this.catalogNavigation = catalogNavigation;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 /// <param name="catalogNavigation">The catalog navigation.</param>
 public NavigationService(
     ILogger logger, 
     INavigationHelper navigationHelper, 
     ISearchHelper searchHelper, 
     IVariationNavigationHelper catalogNavigation)
 {
     this.logger = logger;
     this.navigationHelper = navigationHelper;
     this.searchHelper = searchHelper;
     this.catalogNavigation = catalogNavigation;
 }
Example #12
0
        public static async Task OpenModalAsync(this INavigationHelper helper, Page page, bool withNavigation = false)
        {
            var formsHelper = helper as FormsNavigationHelper;

            if (formsHelper == null)
            {
                throw new ArgumentException("This extension only works in Xamarin Forms");
            }

            await formsHelper.OpenModalAsync(page, withNavigation);
        }
Example #13
0
 public IncidentCurrentPageModel(ILocationService locationService, IIncidentService incidentService,
                                 INavigationService navigationService, IApplicationContext applicationContext, INavigationHelper navigationHelper,
                                 IIncidentsAppService incidentsAppService, IAccessTokenManager accessTokenManager)
 {
     _locationService     = locationService;
     _incidentService     = incidentService;
     _navigationService   = navigationService;
     _applicationContext  = applicationContext;
     _navigationHelper    = navigationHelper;
     _incidentsAppService = incidentsAppService;
     _accessTokenManager  = accessTokenManager;
 }
        public BgReadingsViewModel(IBgReadingsDataService dataService, IMessenger messenger, INavigationHelper navigation)
        {
            this.dataService     = dataService;
            this.messenger       = messenger;
            this.navigation      = navigation;
            this.LogAgainCommand = new AsyncCommand(this.LogAgainClicked);

            if (this.messenger != null)
            {
                this.messenger.Register <JournalEntryDataModel>(this, async(model) => await JournalEntryReceived(model));
            }
        }
 public JournalViewModel(IJournalDataService dataService, INavigationHelper navigation, IMessenger messenger)
 {
     LocalSearchResults    = new ObservableRangeCollection <Grouping <string, JournalEntryDataModel> >();
     SearchCommand         = new AsyncCommand <string>(SearchClicked);
     UpdateEntryCommand    = new RelayCommand(async() => await UpdateClicked().ConfigureAwait(true));
     LogAgainCommand       = new RelayCommand(async() => await LogAgainClicked().ConfigureAwait(true));
     ItemTappedCommand     = new RelayCommand <JournalEntryDataModel>(x => ItemTapped(x));
     CreateNewEntryCommand = new RelayCommand <string>(async entryTitle => await CreateNewEntryClicked(entryTitle).ConfigureAwait(true));
     ViewReadingsCommand   = new AsyncCommand(this.ViewReadingsClicked);
     this.dataService      = dataService;
     this.navigation       = navigation;
     this.messenger        = messenger;
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 /// <param name="catalogNavigation">The catalog navigation.</param>
 /// <param name="taxonomyHelper">The taxonomy helper.</param>
 public NavigationService(
     ILogger logger, 
     INavigationHelper navigationHelper, 
     ISearchHelper searchHelper, 
     IVariationNavigationHelper catalogNavigation,
     ITaxonomyHelper taxonomyHelper)
 {
     this.logger = logger;
     this.navigationHelper = navigationHelper;
     this.searchHelper = searchHelper;
     this.catalogNavigation = catalogNavigation;
     this.taxonomyHelper = taxonomyHelper;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 /// <param name="catalogNavigation">The catalog navigation.</param>
 /// <param name="taxonomyHelper">The taxonomy helper.</param>
 public NavigationService(
     ILogger logger,
     INavigationHelper navigationHelper,
     ISearchHelper searchHelper,
     IVariationNavigationHelper catalogNavigation,
     ITaxonomyHelper taxonomyHelper)
 {
     this.logger            = logger;
     this.navigationHelper  = navigationHelper;
     this.searchHelper      = searchHelper;
     this.catalogNavigation = catalogNavigation;
     this.taxonomyHelper    = taxonomyHelper;
 }
Example #18
0
        protected override void OnStartup(StartupEventArgs e)
        {
            BindKernel();
            EnsureDatabaseIsUpToDate();

            _navigation = _container.Get <INavigationHelper>();

            var viewmodel = _container.Get <MainWindowViewModel>();

            var window = new MainWindow
            {
                DataContext = viewmodel
            };

            Current.MainWindow = window;

            _navigation.RefreshMenu();
            Current.MainWindow.Show();
        }
        public JournalEntryViewModel(IJournalEntryDataService dataService, IMessenger messenger, INavigationHelper navigation, IDataStore <Tag> tags)
        {
            this.dataService  = dataService;
            this.messenger    = messenger;
            this.navigation   = navigation;
            this.tags         = tags;
            this.carbCount    = 5;
            ExistingTagSearch = new ObservableRangeCollection <Tag>();

            if (this.messenger != null)
            {
                this.messenger.Register <JournalEntryDataModel>(this, JournalEntryReceived);
            }

            ConfirmDeleteTappedCommand = new RelayCommand(ConfirmDeleteTapped);
            ExistingTagTappedCommand   = new RelayCommand <TagDataModel>(ExistingTagTapped);
            CreateNewTagCommand        = new RelayCommand <string>(async(x) => await CreateNewTag(x));
            TagTappedCommand           = new RelayCommand <Tag>(SearchTagTapped);
            SaveCommand           = new RelayCommand(async() => await SaveEntry());
            this.PropertyChanged += this.JournalEntryViewModel_PropertyChanged;
        }
        public IncidentUploadPageModel(IIncidentService incidentService, INavigationService navigationService, INavigationHelper navigationHelper,
                                       IAccessTokenManager accessTokenManager, IIncidentsAppService incidentsAppService)
        {
            _incidentService     = incidentService;
            _navigationService   = navigationService;
            _accessTokenManager  = accessTokenManager;
            _incidentsAppService = incidentsAppService;


            Items    = new ObservableRangeCollection <LocalIncident>();
            AllItems = new ObservableRangeCollection <LocalIncident>();

            FilterOptions = new ObservableRangeCollection <DisplayItem>
            {
                new DisplayItem
                {
                    Text  = "ShowAll".Translate(),
                    Value = string.Empty
                },
                new DisplayItem
                {
                    Text  = "Showlastday".Translate(),
                    Value = DateTime.Today.AddDays(-1).ToString(CultureInfo.InvariantCulture)
                },
                new DisplayItem
                {
                    Text  = "Showlastweek".Translate(),
                    Value = DateTime.Today.AddDays(-7).ToString(CultureInfo.InvariantCulture)
                }
            };

            SelectedFilter = new DisplayItem
            {
                Text  = "ShowAll",
                Value = string.Empty
            };

            _navigationHelper = navigationHelper;
        }
 public SelectCityPageModel(IDataStorageManager dataStorageManager, INavigationService navigationService, ITenantAppService tenantAppService, INavigationHelper navigationHelper)
 {
     AllTenants = new ObservableCollection <AllTenantDto>();
     this._dataStorageManager = dataStorageManager;
     this._navigationService  = navigationService;
     _tenantAppService        = tenantAppService;
     _navigationHelper        = navigationHelper;
     this.SubmitCommand       = new Command(OnSubmitClickAsync);
     //AllTenants.Add(new AllTenantDto
     //{
     //    Id = 0,
     //    Name = "Birmingham"
     //});
     //AllTenants.Add(new AllTenantDto
     //{
     //    Id = 1,
     //    Name = "Brussels"
     //});
     //AllTenants.Add(new AllTenantDto
     //{
     //    Id = 2,
     //    Name = "Rotterdam"
     //});
 }
Example #22
0
        public IntroViewModel(IAnalyticsService analyticsService, IAuthService authService, IDialogService dialogService, INavigationHelper navigationHelper)
            : base(analyticsService, authService, dialogService, navigationHelper)
        {
            SignInCommand = new AsyncCommand(() => SignIn());

            OnboardingItems = new List <OnboardingItem> {
                new OnboardingItem {
                    ImageName   = "onboarding1",
                    Title       = "Simple and effective",
                    Description = "Manage all of your community activities from the palm of your hand."
                },
                new OnboardingItem {
                    ImageName   = "onboarding2",
                    Title       = "Gather insights",
                    Description = "Gather additional insights through your contribution statistics. When were you most active? What type of contributions are you favorite?"
                },
                new OnboardingItem {
                    ImageName   = "onboarding3",
                    Title       = "Quick Add",
                    Description = "Directly create contributions based on a URL on your clipboard. Pre-filling whatever we can for you allowing you to quickly add new contributions."
                }
            };
        }
Example #23
0
 /// <summary>
 /// Инициализирует помощник навигации.
 /// </summary>
 /// <param name="navigationHelper">Экземпляр помощника навигации.</param>
 public static void InitializeNavigationHelper(INavigationHelper navigationHelper)
 {
     NavigationHelper = navigationHelper;
 }
Example #24
0
 public NewRequestViewModel(INavigationHelper navigation, IAddNewRequestCommand command)
     : base()
 {
     _command    = command;
     _navigation = navigation;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VariationNavigationHelper" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 public VariationNavigationHelper(ILogger logger, INavigationHelper navigationHelper, ISearchHelper searchHelper)
 {
     this.logger           = logger;
     this.navigationHelper = navigationHelper;
     this.searchHelper     = searchHelper;
 }
Example #26
0
        /// <summary>
        /// Implement your bot here.
        /// </summary>
        /// <param name="map">The gamemap.</param>
        /// <param name="visiblePlayers">Players that are visible to your bot.</param>
        /// <returns>The action you wish to execute.</returns>
        internal string ExecuteTurn(Map map, IEnumerable <IPlayer> visiblePlayers)
        {
            worldMap = WorldMap.ReadMap();
            if (worldMap == null || worldMap.HomePosition != PlayerInfo.HouseLocation)
            {
                worldMap = new WorldMap();
            }
            worldMap.UpdateWorldMap(map);
            worldMap.HomePosition = PlayerInfo.HouseLocation;
            WorldMap.WriteMap(worldMap);
            this.astarService     = new AStarAlgo(worldMap);
            this.ressourcePlaner  = new RessourcePlaner(worldMap, PlayerInfo, astarService);
            this.navigationHelper = new NavigationHelper(PlayerInfo, astarService);
            this.manathan         = new Manathan();
            this.placePlaner      = new PlacePlaner(map, PlayerInfo, astarService);

            Console.WriteLine("Cash : " + PlayerInfo.TotalResources);

            try
            {
                var best_ressource = ressourcePlaner.GetBestRessourcePath();
                //var best_place_for_shop = placePlaner.GetBestPlacePath(TileContent.Shop);
                //	10000	15000	25000	50000	100000
                if (PlayerInfo.Position == PlayerInfo.HouseLocation)
                {
                    bool upgrade = false;
                    switch (PlayerInfo.GetUpgradeLevel(UpgradeType.AttackPower))
                    {
                    case 0:
                        if (PlayerInfo.TotalResources >= 10000)
                        {
                            upgrade = true;
                        }
                        break;

                    case 1:
                        if (PlayerInfo.TotalResources >= 15000)
                        {
                            upgrade = true;
                        }
                        break;

                    case 2:
                        if (PlayerInfo.TotalResources >= 25000)
                        {
                            upgrade = true;
                        }
                        break;

                    case 3:
                        if (PlayerInfo.TotalResources >= 50000)
                        {
                            upgrade = true;
                        }
                        break;

                    case 4:
                        if (PlayerInfo.TotalResources >= 100000)
                        {
                            upgrade = true;
                        }
                        break;
                    }
                    if (upgrade)
                    {
                        return(AIHelper.CreateUpgradeAction(UpgradeType.AttackPower));
                    }
                }

                if (PlayerInfo.CarriedResources < PlayerInfo.CarryingCapacity && best_ressource != null)
                {
                    if (best_ressource.Path.Count == 2)
                    {
                        // On est adjacent à la meilleure ressource
                        var direction = astarService.DirectionToward(PlayerInfo.Position, best_ressource.Tile.Position);
                        return(AIHelper.CreateCollectAction(direction));
                    }
                    else if (best_ressource.Path.Count == 1)
                    {
                        // on est dessus
                        var tileToGo = map.GetTile(PlayerInfo.Position.X - 1, PlayerInfo.Position.Y);
                        var action   = navigationHelper.NavigateToNextPosition(tileToGo);
                        return(action);
                    }
                    else
                    {
                        // On est pas rendu
                        return(navigationHelper.NavigateToNextPosition(best_ressource.Path[1]));
                    }
                }
                else
                {
                    // on doit aller à la base
                    var home_tile    = worldMap.GetTile(PlayerInfo.HouseLocation.X, PlayerInfo.HouseLocation.Y);
                    var current_tile = worldMap.GetTile(PlayerInfo.Position.X, PlayerInfo.Position.Y);
                    if (home_tile == null)
                    {
                        var path = manathan.GetManathanPath(current_tile.Position, PlayerInfo.HouseLocation);
                        return(navigationHelper.NavigateToNextPosition(worldMap.GetTile(path[0].X, path[0].Y)));
                    }
                    else
                    {
                        var best_path_to_home = astarService.Run(current_tile, home_tile);

                        if (best_path_to_home == null)
                        {
                            var path = manathan.GetManathanPath(current_tile.Position, PlayerInfo.HouseLocation);
                            return(navigationHelper.NavigateToNextPosition(worldMap.GetTile(path[0].X, path[0].Y)));
                        }
                        // On est pas rendu
                        return(navigationHelper.NavigateToNextPosition(best_path_to_home[1]));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("*** Reset the map! ***");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.InnerException);
                Console.WriteLine("*** inner exception ***");
                Console.WriteLine(e);
                Console.WriteLine("*** exception ***");

                worldMap = new WorldMap();
                worldMap.UpdateWorldMap(map);
                worldMap.HomePosition = PlayerInfo.HouseLocation;
                WorldMap.WriteMap(worldMap);

                return("");
            }

            /*
             *             AStarAlgo astar = new AStarAlgo(map);
             * var result = astar.Run(PlayerInfo.Position, new Point(-4, 21));
             *
             *
             * var data = StorageHelper.Read<TestClass>("Test");
             * Console.WriteLine(data?.Test);
             * //return AIHelper.CreateMoveAction(new Point(_currentDirection, 0)); astar.DirectionToward(PlayerInfo.Position, result[0].Position);
             * return AIHelper.CreateMoveAction(astar.DirectionToward(PlayerInfo.Position, result[0].Position));*/
        }
Example #27
0
 public ContributionDetailsViewModel(IAnalyticsService analyticsService, IAuthService authService, IDialogService dialogService, INavigationHelper navigationHelper)
     : base(analyticsService, authService, dialogService, navigationHelper)
 {
     DeleteContributionCommand = new AsyncCommand(() => DeleteContribution());
     SecondaryCommand          = new AsyncCommand(() => EditContribution(), (x) => CanBeEdited);
 }
Example #28
0
 public NavController(IUICategoryRepository uiCategoryRepository, INavigationHelper navHelper)
 {
     this.uiCategoryRepository = uiCategoryRepository;
     this.navHelper = navHelper;
 }
Example #29
0
 public MenuGroupFactory(INavigationHelper navigationHelper, IDeleteRequestGroupCommand deleteGroupCommand)
 {
     _navigationHelper   = navigationHelper;
     _deleteGroupCommand = deleteGroupCommand;
 }
Example #30
0
 public StatisticsViewModel(IAnalyticsService analyticsService, IAuthService authService,
                            IDialogService dialogService, INavigationHelper navigationHelper)
     : base(analyticsService, authService, dialogService, navigationHelper)
 {
 }
Example #31
0
 public DialogService(INavigationHelper navigationHelper)
 {
     _navigationHelper = navigationHelper;
 }
 public WizardAdditionalTechnologyViewModel(IAnalyticsService analyticsService, IAuthService authService, IDialogService dialogService, INavigationHelper navigationHelper)
     : base(analyticsService, authService, dialogService, navigationHelper)
 {
     BackCommand             = new AsyncCommand(() => Back());
     NextCommand             = new AsyncCommand(() => Next());
     SelectionChangedCommand = new Command <IList <object> >((list) => SelectionChanged(list));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VariationNavigationHelper" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="navigationHelper">The navigation helper.</param>
 /// <param name="searchHelper">The search helper.</param>
 public VariationNavigationHelper(ILogger logger, INavigationHelper navigationHelper, ISearchHelper searchHelper)
 {
     this.logger = logger;
     this.navigationHelper = navigationHelper;
     this.searchHelper = searchHelper;
 }
Example #34
0
 public MainViewModel(INavigationHelper navigationHelper)
 {
     this.navigationHelper = navigationHelper;
     this.Items = new ObservableCollection<ItemViewModel>();
     this.isDataLoaded = false;
 }
Example #35
0
 /// <summary>
 /// Инициализирует помощник навигации.
 /// </summary>
 /// <param name="navigationHelper">Экземпляр помощника навигации.</param>
 public static void InitializeNavigationHelper(INavigationHelper navigationHelper)
 {
     NavigationHelper = navigationHelper;
 }
 public PageListingBlockController(INavigationHelper helper)
 {
     _helper = helper;
 }