internal static ImageSource GetImage(CompletionDataType completionDataType) { ImageSource image; Images.Value.TryGetValue(completionDataType, out image); return(image); }
/// <summary> /// Initializes a new instance of the <see cref="ResultVisualizer"/> class. /// </summary> /// <param name="result">Resulting object that should be visualized.</param> /// <param name="resultType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public ResultVisualizer(object result, Type resultType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) { this.result = result; this.resultType = resultType; this.interactiveResultVisualizer = interactiveResultVisualizer; Name = name; DataType = dataType; value = SimpleCache.Create(GetValue); typeString = SimpleCache.Create(GetTypeString); valueString = SimpleCache.Create(GetValueString); }
public CompletionData(CompletionDataType completionDataType, object content, double priority = 1, object description = null, string text = null) { CompletionDataType = completionDataType; Content = content; Priority = priority; Description = description ?? content; Text = text ?? content.ToString(); CompletionText = content.ToString(); DisplayText = Text; Image = GetImage(); }
/// <summary> /// Initializes a new instance of the <see cref="GroupResultVisualizer"/> class. /// </summary> /// <param name="name">Name of the variable / property.</param> /// <param name="children">Child elements and groups.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> public GroupResultVisualizer(string name, IEnumerable <IResultVisualizer> children, CompletionDataType dataType = CompletionDataType.Namespace) { Name = name; Children = children; DataType = dataType; }
/// <summary> /// Initializes a new instance of the <see cref="ObjectResultVisualizer"/> class. /// </summary> /// <param name="result">Resulting object that should be visualized.</param> /// <param name="resultType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public ObjectResultVisualizer(object result, Type resultType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) : base(result, resultType, name, dataType, interactiveResultVisualizer) { }
private static ImageSource CreateImage(CompletionDataType completionDataType) { try { using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream($"SharpDebug.UI.Icons.{completionDataType}.png")) { if (stream != null) { BitmapImage imageSource = new BitmapImage(); imageSource.BeginInit(); imageSource.StreamSource = stream; imageSource.EndInit(); return(imageSource); } } } catch { } string text; Brush textColor; switch (completionDataType) { default: case CompletionDataType.Unknown: return(null); //text = "🔒"; //textColor = Brushes.Black; //break; case CompletionDataType.Keyword: text = ""; textColor = Brushes.Black; break; case CompletionDataType.StaticProperty: text = "🔧"; textColor = Brushes.Black; break; case CompletionDataType.Property: text = "🔧"; textColor = Brushes.Gray; break; case CompletionDataType.Method: text = "🔶"; textColor = Brushes.DarkViolet; break; case CompletionDataType.StaticMethod: text = "🔶"; textColor = Brushes.Black; break; case CompletionDataType.Namespace: text = "⧛"; textColor = Brushes.Gray; break; case CompletionDataType.Variable: text = "🔲"; textColor = Brushes.Blue; break; case CompletionDataType.StaticVariable: text = "🔲"; textColor = Brushes.Black; break; case CompletionDataType.Class: text = "🎓"; textColor = Brushes.RosyBrown; break; case CompletionDataType.StaticClass: text = "🎓"; textColor = Brushes.Black; break; case CompletionDataType.Enum: text = ""; // textColor = Brushes.Yellow; break; case CompletionDataType.EnumValue: text = ""; // textColor = Brushes.Blue; break; case CompletionDataType.Event: text = "🔔"; // 🌠 textColor = Brushes.Blue; break; case CompletionDataType.StaticEvent: text = "🔔"; // 🌠 textColor = Brushes.Black; break; } return(CreateTextImage(text, textColor)); }
/// <summary> /// Initializes a new instance of the <see cref="VariableCollectionResultVisualizer"/> class. /// </summary> /// <param name="variableCollection">Variable collection to be visualized.</param> /// <param name="variableCollectionType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public VariableCollectionResultVisualizer(VariableCollection variableCollection, Type variableCollectionType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) : base(variableCollection, variableCollectionType, name, dataType, interactiveResultVisualizer) { this.variableCollection = variableCollection; }
/// <summary> /// Initializes a new instance of the <see cref="ArrayResultVisualizer"/> class. /// </summary> /// <param name="array">Array to be visualized.</param> /// <param name="arrayType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public ArrayResultVisualizer(Array array, Type arrayType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) : base(array, arrayType, name, dataType, interactiveResultVisualizer) { this.array = array; }
/// <summary> /// Initializes a new instance of the <see cref="VariableResultVisualizer"/> class. /// </summary> /// <param name="variable">Variable to be visualized.</param> /// <param name="variableType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public VariableResultVisualizer(Variable variable, Type variableType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) : base(variable, variableType, name, dataType, interactiveResultVisualizer) { this.variable = variable; try { extractUsingClasses = variable.GetCodeType().ClassFieldNames != null; } catch { extractUsingClasses = false; } }
/// <summary> /// Initializes a new instance of the <see cref="DictionaryResultVisualizer"/> class. /// </summary> /// <param name="dictionary">Dictionary to be visualized.</param> /// <param name="dictionaryType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> public DictionaryResultVisualizer(IDictionary dictionary, Type dictionaryType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer) : base(dictionary, dictionaryType, name, dataType, interactiveResultVisualizer) { this.dictionary = dictionary; }
/// <summary> /// Creates <see cref="IResultVisualizer"/> for resulting object. /// </summary> /// <param name="result">Resulting object that should be visualized.</param> /// <param name="resultType">Type of the resulting object that should be visualized.</param> /// <param name="name">Name of the variable / property.</param> /// <param name="dataType">Data type that will be used to generate icon of the variable / property</param> /// <param name="interactiveResultVisualizer">Interactive result visualizer that can be used for creating UI elements.</param> /// <param name="shouldForceDefaultVisualizer">Should we stop using our visualizers and try to force default visualizers? (<see cref="ForceDefaultVisualizerAtttribute"/>)</param> /// <returns>Instance of <see cref="IResultVisualizer"/> interface that can be used to visualize resulting object.</returns> public static IResultVisualizer Create(object result, Type resultType, string name, CompletionDataType dataType, InteractiveResultVisualizer interactiveResultVisualizer, bool shouldForceDefaultVisualizer = false) { ResultVisualizer resultVisualizer = null; if (result != null) { if (result.GetType().IsArray) { resultVisualizer = new ArrayResultVisualizer((Array)result, resultType, name, dataType, interactiveResultVisualizer); } else if (typeof(IDictionary).IsAssignableFrom(result.GetType())) { resultVisualizer = new DictionaryResultVisualizer((IDictionary)result, resultType, name, dataType, interactiveResultVisualizer); } else if (result.GetType() == typeof(Variable)) { resultVisualizer = new VariableResultVisualizer(((Variable)result).DowncastInterface(), resultType, name, dataType, interactiveResultVisualizer); } else if (result.GetType() == typeof(VariableCollection)) { resultVisualizer = new VariableCollectionResultVisualizer((VariableCollection)result, resultType, name, dataType, interactiveResultVisualizer); } } if (resultVisualizer == null) { resultVisualizer = new ObjectResultVisualizer(result, resultType, name, dataType, interactiveResultVisualizer); } resultVisualizer.ShouldForceDefaultVisualizer = shouldForceDefaultVisualizer; return(resultVisualizer); }
private static ImageSource CreateImage(CompletionDataType completionDataType) { string text; Brush textColor; switch (completionDataType) { default: case CompletionDataType.Unknown: return(null); //text = "🔒"; //textColor = Brushes.Black; //break; case CompletionDataType.Keyword: text = ""; textColor = Brushes.Black; break; case CompletionDataType.StaticProperty: text = "🔧"; textColor = Brushes.Black; break; case CompletionDataType.Property: text = "🔧"; textColor = Brushes.Gray; break; case CompletionDataType.Method: text = "🔶"; textColor = Brushes.DarkViolet; break; case CompletionDataType.StaticMethod: text = "🔶"; textColor = Brushes.Black; break; case CompletionDataType.Namespace: text = "⧛"; textColor = Brushes.Gray; break; case CompletionDataType.Variable: text = "🔲"; textColor = Brushes.Blue; break; case CompletionDataType.StaticVariable: text = "🔲"; textColor = Brushes.Black; break; case CompletionDataType.Class: text = "🎓"; textColor = Brushes.RosyBrown; break; case CompletionDataType.StaticClass: text = "🎓"; textColor = Brushes.Black; break; case CompletionDataType.Enum: text = ""; // textColor = Brushes.Yellow; break; case CompletionDataType.EnumValue: text = ""; // textColor = Brushes.Blue; break; case CompletionDataType.Event: text = "🔔"; // 🌠 textColor = Brushes.Blue; break; case CompletionDataType.StaticEvent: text = "🔔"; // 🌠 textColor = Brushes.Black; break; } return(CreateTextImage(text, textColor)); }