/// <summary> /// Presents the member list to the user /// </summary> /// <param name="memberList"></param> /// <param name="syntaxEditor"></param> /// <param name="completeWord"></param> private void PresentMemberList(MemberList memberList, ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor, bool completeWord) { IntelliPromptMemberList prompt = syntaxEditor.IntelliPrompt.MemberList; if (prompt.Visible) { return; } // Initialize the member list prompt.ResetAllowedCharacters(); prompt.AllowedCharacters.Add(new CharInterval(char.MinValue, char.MaxValue)); prompt.Clear(); prompt.ImageList = LuaIntellisenseIcons.GetImageList(); prompt.AddRange(memberList.List); // Show the list if (memberList.TargetTextRange.IsDeleted) { prompt.Show(); } else if (completeWord && memberList.TargetTextRange.Length > 0) { prompt.CompleteWord(memberList.TargetTextRange.StartOffset, memberList.TargetTextRange.Length); } else { prompt.Show(memberList.TargetTextRange.StartOffset, memberList.TargetTextRange.Length); } }
private void IntelliPromptTipImageRequested(object sender, IntelliPromptTipImageRequestedEventArgs e) { try { var images = LuaIntellisenseIcons.GetImageList(); var icontype = (LuaIntellisenseIconType)Enum.Parse(typeof(LuaIntellisenseIconType), e.Source, true); e.Image = images.Images[(int)icontype]; } catch (Exception ex) { ex.ToString(); } }
private static void GotoDefinitions(string title, ILuaIntellisenseDocument document, Func <Expression, List <LuatValue.IReference> > func) { if ((document == null) || (document.SyntaxEditorControl == null) || (func == null)) { return; } var se = (ActiproSoftware.SyntaxEditor.SyntaxEditor)document.SyntaxEditorControl; if ((se.Document == null) || (se.SelectedView == null)) { return; } var expression = GetExpressionAt(se.Document, se.SelectedView.Selection.StartOffset); if (expression == null) { return; } var definitions = func(expression); if (definitions == null) { return; } if (definitions.Count == 0) { return; } if (definitions.Count == 1) { definitions[0].Goto(); return; } using (var gfx = se.SelectedView.CreateGraphics()) { var menu = new ContextMenuStrip { ImageList = LuaIntellisenseIcons.GetImageList() }; SkinService.ApplyActiveSkin(menu); KeyValuePair <string, LuatValue.IReference[]>[] groups = definitions.GroupItems(a => a.Context, a => a); ToolStripLabel label; { label = new ToolStripLabel(title) { Enabled = false }; menu.Items.Add(label); } int index = 0; foreach (KeyValuePair <string, LuatValue.IReference[]> group in groups) { menu.Items.Add(new ToolStripSeparator()); if (groups.Length > 0) { label = new ToolStripLabel("Context: " + group.Key) { Enabled = false }; menu.Items.Add(label); } var items = new List <ToolStripItem>(); foreach (LuatValue.IReference definition in group.Value) { string text = GetReferenceText(definition, document.Project); string file = System.IO.Path.GetFileName(definition.Path); int line = definition.Line; LuatValue.GotoReference gotoRef = definition.Goto; var item = new ToolStripMenuItem { ImageIndex = (int)(definition.Value != null ? definition.Value.Type.Icon : LuaIntellisenseIconType.Unknown), Text = string.Format("&{0} {1}({2}): {3}", index++, file, line, text), Font = se.Font, Tag = line }; item.Width = (int)gfx.MeasureString(item.Text, item.Font).Width; item.Click += (s, e) => gotoRef(); items.Add(item); } menu.Items.AddRange(items.OrderBy(x => (int)x.Tag).ToArray()); } var rect = se.SelectedView.GetCharacterBounds(se.SelectedView.Selection.StartOffset); menu.Show(se, rect.Location); } }