Ejemplo n.º 1
0
        public MainViewModel(INavigationService2 navigationService)
            : base(navigationService)
        {
            MainNavItems = new ObservableCollection <NavItem>()
            {
                new NavItem()
                {
                    Text       = "Settings",
                    ButtonText = "\uE80F",
                    Icon       = (Geometry)Application.Current.Resources["Book_Icon"],
                    Command    = new RelayCommand(() => NavigateTo("Settings"), () => ActivePage != "Settings")
                }
            };

            SecondaryNavItems = new ObservableCollection <NavItem>()
            {
                //new NavItem()
                //{
                //    Text = "Settings",
                //    ButtonText = "\uE713",
                //    Command = new RelayCommand(() => NavigateTo("Settings"), () => ActivePage != "Settings" )
                //}
            };

            navigationService.Navigated += NavigationService_Navigated;

            // do this asynchronously on the dispatcher so that the UI is full instantiated
            // before we attempt to navigate (see comment in NavControl.xaml.cs)
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            DispatcherHelper.RunAsync(() => base.NavigateTo("Home"));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Ejemplo n.º 2
0
        public static INavigationService AttachGestures(this INavigationService service, Window window, params Gesture[] gestures)
        {
            INavigationService2 service2        = service as INavigationService2;
            IGestureService     gesture_service = GestureService.GetForCurrentView(window.CoreWindow);

            foreach (Gesture gesture in gestures)
            {
                switch (gesture)
                {
                case Gesture.Back:
                    AddOnlyOne(gesture_service.BackRequestedCallbacks, service2.FrameFacade.Id, async() => await service.GoBackAsync());
                    break;

                case Gesture.Forward:
                    AddOnlyOne(gesture_service.ForwardRequestedCallbacks, service2.FrameFacade.Id, async() => await service.GoForwardAsync());
                    break;

                case Gesture.Refresh:
                    AddOnlyOne(gesture_service.RefreshRequestedCallbacks, service2.FrameFacade.Id, async() => await service.RefreshAsync());
                    break;
                }
            }
            return(service);

            void AddOnlyOne(Dictionary <string, Action> dictionary, string id, Action action)
            {
                dictionary.Remove(id);
                dictionary.Add(id, action);
            }
        }
Ejemplo n.º 3
0
        public GeoLocationViewModel(Keys keys, INavigationService2 navigationService)
            : base(navigationService)
        {
            var b = new BasicGeoposition()
            {
                Latitude = 0,
                Longitude = 0
            };
            _location = new Geopoint(b);

            _keys = keys;
        }
Ejemplo n.º 4
0
        public AboutViewModel(IAbout about, INavigationService2 navigationService)
            : base(navigationService)
        {
            _about = about;

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RateCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"ms-windows-store:REVIEW?ProductId={_about.ProductId}")));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

//windows-feedback:ADD?PFN=Microsoft.WindowsFeedback_cw5n1h2txyewy
            //FeedbackCommand = new RelayCommand(() => Launcher.LaunchUriAsync(
            //        new Uri($"ms-windows-store:REVIEW?PFN={_about.PackageName}")));
        }
Ejemplo n.º 5
0
        public AboutViewModel(IAbout about, INavigationService2 navigationService)
            : base(navigationService)
        {
            _about = about;

            // TODO - set this to null if you don't want the little "Rate Our App" widget
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RateCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"ms-windows-store:REVIEW?ProductId={_about.ProductId}")));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            // This currently only works for Microsoft's apps so don't uncomment it
            //FeedbackCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"windows-feedback:?contextid=522")));
        }
Ejemplo n.º 6
0
        public AboutViewModel(IAbout about, INavigationService2 navigationService)
            : base(navigationService)
        {
            _about = about;

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RateCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"ms-windows-store:REVIEW?ProductId={_about.ProductId}")));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            //windows-feedback:ADD?PFN=Microsoft.WindowsFeedback_cw5n1h2txyewy
            //FeedbackCommand = new RelayCommand(() => Launcher.LaunchUriAsync(
            //        new Uri($"ms-windows-store:REVIEW?PFN={_about.PackageName}")));
        }
Ejemplo n.º 7
0
        public AboutViewModel(IAbout about, INavigationService2 navigationService)
            : base(navigationService)
        {
            _about = about;

            // TODO - set this to null if you don't want the little "Rate Our App" widget
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RateCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"ms-windows-store:REVIEW?ProductId={_about.ProductId}")));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            // This currently only works for Microsoft's apps so don't uncomment it
            //FeedbackCommand = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri($"windows-feedback:?contextid=522")));
        }
Ejemplo n.º 8
0
        public SettingsViewModel(ISettings settings, Keys keys, IGeoCoder locator, ICongress congress, INavigationService2 navigationService)
            : base(navigationService)
        {
            _settings = settings;
            _congress = congress;
            _zipSearchVm = new ZipCodeSearchViewModel(navigationService);
            _geoVM = new GeoLocationViewModel(keys, navigationService);
            _locator = locator;

            _location = _settings.Location;
            if (_location != null)
            {
                _zipcode = _location.ZipCode;
            }

            _district = new RemoteResult<dynamic>(() => _congress.FindFirstDistrict(_location.Lat, _location.Long), 
                () => RaisePropertiesChanged("District"), new ExpandoObject());
        }
