I think you can make your colors customisable without providing a custom OptionsPage.
You can Export your own colors and they will became configurable from Tools-Options-Fonts and Colors
By your linked example:
[Export(typeof(EditorFormatDefinition))]
[Name("EditorFormatDefinition/MyCustomFormatDefinition")]
[UserVisible(true)]
internal class CustomFormatDefinition : EditorFormatDefinition
{
public CustomFormatDefinition( )
{
this.BackgroundColor = Colors.LightPink;
this.ForegroundColor = Colors.DarkBlue;
this.DisplayName = "My Cusotum Editor Format";
}
}
[Export(typeof(EditorFormatDefinition))]
[Name("EditorFormatDefinition/MyCustomFormatDefinition2")]
[UserVisible(true)]
internal class CustomFormatDefinition2 : EditorFormatDefinition
{
public CustomFormatDefinition2( )
{
this.BackgroundColor = Colors.DeepPink;
this.ForegroundColor = Colors.DarkBlue;
this.DisplayName = "My Cusotum Editor Format 2";
}
}
[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
[TextViewRole(PredefinedTextViewRoles.Document)]
internal class TestViewCreationListener : IWpfTextViewCreationListener
{
[Import]
internal IEditorFormatMapService FormatMapService = null;
public void TextViewCreated( IWpfTextView textView )
{
IEditorFormatMap formatMap = FormatMapService.GetEditorFormatMap(textView);
ResourceDictionary selectedText = formatMap.GetProperties("Selected Text");
ResourceDictionary inactiveSelectedText = formatMap.GetProperties("Inactive Selected Text");
ResourceDictionary myCustom = formatMap.GetProperties("EditorFormatDefinition/MyCustomFormatDefinition");
ResourceDictionary myCustom2 = formatMap.GetProperties("EditorFormatDefinition/MyCustomFormatDefinition2");
formatMap.BeginBatchUpdate();
selectedText[EditorFormatDefinition.BackgroundBrushId] = myCustom[EditorFormatDefinition.BackgroundBrushId];
formatMap.SetProperties("Selected Text", selectedText);
inactiveSelectedText[EditorFormatDefinition.BackgroundBrushId] = myCustom2[EditorFormatDefinition.BackgroundBrushId];
formatMap.SetProperties("Inactive Selected Text", myCustom2);
formatMap.EndBatchUpdate();
}
}
Custom EFDs can provide SolidColorBrush
es.
If this isn't enought, you can also access to the service provider used by VSPackages. You can make a package for the option page, and communicate with the Editor Extension through the service provider with a custom service.
You can import the service provider like this:
[Import]
internal SVsServiceProvider serviceProvider = null;
This soulution also doesn't require from you to migrate the original logic, only the creation of an additional package.