當前位置: 首頁>>代碼示例>>C#>>正文


C# Media.Brush類代碼示例

本文整理匯總了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));
			}
		}
開發者ID:jburrow,項目名稱:progressive-scroll,代碼行數:29,代碼來源:ChangeRenderer.cs

示例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;
        }
開發者ID:bordev,項目名稱:EasyMotion,代碼行數:27,代碼來源:Extensions.cs

示例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);
        }
開發者ID:ijprest,項目名稱:BackgroundColorFix,代碼行數:30,代碼來源:BackgroundColorVisualManager.cs

示例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;
        }
開發者ID:modulexcite,項目名稱:ExtensibilityTools,代碼行數:34,代碼來源:BottomMargin.cs

示例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);
        }
開發者ID:Eddie104,項目名稱:Libra-CSharp,代碼行數:34,代碼來源:GraphicsHelper.cs

示例6: PkgCreateWin

 public PkgCreateWin()
 {
     InitializeComponent();
     EnabledColor = SnapshotBtn.Foreground;
     DisabledColor =  new SolidColorBrush(System.Windows.Media.Colors.LightGray);
     SetUiMode(UiMode.WaitingForFile);
 }
開發者ID:vaginessa,項目名稱:cameyo,代碼行數:7,代碼來源:PkgCreateWin.xaml.cs

示例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);
 }
開發者ID:nickhodge,項目名稱:MahTweets.LawrenceHargrave,代碼行數:7,代碼來源:Websymbolify.cs

示例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);
            }
        }
開發者ID:abererk,項目名稱:xaml-sdk,代碼行數:26,代碼來源:BorderRenderer.cs

示例9: ProjectielVanMonsterkeNaarLinks

 public ProjectielVanMonsterkeNaarLinks(ISpel spel, Point startpunt, Brush brush)
     : base(brush)
 {
     Spel = spel;
     Locatie = startpunt;
     _gestopt = false;
 }
開發者ID:W0dan,項目名稱:SenneGame,代碼行數:7,代碼來源:ProjectielVanMonsterkeNaarLinks.cs

示例10: CPlayer

 public CPlayer(int _row, int _column, bool _state, Brush _color)
 {
     Row = _row;
     Column = _column;
     State = _state;
     ColorPlayer = _color;
 }
開發者ID:haandang,項目名稱:1312179_Gomoku,代碼行數:7,代碼來源:CPlayer.cs

示例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);

        }
開發者ID:Deiwos3,項目名稱:IMS,代碼行數:28,代碼來源:MyDecorator.cs

示例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();
 }
開發者ID:dotob,項目名稱:moni,代碼行數:7,代碼來源:LessThanColorConverter.cs

示例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);
    }
開發者ID:alexiej,項目名稱:YATE,代碼行數:9,代碼來源:DrawingContext.cs

示例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;
        }
開發者ID:hehaotian,項目名稱:igt-editor,代碼行數:33,代碼來源:misc.cs

示例15: DurationBGColorConverter

 private DurationBGColorConverter()
 {
     this.defaultBrush = Brushes.Transparent;
       this.defaultBrush.Freeze();
       this.lessHoursPerDayBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#B3CD6969"));
       this.lessHoursPerDayBrush.Freeze();
 }
開發者ID:vipwolf,項目名稱:moni,代碼行數:7,代碼來源:DurationBGColorConverter.cs


注:本文中的System.Windows.Media.Brush類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。