public ContextMenuModel(IScreen owner, string name, string displayName, Bitmap image = null) { Owner = owner; Name = name; DisplayName = displayName; Image = image; }
/// <summary> /// Gets the fully qualified name of a ViewModel. Just adds the AssemblyQualifiedName to the <see cref="GetViewModelName"/>. /// </summary> /// <param name="screen">The screen</param> /// <param name="targetPostFix">Either <see cref="HomePostFix"/> or <see cref="SinglePostFix"/></param> /// <param name="viewModelPostFix">The <see cref="ViewModelPostFix"/></param> /// <returns>The fully qualified ViewModel-Name</returns> private static string GetQualifiedViewModelName(IScreen screen, string targetPostFix, string viewModelPostFix) { string qualifiedName = screen.GetType().AssemblyQualifiedName; return qualifiedName.Replace( screen.GetType().Name, GetViewModelName(screen, targetPostFix, viewModelPostFix)); }
/// <summary> /// Erstellt ein neues 3D-Modell mit dem angegebenen Spielzustand und den angegebenen Spielinformationen. /// [base=screen, info] /// </summary> public RectangleModel(IScreen screen, Texture2D texture, Parallelogram parallelogram, Vector3 position) : base(screen: screen) { Texture = texture; Position = position; Parallelogram = parallelogram; }
/// <summary> /// Erzeugt eine neue Instanz eines EdgeMovement-Objekts und initialisiert diese /// mit ihrem zugehörigen IGameScreen-Objekt screen, der Spielwelt world und /// Objektinformationen info. /// </summary> public EdgeMovement(IScreen screen, World world, KnotRenderer knotRenderer, Vector3 position) : base(screen, DisplayLayer.None) { Screen = screen; World = world; KnotRenderer = knotRenderer; }
public RegesterViewModel(IScreen screen = null) { HostScreen = screen ?? Locator.Current.GetService<IScreen>(); var canRegester = this.WhenAny( x => x.RegesterEmail, x => x.RegesterPassword, x => x.ConfirmPassword, (e, p, cp) => !string.IsNullOrEmpty(e.Value) && !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(cp.Value) ); Regester = ReactiveCommand.CreateAsyncTask(canRegester, async _ => { var client = new HttpClient(NetCache.UserInitiated) { BaseAddress = new Uri(Helper.address) }; var api = RestService.For<IRestaurantApi>(client); var result = await api.Regester(this.RegesterEmail, this.RegesterPassword, this.ConfirmPassword); return result; }); Regester.Subscribe(r => { Debug.WriteLine("Complete!"); }); Regester.ThrownExceptions.Subscribe(ex => { Debug.WriteLine("Error!"); }); }
public ExerciseProgramViewModelBuilder() { this.loggerService = new LoggerServiceMock(MockBehavior.Loose); this.schedulerService = new SchedulerServiceMock(MockBehavior.Loose); this.hostScreen = new ScreenMock(MockBehavior.Loose); this.model = new ExerciseProgramBuilder(); }
/// <summary> /// Erzeugt eine neue Instanz eines ColorPicker-Objekts und initialisiert diese /// mit der Farbe, auf welche der Farbwähler beim Aufruf aus Sicht des Spielers zeigt. /// </summary> public ColorPicker(IScreen screen, DisplayLayer drawOrder, Color def) : base(screen, drawOrder) { tileSize = new ScreenPoint (screen, 0.032f, 0.032f); // Widget-Attribute BackgroundColorFunc = (s) => Design.WidgetBackground; ForegroundColorFunc = (s) => Design.WidgetForeground; AlignX = HorizontalAlignment.Left; AlignY = VerticalAlignment.Top; // die Farb-Tiles colors = new List<Color> (CreateColors (64)); colors.Sort (ColorHelper.SortColorsByLuminance); tiles = new List<ScreenPoint> (CreateTiles (colors)); // einen Spritebatch spriteBatch = new SpriteBatch (screen.GraphicsDevice); // Position und Größe Bounds.Position = ScreenPoint.Centered (screen, Bounds); Bounds.Size.RelativeFunc = () => { float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count)); return tileSize * sqrt; }; // Die Callback-Funktion zur Selektion setzt das SelectedColor-Attribut ColorSelected += (color, time) => { SelectedColor = color; }; }
public UserPreferencesPageViewModel (IScreen hostScreen, UserSettings userSettings) { HostScreen = hostScreen; var tempPrefChanged = this.WhenAnyValue (x => x.TemperaturePreference).StartWith (userSettings.TemperaturePreference); tempPrefChanged .Subscribe (x => userSettings.TemperaturePreference = x); tempPrefChanged .Select (x => x == TemperatureUnit.Celsius ? "C" : "F") .ToProperty (this, vm => vm.TempPreferenceLabel, out _TempPreferenceLabel); // var volumePrefChanged = this.WhenAnyValue (x => x.VolumePreference); // volumePrefChanged // .StartWith (userSettings.VolumePreference) // .Do (x => System.Diagnostics.Debug.WriteLine ("setting vol pref {0}", x)) // .Subscribe (x => userSettings.VolumePreference = x); // // var equipLossChanged = this.WhenAnyValue (x => x.EquipmentLossVolume); // // equipLossChanged // .StartWith (userSettings.EquipmentLossVolume) // .Subscribe (x => userSettings.EquipmentLossVolume = x); // // var trubLossChanged = this.WhenAnyValue (x => x.TrubLossVolume); // // trubLossChanged // .StartWith (userSettings.TrubLossVolume) // .Subscribe (x => userSettings.TrubLossVolume = x); }
public LogInViewModel(IScreen host, IGitHubClient ghClient) { this.HostScreen = host; this.GHClient = ghClient; // Only allow a submit when the user name is valid var validStuffTyped = this.WhenAny(x => x.UserName, x => x.Password, (user, pass) => !string.IsNullOrWhiteSpace(user.Value) && !string.IsNullOrWhiteSpace(pass.Value)); Submit = new ReactiveCommand(validStuffTyped); //todo: better make a cancel or else you'll get very mad! //Submit.Subscribe(_ => //{ // GHClient.Authorization.Create(); // //try // //{ // // //if (user != null) // // //{ // // // Insert the user into the cache // // BlobCache.UserAccount.InsertObject<User>("MyUser", user); // // //} // //} // //catch (AuthorizationException authEx) // //{ // // Debug.Print("CRAP!"); // // Debug.Print(authEx.Message); // // Debug.Print(authEx.StackTrace); // //} //}); MessageBus.Current.RegisterMessageSource(Submit); }
/// <summary> /// Erstellt ein neues Informationsobjekt für ein 3D-Modell, das eine Kante darstellt. /// [base="pipe1", Angles3.Zero, new Vector3 (10,10,10)] /// </summary> public Pipe(IScreen screen, IGrid grid, Knot knot, Edge edge, Node node1, Node node2) : base(screen: screen) { UniqueKey = edge.ToString (); // Weise Knoten und Kante zu Knot = knot; Edge = edge; Grid = grid; // Berechne die beiden Positionen, zwischen denen die Kante gezeichnet wird PositionFrom = node1; PositionTo = node2; // Kanten sind verschiebbar und auswählbar IsMovable = true; IsSelectable = true; // Berechne die Drehung Rotation += RotationMap [Edge.Direction]; // Aktualisiere die Kategorie Coloring.OnColorChanged += UpdateCategory; IsSingleColored = true; incomplete = true; }
public SearchViewModel(IScreen hostScreen, ILoginMethods loginMethods) { HostScreen = hostScreen; SearchResults = new ReactiveCollection<ISongTileViewModel>(); var playApi = loginMethods.CurrentAuthenticatedClient; if (playApi == null) { hostScreen.Router.Navigate.Execute(RxApp.GetService<IWelcomeViewModel>()); return; } var canSearch = this.WhenAny(x => x.SearchQuery, x => !String.IsNullOrWhiteSpace(x.Value)); PerformSearch = new ReactiveAsyncCommand(canSearch); this.ObservableForProperty(x => x.SearchQuery) .Throttle(TimeSpan.FromMilliseconds(700), RxApp.DeferredScheduler) .InvokeCommand(PerformSearch); var searchResults = PerformSearch.RegisterAsyncObservable(_ => playApi.Search(SearchQuery)); SearchResults = searchResults .Do(_ => SearchResults.Clear()) .SelectMany(list => list.ToObservable()) .LoggedCatch(this, Observable.Empty<Song>()) .CreateCollection(x => (ISongTileViewModel) new SongTileViewModel(x, playApi)); PerformSearch.ItemsInflight.StartWith(0) .Select(x => x > 0 ? Visibility.Visible : Visibility.Collapsed) .ToProperty(this, x => x.SearchBusySpinner); PerformSearch.ThrownExceptions.Subscribe(_ => { }); GoBack = new ReactiveCommand(); GoBack.InvokeCommand(hostScreen.Router.NavigateBack); }
public PersonListViewModel(IScreen hostScreen, IPersonRepository personRepository = null) { HostScreen = hostScreen; personRepository = personRepository ?? new PersonRepository(); Persons = new ReactiveList<PersonItemViewModel>(); NewPersonCommand = new ReactiveCommand(null); NewPersonCommand.RegisterAsyncAction(_ => { }).Subscribe(_ => HostScreen.Router.Navigate.Execute(new PersonAddViewModel(HostScreen))); RefreshCommand = new ReactiveCommand(null); var refresh = RefreshCommand.RegisterAsync<List<Person>>(_ => Observable.Start(() => personRepository.RetrievePersonsAsync(). Result)); refresh.Subscribe(list => { using (Persons.SuppressChangeNotifications()) { Persons.Clear(); Persons.AddRange(personRepository.RetrievePersonsAsync(). Result.Select(d => new PersonItemViewModel(d.FirstName, d.LastName, d.Age))); } }); MessageBus.Current.Listen<Person>(). Subscribe(p => { personRepository.AddPerson(p); RefreshCommand.Execute(null); }); }
public BootstrapLoad(Game1 game, IScreen nextScreen, IScreen errorScreen, Action<Action, Action<String>> load) { Next = nextScreen; this.game = game; loadingThread = new Thread(a => load(() => complete = true, s => strings.Push(s))); }
/// <summary> /// Erstelle einen neuen TextInputDialog. /// </summary> public TextInputDialog(IScreen screen, DisplayLayer drawOrder, string title, string text, string inputText) : base(screen, drawOrder, title) { textItem = new TextItem (screen, drawOrder, String.Empty); Cancel = (time) => { Close (time); }; Submit = (time) => { Close (time); }; Bounds.Size = new ScreenPoint (screen, 0.5f, 0.3f); // Der Titel-Text ist mittig ausgerichtet AlignX = HorizontalAlignment.Center; menu = new Menu (Screen, Index + DisplayLayer.Menu); menu.Bounds = ContentBounds; menu.Bounds.Padding = new ScreenPoint (screen, 0.010f, 0.019f); menu.ItemAlignX = HorizontalAlignment.Left; menu.ItemAlignY = VerticalAlignment.Center; //die Texteingabe textInput = new InputItem (Screen, Index + DisplayLayer.MenuItem, text, inputText); menu.Add (textInput); menu.Add (textItem); textInput.IsEnabled = true; textInput.IsInputEnabled = true; textInput.NameWidth = 0.35f; textInput.ValueWidth = 0.65f; ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape }); }
public ShellViewModel( IScreen screen, Func<SettingsViewModel> getSettings, Func<CheckForUpdatesViewModel> getForegroundUpdater, Func<BackgroundUpdaterViewModel> getBackgroundUpdater) { HostScreen = screen; SettingsCommand = new ReactiveAsyncCommand(); SettingsCommand.RegisterAsyncAction(o => { var viewModel = getSettings(); HostScreen.Navigate(viewModel); }); UpdateBasicsCommand = new ReactiveAsyncCommand(); UpdateBasicsCommand.RegisterAsyncAction(o => { var viewModel = getForegroundUpdater(); HostScreen.Navigate(viewModel); }); BackgroundUpdaterCommand = new ReactiveAsyncCommand(Observable.Return(false)); BackgroundUpdaterCommand.RegisterAsyncAction(o => { var viewModel = getBackgroundUpdater(); HostScreen.Navigate(viewModel); }); }
public TwoFactorViewModel(IScreen host) { HostScreen = host; var codeHasBeenInput = this.WhenAny(x => x.Code, code => !string.IsNullOrWhiteSpace(code.Value)); Submit = new ReactiveCommand(codeHasBeenInput); }
public SettingsViewModel( IScreen screen, ISettingsProvider settingsProvider, IFolderHelper folderHelper, IAppContext appContext) { HostScreen = screen; BackCommand = new ReactiveAsyncCommand(); BackCommand.RegisterAsyncAction(_ => HostScreen.Router.NavigateBack.Execute(null)); SelectFolder = new ReactiveAsyncCommand(); SelectFolder.RegisterAsyncAction(_ => { var result = folderHelper.SelectFolder(); if (result.Result == true) { UpdateLocation = result.Folder; } }, appContext.DispatcherScheduler); UpdateLocation = settingsProvider.UpdateLocation; _IsError = this.WhenAny(vm => vm.UpdateLocation, vm => vm.Value) .DistinctUntilChanged() .Throttle(TimeSpan.FromMilliseconds(500)) .ObserveOn(appContext.DispatcherScheduler) .Select(text => !IsUrlOrFolder(text)) .Do(error => { if (!error) { settingsProvider.UpdateLocation = UpdateLocation; } }) .ToProperty(this, vm => vm.IsError, setViaReflection: false); }
/// <summary> /// Erzeugt ein neues MenuButton-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge, einer Zeichenkette für den Namen der Schaltfläche /// und der Aktion, welche bei einem Klick ausgeführt wird Pflicht. /// </summary> public Button(IScreen screen, DisplayLayer drawOrder, string name, Action<GameTime> onClick) : base(screen, drawOrder) { this.name = name; OnClick = onClick; spriteBatch = new SpriteBatch (screen.GraphicsDevice); }
protected override void Initialize() { base.Initialize(); ActiveScreen = new GameplayScreen(Content, Graphics.GraphicsDevice.Viewport); Viewport = Graphics.GraphicsDevice.Viewport; }
public void Dispose() { var disposable = Screen as IDisposable; if (disposable != null) disposable.Dispose(); Screen = null; }
public OpenCacheViewModel(IScreen hostScreen, IAppState appState) { HostScreen = hostScreen; var isCachePathValid = this.WhenAny( x => x.CachePath, x => x.OpenAsEncryptedCache, x => x.OpenAsSqlite3Cache, (cp, _, sql) => new { Path = cp.Value, Sqlite3 = sql.Value }) .Throttle(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler) .Select(x => x.Sqlite3 ? File.Exists(x.Path) : Directory.Exists(x.Path)); OpenCache = new ReactiveCommand(isCachePathValid); OpenCache.SelectMany(_ => openAkavacheCache(CachePath, OpenAsEncryptedCache, OpenAsSqlite3Cache)) .LoggedCatch(this, Observable.Return<IBlobCache>(null)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { if (x == null) { UserError.Throw("Couldn't open this cache"); return; } appState.CurrentCache = x; hostScreen.Router.Navigate.Execute(new CacheViewModel(hostScreen, appState)); }); }
public void SetScreen(IScreen screen) { if (currentScreen != null) currentScreen.Dispose(); currentScreen = screen; }
/// <summary> /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angabe der Zeichenreihenfolge Pflicht. /// </summary> public ComboBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder, String.Empty) { dropdown = new Menu (screen: screen, drawOrder: Index + DisplayLayer.Menu); dropdown.Bounds.Position = ValueBounds.Position; dropdown.Bounds.Size = new ScreenPoint (Screen, () => ValueBounds.Size.OnlyX + ValueBounds.Size.OnlyY * 10); dropdown.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; // (s) => Container.ItemForegroundColor (s); dropdown.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; // (s) => Design.WidgetBackground; dropdown.BackgroundColorFunc = (s) => Design.WidgetBackground; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.IsVisible = false; dropdownBorder = new Border ( screen: screen, drawOrder: Index + DisplayLayer.Menu, widget: dropdown, lineWidth: 2, padding: 2 ); currentValue = new InputItem (screen: screen, drawOrder: Index, text: text, inputText: String.Empty); currentValue.Bounds = Bounds; currentValue.ForegroundColorFunc = (s) => ForegroundColor; currentValue.BackgroundColorFunc = (s) => Color.Transparent; currentValue.IsVisible = IsVisible; currentValue.IsMouseClickEventEnabled = false; ValidKeys.Add (Keys.Escape); }
public StoryTellerTabItem(IScreen screen, IEventAggregator events) { _screen = screen; _item = new TabItem(); Func<Action<IScreenConductor>, Action> sendMessage = a => () => events.SendMessage(a); _item.Header = new StackPanel().Horizontal() .Configure(x => { x.Height = 25; }) .AddText(screen.Title, x => _label = x) .Add(new TabCloser(sendMessage(s => s.Close(screen)))); _label.VerticalAlignment = VerticalAlignment.Center; _label.Margin = new Thickness(0, 0, 5, 0); _item.Content = new DockPanel().With(screen.View); _item.Tag = screen; // Sets up a context menu for each tab in the screen that can capture "Close" // messages _item.ContextMenu = new ContextMenu().Configure(o => { o.AddItem("Close", sendMessage(s => s.Close(screen))); o.AddItem("Close All But This", sendMessage(s => s.CloseAllBut(screen))); o.AddItem("Close All", sendMessage(s => s.CloseAll())); }); }
public HomeViewModel(ITelephonyService telephonyService = null, IScreen hostScreen = null) { TelephonyService = telephonyService ?? Locator.Current.GetService<ITelephonyService>(); HostScreen = hostScreen ?? Locator.Current.GetService<IScreen>(); var canComposeSMS = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value)); ComposeSMS = ReactiveCommand.CreateAsyncTask(canComposeSMS, async _ => { await TelephonyService.ComposeSMS(Recipient); }); ComposeSMS.ThrownExceptions.Subscribe( ex => UserError.Throw("Does this device have the capability to send SMS?", ex)); var canComposeEmail = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value)); ComposeEmail = ReactiveCommand.CreateAsyncTask(canComposeEmail, async _ => { var email = new Email(Recipient); await TelephonyService.ComposeEmail(email); }); ComposeEmail.ThrownExceptions.Subscribe( ex => UserError.Throw("The recipient is potentially not a well formed email address.", ex)); var canMakePhoneCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value)); MakePhoneCall = ReactiveCommand.CreateAsyncTask(canMakePhoneCall, async _ => { await TelephonyService.MakePhoneCall(Recipient); }); MakePhoneCall.ThrownExceptions.Subscribe( ex => UserError.Throw("Does this device have the capability to make phone calls?", ex)); var canMakeVideoCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value)); MakeVideoCall = ReactiveCommand.CreateAsyncTask(canMakeVideoCall, async _ => { await TelephonyService.MakeVideoCall(Recipient); }); MakeVideoCall.ThrownExceptions.Subscribe( ex => UserError.Throw("Does this device have the capability to make video calls?", ex)); }
/// <summary> /// Erzeugt ein neues TextItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge und der Zeichenkette, die angezeigt wird, für Pflicht. /// </summary> public TextBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder) { Text = text; State = WidgetState.None; spriteBatch = new SpriteBatch (screen.GraphicsDevice); }
public LoginRouteViewModel(IScreen hostScreen) { HostScreen = hostScreen; var authentication = new Authentication(); var canLogin = this.WhenAny(x => x.LoginName, x => x.Password, (l, p) => !String.IsNullOrWhiteSpace(l.Value) && !String.IsNullOrWhiteSpace(p.Value)); LoginCommand = new ReactiveCommand(canLogin); var loggedIn = LoginCommand.RegisterAsync(_ => Observable.Start(() => { var authenticationResult = authentication.AuthenticateAsync(LoginName, Password). Result; return authenticationResult == AuthenticationResult.Authenticated ? "Přihlášen" : "Nepřihlášen"; })); loggedIn.Subscribe(s => { if (s == "Přihlášen") HostScreen.Router.Navigate.Execute(new PersonListViewModel(HostScreen)); }); message = new ObservableAsPropertyHelper<string>(loggedIn, s => raisePropertyChanged("Message")); }
public CacheViewModel(IScreen hostScreen, IAppState appState) { HostScreen = hostScreen; appState.WhenAny(x => x.CachePath, x => x.Value) .Where(x => !String.IsNullOrWhiteSpace(x)) .Select(x => (new DirectoryInfo(x)).Name) .ToProperty(this, x => x.UrlPathSegment, out _UrlPathSegment); Keys = new ReactiveList<string>(); appState.WhenAny(x => x.CurrentCache, x => x.Value) .SelectMany(x => Observable.Start(() => x.GetAllKeys(), RxApp.TaskpoolScheduler)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(newKeys => { Keys.Clear(); newKeys.ForEach(x => Keys.Add(x)); }); FilteredKeys = Keys.CreateDerivedCollection( key => key, key => FilterText == null || key.IndexOf(FilterText, StringComparison.OrdinalIgnoreCase) > -1, signalReset: this.WhenAny(x => x.FilterText, x => x.Value)); SelectedViewer = "Text"; this.WhenAny(x => x.SelectedKey, x => x.SelectedViewer, (k, v) => k.Value) .Where(x => x != null && SelectedViewer != null) .SelectMany(x => appState.CurrentCache.GetAsync(x).Catch(Observable.Return(default(byte[])))) .Select(x => createValueViewModel(x, SelectedViewer)) .LoggedCatch(this, Observable.Return<ICacheValueViewModel>(null)) .ToProperty(this, x => x.SelectedValue, out _SelectedValue); }
public MainViewModel(IScreen screen, ISettingsManager settingsManager, IVersionManager versionManager) { HostScreen = screen; Games = new GamesViewModel(Locator.Current); Downloads = new DownloadsViewModel(Locator.Current.GetService<IJobManager>()); Messsages = new MessagesViewModel(Locator.Current.GetService<IDatabaseManager>(), Locator.Current.GetService<IMessageManager>()); GotoSettings = ReactiveCommand.CreateAsyncObservable(_ => screen.Router.Navigate.ExecuteAsync(new SettingsViewModel(screen, settingsManager, versionManager, Locator.Current.GetService<IGameManager>()))); // login status settingsManager.WhenAnyValue(sm => sm.AuthenticatedUser) .Select(u => u == null ? "Not logged." : $"Logged as {u.Name}") .ToProperty(this, x => x.LoginStatus, out _loginStatus); // show notice when new version arrives but hide when button was clicked versionManager.NewVersionAvailable .Where(release => release != null) .Subscribe(newRelease => { ShowUpdateNotice = true; }); CloseUpdateNotice.Subscribe(_ => { ShowUpdateNotice = false; }); // restart button RestartApp.Subscribe(_ => { UpdateManager.RestartApp(); }); }
public void AddScreen(IScreen screen) { _screens.Add(screen); if (_screens.Count == 1) _activeScreen = screen; }
public override void OnSuspending(IScreen next) { endHandlingTrack(); base.OnSuspending(next); }
public LoginStartViewModel(IScreen screen = null) { HostScreen = screen ?? Locator.Current.GetService <IScreen>(); TeamList = new ReactiveList <LoginTeamTileViewModel>(); // CoolStuff: We're describing here, in a *declarative way*, the // conditions in which the LoadTeamList command is enabled. Now, // our Command IsEnabled is perfectly efficient, because we're only // updating the UI in the scenario when it should change. var canLoadTeamList = this.WhenAny(x => x.Email, x => !String.IsNullOrWhiteSpace(x.Value)); // CoolStuff: ReactiveCommands have built-in support for background // operations. RxCmd guarantees that this block will only run exactly // once at a time, and that the CanExecute will auto-disable while it // is running. LoadTeamList = ReactiveCommand.CreateAsyncTask(canLoadTeamList, async _ => { var client = new HttpClient(NetCache.UserInitiated) { BaseAddress = new Uri("https://slack.com"), }; var api = RestService.For <ISlackApi>(client); var ret = await BlobCache.LocalMachine.GetOrFetchObject("teams_" + email, async() => { var teams = await api.GetTeamsForUser(this.Email); if (teams.users == null || teams.users.Count == 0) { throw new Exception("No teams for this account"); } return(teams); }, RxApp.MainThreadScheduler.Now + TimeSpan.FromMinutes(5)); return(ret.users); }); // CoolStuff: ReactiveCommands are themselves IObservables, whose value // are the results from the async method, guaranteed to arrive on the UI // thread. We're going to take the list of teams that the background // operation loaded, and put them into our TeamList. LoadTeamList.Subscribe(xs => { TeamList.Clear(); TeamList.AddRange(xs.Select(x => new LoginTeamTileViewModel(x))); }); // CoolStuff: ThrownExceptions is any exception thrown from the // CreateAsyncTask piped to this Observable. Subscribing to this // allows you to handle errors on the UI thread. LoadTeamList.ThrownExceptions .Subscribe(ex => { TeamList.Clear(); UserError.Throw("Invalid Email for User", ex); }); // CoolStuff: Whenever the Email address changes, we're going to wait // for one second of "dead airtime", then invoke the LoadTeamList // command. this.WhenAnyValue(x => x.Email) .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler) .InvokeCommand(this, x => x.LoadTeamList); }
public SecondViewModel(IScreen hostScreen) { HostScreen = hostScreen; }
public override bool OnExiting(IScreen next) { Background.FadeTo(1, 250); return(base.OnExiting(next)); }
public void Set(IScreen Screen) { _source = new ScreenItem(Screen); RaisePropertyChanged(nameof(Source)); }
public override bool OnExiting(IScreen next) { //cancel exiting if we haven't loaded the menu yet. return(!DidLoadMenu); }
public override void OnSuspending(IScreen next) { this.FadeOut(300); base.OnSuspending(next); }
public ExerciseProgramsViewModelBuilder WithHostScreen(IScreen hostScreen) => this.With(ref this.hostScreen, hostScreen);
public void AddScreen(IScreen screen) { _screens.Add(screen); screen.Initialise(); }
public Transaction(int userAccountNumber, IBankDatabase atmBankDatabase, IScreen atmScreen) { this.AccountNumber = userAccountNumber; this.BankDatabase = atmBankDatabase; this.Screen = atmScreen; }
/// <summary> /// Creates a new <see cref="ScreenStack"/>, and immediately pushes a <see cref="IScreen"/>. /// </summary> /// <param name="baseScreen">The initial <see cref="IScreen"/> to be loaded</param> /// <param name="suspendImmediately">Whether <see cref="IScreen.OnSuspending"/> should be called immediately, or wait for the next screen to be loaded first.</param> public ScreenStack(IScreen baseScreen, bool suspendImmediately = true) : this(suspendImmediately) { Push(baseScreen); }
public void RemoveScreen(IScreen screen) { _screens.Remove(screen); }
internal IScreen GetChildScreen(IScreen source) => stack.TakeWhile(s => s != source).LastOrDefault();
/// <summary> /// Pushes a <see cref="IScreen"/> to this <see cref="ScreenStack"/>. /// </summary> /// <param name="screen">The <see cref="IScreen"/> to push.</param> public void Push(IScreen screen) { Push(CurrentScreen, screen); }
public Ferry2(IScreen screen, IKeyPad keyPad) : base(screen, keyPad) { _screen = screen; _keyPad = keyPad; }
/// <summary> /// Unbind and return leases for all <see cref="Bindable{T}"/>s managed by the exiting screen. /// </summary> /// <remarks> /// While all bindables will eventually be cleaned up by disposal logic, this is too late as /// leases could potentially be in a leased state during exiting transitions. /// This method should be called after exiting is confirmed to ensure a correct leased state before <see cref="IScreen.OnResuming"/>. /// </remarks> private void onExited(IScreen prev, IScreen next) => (prev as CompositeDrawable)?.UnbindAllBindables();
public virtual void OnResuming(IScreen last) { }
internal bool IsCurrentScreen(IScreen source) => source == CurrentScreen;
public virtual void OnEntering(IScreen last) { }
public virtual void OnSuspending(IScreen next) { }
public override bool OnExiting(IScreen next) { this.MoveToX(-1, 1000, Easing.InOutQuart); return(base.OnExiting(next)); }
public virtual bool OnExiting(IScreen next) => false;
public override void OnEntering(IScreen last) { this.FadeIn(); waves.Show(); }
public override void OnEntering(IScreen last) { base.OnEntering(last); GameplayClockContainer.Stop(); }
public override void OnSuspending(IScreen next) { fadeOut(); base.OnSuspending(next); }
private void screenPushed(IScreen lastScreen, IScreen newScreen) => updatePollingRate(isIdle.Value);
public override void OnEntering(IScreen last) { base.OnEntering(last); beginHandlingTrack(); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.LoginPageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public LoginPageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Welcome"; _webServiceController = webServiceController; _device = device; scheduler.ScheduleAsync((arg1, arg2) => SetupSQLite()); scheduler.ScheduleAsync((arg1, arg2) => Load()); var canLogin = this.WhenAnyValue( vm => vm.Username, vm => vm.Password, vm => vm.IsLoading, (username, password, loading) => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password) && !IsLoading); LoginCommand = ReactiveCommand.CreateFromObservable(LoginAsync, canLogin, Scheduler); }
public override void OnResuming(IScreen last) { base.OnResuming(last); beginHandlingTrack(); updateMods(); }
public override void OnEntering(IScreen last) { base.OnEntering(last); ApplyToBackground(b => ReplacesBackground.BindTo(b.StoryboardReplacesBackground)); }