protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyData == Keys.F2) { int index = SelectedIndex; if (index == ListBox.NoMatches || index == 65535) { if (Items.Count > 0) { index = 0; } } if (index != ListBox.NoMatches && index != 65535) { string s = Items[index].ToString(); Rectangle rect = GetItemRectangle(index); tbox.Location = new Point(rect.X, rect.Y); tbox.Size = new Size(rect.Width, rect.Height); tbox.Text = s; tbox.index = index; tbox.SelectAll(); tbox.Show(); tbox.Focus(); } } base.OnKeyDown(e); }
private void OnAddAttributeButtonClick(NEventArgs arg) { NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(); dialog.SetupDialogWindow("Enter attribute's name and value", false); NTableFlowPanel table = new NTableFlowPanel(); table.Direction = ENHVDirection.LeftToRight; table.ColFillMode = ENStackFillMode.Last; table.ColFitMode = ENStackFitMode.Last; table.MaxOrdinal = 2; NLabel nameLabel = new NLabel("Name:"); table.Add(nameLabel); NTextBox nameTextBox = new NTextBox(); table.Add(nameTextBox); NLabel valueLabel = new NLabel("Value:"); table.Add(valueLabel); NTextBox valueTextBox = new NTextBox(); table.Add(valueTextBox); table.Add(new NWidget()); NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); table.Add(buttonStrip); dialog.Content = table; dialog.Opened += delegate(NEventArgs args) { nameTextBox.Focus(); }; dialog.Closed += delegate(NEventArgs args) { if (dialog.Result == ENWindowResult.OK) { NElementInfo elementInfo = (NElementInfo)m_TreeView.SelectedItem.Tag; elementInfo.Attributes.Set(nameTextBox.Text, valueTextBox.Text); UpdateTreeViewItemText(m_TreeView.SelectedItem); if (m_RemoveAttributeButton.Enabled == false) { m_RemoveAttributeButton.Enabled = true; } } }; dialog.Open(); }
private void OnAddChildItemButtonClick(NEventArgs arg) { NTopLevelWindow dialog = NApplication.CreateTopLevelWindow(NWindow.GetFocusedWindowIfNull(OwnerWindow)); dialog.SetupDialogWindow("Enter element's name", false); NTextBox textBox = new NTextBox(); NButtonStrip buttonStrip = new NButtonStrip(); buttonStrip.InitOKCancelButtonStrip(); NPairBox pairBox = new NPairBox(textBox, buttonStrip, ENPairBoxRelation.Box1AboveBox2); pairBox.Spacing = NDesign.VerticalSpacing; dialog.Content = pairBox; dialog.Opened += delegate(NEventArgs args) { textBox.Focus(); }; dialog.Closed += delegate(NEventArgs args) { if (dialog.Result == ENWindowResult.OK) { // Add an item with the specified name m_TreeView.SelectedItem.Items.Add(CreateTreeViewItem(textBox.Text)); m_TreeView.SelectedItem.Expanded = true; if (m_SerializeButton.Enabled == false) { m_SerializeButton.Enabled = true; } } }; dialog.Open(); }