예제 #1
0
        public NotifierValidator()
        {
            Messages       = new ReadOnlyObservableCollection <NotifierValidatorMessage>(_messages);
            StringMessages = new ReadOnlyObservableCollection <string>(_stringMessages);
            ((INotifyCollectionChanged)Messages).CollectionChanged += (s, e) =>
            {
                HasMessages = Messages.Count > 0;
                if (e.NewItems != null)
                {
                    foreach (NotifierValidatorMessage item in e.NewItems.Cast <NotifierValidatorMessage>())
                    {
                        _stringMessages.Add(item.Message);
                    }
                }

                if (e.OldItems != null)
                {
                    foreach (NotifierValidatorMessage item in e.OldItems.Cast <NotifierValidatorMessage>())
                    {
                        _stringMessages.Remove(item.Message);
                    }
                }

                if (e.Action == NotifyCollectionChangedAction.Reset)
                {
                    _stringMessages.Clear();
                }

                ValidationChanged?.Invoke(this, EventArgs.Empty);
            };
        }
예제 #2
0
        public void PlayerConfigurationPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            int botzoneAICount = 0, localAICount = 0, humanCount = 0;

            if (Game == null || Game.PlayerCount == 0)
            {
                ValidationFailDueTo(StringResources.CHOOSE_GAME_FIRST);
                return;
            }

            IsLocalMatch = this.All(x => x.Type != PlayerType.BotzoneBot);
            foreach (var config in this)
            {
                if (!config.IsValid)
                {
                    ValidationFailDueTo(config.ValidationString);
                    return;
                }

                if (config.Type == PlayerType.BotzoneBot)
                {
                    botzoneAICount++;
                }
                else if (config.Type == PlayerType.LocalAI)
                {
                    localAICount++;
                }
                else if (config.Type == PlayerType.LocalHuman)
                {
                    humanCount++;
                }
            }
            if (humanCount > 1)
            {
                ValidationFailDueTo(StringResources.TOO_MANY_HUMAN);
                return;
            }
            if (!IsLocalMatch && humanCount > 0)
            {
                ValidationFailDueTo(StringResources.BOTZONE_MATCH_NO_HUMAN);
                return;
            }
            if (!IsLocalMatch && localAICount != 1)
            {
                ValidationFailDueTo(StringResources.BOTZONE_MATCH_ONE_LOCALAI);
                return;
            }
            IsValid = true;
            ValidationChanged?.Invoke(this, null);
        }
예제 #3
0
        void UpdateSelected(object selected, EventArgs e)
        {
            foreach (var item in this.Children)
            {
                if (item is RadioButton)
                    (item as RadioButton).IsChecked = item == selected;
            }

            SetValue(SelectedItemProperty, this.SelectedItem);
            OnPropertyChanged(nameof(SelectedItem));
            SetValue(SelectedIndexProperty, this.SelectedIndex);
            OnPropertyChanged(nameof(SelectedIndex));
            SelectedItemChanged?.Invoke(this, new EventArgs());
            if (SelectedItemChangedCommand?.CanExecute(CommandParameter ?? this) ?? false)
                SelectedItemChangedCommand?.Execute(CommandParameter ?? this);
            ValidationChanged?.Invoke(this, new EventArgs());
        }
예제 #4
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public CheckBox()
 {
     this.Orientation      = StackOrientation.Horizontal;
     this.Padding          = new Thickness(0, 10);
     this.Spacing          = 10;
     boxBackground.Content = boxSelected;
     this.Children.Add(boxBackground);
     //this.Children.Add(new Grid { Children = { boxBackground, boxSelected }, MinimumWidthRequest = 35 });
     this.Children.Add(lblOption);
     this.GestureRecognizers.Add(new TapGestureRecognizer
     {
         Command = new Command(() =>
         {
             if (IsDisabled)
             {
                 return;
             }
             IsChecked = !IsChecked;
             ExecuteCommand();
             CheckChanged?.Invoke(this, new EventArgs());
             ValidationChanged?.Invoke(this, new EventArgs());
         }),
     });
 }
예제 #5
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public CheckBox()
        {
            InitVisualStates();
            this.Orientation           = StackOrientation.Horizontal;
            this.Padding               = new Thickness(0, 10);
            this.Spacing               = 10;
            this.frmBackground.Content = boxSelected;

            ApplyLabelPosition(LabelPosition);

            this.ApplyIsCheckedAction = ApplyIsChecked;
            this.ApplyIsPressedAction = ApplyIsPressed;
            this.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => { if (IsDisabled)
                                              {
                                                  return;
                                              }
                                              IsChecked = !IsChecked; ExecuteCommand(); CheckChanged?.Invoke(this, new EventArgs()); ValidationChanged?.Invoke(this, new EventArgs()); }),
            });
        }
예제 #6
0
 private void ValidationFailDueTo(string message)
 {
     IsValid          = false;
     ValidationString = message;
     ValidationChanged?.Invoke(this, null);
 }
 protected virtual void OnValidationChanged()
 {
     ValidationChanged?.Invoke(this, EventArgs.Empty);
 }