Example #1
0
        internal static ImageSource GetImage(CompletionDataType completionDataType)
        {
            ImageSource image;

            Images.Value.TryGetValue(completionDataType, out image);
            return(image);
        }
Example #2
0
 /// <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);
 }
Example #3
0
 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;
 }
Example #5
0
 /// <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)
 {
 }
Example #6
0
        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));
        }
Example #7
0
 /// <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;
 }
Example #8
0
 /// <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;
 }
Example #9
0
 /// <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;
     }
 }
Example #10
0
 /// <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;
 }
Example #11
0
        /// <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);
        }
Example #12
0
        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));
        }