private void AddItem([NotNull] string name, [NotNull] string value, int index) { Debug.ArgumentNotNull(name, nameof(name)); Debug.ArgumentNotNull(value, nameof(value)); itemsList.Add(new KeyValuePair <string, string>(name, value)); // There's only 2 tabbable fields for each item. var firstTabIndex = index << 1; var itemNameBox = new FocusedTextBox { Text = name, TabIndex = firstTabIndex, Style = textBoxStyle }; itemNameBox.TextChanged += ItemTextChanged(index); itemNameBox.LostFocus += ItemLostFocus(index); var itemValueBox = new ComboBox { TabIndex = firstTabIndex + 1, Style = comboBoxStyle }; LoadItems(itemValueBox); SelectItem(itemValueBox, value); itemValueBox.SelectionChanged += ItemSelectionChanged(index); itemValueBox.LostFocus += ItemLostFocus(index); NameStack.Children.Add(itemNameBox); ValueStack.Children.Add(itemValueBox); }
/// <summary> /// Construct a new instance. /// </summary> /// <param name="postingTextbox">Whether a textbox for posting new messages should be displayed.</param> public StandAloneChatDisplay(bool postingTextbox = false) { this.postingTextbox = postingTextbox; CornerRadius = 10; Masking = true; InternalChildren = new Drawable[] { new Box { Colour = Color4.Black, Alpha = 0.8f, RelativeSizeAxes = Axes.Both }, }; if (postingTextbox) { AddInternal(textbox = new FocusedTextBox { RelativeSizeAxes = Axes.X, Height = textbox_height, PlaceholderText = "type your message", OnCommit = postMessage, ReleaseFocusOnCommit = false, HoldFocus = true, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }); } Channel.BindValueChanged(channelChanged); }
private void LastTextChanged([NotNull] object sender, [NotNull] TextChangedEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); var lastIndex = itemsList.Count; var lastNameBox = (FocusedTextBox)NameStack.Children[lastIndex]; var lastValueBox = (FocusedTextBox)ValueStack.Children[lastIndex]; if (lastNameBox == null || lastValueBox == null) { return; } // If there's no content in either of the boxes, return. if (lastNameBox.Text == string.Empty && lastValueBox.Text == string.Empty) { return; } // Add the newly created item to the model. itemsList.Add(new KeyValuePair <string, string>(lastNameBox.Text, lastValueBox.Text)); var currentTabIndex = lastValueBox.TabIndex; // Add some new last boxes. var newLastNameBox = new FocusedTextBox { TabIndex = ++currentTabIndex, Style = textBoxStyle }; newLastNameBox.TextChanged += LastTextChanged; NameStack.Children.Add(newLastNameBox); var newLastValueBox = new FocusedTextBox { TabIndex = ++currentTabIndex, Style = textBoxStyle }; newLastValueBox.TextChanged += LastTextChanged; ValueStack.Children.Add(newLastValueBox); // Unbind last text listeners (the delegate boxes are no longer last). lastNameBox.TextChanged -= LastTextChanged; lastValueBox.TextChanged -= LastTextChanged; lastNameBox.TextChanged += ItemTextChanged(lastIndex); lastValueBox.TextChanged += ItemTextChanged(lastIndex); lastNameBox.LostFocus += ItemLostFocus(lastIndex); lastValueBox.LostFocus += ItemLostFocus(lastIndex); }
private void LastTextChanged() { var lastIndex = itemsList.Count; var lastNameBox = (FocusedTextBox)NameStack.Children[lastIndex]; var lastValueBox = (ComboBox)ValueStack.Children[lastIndex]; if (lastNameBox == null || lastValueBox == null) { return; } // If there's no content in either of the boxes, return. if (lastNameBox.Text == string.Empty && GetSelectedValue(lastValueBox) == string.Empty) { return; } // Add the newly created item to the model. itemsList.Add(new KeyValuePair <string, string>(lastNameBox.Text, GetSelectedValue(lastValueBox))); var currentTabIndex = lastValueBox.TabIndex; // Add some new last boxes. var newLastNameBox = new FocusedTextBox { TabIndex = ++currentTabIndex, Style = textBoxStyle }; newLastNameBox.TextChanged += LastTextChanged; NameStack.Children.Add(newLastNameBox); var newLastValueBox = new ComboBox { TabIndex = ++currentTabIndex, Style = comboBoxStyle }; LoadItems(newLastValueBox); newLastValueBox.SelectionChanged += LastTextChanged; ValueStack.Children.Add(newLastValueBox); // Unbind last text listeners (the delegate boxes are no longer last). lastNameBox.TextChanged -= LastTextChanged; lastValueBox.SelectionChanged -= LastTextChanged; lastNameBox.TextChanged += ItemTextChanged(lastIndex); lastValueBox.SelectionChanged += ItemSelectionChanged(lastIndex); lastNameBox.LostFocus += ItemLostFocus(lastIndex); lastValueBox.LostFocus += ItemLostFocus(lastIndex); }
private void AggregateView_OnLoaded(object sender, RoutedEventArgs e) { FocusedTextBox.Focus(); }
public void SetValue(string value) { Assert.ArgumentNotNull(value, nameof(value)); var items = value.Split('&'); var i = -1; var changed = false; foreach (var item in items) { var parts = item.Split('='); if (parts.Length < 2) { continue; } i++; var itemName = HttpUtility.UrlDecode(parts[0]) ?? string.Empty; var itemValue = HttpUtility.UrlDecode(parts[1]) ?? string.Empty; var lastIndex = itemsList.Count; if (lastIndex == 0) { NameStack.Children.Clear(); ValueStack.Children.Clear(); } changed = lastIndex <= i; if (changed) { AddItem(itemName, itemValue, i); } else if (itemsList[i].Key != itemName || itemsList[i].Value != itemValue) { changed = true; itemsList[i] = new KeyValuePair <string, string>(itemName, itemValue); var currentNameBox = (FocusedTextBox)NameStack.Children[i]; var currentValueBox = (ComboBox)ValueStack.Children[i]; if (currentNameBox == null || currentValueBox == null) { continue; } currentNameBox.Text = itemName; SelectItem(currentValueBox, itemValue); } } i++; var remainderCount = itemsList.Count - i; NameStack.Children.RemoveRange(i, remainderCount); ValueStack.Children.RemoveRange(i, remainderCount); itemsList.RemoveRange(i, remainderCount); var lastNameBox = new FocusedTextBox { Style = textBoxStyle }; lastNameBox.TextChanged += LastTextChanged; var lastValueBox = new ComboBox { Style = comboBoxStyle }; LoadItems(lastValueBox); lastValueBox.SelectionChanged += LastTextChanged; NameStack.Children.Add(lastNameBox); ValueStack.Children.Add(lastValueBox); if (changed) { ValueModifiedNotify(); } }
protected void Page_Load(object sender, EventArgs e) { FocusedTextBox.Focus(); }