Example #1
0
        public NavigationVM(ViewModelBase favVM_)
        {
            FromToggle         = true;
            Pins               = new ObservableCollection <Pushpin>();
            FavVM              = favVM_ as FavouritesVM;
            ToAddressessSearch = new MixedSearch();
            ToAddressessSearch.OnSelectedAction += ToAddressessSearch_OnSelectedAction;
            FromAddressessSearch = new MixedSearch();
            FromAddressessSearch.OnSelectedAction += FromAddressessSearch_OnSelectedAction;
            MainMap                              = new MapVM();
            FindRouteCommand                     = new Command(arg => FindRoute());
            CenterOnRouteCommand                 = new Command(arg => CenterOnRoute(arg));
            CenterOnUserLocationCommand          = new Command(arg => CenterOnUserLocation(arg));
            SwapAddressesCommand                 = new Command(arg => SwapAddresses());
            SearchLocationEnterClick             = new Command(arg => FindRoute());
            MapDoubleClickCommand                = new Command(arg => MapDoubleClick(arg));
            FromAddressessSearch.StoredLocations = FavVM.Locations;
            ToAddressessSearch.StoredLocations   = FavVM.Locations;

            FavVM.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Locations")
                {
                    if (FavVM.Locations.Count > 0)
                    {
                        MainMap.Center = MapVM.GetLocation(FavVM.Locations.First().Address);
                    }
                    else
                    {
                        MainMap.Center    = new Location(52.0, 19.0);
                        MainMap.ZoomLevel = 5;
                    }
                }
            };
        }
Example #2
0
        public void NavigateTo(object arg)
        {
            if (arg is string dest)
            {
                switch (dest)
                {
                case "Login":
                    SelectedVM = new LoginVM(this);
                    break;

                case "Logout":
                    Logout();
                    SelectedVM = new LoginVM(this);
                    navigation = null;
                    favourites = null;
                    MenuToggle = false;
                    LoggedIn   = false;
                    break;

                case "Navigation":
                    if (favourites == null || navigation == null)
                    {
                        favourites = new FavouritesVM(this);
                        navigation = new NavigationVM(favourites);
                        LoggedIn   = true;
                    }
                    SelectedVM = navigation;
                    MenuToggle = false;
                    break;

                case "Favourites":
                    SelectedVM = favourites;
                    MenuToggle = false;
                    break;

                case "Register":
                    SelectedVM = new RegisterVM(this);
                    break;

                case "Profile":
                    SelectedVM = new ProfileVM(this);
                    MenuToggle = false;
                    break;

                default:
                    break;
                }
            }
        }