void ProcessHullID(AttributeElement currentActiveAttribute) { currentActiveAttribute.AttributeType = AttributeType.LimitedListString; currentActiveAttribute.Values = new System.Collections.ObjectModel.ObservableCollection <XmlCompletionData>(); if (vesselData != null) { foreach (VesselDataLibrary.Xml.Vessel v in vesselData.Vessels) { string race = string.Empty; foreach (VesselDataLibrary.Xml.HullRace r in vesselData.HullRaces) { if (v.Side == r.ID) { race = r.Name; break; } } string wrkD = string.Empty; if (!string.IsNullOrEmpty(v.Description.Text)) { wrkD = v.Description.Text.Replace("^", "\r\n"); } if (string.IsNullOrEmpty(wrkD)) { wrkD = string.Format(CultureInfo.InvariantCulture, "{0} {1}", v.ClassName, v.BroadType); } string de = string.Format(CultureInfo.InvariantCulture, "{2} ({0}) {1}", race, wrkD, v.UniqueID.ToString(CultureInfo.InvariantCulture)); StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; if (wrkD.Contains("\r\n")) { wrkD = wrkD.Substring(0, wrkD.IndexOf("\r\n", StringComparison.OrdinalIgnoreCase)); } TextBlock t = new TextBlock(); t.VerticalAlignment = VerticalAlignment.Center; t.Text = v.UniqueID.ToString(CultureInfo.InvariantCulture); t.Padding = new Thickness(0, 0, 4, 0); t.FontWeight = FontWeights.Bold; sp.Children.Add(t); TextBlock t2 = new TextBlock(); t2.VerticalAlignment = VerticalAlignment.Center; t2.Text = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", race, wrkD); sp.Children.Add(t2); XmlCompletionData value = new XmlCompletionData(v.UniqueID.ToString(CultureInfo.InvariantCulture), de, sp); currentActiveAttribute.Values.Add(value); } } }
void w_ResultProvided(object sender, ResultProvidedEventArgs e) { // remove the event handler popup.ResultProvided -= w_ResultProvided; if (!e.Canceled) { int _CurrCaretIndex = TextEditor.ActiveTextAreaControl.Caret.Offset; int inputlength = (_CurrCaretIndex - _BeginCaretIndex); if (inputlength < 0) { inputlength = 0; } string inserttext = ""; if (e.Item is SnippetCompletionData) { SnippetCompletionData snippet = e.Item as SnippetCompletionData; TextEditor.ActiveTextAreaControl.Caret.ValidateCaretPos(); inserttext = snippet.Snippet.IndentedText(TextEditor.ActiveTextAreaControl.Caret.Position.X - inputlength, true); } if (e.Item is XmlCompletionData) { XmlCompletionData xml = e.Item as XmlCompletionData; inserttext = xml.Text; } if (_CurrCaretIndex > _BeginCaretIndex) { string prefix = Text.Substring(_BeginCaretIndex, _CurrCaretIndex - _BeginCaretIndex); if (e.ForcedAccept || e.Text.ToLowerInvariant().StartsWith(prefix.ToLowerInvariant())) { // clear the user entered text RemoveString(_BeginCaretIndex, _CurrCaretIndex - _BeginCaretIndex); // insert the selected string InsertString(inserttext, _BeginCaretIndex); // place the caret at the end of the inserted text TextEditor.ActiveTextAreaControl.TextArea.Caret.Column += inserttext.Length; } } else if (_CurrCaretIndex - _BeginCaretIndex == 0) { InsertStringAtCaret(inserttext); } } }
public void NamespaceUriCompletionString(bool autoInsertFragments) { var settingBefore = XmlEditorOptions.AutoInsertFragments; try { XmlEditorOptions.AutoInsertFragments = autoInsertFragments; XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.NamespaceUri); if (autoInsertFragments) { Assert.AreEqual("\"foo\"", data.CompletionText); } else { Assert.AreEqual("foo", data.CompletionText); } } finally { XmlEditorOptions.AutoInsertFragments = settingBefore; } }
public void AttributeCompletionString(bool autoInsertFragments) { var settingBefore = XmlEditorOptions.AutoInsertFragments; try { XmlEditorOptions.AutoInsertFragments = autoInsertFragments; XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlAttribute); if (autoInsertFragments) { Assert.AreEqual("foo=\"|\"", data.CompletionText); } else { Assert.AreEqual("foo", data.CompletionText); } } finally { XmlEditorOptions.AutoInsertFragments = settingBefore; } }
protected override void GetElementCompletions(CompletionDataList list) { var currentPath = GetCurrentPath(); var path = GetPath(currentPath); var namespaces = GetNamespaces(currentPath); var completions = Completion.GetCompletions(namespaces).ToList(); var filter = completions.Select(r => r.GetFilter(path)).FirstOrDefault(r => r != null); foreach (var completion in completions) { foreach (var item in completion.GetClasses(path, filter)) { var xmlCompletion = new XmlCompletionData(item.Name, item.Description, XmlCompletionData.DataType.XmlElement); xmlCompletion.Icon = Stock.Class; list.Add(xmlCompletion); } } BaseXmlEditorExtension.AddMiscBeginTags(list); base.GetElementCompletions(list); }
protected override async Task <CompletionDataList> GetAttributeValueCompletions(IAttributedXObject attributedOb, XAttribute att, CancellationToken token) { isParameterValueCompletion = true; var list = await base.GetAttributeValueCompletions(attributedOb, att, token); var currentPath = GetCurrentPath(); var path = GetPath(currentPath); var namespaces = GetNamespaces(currentPath); var objectName = attributedOb.Name.FullName; foreach (var completion in Completion.GetCompletions(namespaces)) { foreach (var item in completion.GetPropertyValues(objectName, att.Name.FullName, path)) { var xmlCompletion = new XmlCompletionData(item.Name, item.Description, XmlCompletionData.DataType.XmlAttributeValue); xmlCompletion.Icon = GetIcon(item.Type); list.Add(xmlCompletion); } } return(list); }
protected override async Task <CompletionDataList> GetElementCompletions(System.Threading.CancellationToken token) { var list = await base.GetElementCompletions(token); var currentPath = GetCurrentPath(); var path = GetPath(currentPath); var namespaces = GetNamespaces(currentPath); var completions = Completion.GetCompletions(namespaces).ToList(); var filter = completions.Select(r => r.GetFilter(path)).FirstOrDefault(r => r != null); foreach (var completion in completions) { foreach (var item in completion.GetClasses(path, filter)) { var xmlCompletion = new XmlCompletionData(item.Name, item.Description, XmlCompletionData.DataType.XmlElement); xmlCompletion.Icon = Stock.Class; list.Add(xmlCompletion); } } AddMiscBeginTags(list); return(list); }
CompletionDataList GetAttributeCompletions(IAttributedXObject attributedOb, Dictionary <string, string> existingAtts, XmlCompletionData.DataType type, bool elementNamespacesOnly) { var list = base.GetAttributeCompletions(attributedOb, existingAtts) ?? new CompletionDataList(); var currentPath = GetCurrentPath(); var path = GetPath(currentPath); var namespaces = GetNamespaces(currentPath); var objectName = attributedOb.Name.FullName; if (elementNamespacesOnly) { namespaces = namespaces.Where(r => (r.Prefix ?? string.Empty) == (attributedOb.Name.Prefix ?? string.Empty)).ToList(); } foreach (var completion in Completion.GetCompletions(namespaces)) { foreach (var item in completion.GetProperties(objectName, path).Where(r => !existingAtts.ContainsKey(r.Name))) { var xmlCompletion = new XmlCompletionData(item.Name, item.Description, type); xmlCompletion.Icon = GetIcon(item.Type); list.Add(xmlCompletion); } } return(list); }
public void NamespaceUriCompletionString() { XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.NamespaceUri); Assert.AreEqual("foo", data.CompletionString); }
public void XmlElementCompletionString() { XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlElement); Assert.AreEqual("foo", data.CompletionString); }
public void IconNotNull() { XmlCompletionData data = new XmlCompletionData("foo"); Assert.IsFalse(data.Icon.IsNull); }
public void IconNotEmptyString() { XmlCompletionData data = new XmlCompletionData("foo"); Assert.IsTrue(data.Icon.Name.Length > 0); }
void ProcessHullKeys(AttributeElement currentActiveAttribute) { currentActiveAttribute.AttributeType = AttributeType.LimitedListString; currentActiveAttribute.Values = new System.Collections.ObjectModel.ObservableCollection <XmlCompletionData>(); List <string> vesselDictionary = new List <string>(); List <XmlCompletionData> items = new List <XmlCompletionData>(); if (vesselData != null) { foreach (VesselDataLibrary.Xml.Vessel v in vesselData.Vessels) { XmlCompletionData value = null; string key = v.ClassName + " " + v.BroadType; if (!vesselDictionary.Contains(key)) { string race = string.Empty; foreach (VesselDataLibrary.Xml.HullRace r in vesselData.HullRaces) { if (v.Side == r.ID) { race = r.Name; break; } } string wrkD = string.Empty; if (!string.IsNullOrEmpty(v.Description.Text)) { wrkD = v.Description.Text.Replace("^", "\r\n"); } string desc = string.Format(CultureInfo.InvariantCulture, "{0} ({1}-{2})", key, wrkD, race); StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; TextBlock t = new TextBlock(); t.VerticalAlignment = VerticalAlignment.Center; t.Text = key; t.Padding = new Thickness(0, 0, 4, 0); t.FontWeight = FontWeights.Bold; sp.Children.Add(t); TextBlock t2 = new TextBlock(); t2.VerticalAlignment = VerticalAlignment.Center; t2.Text = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", race, wrkD); sp.Children.Add(t2); value = new XmlCompletionData(key, desc, sp); vesselDictionary.Add(key); items.Add(value); } if (items.Count > 0) { currentActiveAttribute.Values = new System.Collections.ObjectModel.ObservableCollection <XmlCompletionData>(); foreach (XmlCompletionData data in items) { currentActiveAttribute.Values.Add(data); } } } } }
public void ImageNotNull() { XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlElement); Assert.IsNotNull(data.Image); }
public void ImageNotEmptyString() { XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlElement); Assert.IsTrue(data.Image.Length > 0); }
public void AttributeValueCompletionString() { XmlCompletionData data = new XmlCompletionData("foo", XmlCompletionData.DataType.XmlAttributeValue); Assert.AreEqual("foo", data.CompletionString); }
void UpdateDeclarationView() { if (completionData == null || List.Selection >= completionData.Length || List.Selection == -1) { return; } if (List.GdkWindow == null) { return; } Gdk.Rectangle rect = List.GetRowArea(List.Selection); int listpos_x = 0, listpos_y = 0; while (listpos_x == 0 || listpos_y == 0) { GetPosition(out listpos_x, out listpos_y); } int vert = listpos_y + rect.Y; int lvWidth = 0, lvHeight = 0; while (lvWidth == 0) { this.GdkWindow.GetSize(out lvWidth, out lvHeight); } if (vert >= listpos_y + lvHeight - 2) { vert = listpos_y + lvHeight - rect.Height; } else if (vert < listpos_y) { vert = listpos_y; } ICompletionData data = completionData[List.Selection]; ICompletionDataWithMarkup datawMarkup = data as ICompletionDataWithMarkup; XmlCompletionData ccdata = (XmlCompletionData)data; string descMarkup = datawMarkup != null ? datawMarkup.DescriptionPango : data.Description; declarationviewwindow.Hide(); if (data != currentData) { declarationviewwindow.Clear(); declarationviewwindow.Realize(); declarationviewwindow.AddOverload(descMarkup); //foreach (CodeCompletionData odata in ccdata.GetOverloads ()) { // ICompletionDataWithMarkup odatawMarkup = odata as ICompletionDataWithMarkup; // declarationviewwindow.AddOverload (odatawMarkup == null ? odata.Description : odatawMarkup.DescriptionPango); //} } currentData = data; if (declarationviewwindow.DescriptionMarkup.Length == 0) { return; } int dvwWidth, dvwHeight; declarationviewwindow.Move(this.Screen.Width + 1, vert); declarationviewwindow.SetFixedWidth(-1); declarationviewwindow.ReshowWithInitialSize(); declarationviewwindow.ShowAll(); //declarationviewwindow.Multiple = (ccdata.Overloads != 0); declarationviewwindow.GdkWindow.GetSize(out dvwWidth, out dvwHeight); int horiz = listpos_x + lvWidth + declarationWindowMargin; if (this.Screen.Width - horiz >= lvWidth) { if (this.Screen.Width - horiz < dvwWidth) { declarationviewwindow.SetFixedWidth(this.Screen.Width - horiz); } } else { if (listpos_x - dvwWidth - declarationWindowMargin < 0) { declarationviewwindow.SetFixedWidth(listpos_x - declarationWindowMargin); dvwWidth = declarationviewwindow.SizeRequest().Width; } horiz = listpos_x - dvwWidth - declarationWindowMargin; } declarationviewwindow.Move(horiz, vert); }