Ответ 1
Я думаю, вы можете настроить свои цвета без предоставления настраиваемых параметров. Вы можете экспортировать свои собственные цвета, и они станут настраиваемыми с Tools - Options - Fonts and Colors
По вашему связанному примеру:
[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();
}
}
Пользовательские EFD могут предоставить SolidColorBrush
es.
Если этого недостаточно, вы также можете обратиться к поставщику услуг, используемому VSPackages. Вы можете сделать пакет для страницы параметров и связаться с редактором Extension через поставщика услуг с помощью настраиваемой службы.
Вы можете импортировать поставщика услуг следующим образом:
[Import]
internal SVsServiceProvider serviceProvider = null;
Эта душа также не требует от вас переноса исходной логики, только создание дополнительного пакета.