public WolSettingsView()
 {
     InitializeComponent();
     tbTryCount.Validation = EntryViewValidation.UShortValidation(min: 1);
     tbPort.Validation     = EntryViewValidation.UShortValidation();
     tbMac.Validation      = (v) => {
         try
         {
             LanUtils.MacAddressParse(v.EntryView.Text);
         }
         catch
         {
             v.ErrorMessage = "МAC-адрес должен состоять из шести\r\nшестнадцатеричных чисел (от 00 до FF), разделенных двоеточием";
         }
     };
     tbMac.ErrorStateChanged += (o, args) => {
         var isError = args.Value.InputWrong;
         if (isError)
         {
             tbError.Text = args.Value.ErrorMessage;
         }
         else
         {
             tbError.Text = null;
         }
         ErrorStateChanged?.Invoke(isError);
     };
 }
예제 #2
0
        private void ReportStateChange(bool isInErrorState, string errorText = "")
        {
            _errorStatusText = errorText;
            _errorState      = isInErrorState;

            if (ErrorStateChanged != null)
            {
                ErrorStateChanged.Invoke(this, null);
            }
        }
예제 #3
0
 void RaiseErrorStateChanged()
 {
     ErrorStateChanged?.Invoke(this);
 }
예제 #4
0
 private void NotifyErrorStateChanged(ErrorStateChangedEventArgs e)
 {
     ErrorStateChanged?.Invoke(e.AppendObject(this));
 }
예제 #5
0
        public EntryView()
        {
            Background = new SolidColorBrush(Colors.Transparent);
            VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
            HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            Foreground      = new SolidColorBrush(Colors.White);
            BorderThickness = new System.Windows.Thickness(0, 0, 0, 2);
            BorderBrush     = new SolidColorBrush(Colors.SteelBlue);
            CaretBrush      = new SolidColorBrush(Colors.SteelBlue);
            var ignoreTextChangedFlag = false;

            base.TextChanged += (o, e) =>
            {
                if (ignoreTextChangedFlag)
                {
                    return;
                }
                int caretIndex = CaretIndex;
                var text       = Text;
                var validation = new EntryViewValidation(this);
                validation.InputString = text;
                try
                {
                    Validation?.Invoke(validation);
                    var oldErrorState = ErrorMessage;
                    if (!string.IsNullOrEmpty(validation.ErrorMessage))
                    {
                        ErrorMessage = validation.ErrorMessage;
                        InputWrong   = true;
                    }
                    else
                    {
                        ErrorMessage = null;
                        InputWrong   = false;
                    }

                    if (oldErrorState != ErrorMessage)
                    {
                        ErrorStateChanged?.Invoke(this, new EventsArgs <EntryView>(this));
                    }

                    if (!string.IsNullOrEmpty(validation.OutputString))
                    {
                        ignoreTextChangedFlag = true;
                        Text = validation.OutputString;
                        ignoreTextChangedFlag = false;
                        CaretIndex            = caretIndex;
                    }
                    _oldText = Text;
                    TextChanged?.Invoke(this, new RoutedEventArgs());
                }
                catch
                {
                    ignoreTextChangedFlag = true;
                    Text = _oldText;
                    ignoreTextChangedFlag = false;
                    CaretIndex            = caretIndex;
                }
                if (validation.SelectAll)
                {
                    SelectAll();
                }
                validation.AfterValidation?.Invoke(this);
            };
        }
예제 #6
0
 protected virtual void RaiseErrorChanged()
 {
     ErrorStateChanged?.Invoke(new ErrorStateChangedEventArgs(this));
 }
예제 #7
0
파일: BaseCell.cs 프로젝트: seuribe/Logik
 public void SetError(string message)
 {
     Error        = true;
     ErrorMessage = message;
     ErrorStateChanged?.Invoke(this);
 }
예제 #8
0
파일: BaseCell.cs 프로젝트: seuribe/Logik
 public void ClearError()
 {
     Error        = false;
     ErrorMessage = "";
     ErrorStateChanged?.Invoke(this);
 }