예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
 public void SetText(string text)
 {
     ButtonTextProperty.SetValue(text);
 }
예제 #10
0
        private void UpdateProgressBarColor()
        {
            var color = _enabled ? _enabledProgressBarColor : _disabledProgessBarColor;

            ProgressBarColorPoperty.SetValue(color);
        }
예제 #11
0
        private void UpdateTextColor()
        {
            var color = _enabled ? _enabledTextColor : _disabledTextColor;

            ButtonTextColorProperty.SetValue(color);
        }
예제 #12
0
 public void OnCenterPositionChanged(Vector3 center)
 {
     _center = center;
     PositionProperty.SetValue(CalculatePosition(center, SizeProperty.GetValue()));
 }
예제 #13
0
 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);
 }