private void UpdateProgressBarDimensions() { // ToDo: clean up the mess ProgressBarAnchorMinProperty.SetValue(new Vector2(0.5f, (1f - _progressBarHeightPercentage / 100f) / 2f)); ProgressBarAnchorMaxProperty.SetValue(new Vector2( 0.5f, _progressBarHeightPercentage * _progress / 10000f + (1 - _progressBarHeightPercentage / 100f) / 2f)); }
public CooldownButtonViewModel() { ProgressBarAnchorMinProperty = new NotifyingObject <Vector2>(); ProgressBarAnchorMaxProperty = new NotifyingObject <Vector2>(); ProgressBarColorPoperty = new NotifyingObject <Color>(); ButtonColorProperty = new NotifyingObject <Color>(); ButtonTextProperty = new NotifyingObject <string>(); ButtonTextColorProperty = new NotifyingObject <Color>(); CommandProperty = new NotifyingObject <ICommand>(); _cooldownButtonCommand = new DelegateCommand(CommandExecute, CommandCanExecute); CommandProperty.SetValue(_cooldownButtonCommand); }
public CooldownButtonViewModel() { ProgressBarAnchorMinProperty = new NotifyingObject<Vector2>(); ProgressBarAnchorMaxProperty = new NotifyingObject<Vector2>(); ProgressBarColorPoperty = new NotifyingObject<Color>(); ButtonColorProperty = new NotifyingObject<Color>(); ButtonTextProperty = new NotifyingObject<string>(); ButtonTextColorProperty = new NotifyingObject<Color>(); CommandProperty = new NotifyingObject<ICommand>(); _cooldownButtonCommand = new DelegateCommand(CommandExecute, CommandCanExecute); CommandProperty.SetValue(_cooldownButtonCommand); }
public void SetValue_ReferenceType_PropertyChangedRaised() { var newValue = new List(); var eventRaised = false; var subject = new NotifyingObject<List>(); subject.PropertyChanged += (sender, args) => { Assert.IsFalse(eventRaised); Assert.IsNull(args.OldValue); Assert.AreEqual(newValue, args.NewValue); eventRaised = true; }; subject.SetValue(newValue); Assert.IsTrue(eventRaised); }
public void SetValue_ValueType_PropertyChangedRaised() { const int oldValue = default(int); const int newValue = 64; var eventRaised = false; var subject = new NotifyingObject<int>(); subject.PropertyChanged += (sender, args) => { Assert.IsFalse(eventRaised); Assert.AreEqual(oldValue, args.OldValue); Assert.AreEqual(newValue, args.NewValue); eventRaised = true; }; subject.SetValue(newValue); Assert.IsTrue(eventRaised); }
public void SetValue_ReferenceType_PropertyChangedRaised() { var newValue = new List(); var eventRaised = false; var subject = new NotifyingObject <List>(); subject.PropertyChanged += (sender, args) => { Assert.IsFalse(eventRaised); Assert.IsNull(args.OldValue); Assert.AreEqual(newValue, args.NewValue); eventRaised = true; }; subject.SetValue(newValue); Assert.IsTrue(eventRaised); }
public void SetValue_ValueType_PropertyChangedRaised() { const int oldValue = default(int); const int newValue = 64; var eventRaised = false; var subject = new NotifyingObject <int>(); subject.PropertyChanged += (sender, args) => { Assert.IsFalse(eventRaised); Assert.AreEqual(oldValue, args.OldValue); Assert.AreEqual(newValue, args.NewValue); eventRaised = true; }; subject.SetValue(newValue); Assert.IsTrue(eventRaised); }
public ViewModel() { PositionProperty = new NotifyingObject <Vector3>(); UpButtonTextProperty = new NotifyingObject <string>(); DownButtonTextProperty = new NotifyingObject <string>(); UpThresholdProperty = new NotifyingObject <float>(); DownThresholdProperty = new NotifyingObject <float>(); UpButtonCommandProperty = new NotifyingObject <ICommand>(); DownButtonCommandProperty = new NotifyingObject <ICommand>(); DownButtonTextProperty = new NotifyingObject <string>(); UpAvailableProperty = new NotifyingObject <bool>(); DownAvailableProperty = new NotifyingObject <bool>(); PositionProperty.PropertyChanged += (o, e) => { SetUpAvailable(); SetDownAvailable(); }; SetUpAvailable(); SetDownAvailable(); UpAvailableProperty.PropertyChanged += (o, e) => SetUpAvailable(); DownAvailableProperty.PropertyChanged += (o, e) => SetDownAvailable(); var upButtonCommand = new DelegateCommand( () => Position += _upDownVector, () => UpAvailable); PositionProperty.PropertyChanged += (o, e) => upButtonCommand.RaiseCanExecuteChanged(); UpThresholdProperty.PropertyChanged += (o, e) => upButtonCommand.RaiseCanExecuteChanged(); UpButtonCommandProperty.SetValue(upButtonCommand); var downButtonCommand = new DelegateCommand( () => Position -= _upDownVector, () => DownAvailable); PositionProperty.PropertyChanged += (o, e) => downButtonCommand.RaiseCanExecuteChanged(); DownThresholdProperty.PropertyChanged += (o, e) => downButtonCommand.RaiseCanExecuteChanged(); DownButtonCommandProperty.SetValue(downButtonCommand); }
public void SetText(string text) { ButtonTextProperty.SetValue(text); }
private void UpdateProgressBarColor() { var color = _enabled ? _enabledProgressBarColor : _disabledProgessBarColor; ProgressBarColorPoperty.SetValue(color); }
private void UpdateTextColor() { var color = _enabled ? _enabledTextColor : _disabledTextColor; ButtonTextColorProperty.SetValue(color); }
public void OnCenterPositionChanged(Vector3 center) { _center = center; PositionProperty.SetValue(CalculatePosition(center, SizeProperty.GetValue())); }
public void OnHealthChanged(float health, float maxHealth) { TextProperty.SetValue(FormatHealth(health, maxHealth)); }
public void OnMouseEnter() { VisibleProperty.SetValue(true); }
public void OnLevelChange(TowerLevel level) { TowerSpriteProperty.SetValue(level.TowerSprite); RangeProperty.SetValue(level.Range); }