public SettingsViewModel(IAppBootstrapper bootstrapper, IMessageBus messageBus) : base(bootstrapper, messageBus) { base.PathSegment = Constants.PATH_SEGMENT_SETTINGS; this.localSettings = ApplicationData.Current.LocalSettings; #region Local Storage Configuration // IsLocalStorageOn default value _isLocalStorageOn = ApplicationDataSettingsHelper.ReadValue<bool>(Constants.SETTINGS_IS_LOCALSTORAGE_ENABLED); this.ObservableForProperty(vm => vm.IsLocalStorageOn) .Subscribe(x => { ApplicationDataSettingsHelper.SaveOrUpdateValue(Constants.SETTINGS_IS_LOCALSTORAGE_ENABLED, x.Value); }); #endregion Local Storage Configuration #region Location Service Configuration // IsLocationServiceOn default value _isLocationServiceOn = ApplicationDataSettingsHelper.ReadValue<bool>(Constants.SETTINGS_IS_LOCATION_ENABLED); this.ObservableForProperty(vm => vm.IsLocationServiceOn) .Subscribe(x => { ApplicationDataSettingsHelper.SaveOrUpdateValue(Constants.SETTINGS_IS_LOCATION_ENABLED, x.Value); }); #endregion Location Service Configuration }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); _appBootstrapper = new Zephyr.Web.Mvc.Initialization.MvcAppBootstrapper(); _appBootstrapper.Run(); }
public static void Run(string[] args, IAppBootstrapper bootstrapper, bool runAsSingleInstanceApplication = true) { if (runAsSingleInstanceApplication) { if (!SingleInstance <AppRunner> .InitializeAsFirstInstance(bootstrapper.GetApplicationUniqueName())) { return; } } Run(args, bootstrapper); }
public static void RunAsAdmin(string[] args, IAppBootstrapper bootstrapper, bool runAsSingleInstanceApplication = true) { if (runAsSingleInstanceApplication) { if (!SingleInstance <AppRunner> .InitializeAsFirstInstance(bootstrapper.GetApplicationUniqueName())) { return; } } Current = new AppRunner(bootstrapper); Current.RunAsAdmin(ParseCommandLineArgs(args)); }
public RouteViewModel(IAppBootstrapper bootstrapper, IMessageBus messageBus, Route selectedRoute) : base(bootstrapper, messageBus) { base.PathSegment = Constants.PATH_SEGMENT_ROUTE; this.SelectedRoute = selectedRoute; #region ApplicationBar Configuration RefreshCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value)); RefreshCommand.Subscribe(async _ => { await RequestInternetData(); }); SearchCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value)); SearchCommand.Subscribe(async _ => { await GetRealTimeInfo(); }); PinCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value)); PinCommand.Subscribe(async _ => { await PinToScreen(); }); #endregion ApplicationBar Configuration if (ApplicationDataSettingsHelper.ReadValue<bool>(Constants.SETTINGS_IS_LOCALSTORAGE_ENABLED)) { Observable.StartAsync(RequestLocalData); } else { Observable.StartAsync(RequestInternetData); } }
/* COOLSTUFF: Why the Screen here? * * Every RoutableViewModel has a pointer to its IScreen. This is really * useful in a unit test runner, because you can create a dummy screen, * invoke Commands / change Properties, then test to see if you navigated * to the correct new screen */ public ViewModelBase(IAppBootstrapper bootstrapper, IMessageBus messageBus) { HostScreen = bootstrapper; HostMessageBus = messageBus; }
public static void Run(string[] args, IAppBootstrapper bootstrapper) { Current = new AppRunner(bootstrapper); Current.Run(ParseCommandLineArgs(args)); }
private AppRunner(IAppBootstrapper appBootstrapper) { _appBootstrapper = appBootstrapper; }
public IAPViewModel(IAppBootstrapper bootstrapper, IMessageBus messageBus) : base(bootstrapper, messageBus) { base.PathSegment = Constants.PATH_SEGMENT_IAP; }
public void Init() { appBootstrapper = new MvcAppBootstrapper(); appBootstrapper.Run(); }
public MainViewModel(IAppBootstrapper bootstrapper, IMessageBus messageBus) : base(bootstrapper, messageBus) { base.PathSegment = Constants.PATH_SEGMENT_MAIN; #region FilterData Configuration this.ObservableForProperty(vm => vm.FilterTerm) .Throttle(TimeSpan.FromMilliseconds(300), RxApp.MainThreadScheduler) .Select(v => v.Value) .DistinctUntilChanged() .Subscribe(v => { if (string.IsNullOrEmpty(v)) { Routes = SourceRoutes; } else { IList<Route> resultList = new ObservableCollection<Route>(); foreach (Route route in SourceRoutes) { if (route.RouteName.Contains(v)) { resultList.Add(route); } } Routes = resultList; } }); #endregion FilterData Configuration #region Navigation Configuration // RouteView this.ObservableForProperty(vm => vm.SelectedRoute) .Where(v => null != v.Value) .Select(v => v.Value) //.DistinctUntilChanged() .Subscribe(r => { base.HostScreen.Router.Navigate.Execute(new RouteViewModel(base.HostBootstrapper, base.HostMessageBus, r)); this.SelectedRoute = null; }); // SettingsView NavigateSettingsCommand = ReactiveCommand.Create(); NavigateSettingsCommand.Subscribe(_ => { base.HostScreen.Router.Navigate.Execute(new SettingsViewModel(base.HostBootstrapper, base.HostMessageBus)); }); #endregion Navigation Configuration #region Refresh Data Configuration RefreshCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value)); RefreshCommand.Subscribe(async _ => { await RequestInternetRoutes(); }); // don't use ToProperty(), because the ToProperty() is a Lazy Observation // https://github.com/reactiveui/ReactiveUI/blob/master/docs/basics/to-property.md this.WhenAny(vm => vm.IsBusy, x => x.Value) .Select(x => !x) .Subscribe(x => { IsEnabled = x; }); #endregion Refresh Data Configuration #region Location Configuration messageBus.Listen<bool>(Constants.SETTINGS_IS_LOCATION_ENABLED).Subscribe(x => { IsFlipSegmentsNearbyEnabled = x; }); LocationCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value)); LocationCommand.Subscribe(async _ => { IsBusy = true; messageBus.SendMessage<string>(Constants.MSG_MAP_LOCATION_GET, Constants.MSGBUS_TOKEN_MESSAGEBAR); Geolocator geolocator = new Geolocator { ReportInterval = 1000, DesiredAccuracy = PositionAccuracy.High, DesiredAccuracyInMeters = 10, MovementThreshold = 5 }; //geolocator.StatusChanged += geolocator_StatusChanged; try { Geoposition location = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(5)); if (location.Coordinate.Point.Position.Latitude == HostBootstrapper.MyPosition.Latitude && location.Coordinate.Point.Position.Longitude == HostBootstrapper.MyPosition.Longitude) { #if DEBUG messageBus.SendMessage<string>(Constants.MSG_MAP_LOCATION_HAVENT_CHANGE, Constants.MSGBUS_TOKEN_MESSAGEBAR); #endif } else { messageBus.SendMessage<BasicGeoposition>(location.Coordinate.Point.Position, Constants.MSGBUS_TOKEN_MY_GEOPOSITION); } } catch (Exception ex) { if (geolocator.LocationStatus == PositionStatus.Disabled) { messageBus.SendMessage<string>(Constants.MSG_MAP_LOCATION_SERVICE_UNAVAILABLE, Constants.MSGBUS_TOKEN_MESSAGEBAR); } else { messageBus.SendMessage<string>(ex.Message, Constants.MSGBUS_TOKEN_MESSAGEBAR); } } IsBusy = false; }); #endregion Location Configuration #region Request data when MyPosition is ready this.WhenAnyValue(vm => vm.HostBootstrapper.MyPosition) .Subscribe(position => { if (!SourceRoutes.Any()) { if (ApplicationDataSettingsHelper.ReadValue<bool>(Constants.SETTINGS_IS_LOCALSTORAGE_ENABLED)) { Observable.StartAsync(RequestLocalRoutes); } else { Observable.StartAsync(RequestInternetRoutes); } } if (position.Longitude != 0 && position.Latitude != 0) { Observable.StartAsync(RequestSegmentsNearby); } }); #endregion Request data when MyPosition is ready }