Ejemplo n.º 9
0
        public MainViewModel(INavigationService2 navigationService)
            : base(navigationService)
        {
            MainNavItems = new ObservableCollection<NavItem>()
            {
                new NavItem()
                {
                    Text = "Home",
                    ButtonText = "\uE80F",
                    Command = new RelayCommand(() => NavigateTo("Home"), () => ActivePage != "Home" )
                }
            };

            SecondaryNavItems = new ObservableCollection<NavItem>()
            {
                new NavItem()
                {
                    Text = "Visit website",
                    ButtonText = "\uE909",
                    Command = new RelayCommand(() =>
                    {
                        // TODO - add your website address here
                        var uri = new Uri("http://google.com/", UriKind.Absolute);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        Launcher.LaunchUriAsync(uri);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    })
                },
                new NavItem()
                {
                    Text = "Settings",
                    ButtonText = "\uE713",
                    Command = new RelayCommand(() => NavigateTo("Settings"), () => ActivePage != "Settings" )
                }
            };

            navigationService.Navigated += NavigationService_Navigated;

            // do this asynchronously on the dispatcher so that the UI is full instantiated
            // before we attempt to navigate (see comment in NavControl.xaml.cs)
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            DispatcherHelper.RunAsync(() => base.NavigateTo("Home"));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Ejemplo n.º 10
0
        public MainViewModel(INavigationService2 navigationService)
            : base(navigationService)
        {
            MainNavItems = new ObservableCollection <NavItem>()
            {
                new NavItem()
                {
                    Text       = "Home",
                    ButtonText = "\uE80F",
                    Command    = new RelayCommand(() => NavigateTo("Home"), () => ActivePage != "Home")
                }
            };

            SecondaryNavItems = new ObservableCollection <NavItem>()
            {
                new NavItem()
                {
                    Text       = "Visit website",
                    ButtonText = "\uE909",
                    Command    = new RelayCommand(() =>
                    {
                        // TODO - add your website address here
                        var uri = new Uri("http://google.com/", UriKind.Absolute);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        Launcher.LaunchUriAsync(uri);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    })
                },
                new NavItem()
                {
                    Text       = "Settings",
                    ButtonText = "\uE713",
                    Command    = new RelayCommand(() => NavigateTo("Settings"), () => ActivePage != "Settings")
                }
            };

            navigationService.Navigated += NavigationService_Navigated;

            // do this asynchronously on the dispatcher so that the UI is full instantiated
            // before we attempt to navigate (see comment in NavControl.xaml.cs)
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            DispatcherHelper.RunAsync(() => base.NavigateTo("Home"));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Ejemplo n.º 11
0
        public HomeViewModel(ISettings settings, ICongress congress, ICurrentCongressionalSession currentSession, INavigationService2 navigationService)
            : base(navigationService)
        {
            _settings = settings;
            _congress = congress;
            _currentSession = currentSession;

            _upcomingBills = new RemoteResult<dynamic>(() => _congress.GetUpcomingBills(), () => RaisePropertiesChanged("UpcomingBills"), null);
            _legislators = new RemoteResult<dynamic>(() => _congress.FindLegislators(_settings.Location.Lat, _settings.Location.Long), () => RaisePropertiesChanged("Legislators"), null);

            SelectCommand = new RelayCommand<dynamic>(o =>
            {
                var vm = new DynamicViewModel(_navigationService, o);
                string id = o.bioguide_id as string;

                vm.AppendModel(new Dictionary<string, Func<Task<dynamic>>>()
                    {
                        { "committees", () => _congress.GetCommittees(id) },
                        { "sponsored_bills", () => _congress.GetBills(id) }
                    });

                NavigateTo("LegislatorDetail", vm);
            });
        }
Ejemplo n.º 12
0
 public SettingsViewModel(ISettings settings, INavigationService2 navigationService)
     : base(navigationService)
 {
     _settings = settings;
 }
Ejemplo n.º 13
0
 public SettingsViewModel(ISettings settings, INavigationService2 navigationService)
     : base(navigationService)
 {
     _settings = settings;
 }
Ejemplo n.º 14
0
 protected ViewModel(INavigationService2 navigationService)
 {
     _navigationService = navigationService;
 }
Ejemplo n.º 15
0
 public ZipCodeSearchViewModel(INavigationService2 navigationService)
     : base(navigationService)
 {
 }
Ejemplo n.º 16
0
 public DynamicViewModel(INavigationService2 navigationService, dynamic model)
     : base(navigationService)
 {
     Model = model;
 }
Ejemplo n.º 17
0
 protected ViewModel(INavigationService2 navigationService)
 {
     _navigationService = navigationService;
 }
Ejemplo n.º 18
0
 public MenuOptionViewModel(INavigationService2 navigationService) : base(navigationService)
 {
 }
Ejemplo n.º 19
0
 public TrainingItemViewModel(INavigationService2 navigationService) : base(navigationService)
 {
 }