public override void OnStateChanged(ViewModelState state) { switch (state) { case ViewModelState.AddNew: EnableSave = true; SyncEnabled = true; ProgressVisibility = false; break; case ViewModelState.InEdit: SyncEnabled = false; ProgressVisibility = true; break; case ViewModelState.Saved: break; case ViewModelState.Deleted: break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
public override void OnStateChanged(ViewModelState state) { State = state; switch (state) { case ViewModelState.AddNew: State = ViewModelState.AddNew; ResetErrors(); SetChangedFlag(false); break; case ViewModelState.InEdit: SetChangedFlag(true); break; case ViewModelState.Saved: SetChangedFlag(false); break; case ViewModelState.Deleted: State = ViewModelState.Deleted; break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
public override void OnStateChanged(ViewModelState state) { State = state; switch (state) { case ViewModelState.AddNew: EnableSave = false; EnableMemberCode = true; break; case ViewModelState.InEdit: EnableSave = true; EnableMemberCode = false; break; case ViewModelState.Busy: break; case ViewModelState.Saved: EnableSave = true; EnableMemberCode = false; break; case ViewModelState.Deleted: break; } }
public override (string, float) GetHandAnimation(ViewModelState newState, ViewModelHandednessState handedness) { if (!ShowHands) { return(HandsHidden, -1f); } switch (newState) { case ViewModelState.Idle: return(string.IsNullOrEmpty(HandAnimations.IdleAnim) ? ("Idle", -1) : (HandAnimations.IdleAnim, -1)); case ViewModelState.Raise: return(HandAnimations.RaiseAnim, HandAnimations.RaiseAnimDuration); case ViewModelState.Lower: return(HandAnimations.LowerAnim, HandAnimations.LowerAnimDuration); case ViewModelState.Block: throw new NotImplementedException(); case ViewModelState.Charge: throw new NotImplementedException(); case ViewModelState.Fire: return(HandAnimations.AttackAnim, HandAnimations.AttackAnimDuration); default: Debug.LogWarning($"Tried to get hand state {newState} from {name} which is not supported for {nameof(MeleeWeaponViewModelScript)}"); return("Idle", -1); } }
public override void SetState(ViewModelState newState, ViewModelHandednessState handedness, float timeScale) { if (newState == ViewModelState.Fire) { FireSound.Ref()?.Play(); } }
private void ProcessViewModelState(ViewModelState state) { Log.Info($"Processing view model state {state}"); if (state.IsRefreshed) { Log.Info("Refreshing set to false"); _refreshLayout.Refreshing = false; } _loader.SetIsVisible(state.Display == DisplayState.Loading); if (_refreshLayout.SetIsVisible(state.Display == DisplayState.Result)) { UpdateRecyclerView(state.Error, state.IsRefreshed); } if (_errorViewSwitcher.SetIsVisible(state.Display == DisplayState.Error)) { _errorViewSwitcher.Switch(state.Error); } Log.Info( string.Format( "End of ProcessViewModelState: loader {0}, refreshLayout {1}, error view {2}", _loader.GetVisibilityDescription(), _refreshLayout.GetVisibilityDescription(), _errorViewSwitcher.GetVisibilitDescription())); }
public MainViewModel() { State = new ViewModelState() { State = "I'm Root!" }; }
public override Brush GetBrush(Color color, ViewModelState state, BrushSetUsage usage) { HSL c = color.ToHSL(); switch (state) { case ViewModelState.Default: c = c.Highlight(0.8).Desaturate(0.5); break; case ViewModelState.Moving: c = c.Highlight(0.8).Desaturate(0.5); break; case ViewModelState.LeftHighlighted: c = c.Darken(0.3).Saturate(0.6); break; case ViewModelState.RightHighlighted: c = c.Darken(0.3).Saturate(0.6); break; case ViewModelState.Selected: c = c.Highlight(0.2); break; case ViewModelState.Disabled: c = c.Desaturate(0.2); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } switch (usage) { case BrushSetUsage.Front: break; case BrushSetUsage.Background: c = c.Highlight(0.5).Desaturate(0.3) /*.Transparent(0.5)*/; if (state == ViewModelState.Moving) { c = c.Transparent(0.5); } break; case BrushSetUsage.Border: break; default: throw new ArgumentOutOfRangeException(nameof(usage), usage, null); } HSL c2 = c.Darken(0.6); return(new LinearGradientBrush(c, c2, new Point(0, 0), new Point(0, 1))); //return new SolidColorBrush(c); }
/// <summary> /// Gets the default animations for a state /// </summary> private string GetAnimForState(ViewModelState state, ViewModelHandednessState handednessState) { //TODO handle this properly //return state.ToString(); //for now return(WeaponViewModelScript.HandsHidden); //if we have no ViewModel, we should not have hands either }
protected override void OnCreate(Bundle savedInstanceState) { ViewModelState.Initialise(new NavigationService(this), new DeviceIntegration(this)); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MovieDetails); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); ViewModelMovieDetails viewModel = new ViewModelMovieDetails(); viewModel.Initialise(); SupportActionBar.Title = viewModel.Title; viewModel.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(ViewModelMovieDetails.Title)) { SupportActionBar.Title = viewModel.Title; } }; new ConnectorImageView(FindViewById <ImageView>(Resource.Id.poster), viewModel, nameof(ViewModelMovieDetails.PosterURL)); new ConnectorListView <ListItemMovieAttributeBase>(this, FindViewById <ListView>(Resource.Id.attributes), viewModel, nameof(ViewModelMovieDetails.Attributes), null, (item) => { if (item is ListItemMovieAttributeLabel) { return(Resource.Layout.TemplateListItemAttributeLabel); } return(Resource.Layout.TemplateListItemAttributeValue); }, (context, item, view, parent) => { LayoutInflater layoutInflator = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (item is ListItemMovieAttributeLabel) { ListItemMovieAttributeLabel label = (ListItemMovieAttributeLabel)item; view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeLabel, parent, false); view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeLabel).Text = label.Label; } else { ListItemMovieAttributeValue value = item as ListItemMovieAttributeValue; view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeValue, parent, false); view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeValue).Text = value.Value; } return(view); }); new ConnectorTextView(FindViewById <TextView>(Resource.Id.plot), viewModel, nameof(ViewModelMovieDetails.Plot)); new ConnectorButton(FindViewById <Button>(Resource.Id.imdbWebsite), viewModel.CommandBrowseToMovie); }
private void UpdateState(ViewModelState state) { State = state; this.RaiseCanExecuteChanged(vm => vm.Start()); this.RaiseCanExecuteChanged(vm => vm.Restart()); this.RaiseCanExecuteChanged(vm => vm.Tick()); State.Update(); UpdateDisplayText(); }
public static bool CanChangeTo(ViewModelState currentState, ViewModelState newState) { if (StateMap.ContainsKey(currentState)) { return StateMap[currentState].Contains(newState); } return false; }
public ValidObservableObject(IValidator <T> validator, ViewModelState initState = ViewModelState.Original) { _validator = validator; PropertyChanged += (s, e) => { AddState(ViewModelState.Updated); }; }
public void AllowedChanges(ViewModelState currentState, ViewModelState newState) { // Arrange // Act var result = ViewModelStateGraph.CanChangeTo(currentState, newState); // Assert Assert.IsTrue(result); }
public void ForbiddenChanges(ViewModelState currentState, ViewModelState newState) { // Arrange // Act var result = ViewModelStateGraph.CanChangeTo(currentState, newState); // Assert Assert.IsFalse(result); }
public override void SetState(ViewModelState newState, ViewModelHandednessState handedness, float timeScale) { if (Mode == MeleeWeaponViewModelMode.ExplicitAnimation || Mode == MeleeWeaponViewModelMode.GlueAndAnimate) { ModelAnimator.speed = 1f / timeScale; switch (newState) { case ViewModelState.Idle: ModelAnimator.Play("Idle"); break; case ViewModelState.Raise: ModelAnimator.Play("Raise"); break; case ViewModelState.Lower: ModelAnimator.Play("Lower"); break; case ViewModelState.Block: //TODO break; case ViewModelState.Charge: //TODO break; case ViewModelState.Fire: ModelAnimator.Play("Attack"); break; default: Debug.LogWarning($"Tried to put {name} into state {newState} which is not supported for {nameof(MeleeWeaponViewModelScript)}"); ModelAnimator.Play("Idle"); break; } } //we don't animate in other modes but we still play sounds switch (newState) { case ViewModelState.Raise: //TODO will probably have to rethink raise and lower sounds RaiseSound.Ref()?.Play(); break; case ViewModelState.Lower: LowerSound.Ref()?.Play(); break; case ViewModelState.Fire: AttackSound.Ref()?.Play(); break; } }
protected void Set <TE>(ref TE oldValue, TE newValue, [CallerMemberName] string membername = "") { if (EqualityComparer <TE> .Default.Equals(oldValue, newValue)) { return; } oldValue = newValue; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(membername)); State = ViewModelState.Changed; }
private void UpdateDetails(ViewModelState state) { Contract.Requires(() => state.Display == ViewModels.DisplayState.Result && state.Error == ErrorType.None); CollapsingToolbarLayout collapsingToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar); collapsingToolbarLayout.SetTitle(_viewModel.Name); _roleTextView.Text = _viewModel.Role; _descriptionTextView.Text = _viewModel.Description; }
private void ViewModelOnTaskCompleted(object sender, EventArgs eventArgs) { Log.Info("ViewModelOnTaskCompleted"); ViewModelState viewModelState = _viewModel.GetState(); Contract.Requires(() => viewModelState.Display != DisplayState.Loading); _toolbar.Title = _viewModel.Title; ProcessViewModelState(viewModelState); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Window = new UIWindow(UIScreen.MainScreen.Bounds) { RootViewController = UIStoryboard.FromName("Main", null).InstantiateInitialViewController() }; Window.MakeKeyAndVisible(); Style.Initialise(); ViewModelState.Initialise(new NavigationService(Window.RootViewController as UINavigationController), new DeviceIntegration()); return(true); }
/// <summary> /// Adds a reaction that depends on this view-model entering a specified <see cref="ViewModelState"/>. /// </summary> /// <param name="state"></param> /// <param name="action"></param> /// <returns></returns> public IDisposable AddTrigger(ViewModelState state, Action action) { var subscription = _state .Where(s => s == state) .OnBackground() .Subscribe( _ => action.VerifyThread(this.Dispatcher, false), error => /*Logs.UseLogger(l => l.ReportError("Observing state for trigger.", error))*/ { }); _subscriptions.Add(subscription); return(Disposable.Create(() => _subscriptions.Remove(subscription))); }
public override (string, float) GetHandAnimation(ViewModelState newState, ViewModelHandednessState handednessState) { RangedWeaponViewModelAnimations animSet; //TODO handle 2hand, 1hand, ADS switch (handednessState) { case ViewModelHandednessState.OneHanded: animSet = OneHandAnimations; break; case ViewModelHandednessState.TwoHanded: animSet = TwoHandAnimations; break; case ViewModelHandednessState.ADS: animSet = ADSAnimations; break; default: Debug.LogWarning($"Tried to get animation for \"{handednessState}\" handedness from {name} which is not supported for {nameof(RangedWeaponViewModelScript)}"); return("Idle", -1); } switch (newState) { case ViewModelState.Idle: return(string.IsNullOrEmpty(animSet.IdleAnim) ? ("Idle", -1) : (animSet.IdleAnim, -1)); case ViewModelState.Raise: return(animSet.RaiseAnim, animSet.RaiseAnimDuration); case ViewModelState.Lower: return(animSet.LowerAnim, animSet.LowerAnimDuration); case ViewModelState.Reload: return(animSet.ReloadAnim, animSet.ReloadAnimDuration); case ViewModelState.Charge: return(animSet.ChargeAnim, animSet.ChargeAnimDuration); case ViewModelState.Fire: return(animSet.FireAnim, animSet.FireAnimDuration); case ViewModelState.Recock: return(animSet.RecockAnim, animSet.RecockAnimDuration); default: Debug.LogWarning($"Tried to get hand state {newState} from {name} which is not supported for {nameof(RangedWeaponViewModelScript)}"); return("Idle", -1); } }
public override (string, float) GetHandAnimation(ViewModelState newState, ViewModelHandednessState handednessState) { /* * switch (newState) * { * case ViewModelState.Reload: * return ("LegacyReload", -1); * case ViewModelState.Fire: * return ("LegacyFire", -1); * default: * return ("LegacyIdle", -1); * } */ return("Hidden", -1); }
public override void OnStateChanged(ViewModelState state) { State = state; switch (state) { case ViewModelState.AddNew: break; case ViewModelState.InEdit: EnableSave = true; break; case ViewModelState.Saved: break; } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } NavigationService navigationService = new NavigationService(rootFrame); DeviceIntegration deviceIntegration = new DeviceIntegration(); Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) => { navigationService.NavigateBack(); args.Handled = true; }; ViewModelState.Initialise(navigationService, deviceIntegration); if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(PageSearch), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
private void ApplyRowUpdate(DealRowViewModel row) { int indexOf = IndexOf(ActiveDeals, ad => ad.DealId == row.DealId); if (indexOf == -1) { ActiveDeals.Add(row); } else { ActiveDeals[indexOf] = row; } if (row.CategoryVersion >= _headVersion) { State = ViewModelState.Idle; } }
public void SaveState(IDataContext state) { if (!IsEntityInitialized) { return; } var viewModelState = new ViewModelState { Order = Entity, IsNewRecord = IsNewRecord }; viewModelState.SetLinks(_oldLinks); var selectedProducts = GridViewModel.OriginalItemsSource .Where(wrapper => wrapper.IsSelected) .Select(wrapper => wrapper.Model.Id) .ToList(); viewModelState.SelectedProducts = selectedProducts; state.AddOrUpdate(StateConstant, viewModelState); }
public override void OnStateChanged(ViewModelState state) { switch (state) { case ViewModelState.AddNew: break; case ViewModelState.InEdit: break; case ViewModelState.Busy: break; case ViewModelState.Saved: break; case ViewModelState.Deleted: break; } }
private void Submit() { State = ViewModelState.Processing; var cmd = BuildCreateDealCommand(); _dealRepository.CreateDeal(cmd) .SubscribeOn(Scheduler.Default) .ObserveOnDispatcher() .Subscribe( _ => { }, ex => { State = ViewModelState.Error(ex.ToString()); }, () => { State = ViewModelState.Terminal; }); }
protected virtual void OnStateChanged(ViewModelState oldState) { switch (State) { case ViewModelState.Idle: case ViewModelState.Restricted: FamilialLocker.RequestUnlock(_token); ApplicationRestrictor.RequestUnlock(_token); OnLockStatusChanged(FamilialLocker.CurrentStatus, ApplicationRestrictor.CurrentStatus); break; case ViewModelState.NonCriticalOperation: FamilialLocker.RequestLock(_token); break; case ViewModelState.CriticalOperation: FamilialLocker.RequestLock(_token); ApplicationRestrictor.RequestLock(_token); break; } }
public override (string, float) GetHandAnimation(ViewModelState newState, ViewModelHandednessState handedness) { switch (newState) { case ViewModelState.Idle: return(IdleAnimation, IdleDuration); case ViewModelState.Raise: return(RaiseAnimation, RaiseDuration); case ViewModelState.Lower: return(LowerAnimation, LowerDuration); case ViewModelState.Fire: return(FireAnimation, FireDuration); default: Debug.LogWarning($"Tried to get hand state {newState} from {name} which is not supported for {nameof(PlaceholderWeaponViewModelScript)}"); return("Idle", -1); } }
public override void OnStateChanged(ViewModelState state) { State = state; switch (state) { case ViewModelState.AddNew: break; case ViewModelState.InEdit: break; case ViewModelState.Saved: LoadTypesList(); break; case ViewModelState.Deleted: break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
/// <summary> /// Logic used when the State changes. /// </summary> /// <param name="oldValue">The old State value.</param> protected override void OnStateChanged(ViewModelState oldValue) { base.OnStateChanged(oldValue); Navigation.State = State; switch (State) { case ViewModelState.Idle: CriticalOperationType = CriticalOperationType.None; ModelSearcher?.RequestEnable(_adminToken); break; case ViewModelState.FamilialOperation: case ViewModelState.Restricted: ModelSearcher?.RequestEnable(_adminToken); break; case ViewModelState.NonCriticalOperation: case ViewModelState.CriticalOperation: ModelSearcher?.RequestDisable(_adminToken); break; } }
public void ReloadState(ViewModelState searchText) { MvxTrace.Trace("ReloadState called with {0}", searchText.SearchText); SearchText = searchText.SearchText; }
protected void MarkAsDirty() { ViewModelState = ViewModelState.Dirty; }
private void Init() { IsValidationOn = true; State = ViewModelState.Still; }
public void SetState(ViewModelState newState) { if (State != newState) { State = newState; } }
protected void Initialise() { ViewModelState = ViewModelState.Clean; }
public StatefulViewModel() { _errorMessage = string.Empty; _state = ViewModelState.UnInitialized; }
public ViewModelClosingDefferal(Action closedAction, Action<ViewModelState> closingRejectedAction, ViewModelState currentState) { _closedAction = closedAction; _closingRejectedAction = closingRejectedAction; _stateBeforeCloseRequest = currentState; }
protected void MarkAsDirtyAndNotifyPropertyChange([CallerMemberName]string propertyName = "") { ViewModelState = ViewModelState.Dirty; NotifyPropertyChanged(propertyName); }
public void OnCurrentStateChanged(ViewModelState e) { Debug.WriteLine("CurrentStateChanged: " + e.ToString()); }