public override Innovator.Client.IPromise <CompletionContext> ShowCompletions(EditorWinForm control) { var length = control.Editor.Document.TextLength; var caret = control.Editor.CaretOffset; var data = new CompletionContext(); if (caret > 0 && control.Editor.Document.GetCharAt(caret - 1) == '\\') { data.Items = _completionInfo .OrderBy(i => i[0].ToLowerInvariant()) .ThenBy(i => i[1]) .Select(i => new BasicCompletionData() { Content = FormatText.Span(FormatText.Text(i[0] + " "), FormatText.MutedText(i[1])), Text = i[0], Action = () => i[0] }); } if (data.Items.Any()) { var items = data.Items.ToArray(); var contextItems = items.OfType <IContextCompletions>(); foreach (var contextItem in contextItems) { contextItem.SetContext(this, control); } control.ShowCompletionWindow(items, data.Overlap); } return(Promises.Resolved(data)); }
public static object Documentation(OperationElement documentation, string type) { if (documentation == null) { return(null); } return(FormatText.Invoke(() => { var block = new TextBlock() { TextWrapping = TextWrapping.Wrap }; block.Inlines.Add(new Run(type + " ") { Foreground = Brushes.Gray }); block.Inlines.Add(new Run(documentation.Name) { FontWeight = FontWeight.FromOpenTypeWeight(700) }); if (documentation.ValueTypes.Any(t => t.Type != AmlDataType.Unknown)) { block.Inlines.Add(new Run(": ")); block.Inlines.Add(new Run(string.Join("|", documentation.ValueTypes .Where(t => t.Type != AmlDataType.Unknown) .Select(v => { var typeString = v.Type.ToString(); typeString = typeString.Substring(0, 1).ToLowerInvariant() + typeString.Substring(1); if (!string.IsNullOrEmpty(v.Source)) { typeString += "[" + v.Source + "]"; } else if (v.Values.Any()) { typeString += "[" + string.Join("|", v.Values) + "]"; } return typeString; }))) { Foreground = Brushes.Blue }); } var visitor = new TooltipElementVisitor(); var content = new List <DependencyObject>() { block }; content.AddRange(documentation.Summary .Select(e => e.Visit(visitor)) .ToList()); return visitor.GetBlock(content); })); }
public static object Documentation(AmlDocumentation documentation, string type) { if (documentation == null) { return(null); } return(FormatText.Invoke(() => { var block = new TextBlock() { TextWrapping = TextWrapping.Wrap }; block.Inlines.Add(new Run(type + " ") { Foreground = Brushes.Gray }); block.Inlines.Add(new Run(documentation.Name) { FontWeight = FontWeight.FromOpenTypeWeight(700) }); if (documentation.ValueTypes.Any(t => t.Type != AmlDataType.Unknown)) { block.Inlines.Add(new Run(": ")); block.Inlines.Add(new Run(string.Join("|", documentation.ValueTypes .Where(t => t.Type != AmlDataType.Unknown) .Select(v => { var typeString = v.Type.ToString(); typeString = typeString.Substring(0, 1).ToLowerInvariant() + typeString.Substring(1); if (!string.IsNullOrEmpty(v.Source)) { typeString += "[" + v.Source + "]"; } else if (v.Values.Any()) { typeString += "[" + string.Join("|", v.Values) + "]"; } return typeString; }))) { Foreground = Brushes.Blue }); } if (!string.IsNullOrEmpty(documentation.Summary)) { block.Inlines.Add(new LineBreak()); block.Inlines.Add(new Run(documentation.Summary)); } return block; })); }
public static object ItemType(ItemType itemType) { if (itemType == null) { return(null); } return(FormatText.Invoke(() => { var block = new TextBlock() { TextWrapping = TextWrapping.Wrap }; var typeName = "itemtype"; if (itemType.IsPolymorphic) { typeName = "poly item"; } else if (itemType.IsRelationship) { typeName = "relationship"; } block.Inlines.Add(new Run(typeName + " ") { Foreground = Brushes.Gray }); block.Inlines.Add(new Run(itemType.Name) { FontWeight = FontWeight.FromOpenTypeWeight(700) }); if (!string.IsNullOrEmpty(itemType.Label ?? itemType.TabLabel)) { block.Inlines.Add(new Run(" (" + (itemType.Label ?? itemType.TabLabel) + ")")); } if (itemType.IsRelationship) { block.Inlines.Add(new Run(": ")); block.Inlines.Add(new Run((itemType.SourceTypeName ?? "null") + " -> " + (itemType.RelatedTypeName ?? "null")) { Foreground = Brushes.Blue }); } if (!string.IsNullOrEmpty(itemType.Description)) { block.Inlines.Add(new LineBreak()); block.Inlines.Add(new Run(itemType.Description)); } return block; })); }
protected virtual BasicCompletionData ConfigureLabeledProperty(BasicCompletionData data, IListValue prop) { var label = prop.Label + " (" + prop.Value + ")"; data.Text = label; data.Description = Tooltips.Property(prop as Property); data.Content = FormatText.MutedText(label); data.Image = Icons.Property16.Wpf; var insertValue = prop.Value; if (_insertion != null) { insertValue = _insertion(prop.Value); } data.Action = () => insertValue; return(data); }
public static object Property(Property property) { if (property == null) { return(null); } return(FormatText.Invoke(() => { var block = new TextBlock() { TextWrapping = TextWrapping.Wrap }; block.Inlines.Add(new Run("property ") { Foreground = Brushes.Gray }); block.Inlines.Add(new Run(property.Name) { FontWeight = FontWeight.FromOpenTypeWeight(700) }); if (!string.IsNullOrEmpty(property.Label)) { block.Inlines.Add(new Run(" (" + property.Label + ")")); } block.Inlines.Add(new Run(": ")); block.Inlines.Add(new Run(property.TypeDisplay()) { Foreground = Brushes.Blue }); if (!string.IsNullOrEmpty(property.Description)) { block.Inlines.Add(new LineBreak()); block.Inlines.Add(new Run(property.Description)); } return block; })); }