private void BeforeValueChange(BeforeValueChangeEventArgs args) { var module = this.modules[args.NewValue <int>()]; var oldValue = this.Current.Menu.Id; var newValue = module.Menu.Id; var detector = BeforeValueChangeEventArgs.Create(oldValue, newValue); this.OnModuleSelected.SafeInvoke(detector); if (detector.IsBlocked) { args.Block(); return; } if (Platform.HasCoreAPI) { this.Current.Pause(); module.Start(); } this.Current = module; }
protected bool UpdateValue <T>(T @new, bool notifyOnly = false) { var t = this.MenuValue <T>(); if (this.BeforeValueChange != null) { var args = BeforeValueChangeEventArgs.Create(t.Value, @new); this.BeforeValueChange.SafeInvoke(args); if (args.IsBlocked) { return(false); } } if (!notifyOnly) { this.save = true; } return(true); }