コード例 #1
0
        public UIElement GetUIElement(Completion itemToRender, ICompletionSession context, UIElementType elementType)
        {
            GLSLCompletion completion = itemToRender as GLSLCompletion;

            if (completion != null)
            {
                return(completion.TextBlock);
            }

            if (elementType == UIElementType.Tooltip)
            {
                return(new TextBlock(new Run(itemToRender.Description)));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: GLSLCompletionSource.cs プロジェクト: Xannden/VGLSL
        internal static void LoadDefaultCompletions(IGlyphService glyphService, IClassificationFormatMapService formatMapService, IClassificationTypeRegistryService typeRegistry)
        {
            IClassificationFormatMap formatMap = formatMapService.GetClassificationFormatMap("text");

            ImageSource keywordIcon = glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic);

            for (SyntaxType syntaxType = SyntaxType.AttributeKeyword; syntaxType <= SyntaxType.LinePreprocessorKeyword; syntaxType++)
            {
                string text = syntaxType.GetText();

                TextBlock textBlock = new TextBlock();

                if (syntaxType.IsPreprocessor())
                {
                    textBlock.Inlines.Add(text.ToRun(formatMap, typeRegistry.GetClassificationType(GLSLConstants.PreprocessorKeyword)));
                }
                else
                {
                    textBlock.Inlines.Add(text.ToRun(formatMap, typeRegistry.GetClassificationType(GLSLConstants.Keyword)));
                }

                textBlock.Inlines.Add(new Run(" Keyword"));

                keywords.Add(new GLSLCompletion(textBlock, text, text + "Keyword", keywordIcon));
            }

            for (int j = 1; j <= 32; j *= 2)
            {
                builtIn.Add((ShaderType)j, new List <Completion>());
            }

            foreach (List <Definition> definitions in BuiltInData.Instance.Definitions.Values)
            {
                for (int i = 0; i < definitions.Count; i++)
                {
                    GLSLCompletion completion = new GLSLCompletion(definitions[i].ToTextBlock(formatMap, typeRegistry, definitions.Count), definitions[i], definitions[i].GetImageSource(glyphService));

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Compute))
                    {
                        builtIn[ShaderType.Compute].Add(completion);
                    }

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Vertex))
                    {
                        builtIn[ShaderType.Vertex].Add(completion);
                    }

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Geometry))
                    {
                        builtIn[ShaderType.Geometry].Add(completion);
                    }

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.TessellationControl))
                    {
                        builtIn[ShaderType.TessellationControl].Add(completion);
                    }

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.TessellationEvaluation))
                    {
                        builtIn[ShaderType.TessellationEvaluation].Add(completion);
                    }

                    if (definitions[i].ShaderType.HasFlag <ShaderType>(ShaderType.Fragment))
                    {
                        builtIn[ShaderType.Fragment].Add(completion);
                    }
                }
            }
        }