本文整理汇总了C#中System.Windows.Media.Brush类的典型用法代码示例。如果您正苦于以下问题:C# Brush类的具体用法?C# Brush怎么用?C# Brush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Brush类属于System.Windows.Media命名空间,在下文中一共展示了Brush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawChanges
private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
{
if (changes.Count > 0)
{
double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;
for (int i = 1; i < changes.Count; ++i)
{
double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
if (yBottom < y)
{
drawingContext.DrawRectangle(
brush,
null,
new Rect(0, yTop, markerWidth, yBottom - yTop));
yTop = y;
}
yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
}
drawingContext.DrawRectangle(
brush,
null,
new Rect(0, yTop, markerWidth, yBottom - yTop));
}
}
示例2: GetBrush
internal static Brush GetBrush(this ResourceDictionary dictionary, string brushName, string colorName, Brush defaultBrush)
{
if (dictionary == null)
{
return defaultBrush;
}
var obj = dictionary[brushName];
if (obj is Brush)
{
return (Brush)obj;
}
obj = dictionary[colorName];
if (obj is Color?)
{
var color = (Color?)obj;
if (color.HasValue)
{
var brush = new SolidColorBrush(color.Value);
brush.Freeze();
return brush;
}
}
return defaultBrush;
}
示例3: CreateAndAddAdornment
void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
{
var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);
double left = 0;
double width = _view.ViewportWidth + _view.MaxTextRightCoordinate;
if (markerGeometry != null)
{
left = markerGeometry.Bounds.Left;
if (!extendToRight) width = markerGeometry.Bounds.Width;
}
Rect rect = new Rect(left, line.Top, width, line.Height);
RectangleGeometry geometry = new RectangleGeometry(rect);
GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
Canvas.SetLeft(image, geometry.Bounds.Left);
Canvas.SetTop(image, geometry.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
}
示例4: BottomMargin
public BottomMargin(IWpfTextView textView, IClassifierAggregatorService classifier, ITextDocumentFactoryService documentService)
{
_textView = textView;
_classifier = classifier.GetClassifier(textView.TextBuffer);
_foregroundBrush = new SolidColorBrush((Color)FindResource(VsColors.CaptionTextKey));
_backgroundBrush = new SolidColorBrush((Color)FindResource(VsColors.ScrollBarBackgroundKey));
this.Background = _backgroundBrush;
this.ClipToBounds = true;
_lblEncoding = new TextControl("Encoding");
this.Children.Add(_lblEncoding);
_lblContentType = new TextControl("Content type");
this.Children.Add(_lblContentType);
_lblClassification = new TextControl("Classification");
this.Children.Add(_lblClassification);
_lblSelection = new TextControl("Selection");
this.Children.Add(_lblSelection);
UpdateClassificationLabel();
UpdateContentTypeLabel();
UpdateContentSelectionLabel();
if (documentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _doc))
{
_doc.FileActionOccurred += FileChangedOnDisk;
UpdateEncodingLabel(_doc);
}
textView.Caret.PositionChanged += CaretPositionChanged;
}
示例5: Draw
public static void Draw(Canvas canvas, List<LinePoint> points, Brush stroke, bool clear = true)
{
if (clear)
{
canvas.Children.Clear();
}
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
PathGeometry myPathGeometry = new PathGeometry();
foreach (LinePoint p in points)
{
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = p.StartPoint;
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = p.EndPoint;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentCollection;
myPathFigureCollection.Add(myPathFigure);
}
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = stroke == null ? Brushes.Black : stroke;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
canvas.Children.Add(myPath);
}
示例6: PkgCreateWin
public PkgCreateWin()
{
InitializeComponent();
EnabledColor = SnapshotBtn.Foreground;
DisabledColor = new SolidColorBrush(System.Windows.Media.Colors.LightGray);
SetUiMode(UiMode.WaitingForFile);
}
示例7: Match
public InlineLink Match(String word, Brush lBrush, IStatusUpdate oStatusUpdate)
{
if (word == null) return null;
bool result = _websymbols.AsParallel().Any(p => p.Key == word.ToLower());
if (!result) return null;
return _textProcessorEngine.WebSymbolHelper(_websymbols[word.ToLower()], word);
}
示例8: DrawBorderStroke
private void DrawBorderStroke(PdfRenderContext context, Thickness thickness, Brush stroke, double actualWidth, double actualHeight)
{
if (stroke == null)
{
return;
}
if (thickness.Left != 0)
{
LineRenderer.DrawLine(context, thickness.Left / 2, 0, thickness.Left / 2, actualHeight, thickness.Left, stroke, null);
}
if (thickness.Top != 0)
{
LineRenderer.DrawLine(context, 0, thickness.Top / 2, actualWidth, thickness.Top / 2, thickness.Top, stroke, null);
}
if (thickness.Right != 0)
{
double x = actualWidth - (thickness.Right / 2);
LineRenderer.DrawLine(context, x, 0, x, actualHeight, thickness.Right, stroke, null);
}
if (thickness.Bottom != 0)
{
double y = actualHeight - (thickness.Bottom / 2);
LineRenderer.DrawLine(context, 0, y, actualWidth, y, thickness.Bottom, stroke, null);
}
}
示例9: ProjectielVanMonsterkeNaarLinks
public ProjectielVanMonsterkeNaarLinks(ISpel spel, Point startpunt, Brush brush)
: base(brush)
{
Spel = spel;
Locatie = startpunt;
_gestopt = false;
}
示例10: CPlayer
public CPlayer(int _row, int _column, bool _state, Brush _color)
{
Row = _row;
Column = _column;
State = _state;
ColorPlayer = _color;
}
示例11: AddVisualText
public void AddVisualText(String text, String name_of_element, FontFamily fontFamily, Double fontSize, Point location, Double rotateAngle, Brush brush)
{
Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
DrawingContext dc;
DrawingVisual dv = new DrawingVisual();
FormattedText ft1 = new FormattedText(text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, brush);
if (location.X == -1)
{
location = new Point(this.Width / 2 - ft1.Width / 2, location.Y);
}
if (location.Y == -1)
{
location = new Point(location.X, this.Height / 2 - ft1.Height / 2);
}
RotateTransform rt = new RotateTransform(rotateAngle, location.X + ft1.Width / 2, location.Y + ft1.Height / 2);
dc = dv.RenderOpen();
dc.PushTransform(rt);
dc.DrawText(ft1, location);
dc.Close();
this.visuals.Add(new NamedVisual(name_of_element, dv));
this.AddVisualChild(dv);
}
示例12: LessThanColorConverter
private LessThanColorConverter()
{
this.okBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CC7DBEDA"));
this.okBrush.Freeze();
this.notOkBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#B3CD6969"));
this.notOkBrush.Freeze();
}
示例13: DrawEllipse
//public void DrawDrawing(Drawing drawing);
public void DrawEllipse(Brush brush, Pen pen, Point center, double radiusX, double radiusY)
{
Ellipse ellipse = new Ellipse();
SetupShape(ellipse, center.X - radiusX, center.Y - radiusY, radiusX * 2, radiusY * 2, brush, pen);
ellipse.Fill = brush;
_canvas.Children.Add(ellipse);
}
示例14: GetImage
public static RenderTargetBitmap GetImage(UIElement fe, Brush background = null, Size sz = default(Size), int dpi = 144)
{
if (sz.Width < alib.Math.math.ε || sz.Height < alib.Math.math.ε)
{
fe.Measure(util.infinite_size);
sz = fe.DesiredSize; //VisualTreeHelper.GetContentBounds(fe).Size; //
}
DrawingVisual dv = new DrawingVisual();
RenderOptions.SetEdgeMode(dv, EdgeMode.Aliased);
using (DrawingContext ctx = dv.RenderOpen())
{
Rect r = new Rect(0, 0, sz.Width, sz.Height);
if (background != null)
ctx.DrawRectangle(background, null, r);
VisualBrush br = new VisualBrush(fe);
br.AutoLayoutContent = true;
ctx.DrawRectangle(br, null, r);
}
Double f = dpi / 96.0;
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)(sz.Width * f) + 1,
(int)(sz.Height * f) + 1,
dpi,
dpi,
PixelFormats.Pbgra32);
bitmap.Render(dv);
return bitmap;
}
示例15: DurationBGColorConverter
private DurationBGColorConverter()
{
this.defaultBrush = Brushes.Transparent;
this.defaultBrush.Freeze();
this.lessHoursPerDayBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#B3CD6969"));
this.lessHoursPerDayBrush.Freeze();
}