private void LookupContextMenuStrip_Opening( object sender, CancelEventArgs e) { LookupListItem li = null; if (_listView.SelectedItems.Count > 0) { li = _listView.SelectedItems[0].Tag as LookupListItem; } if (li == null || li.MenuItems.Count == 0) { e.Cancel = true; return; } _lookupContextMenuStrip.Items.Clear(); foreach (LookupMenuItem lmi in li.MenuItems) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = lmi.DisplayText; item.Tag = lmi; item.Click += LookupToolStripMenuItem_Click; // Apply theme color if available. if (_themeFlags != null && _themeFlags.MenuForeColor != Color.Empty) { item.ForeColor = _themeFlags.MenuForeColor; } _lookupContextMenuStrip.Items.Add(item); } }
private static List <LookupListItem> GetQuickSharpOptionsList() { string[] options = { "RunInOwnWindow", "DoPreCompile", "DoPostCompile", "DoPreRun", "DoPostRun" }; List <LookupListItem> list = new List <LookupListItem>(); foreach (string option in options) { LookupListItem item = new LookupListItem(); item.DisplayText = item.InsertText = item.ToolTipText = option; item.Category = Constants.PROPERTIES; list.Add(item); } return(list); }
private void ListView_MouseDoubleClick( object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (_listView.SelectedItems.Count > 0) { LookupListItem li = _listView.SelectedItems[0].Tag as LookupListItem; _selectedText = li.InsertText; _insertionTemplateIndex = li.TemplateIndex; DialogResult = DialogResult.OK; } } }
private void LookupForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Back) { DialogResult = DialogResult.Cancel; return; } if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) { if (_listView.SelectedItems.Count > 0) { LookupListItem li = _listView.SelectedItems[0].Tag as LookupListItem; _selectedText = li.InsertText; _insertionTemplateIndex = li.TemplateIndex; DialogResult = DialogResult.OK; } return; } if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) { _incrementalSearchText += (char)e.KeyValue; ListViewItem item = _listView.FindItemWithText( _incrementalSearchText, false, 0, true); if (item != null) { item.Selected = true; item.Focused = true; item.EnsureVisible(); } } else { _incrementalSearchText = " "; } }
private static List <LookupListItem> GetFileList(string pattern) { List <LookupListItem> list = new List <LookupListItem>(); string workspace = Directory.GetCurrentDirectory(); foreach (string file in Directory.GetFiles(workspace, pattern)) { string filename = Path.GetFileName(file); LookupListItem item = new LookupListItem(); item.DisplayText = filename; item.InsertText = filename; item.Category = Constants.FILE_REF; list.Add(item); } return(list); }