Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Add an assembly reference
            var projectAssembly = leftEditor.Document.Language.GetProjectAssembly();

            if (projectAssembly != null)
            {
                projectAssembly.AssemblyReferences.AddMsCorLib();
            }

            // Use the default ambient highlighting style registry for the left editor
            var leftRegistry = AmbientHighlightingStyleRegistry.Instance;

            new DisplayItemClassificationTypeProvider(leftRegistry).RegisterAll();
            new DotNetClassificationTypeProvider(leftRegistry).RegisterAll();

            // Create a custom highlighting style registry for the right editor
            var rightRegistry = new HighlightingStyleRegistry();

            new DisplayItemClassificationTypeProvider(rightRegistry).RegisterAll();
            new DotNetClassificationTypeProvider(rightRegistry).RegisterAll();
            rightEditor.HighlightingStyleRegistry = rightRegistry;

            // Load a dark theme, which has some example pre-defined styles for some of the more common syntax languages
            string path = SyntaxEditorHelper.ThemesPath + "Dark.vssettings";

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path)) {
                if (stream != null)
                {
                    rightRegistry.ImportHighlightingStyles(stream);
                }
            }
        }
Exemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes the <c>CustomClassificationTagger</c> class.
        /// </summary>
        static CustomClassificationTagger()
        {
            // Create a custom IHighlightingStyleRegistry, meaning that the classification types defined
            //   in this sample and related styles will not be included in the AmbientHighlightingStyleRegistry...
            //   Normally the AmbientHighlightingStyleRegistry is used but in this sample we wanted to also show
            //   how you can use custom IHighlightingStyleRegistry instances with classification tags
            styleRegistry = new HighlightingStyleRegistry();
            styleRegistry.Register(commentCT, new HighlightingStyle(Colors.Green));
            styleRegistry.Register(errorCT, new HighlightingStyle(Colors.Maroon)
            {
                Bold = true
            });
        }
Exemplo n.º 3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Create a custom Console Window registry
            IHighlightingStyleRegistry consoleWindowRegistry = new HighlightingStyleRegistry();

            consoleWindowRegistry.Description = "Console Window";
            console.HighlightingStyleRegistry = consoleWindowRegistry;

            // Register the default display item classification types on the ambient and custom registries
            new DisplayItemClassificationTypeProvider().RegisterAll();
            new DisplayItemClassificationTypeProvider(consoleWindowRegistry).RegisterAll();

            // Populate the registry combobox
            registryComboBox.Items.Add(AmbientHighlightingStyleRegistry.Instance);
            registryComboBox.Items.Add(consoleWindowRegistry);
            registryComboBox.SelectedIndex = 0;
        }