private void TextBoxTextChangingHandler(TextBox sender, TextBoxTextChangingEventArgs args) { var text = sender.Text; text = text.StripNonDigit(); long value; if (String.IsNullOrWhiteSpace(text)) { sender.Text = ""; return; } else { value = long.Parse(text); } if (value > MaxNumber) { value = MaxNumber; } else if (value < MinNumber) { value = MinNumber; } Number = (int)value; sender.Text = value.ToString(); NumberChanged?.Invoke(sender, null); }
internal void MyNumberChanged() { textBox.Text = Number.ToString(FormatString); scrollBar.Value = Invert(Number); NumberChanged?.Invoke(this, null); }
private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if ((sender == textBoxAreaCode) && (textBoxAreaCode.Text.Length == 3)) { textBoxPrefix.Focus(); } if ((sender == textBoxPrefix) && (textBoxPrefix.Text.Length == 3)) { textBoxNumber.Focus(); } if ((textBoxAreaCode.Text.Length == 3) && (textBoxPrefix.Text.Length == 3) && (textBoxNumber.Text.Length == 4)) { try { int areaCode = Convert.ToInt32(textBoxAreaCode.Text); int prefix = Convert.ToInt32(textBoxPrefix.Text); int number = Convert.ToInt32(textBoxNumber.Text); if (NumberChanged != null) { NumberChanged.Invoke(this, new EventArgs()); } return; } catch { } } if (ContentsInvalid != null) { ContentsInvalid.Invoke(this, new EventArgs()); } }
public void NotifyNumberChanged(int value) { if (!value.Equals(_Value)) { _Value = value; NumberChanged?.Invoke(this, EventArgs.Empty); } }
public void CaseNumberChanged() { var id = Guid.NewGuid(); NumberChanged numObj = new NumberChanged(id, ModuleType.Incident, "data"); numObj.NumberId.Should().Be(id); numObj.ModuleType.Should().Be(ModuleType.Incident); numObj.NewValue.Should().Be("data"); }
public List <string> DoSomething() { List <string> strList = new List <string>(); if (NumberChanged == null) { return(strList); } Delegate[] delArray = NumberChanged.GetInvocationList(); foreach (Delegate del in delArray) { DemoEventHandler method = (DemoEventHandler)del;//强制向下转换 strList.Add(method(100)); } return(strList); }
public event DemoEventHandler NumberChanged; // 声明一个事件 public List <string> DoSomething() { // 做某些其他的事 List <string> strList = new List <string>(); if (NumberChanged == null) { return(strList); } // 获得委托数组 Delegate[] delArray = NumberChanged.GetInvocationList(); foreach (Delegate del in delArray) { // 进行一个向下转换 DemoEventHandler method = (DemoEventHandler)del; strList.Add(method(100)); // 调用方法并获取返回值 } return(strList); }
public void DoSomething() { if (NumberChanged != null) { Delegate[] dels = NumberChanged.GetInvocationList(); foreach (Delegate del in dels) { NumberChangedEventHandler handler = del as NumberChangedEventHandler; try { handler(serverName, count); } catch (Exception ex) { Delegate.Remove(NumberChanged, del); } } } }
public void DoSomething() { count++; if (NumberChanged != null) { Delegate[] delArray = NumberChanged.GetInvocationList(); foreach (Delegate del in delArray) { NumberChangedEventHandler method;//=(NumberChangedEventHandler) try { method(serverName, count); } catch (Exception) { Delegate.Remove(NumberChanged, del); } } } }
public event NumberChangedEventHandler NumberChanged; // public List <string> PublishNumber(int count) { List <string> list = new List <string>(); if (NumberChanged == null) { return(list); } // 获得委托数组 Delegate[] delegateArray = NumberChanged.GetInvocationList(); foreach (var item in delegateArray) { // 进行一个向下转换 NumberChangedEventHandler method = (NumberChangedEventHandler)item; if (NumberChanged == null) { return(list); } list.Add(method(100)); // 调用方法并获取返回值 } return(list); }
public void OnNumberboxChanged(int Id, double Value) => NumberChanged?.Invoke(Id, Value);
public void OnNumberboxChanged(int Id, double Value) { NumberChanged?.Invoke(Id, Value); DataChanged?.Invoke(); }
/// <summary> /// Benachrichtigt die registrierten Beobachter, dass eine neue Zahl generiert wurde. /// </summary> /// <param name="number">Die generierte Zahl.</param> public void NotifyObservers(int number) { NumberChanged.Invoke(number); }
private void Apply(NumberChanged e) { Number = e.Number; }
public void DetermineNumber() { _elapsedTime = 0; _currentNumber = Random.Range(_minValue, _maxValue); NumberChanged?.Invoke(_currentNumber); }
private async Task HasLostFocus() { var data = await JsModule.InvokeAsync <string>("GetNumericTextBoxValue", new string[] { "#" + Id }); var cleaned = string.Join("", data.Replace("(", "-").Where(x => char.IsDigit(x) || x == '-' || x.ToString() == DecimalSeparator).ToArray()); var parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var valueAsDecimal); if (!parsed) { if (string.IsNullOrEmpty(Format)) { VisibleValue = ""; } else { VisibleValue = 0.ToString(Format); } } else { if (string.IsNullOrEmpty(Format)) { VisibleValue = cleaned; } else { VisibleValue = valueAsDecimal.ToString(Format); } } // Negative monetary values a represented with parenthesis cleaned = string.Join("", VisibleValue.Replace("(", "-") .Where(x => char.IsDigit(x) || x == '-' || x.ToString() == DecimalSeparator).ToArray()); parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var roundedValue); if (parsed) { Value = (TItem)Convert.ChangeType(roundedValue, typeof(TItem)); } else { Value = (TItem)Convert.ChangeType(valueAsDecimal, typeof(TItem)); } // Do not remove. Problems in browser events and Blazor changes the value of the Value property var value = Value; await SetVisibleValue(Value); Value = value; await ValueChanged.InvokeAsync(Value); if (!PreviousValue.Equals(Value)) { if (!string.IsNullOrEmpty(FieldIdentifier.FieldName)) { EditContext.NotifyFieldChanged(FieldIdentifier); } await NumberChanged.InvokeAsync(Value); } AdditionalStyles = AlignToRight; if (OnBlur != null) { await OnBlur.Invoke(); } }