private static void AddAttributesFromWrapper(XmlObjectsListWrapper wrapper, IList <ICompletionData> data, bool excludeQuotes = false) { foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys) { //Get an attribute dictionary for a tag Dictionary <string, List <string> > attributeDictinaryForTag = wrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey); if (attributeDictinaryForTag != null) { foreach (string attributeKey in attributeDictinaryForTag.Keys) { List <string> allAttributesForTag = attributeDictinaryForTag.GetValueOrDefault(attributeKey); SortedSet <string> allKeysToAdd = new SortedSet <string> (); allKeysToAdd.UnionWith(allAttributesForTag); foreach (string nextAttribute in allKeysToAdd) { MyCompletionData attributeCompletionDataNoQuotes = new MyCompletionData(nextAttribute, "Xml Node Attribute value: "); data.Add(attributeCompletionDataNoQuotes); if (!excludeQuotes) { MyCompletionData attributeCompletionDataJustEndQuote = new MyCompletionData(nextAttribute + "\" ", "Xml Node Attribute value: "); data.Add(attributeCompletionDataJustEndQuote); } } } } } }
private void ElementoAutoCompletado_Loaded(object sender, RoutedEventArgs e) { MyCompletionData data = (MyCompletionData)this.DataContext; this.Imagen.Source = new BitmapImage(new Uri(data.ImgSource, UriKind.Relative)); }
private void Compelet() { Regex re = new Regex(@"\\bibliography\{(\w+)\}"); Match m = re.Match(this.textEditor.Document.Text); string path = @"Z:\30\1\ref.bib";// m.Groups[1].Captures[0].ToString() + " .bib"; //if (e.Text == @"\ref{") { // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(textEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; StringBuilder entry = new StringBuilder(); foreach (BibTex b in BibTex.Parse(path)) { MyCompletionData d = new MyCompletionData(b.UID); //d.Name = "name"; //d.Description = "des"; //d.Content = "content"; data.Add(d); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } }
private static void AddAttributesFromWrapper(XmlObjectsListWrapper wrapper, IList <ICompletionData> data, bool excludeQuotes = false) { foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys) { //Get an attribute dictionary for a tag Dictionary <string, List <string> > attributeDictinaryForTag = wrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey); if (attributeDictinaryForTag != null) { foreach (string attributeKey in attributeDictinaryForTag.Keys) { List <string> allAttributesForTag = attributeDictinaryForTag.GetValueOrDefault(attributeKey); SortedSet <string> allKeysToAdd = new SortedSet <string> (); allKeysToAdd.UnionWith(allAttributesForTag); foreach (string nextAttribute in allKeysToAdd) { MatchCollection matches = IsStringNumberRegex.Matches(nextAttribute); //If there are matches that means it is a number, and we want to filter those out if (matches.Count < 1) { MyCompletionData attributeCompletionDataNoQuotes = new MyCompletionData(nextAttribute, "Xml Node Attribute value: "); data.Add(attributeCompletionDataNoQuotes); if (!excludeQuotes) { MyCompletionData attributeCompletionDataJustEndQuote = new MyCompletionData(nextAttribute + "\" ", "Xml Node Attribute value: "); data.Add(attributeCompletionDataJustEndQuote); } } } } } } }
private IList <ICompletionData> GetDataList(string lastTypedWord, TextEditor textEditor) { completionWindow = CompletionWindow.GetInstance(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; Dictionary <string, float> keywordsScore = new Dictionary <string, float>(); IOrderedEnumerable <string> sorted; ContextKeywords.ForEach(keyword => keywordsScore.TryAdd(keyword, CompletionScore(keyword, lastTypedWord))); sorted = ContextKeywords.Where(keyword => { return(keywordsScore[keyword] >= 0); }) .OrderBy(keyword => keywordsScore[keyword]); foreach (var keyword in sorted) { if (keyword == null) { continue; } string description = default; keyWordsDescriptions?.TryGetValue(keyword, out description); MyCompletionData myCompletionData = new MyCompletionData(keyword, description, language, textEditor, () => CodeBoxText(null, null)); data.Add(myCompletionData); } return(data); }
void textEditor_TextArea_TextEntered1(object sender, TextCompositionEventArgs e) { if (e.Text == @"\") { // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(textEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (string s in TexHelper.TexEntries()["Greek letters"]) { MyCompletionData d = new MyCompletionData(s); data.Add(new MyCompletionData(s.Substring(1, s.Length - 1))); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } }
private void Compelet() { string path = ""; Regex reBiblio = new Regex(@"(?<!%)(?<=\\bibliography\{)([^\{]+)(?=\})", RegexOptions.IgnoreCase); Match m = reBiblio.Match(txtEditor.Text); if (m.Success) { path = this.CurrentFileInfo.Directory + "\\" + m.Groups[1].Captures[0].Value.ToString() + ".bib"; } if (!File.Exists(path)) { return; } //if (e.Text == @"\ref{") //{ // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(txtEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; StringBuilder entry = new StringBuilder(); foreach (BibTex b in BibTex.Parse(path)) { MyCompletionData d = new MyCompletionData(b.UID); d.Data = b.Text; //d.Description = "des"; //d.Content = "content"; data.Add(d); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; //} }