private static void AppendStyle(this StringBuilder sb, IHighlightingStyle highlightingStyle)
 {
     sb.AppendColor(@"background-color", highlightingStyle.Background);
     sb.AppendColor(@"color", highlightingStyle.Foreground);
     sb.AppendFontFamiliy(@"font-family", highlightingStyle.FontFamilyName);
     sb.AppendFontSize(@"font-size", highlightingStyle.FontSize);
     sb.AppendFontWeight(@"font-weight", highlightingStyle.Bold);
     sb.AppendFontStyle(@"font-style", highlightingStyle.Italic);
     sb.AppendTextDecoration(@"text-decoration", highlightingStyle.UnderlineStyle);
 }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when a property is changed that needs to refresh the control.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> whose property is changed.</param>
        /// <param name="e">A <see cref="DependencyPropertyChangedEventArgs"/> that contains the event data.</param>
        private static void OnPropertyChangedForRefresh(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            HighlightingStyleEditor control = (HighlightingStyleEditor)obj;

            // Get the style to edit
            IHighlightingStyle style = null;

            if ((control.ClassificationType != null) && (control.HighlightingStyleRegistry != null))
            {
                style = control.HighlightingStyleRegistry[control.ClassificationType];
            }

            // Update the data context
            control.DataContext = style;
        }
Example #3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

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

            // Load a language from a language definition
            editor.Document.Language = ActiproSoftware.ProductSamples.SyntaxEditorSamples.Common.SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("Css.langdef");

            // Register the default display item classification types on the ambient registry
            DisplayItemClassificationTypeProvider provider = new DisplayItemClassificationTypeProvider();

            provider.RegisterAll();

            // Get the syle for the current line and bind it to the edit box
            IHighlightingStyle style        = AmbientHighlightingStyleRegistry.Instance[provider.CurrentLine];
            Binding            valueBinding = new Binding();

            valueBinding.Source = style;
            valueBinding.Path   = new PropertyPath("Background");
            valueBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            colorEditbox.SetBinding(ColorEditBox.ValueProperty, valueBinding);
        }