private void tbMag_AfterValueChange(object sender, EventArgs e) { ValueTextBox tb = sender as ValueTextBox; if (tb == null) { return; } if (_IgnoreGuiEvents) { return; } if (!string.IsNullOrEmpty(tb.ErrorMessage)) { return; } if (tb == this.tbMag) { _ViewMag = this.tbMag.Double / 100.0; } ApplyScalePosition(); }
private void baseNodeControl_Loaded(object sender, RoutedEventArgs e) { var bindExp = ValueTextBox.GetBindingExpression(TextBox.TextProperty); if (bindExp != null) { if (bindExp.ParentBinding.ValidationRules.Count > 0) { var rule = bindExp.ParentBinding.ValidationRules[0] as InputWindow.RequiredRule; if (rule != null) { rule.OnValidateCheck = (object value, CultureInfo cultureInfo) => { var param = CSParam as CommonValueConstructionParams; if (param == null) { return(new ValidationResult(false, "参数类型不合法")); } try { System.Convert.ChangeType(value, param.ValueType); return(ValidationResult.ValidResult); } catch (System.Exception) { return(new ValidationResult(false, "数值不合法")); } } } ; } } } }
private void Install() { int rowcount = Values.Length >> 3; //int colcount = 8; //G_Table.RowDefinitions.Clear(); //G_Table.Children.Clear(); for (int i = 0; i < rowcount; i++) { RowDefinition rdef = new RowDefinition(); rdef.Height = new GridLength(24); G_Table.RowDefinitions.Add(rdef); TextBlock tb = new TextBlock(); tb.Text = String.Format("{0:d}", Series.Offset + (i << 3)); tb.FontSize = 18; Grid.SetRow(tb, i); Grid.SetColumn(tb, 0); G_Table.Children.Add(tb); } vtb_values = new ValueTextBox[Values.Count()]; for (int i = 0; i < Values.Count(); i++) { vtb_values[i] = new ValueTextBox(Values[i]); Grid.SetRow(vtb_values[i], i >> 3); Grid.SetColumn(vtb_values[i], (i & 7) + 1); G_Table.Children.Add(vtb_values[i]); vtb_values[i].GotFocus += OnVTBGotFocus; } }
private void UCDataColGrid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { //TODO: check why we come here with non matching object if (!typeof(IObservableList).IsAssignableFrom(e.NewValue.GetType())) { return; //avoid invalid cast exception } this.Dispatcher.Invoke(() => { l = (IObservableList)e.NewValue; if (l.Count == 0) { return; } // If it is input and we have only one row then no need to show the grid if (l[0].GetType() == typeof(ActInputValue) && l.Count == 1) { ValueTextBox.Visibility = System.Windows.Visibility.Visible; MainDataGrid2.Visibility = System.Windows.Visibility.Collapsed; Binding bd = new Binding("Value"); ValueTextBox.DataContext = l[0]; ValueTextBox.SetBinding(TextBox.TextProperty, bd); } else { MainDataGrid2.Visibility = System.Windows.Visibility.Visible; ValueTextBox.Visibility = System.Windows.Visibility.Collapsed; SetGridData(); } }); }
private void RegistryKeyTextBox_TextChanged(object sender, TextChangedEventArgs e) { RegistryKey key = Registry.LocalMachine.OpenSubKey(SubKeyTextBox.Text); if (key != null) { string keyValue = (string)key.GetValue(RegistryKeyTextBox.Text); if (keyValue == null) { state["RegistryKey"] = false; state["Value"] = false; ValueTextBox.Clear(); RegistryKeyErrorLabel.Content = "Registry Key Does not exitst"; } else { state["RegistryKey"] = true; state["Value"] = true; RegistryKeyErrorLabel.Content = ""; ValueTextBox.Text = keyValue.ToString(); } key.Close(); } }
private void SetSearchInlineError(bool isInvalid, string message = "") { var bindingExpressionBase = ValueTextBox?.GetBindingExpression(TextBox.TextProperty); if (bindingExpressionBase == null) { return; } if (isInvalid) { var validationError = new ValidationError(new ExceptionValidationRule(), bindingExpressionBase) { ErrorContent = message }; Validation.MarkInvalid(bindingExpressionBase, validationError); } else { Validation.ClearInvalid(bindingExpressionBase); } }
public InputBox(string message) { InitializeComponent(); ValueTextBox.Focus(); messageTextBlock.Text = message; value = 0; }
public ExpensePage(Flyout parentFlyout, Expense exp, ExpenseCategory cat, DateTime?datetime) { InitializeComponent(); parent = parentFlyout; expense = exp; if (expense != null) { category = expense.category; date = expense.date; DeleteButton.IsEnabled = true; TitleTextBlock.Text = "Edycja wydatku"; } else { category = cat; date = datetime; TitleTextBlock.Text = "Nowy wydatek"; DeleteButton.Visibility = Visibility.Collapsed; } LoadCategories(); SetupDatePicker(); FillWithCorrectValues(); ValueTextBox.Focus(); }
public void Init(string title, string message, Object obj, string Property) { winTitle.Content = title; MessageLabel.Text = message; ObjFieldBinding(ValueTextBox, TextBox.TextProperty, obj, Property); mOriginalValue = ValueTextBox.Text; ValueTextBox.Focus(); }
private void RenameItem_Click(object sender, RoutedEventArgs e) { AddButton.Content = "Ok"; viewModel.EditMode = true; ValueTextBox.SetBinding(TextBox.TextProperty, new Binding("Value") { Source = viewModel.SelectedItem }); }
private void SetValueButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(KeyTextBox.Text)) { settings[KeyTextBox.Text] = ValueTextBox.Text; KeyTextBox.Clear(); ValueTextBox.Clear(); RefreshDictionaryView(settings, SettingsListBox); } }
public NewModPropNewForm(NewModForm modform, ListViewItem listViewItem) { InitializeComponent(); Modform = modform; WorkingListViewItem = listViewItem; // Clears all items inside of GroupComboBox. GroupComboBox.Items.Clear(); // Adds all groups from the ListView into GroupComboBox. foreach (ListViewGroup group in modform.GetListView().Groups) { GroupComboBox.Items.Add(group.Header); } // Adds "Add Group" to GroupComboBox so the user can create groups. GroupComboBox.Items.Add("Add Group"); GroupComboBox.SelectedIndex = 0; Text = "New Property"; if (listViewItem != null) { Text = "Edit Property"; label1.Text = "Edit Property: " + listViewItem.Text; TypeComboBox.Text = listViewItem.Tag as string; textBox1.Text = listViewItem.Text; GroupComboBox.SelectedIndex = modform.GetListView().Groups.IndexOf(listViewItem.Group); AddButton.Text = "Update"; ValueTextBox.Select(); UpdateType(); // Parses the text. switch (listViewItem.Tag) { case "Integer": if (listViewItem.SubItems[1].Text.Length > 0) { ValueNumericUpDown.Value = int.Parse(listViewItem.SubItems[1].Text); } break; case "Boolean": if (listViewItem.SubItems[1].Text.Length > 0) { ValueCheckBox.Checked = bool.Parse(listViewItem.SubItems[1].Text); } break; default: ValueTextBox.Text = listViewItem.SubItems[1].Text.Replace("\\n", "\r\n"); break; } } }
public void DisableConditionModules() { OperatorsComboBox.Items.Clear(); ValueTextBox.Clear(); DateValueMaskedTextBox.Clear(); OperatorsComboBox.Enabled = false; ValueTextBox.Enabled = false; DateValueMaskedTextBox.Enabled = false; AddConditionButton.Enabled = false; ColumnsComboBox.SelectedIndex = -1; }
public void Init(string title, string message, ref string Value, bool isMultiline) { if (!isMultiline) { ValueTextBox.TextWrapping = TextWrapping.NoWrap; ValueTextBox.AcceptsReturn = false; } winTitle.Content = title; MessageLabel.Text = message; ValueTextBox.Text = Value; ValueTextBox.Focus(); }
private void TB_Current_TextChanged(object sender, TextChangedEventArgs e) { TB_Current.Background = Brushes.Red; foreach (ValueTextBox vtbox in vtb_values) { if (vtbox.SVUnit.Name.Equals(TB_Current.Text)) { Cursor = vtbox; TB_Current.Background = Brushes.Transparent; return; } } }
public InputDialogView() { InitializeComponent(); DataContext = this; ValueTextBox.SetBinding(TextBox.TextProperty, new Binding { Path = new PropertyPath(nameof(Text)), Mode = BindingMode.TwoWay, ValidatesOnExceptions = true, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Source = this }); }
private void EditItem_Click(object sender, RoutedEventArgs e) { if (ValueTextBox.Text.Trim().Length < 1) { MessageBox.Show("Введите значение в текстовое поле!"); return; } viewModel.AddItem(ValueTextBox.Text); ValueTextBox.SetBinding(TextBox.TextProperty, new Binding("V") { Source = new object() }); ValueTextBox.Text = ""; AddButton.Content = "+"; }
private void AddConditionButton_Click(object sender, EventArgs e) { if (IsParsing(GetValue())) { Condition condition = new Condition(GetColumn(), GetOperator(), GetValue()); ConditionsListBox.Items.Add(condition.ToString()); conditions.Add(condition); ConditionsListBox.SelectedIndex = 0; DisableConditionModules(); } else { ValueTextBox.Clear(); DateValueMaskedTextBox.Clear(); MessageBox.Show("Not Parsed!"); } }
//ValuesListView的SelectedIndexChanged事件 private void StartEdit(object sender, EventArgs e) { try { if (ValuesListView.SelectedItems.Count > 0) { BandTextBox.Text = "Band " + (ValuesListView.SelectedIndices[0] + 1).ToString(); ValueTextBox.Text = BandValues[ValuesListView.SelectedIndices[0]].ToString("0.000000"); CurrentBand = ValuesListView.SelectedIndices[0]; ValueTextBox.Focus(); ValueTextBox.SelectAll(); } } catch (Exception err) { MessageBox.Show(err.Message); } }
//重置和刷新ListView操作 public void Reset() { if (BandCount > 0) { BandValues.Clear(); ValuesListView.Clear(); BandTextBox.Clear(); ValueTextBox.Clear(); for (int i = 0; i < BandCount; i++) { BandValues.Add(ResetNum); } for (int i = 0; i < BandCount; i++) { ValuesListView.Items.Add("Band" + (i + 1).ToString() + " " + BandValues[i].ToString("0.000000")); } } }
public void Init(ValueTextBox targetCtl, SearchDataGrid dataGrid) { _dataGrid = dataGrid; this.targetControl = targetCtl; this._parentForm = this.targetControl.FindForm(); dataGrid.Parent.Controls.Remove(dataGrid); dataGrid.Dock = DockStyle.Fill; this.Controls.Add(dataGrid); this.Width = 500; this.Height = 300; this.targetControl.KeyDown += (s, e) => { e.Handled = true; this._dataGrid.OnKeyDown(s, e); }; this.targetControl.ValueInitDone += (val) => { this.ClosePanel(true); }; this.targetControl.TextChanged += (s, e) => { var p = this.targetControl.Location; p.Offset(0, this.targetControl.Height); this.Location = p; this._parentForm.Controls.Add(this); this.BringToFront(); }; this.targetControl.LostFocus += (s, e) => { if (!inGrid) { this.ClosePanel(false); } }; dataGrid.MouseEnter += (s, e) => { inGrid = true; }; dataGrid.MouseLeave += (s, e) => { inGrid = false; this.targetControl.Focus(); }; }
private void OperatorsComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (OperatorsComboBox.SelectedItem != null) { AddConditionButton.Enabled = true; string op = OperatorsComboBox.SelectedItem.ToString(); if (op == "IS NULL" || op == "IS NOT NULL") { DateValueMaskedTextBox.Clear(); ValueTextBox.Clear(); DateValueMaskedTextBox.Enabled = false; ValueTextBox.Enabled = false; } else { SwitchTextBoxes(IsDate(GetColumnType())); } } }
public void SwitchTextBoxes(bool isDate) { if (isDate) { DateValueMaskedTextBox.Clear(); ValueTextBox.Clear(); DateValueMaskedTextBox.Enabled = true; DateValueMaskedTextBox.Visible = true; ValueTextBox.Enabled = false; ValueTextBox.Visible = false; } else { DateValueMaskedTextBox.Clear(); ValueTextBox.Clear(); DateValueMaskedTextBox.Enabled = false; DateValueMaskedTextBox.Visible = false; ValueTextBox.Enabled = true; ValueTextBox.Visible = true; } }
// Initializes the edit dialog to set the value of the given element. public void Initialize(Element element) { if ((object)element == null) { return; } Tag tag = GSF.PQDIF.Tag.GetTag(element.TagOfElement); // Determine whether the tag definition contains // a list of identifiers which can be used to // display the value in a more readable format IReadOnlyCollection <Identifier> identifiers = tag?.ValidIdentifiers ?? new List <Identifier>(); // Some identifier collections define a set of bitfields which can be // combined to represent a collection of states rather than a single value // and these are identified by the values being represented in hexadecimal List <Identifier> bitFields = identifiers.Where(id => id.Value.StartsWith("0x")).ToList(); if (bitFields.Count > 0) { // Get the value of the element uint value = Convert.ToUInt32(((ScalarElement)element).Get()); // Values with bitfields will be displayed in a checked list box ValueCheckedListBox.Visible = true; ValueCheckedListBox.Focus(); // Populate the checked list box with the valid bitfields foreach (Identifier bitField in bitFields) { uint bit = Convert.ToUInt32(bitField.Value, 16); ValueCheckedListBox.Items.Add(bitField.Name, (value & bit) > 0u); } // Set up the function to get the value entered by the user m_getValue = () => "{ " + string.Join(", ", ValueCheckedListBox.CheckedItems.Cast <string>()) + " }"; } else if (identifiers.Count > 0) { // Get the value of the element string value = ((ScalarElement)element).Get().ToString(); // Values with IDs will be displayed in a regular list box ValueListBox.Visible = true; ValueListBox.Focus(); // Populate the list box with the valid identifiers foreach (Identifier identifier in identifiers.OrderBy(identifier => identifier.Name)) { ValueListBox.Items.Add(identifier.Name); if (value == identifier.Value) { ValueListBox.SelectedIndex = ValueListBox.Items.Count - 1; } } // Set up the function to get the value entered by the user m_getValue = () => ValueListBox.SelectedItem?.ToString(); } else { // All other values will be displayed in an editable text box ValueTextBox.Visible = true; ValueTextBox.Focus(); ValueTextBox.Text = element.ValueAsString(); // Set up the function to get the value entered by the user m_getValue = () => ValueTextBox.Text; } }
private void OnVTBGotFocus(object sender, RoutedEventArgs e) { Cursor = (ValueTextBox)sender; }
protected override void OnActivated(EventArgs e) { ValueTextBox.SelectAll(); base.OnActivated(e); }
public ConnectionWindow() { InitializeComponent(); ValueTextBox.SelectAll(); }