本文整理汇总了C#中TextEditor.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ClearValue方法的具体用法?C# TextEditor.ClearValue怎么用?C# TextEditor.ClearValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor.ClearValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyCustomizationsToDefaultElements
public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations)
{
textEditor.ClearValue(TextEditor.BackgroundProperty);
textEditor.ClearValue(TextEditor.ForegroundProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBorderProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBrushProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionForegroundProperty);
bool assignedDefaultText = false;
bool assignedSelectedText = false;
foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) {
case DefaultTextAndBackground:
if (assignedDefaultText)
continue;
assignedDefaultText = true;
if (color.Background != null)
textEditor.Background = CreateFrozenBrush(color.Background.Value);
if (color.Foreground != null)
textEditor.Foreground = CreateFrozenBrush(color.Foreground.Value);
break;
case SelectedText:
if (assignedSelectedText)
continue;
assignedSelectedText = true;
if (color.Background != null) {
Pen pen = new Pen(CreateFrozenBrush(color.Background.Value), 1);
pen.Freeze();
textEditor.TextArea.SelectionBorder = pen;
SolidColorBrush back = new SolidColorBrush(color.Background.Value);
back.Opacity = 0.7;
back.Freeze();
textEditor.TextArea.SelectionBrush = back;
}
if (color.Foreground != null) {
textEditor.TextArea.SelectionForeground = CreateFrozenBrush(color.Foreground.Value);
}
break;
}
}
}
示例2: ApplyToFolding
public static void ApplyToFolding(TextEditor editor, IEnumerable<CustomizedHighlightingColor> customisations)
{
bool assignedFoldingMarker = false, assignedSelectedFoldingControls = false, assignedFoldingTextMarkers = false;
editor.ClearValue(FoldingMargin.FoldingMarkerBrushProperty);
editor.ClearValue(FoldingMargin.FoldingMarkerBackgroundBrushProperty);
editor.ClearValue(FoldingMargin.SelectedFoldingMarkerBrushProperty);
editor.ClearValue(FoldingMargin.SelectedFoldingMarkerBackgroundBrushProperty);
FoldingElementGenerator.TextBrush = FoldingElementGenerator.DefaultTextBrush;
foreach (CustomizedHighlightingColor color in customisations) {
switch (color.Name) {
case FoldingControls:
if (assignedFoldingMarker)
continue;
assignedFoldingMarker = true;
if (color.Foreground != null)
editor.SetValue(FoldingMargin.FoldingMarkerBrushProperty, CreateFrozenBrush(color.Foreground.Value));
if (color.Background != null)
editor.SetValue(FoldingMargin.FoldingMarkerBackgroundBrushProperty, CreateFrozenBrush(color.Background.Value));
break;
case FoldingSelectedControls:
if (assignedSelectedFoldingControls)
continue;
assignedSelectedFoldingControls = true;
if (color.Foreground != null)
editor.SetValue(FoldingMargin.SelectedFoldingMarkerBrushProperty, CreateFrozenBrush(color.Foreground.Value));
if (color.Background != null)
editor.SetValue(FoldingMargin.SelectedFoldingMarkerBackgroundBrushProperty, CreateFrozenBrush(color.Background.Value));
break;
case FoldingTextMarkers:
if (assignedFoldingTextMarkers)
continue;
assignedFoldingTextMarkers = true;
if (color.Foreground != null)
FoldingElementGenerator.TextBrush = CreateFrozenBrush(color.Foreground.Value);
break;
}
}
}
示例3: ApplyCustomizationsToDefaultElements
public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations)
{
textEditor.ClearValue(TextEditor.BackgroundProperty);
textEditor.ClearValue(TextEditor.ForegroundProperty);
textEditor.ClearValue(TextEditor.LineNumbersForegroundProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBorderProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBrushProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionForegroundProperty);
textEditor.TextArea.TextView.ClearValue(TextView.NonPrintableCharacterBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextForegroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextBackgroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.ColumnRulerPenProperty);
// 'assigned' flags are used so that the first matching customization wins.
// This is necessary because more specific customizations come first in the list
// (language-specific customizations are first, followed by 'all languages' customizations)
bool assignedDefaultText = false;
bool assignedSelectedText = false;
bool assignedNonPrintableCharacter = false;
bool assignedLineNumbers = false;
bool assignedLinkText = false;
bool assignedColumnRulerColor = false;
foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) {
case DefaultTextAndBackground:
if (assignedDefaultText)
continue;
assignedDefaultText = true;
if (color.Background != null)
textEditor.Background = CreateFrozenBrush(color.Background.Value);
if (color.Foreground != null)
textEditor.Foreground = CreateFrozenBrush(color.Foreground.Value);
break;
case SelectedText:
if (assignedSelectedText)
continue;
assignedSelectedText = true;
if (color.Background != null) {
Pen pen = new Pen(CreateFrozenBrush(color.Background.Value), 1);
pen.Freeze();
textEditor.TextArea.SelectionBorder = pen;
SolidColorBrush back = new SolidColorBrush(color.Background.Value);
back.Opacity = 0.7; // TODO : remove this constant, let the use choose the opacity.
back.Freeze();
textEditor.TextArea.SelectionBrush = back;
}
if (color.Foreground != null) {
textEditor.TextArea.SelectionForeground = CreateFrozenBrush(color.Foreground.Value);
}
break;
case NonPrintableCharacters:
if (assignedNonPrintableCharacter)
continue;
assignedNonPrintableCharacter = true;
if (color.Foreground != null)
textEditor.TextArea.TextView.NonPrintableCharacterBrush = CreateFrozenBrush(color.Foreground.Value);
break;
case LineNumbers:
if (assignedLineNumbers)
continue;
assignedLineNumbers = true;
if (color.Foreground != null)
textEditor.LineNumbersForeground = CreateFrozenBrush(color.Foreground.Value);
break;
case LinkText:
if (assignedLinkText)
continue;
assignedLinkText = true;
if (color.Foreground != null)
textEditor.TextArea.TextView.LinkTextForegroundBrush = CreateFrozenBrush(color.Foreground.Value);
if (color.Background != null)
textEditor.TextArea.TextView.LinkTextBackgroundBrush = CreateFrozenBrush(color.Background.Value);
break;
case ColumnRuler:
if (assignedColumnRulerColor)
continue;
assignedColumnRulerColor = true;
if (color.Foreground != null)
textEditor.TextArea.TextView.ColumnRulerPen = CreateFrozenPen(color.Foreground.Value);
break;
}
}
}
示例4: ApplyCustomizationsToDefaultElements
public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations)
{
textEditor.ClearValue(TextEditor.BackgroundProperty);
textEditor.ClearValue(TextEditor.ForegroundProperty);
textEditor.ClearValue(TextEditor.LineNumbersForegroundProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBorderProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionBrushProperty);
textEditor.TextArea.ClearValue(TextArea.SelectionForegroundProperty);
textEditor.TextArea.TextView.ClearValue(TextView.NonPrintableCharacterBrushProperty);
bool assignedDefaultText = false;
bool assignedSelectedText = false;
bool assignedNonPrintableCharacter = false;
bool assignedLineNumbers = false;
foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) {
case DefaultTextAndBackground:
if (assignedDefaultText)
continue;
assignedDefaultText = true;
if (color.Background != null)
textEditor.Background = CreateFrozenBrush(color.Background.Value);
if (color.Foreground != null)
textEditor.Foreground = CreateFrozenBrush(color.Foreground.Value);
break;
case SelectedText:
if (assignedSelectedText)
continue;
assignedSelectedText = true;
if (color.Background != null) {
Pen pen = new Pen(CreateFrozenBrush(color.Background.Value), 1);
pen.Freeze();
textEditor.TextArea.SelectionBorder = pen;
SolidColorBrush back = new SolidColorBrush(color.Background.Value);
back.Opacity = 0.7; // TODO : remove this constant, let the use choose the opacity.
back.Freeze();
textEditor.TextArea.SelectionBrush = back;
}
if (color.Foreground != null) {
textEditor.TextArea.SelectionForeground = CreateFrozenBrush(color.Foreground.Value);
}
break;
case NonPrintableCharacters:
if (assignedNonPrintableCharacter)
continue;
assignedNonPrintableCharacter = true;
if (color.Foreground != null)
textEditor.TextArea.TextView.NonPrintableCharacterBrush = CreateFrozenBrush(color.Foreground.Value);
break;
case LineNumbers:
if (assignedLineNumbers)
continue;
assignedLineNumbers = true;
if (color.Foreground != null)
textEditor.LineNumbersForeground = CreateFrozenBrush(color.Foreground.Value);
break;
}
}
}
示例5: ApplyToRendering
public static void ApplyToRendering(TextEditor editor, IEnumerable<CustomizedHighlightingColor> customisations)
{
bool assignedFoldingMarker = false, assignedSelectedFoldingControls = false, assignedFoldingTextMarkers = false;
editor.ClearValue(FoldingMargin.FoldingMarkerBrushProperty);
editor.ClearValue(FoldingMargin.FoldingMarkerBackgroundBrushProperty);
editor.ClearValue(FoldingMargin.SelectedFoldingMarkerBrushProperty);
editor.ClearValue(FoldingMargin.SelectedFoldingMarkerBackgroundBrushProperty);
FoldingElementGenerator.TextBrush = FoldingElementGenerator.DefaultTextBrush;
bool assignedErrorColor = false;
bool assignedWarningColor = false;
bool assignedMessageColor = false;
foreach (var instance in ErrorPainter.Instances) {
instance.ErrorColor = Colors.Red;
instance.WarningColor = Colors.Orange;
instance.MessageColor = Colors.Blue;
}
foreach (CustomizedHighlightingColor color in customisations) {
switch (color.Name) {
case FoldingControls:
if (assignedFoldingMarker)
continue;
assignedFoldingMarker = true;
if (color.Foreground != null)
editor.SetValue(FoldingMargin.FoldingMarkerBrushProperty,
CreateFrozenBrush(color.Foreground.Value));
if (color.Background != null)
editor.SetValue(FoldingMargin.FoldingMarkerBackgroundBrushProperty,
CreateFrozenBrush(color.Background.Value));
break;
case FoldingSelectedControls:
if (assignedSelectedFoldingControls)
continue;
assignedSelectedFoldingControls = true;
if (color.Foreground != null)
editor.SetValue(FoldingMargin.SelectedFoldingMarkerBrushProperty,
CreateFrozenBrush(color.Foreground.Value));
if (color.Background != null)
editor.SetValue(FoldingMargin.SelectedFoldingMarkerBackgroundBrushProperty,
CreateFrozenBrush(color.Background.Value));
break;
case FoldingTextMarkers:
if (assignedFoldingTextMarkers)
continue;
assignedFoldingTextMarkers = true;
if (color.Foreground != null)
FoldingElementGenerator.TextBrush = CreateFrozenBrush(color.Foreground.Value);
break;
case ErrorPainter.ErrorColorName:
if (assignedErrorColor)
continue;
assignedErrorColor = true;
if (color.Foreground != null) {
foreach (var instance in ErrorPainter.Instances) {
instance.ErrorColor = color.Foreground.Value;
}
}
break;
case ErrorPainter.WarningColorName:
if (assignedWarningColor)
continue;
assignedWarningColor = true;
if (color.Foreground != null) {
foreach (var instance in ErrorPainter.Instances) {
instance.WarningColor = color.Foreground.Value;
}
}
break;
case ErrorPainter.MessageColorName:
if (assignedMessageColor)
continue;
assignedMessageColor = true;
if (color.Foreground != null) {
foreach (var instance in ErrorPainter.Instances) {
instance.MessageColor = color.Foreground.Value;
}
}
break;
}
}
}