• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Media.VisualBrush类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Media.VisualBrush的典型用法代码示例。如果您正苦于以下问题:C# VisualBrush类的具体用法?C# VisualBrush怎么用?C# VisualBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VisualBrush类属于System.Windows.Media命名空间,在下文中一共展示了VisualBrush类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PuzzlePiece

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="pieceNumber">Which piece number this piece contains.</param>
 /// <param name="pieceShape">The shape of the pieces.</param>
 /// <param name="brush">The image and viewbox to use as this piece's visual.</param>
 public PuzzlePiece(int pieceNumber, Geometry pieceShape, VisualBrush brush) 
 {
     clipShape = pieceShape;
     imageBrush = brush;
     pieces = new HashSet<int>();
     pieces.Add(pieceNumber);
 }
开发者ID:AnthonyB28,项目名称:Marist_Map,代码行数:13,代码来源:PuzzlePiece.cs


示例2: DragAdorner

        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            System.Diagnostics.Debug.Assert(owner != null);
            System.Diagnostics.Debug.Assert(adornElement != null);
            _owner = owner;
            if (useVisualBrush)
            {
                VisualBrush _brush = new VisualBrush(adornElement);
                _brush.Opacity = opacity;
                Rectangle r = new Rectangle();
                r.RadiusX = 3;
                r.RadiusY = 3;

                //TODO: questioning DesiredSize vs. Actual 
                r.Width = adornElement.DesiredSize.Width;
                r.Height = adornElement.DesiredSize.Height;

                XCenter = adornElement.DesiredSize.Width / 2;
                YCenter = adornElement.DesiredSize.Height / 2;

                r.Fill = _brush;
                _child = r;

            }
            else
                _child = adornElement;


        }
开发者ID:just8,项目名称:Open-Source-Automation,代码行数:30,代码来源:DragAdorner.cs


示例3: GetPngImage

 private static byte[] GetPngImage(FrameworkElement element)
 {
     var size = new Size(double.PositiveInfinity, double.PositiveInfinity);
     element.Measure(size);
     element.Arrange(new Rect(element.DesiredSize));
     var renderTarget =
       new RenderTargetBitmap((int)element.RenderSize.Width,
                              (int)element.RenderSize.Height,
                              96, 96,
                              PixelFormats.Pbgra32);
     var sourceBrush = new VisualBrush(element);
     var drawingVisual = new DrawingVisual();
     using (DrawingContext drawingContext = drawingVisual.RenderOpen())
     {
         drawingContext.DrawRectangle(
             sourceBrush, null, new Rect(
                                    new Point(0, 0),
                                    new Point(element.RenderSize.Width,
                                    element.RenderSize.Height)));
     }
     renderTarget.Render(drawingVisual);
     var pngEncoder = new PngBitmapEncoder();
     pngEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
     using (var outputStream = new MemoryStream())
     {
         pngEncoder.Save(outputStream);
         return outputStream.ToArray();
     }
 }
开发者ID:jwynia,项目名称:ImageGenerator,代码行数:29,代码来源:ImageGenerator.cs


示例4: Tile

        public Tile(ICase tile, TileFactory tileFactory, List<Unite> listUnite, SolidColorBrush playerBrush)
        {
            InitializeComponent();
            this.tile = tile;
            this.nbUnite = listUnite.Count;
            VisualBrush myBrush = new VisualBrush();
            aPanel = new Grid();

            aPanel.Background = tileFactory.getViewTile(tile);

            // Create some text.
            TextBlock backText = new TextBlock();
            Canvas.SetZIndex(backText, 3);
            if (listUnite != null && listUnite.Count > 0)
            {
                backText.Text = " " + listUnite.Count.ToString() + " ";
                backText.Background = (SolidColorBrush)new BrushConverter().ConvertFromString(listUnite[0].Proprietaire.Couleur);
                backText.Foreground = Brushes.White;
            }
            FontSizeConverter fSizeConverter = new FontSizeConverter();
            backText.FontSize = (double)fSizeConverter.ConvertFromString("10pt");
            backText.Margin = new Thickness(10);
            Grid.SetColumn(backText, 0);
            Grid.SetRow(backText, 0);
            DropShadowEffect myDropShadowEffect  = new DropShadowEffect();
            myDropShadowEffect.BlurRadius = 1;
            myDropShadowEffect.Color = Color.FromRgb(0,0,0);
            myDropShadowEffect.ShadowDepth = 2;
            backText.Effect=myDropShadowEffect;
            aPanel.Children.Add(backText);
            myBrush.Visual = aPanel;
            rect.Fill = myBrush;
            rect1.Stroke = playerBrush;
        }
开发者ID:BenjBoug,项目名称:INSA-SmallWorld,代码行数:34,代码来源:Tile.xaml.cs


示例5: BuildGrid

        private static Border BuildGrid(int cellWidth = 50, int cellHeight = 50)
        {
            var gridBorder = new Border();

            var cellRect = new Rectangle
            {
                Stroke = Brushes.DarkGray,
                StrokeThickness = 1,
                Height = 50,
                Width = 50,
                StrokeDashArray = new DoubleCollection(new double[] {5, 3})
            };

            var vb = new VisualBrush(cellRect)
            {
                TileMode = TileMode.Tile,
                Viewport = new System.Windows.Rect(0, 0, cellHeight, cellWidth),
                ViewportUnits = BrushMappingMode.Absolute,
                Viewbox = new System.Windows.Rect(0, 0, cellHeight, cellWidth),
                ViewboxUnits = BrushMappingMode.Absolute
            };
            gridBorder.Background = vb;

            return gridBorder;
        }
开发者ID:Neakas,项目名称:ProjectSWN,代码行数:25,代码来源:GridManager.cs


示例6: Squiggly

        public static TextDecoration Squiggly(Color color, TextDecorationLocation location = TextDecorationLocation.Underline)
        {
            var penVisual = new Path
            {
                Stroke = new SolidColorBrush(color),
                StrokeThickness = 0.2,
                StrokeEndLineCap = PenLineCap.Square,
                StrokeStartLineCap = PenLineCap.Square,
                Data = new PathGeometry(new[] { new PathFigure(new Point(0, 1), new[] { new BezierSegment(new Point(1, 0), new Point(2, 2), new Point(3, 1), true) }, false) })
            };

            var penBrush = new VisualBrush
            {
                Viewbox = new Rect(0, 0, 3, 2),
                ViewboxUnits = BrushMappingMode.Absolute,
                Viewport = new Rect(0, 0.8, 6, 3),
                ViewportUnits = BrushMappingMode.Absolute,
                TileMode = TileMode.Tile,
                Visual = penVisual
            };

            var pen = new Pen
            {
                Brush = penBrush,
                Thickness = 6
            };

            return new TextDecoration(location, pen, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
        }
开发者ID:robert-hoffmann,项目名称:WebEssentials2013,代码行数:29,代码来源:SquigglyHelper.cs


示例7: fullscreen

        public fullscreen(VisualBrush vb, MW_ViewModel vm)
        {
            this.DataContext = vm;
            InitializeComponent();

            display.Fill = vb;
        }
开发者ID:Vyko,项目名称:MyWmp,代码行数:7,代码来源:fullscreen.xaml.cs


示例8: ParticleSystem

        public ParticleSystem(int maxCount, System.Windows.Media.Color color)
        {
            this.maxParticleCount = maxCount;

            this.particleList = new List<Particle>();

            this.particleModel = new GeometryModel3D();
            this.particleModel.Geometry = new MeshGeometry3D();

            Ellipse e = new Ellipse();
            e.Width = 32.0;
            e.Height = 32.0;
            RadialGradientBrush b = new RadialGradientBrush();
            b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0xFF, color.R, color.G, color.B), 0.25));
            b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0x00, color.R, color.G, color.B), 1.0));
            e.Fill = b;
            e.Measure(new System.Windows.Size(32, 32));
            e.Arrange(new Rect(0, 0, 32, 32));

            var brush = new VisualBrush(e);

            DiffuseMaterial material = new DiffuseMaterial(brush);

            this.particleModel.Material = material;

            this.rand = new Random(brush.GetHashCode());
        }
开发者ID:xerxesb,项目名称:codekatas,代码行数:27,代码来源:ParticleSystem.cs


示例9: DragAdorner

        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity, double scaleRatio)
            : base(owner)
        {
            _owner = owner;
            if (useVisualBrush)
            {
                VisualBrush brush = new VisualBrush(adornElement);
                brush.Opacity = opacity;
                Rectangle r = new Rectangle();
                r.RadiusX = 3;
                r.RadiusY = 3;

                r.Width = adornElement.DesiredSize.Width * scaleRatio;
                r.Height = adornElement.DesiredSize.Height * scaleRatio;

                _xCenter = r.Width / 2;
                _yCenter = r.Height / 2;

                r.Fill = brush;
                _child = r;

            }
            else
                _child = adornElement;
        }
开发者ID:atombender,项目名称:learning,代码行数:25,代码来源:DragAdorner.cs


示例10: DragAdorner

        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            Debug.Assert(owner != null);
            Debug.Assert(adornElement != null);
            Owner = owner;
            if (useVisualBrush)
            {
                var brush = new VisualBrush(adornElement) {Opacity = opacity};
                var r = new Rectangle
                            {
                                RadiusX = 3,
                                RadiusY = 3,
                                Width = adornElement.DesiredSize.Width,
                                Height = adornElement.DesiredSize.Height
                            };

                XCenter = adornElement.DesiredSize.Width/2;
                YCenter = adornElement.DesiredSize.Height/2;

                r.Fill = brush;
                Child = r;
            }
            else
                Child = adornElement;
        }
开发者ID:bejumi,项目名称:OCTGN,代码行数:26,代码来源:DragAdorner.cs


示例11: 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


示例12: DiagramCanvas

        public DiagramCanvas()
        {
            this.selectedItems = new List<ISelectable>();

            // Create ParentDiagram grdi visual brush
            //<VisualBrush x:Key="DiagramDotFillBrush"
            //		TileMode="Tile"
            //		Viewport="0,0,10,10"
            //		ViewportUnits="Absolute"
            //		Viewbox="0,0,12,12"
            //		ViewboxUnits="Absolute">
            //	<VisualBrush.Visual>
            //		<Ellipse Fill="#777" Width="1" Height="1" />
            //	</VisualBrush.Visual>
            //</VisualBrush>
            var brushViewport = new Rect(0, 0, DiagramCanvas.DiagramViewPadding, DiagramCanvas.DiagramViewPadding);
            this.diagramGridBrush = new VisualBrush(
                new Ellipse() {
                    Fill = new SolidColorBrush(new Color() {R = 119, G = 119, B = 119, A = 255}),
                    Width = 1.0,
                    Height = 1.0
                }) {
                    TileMode = TileMode.Tile,
                    ViewboxUnits = BrushMappingMode.Absolute,
                    ViewportUnits = BrushMappingMode.Absolute,
                    Viewbox = brushViewport,
                    Viewport = brushViewport
                };
            this.ShowDiagramGrid = true;
            this.StickToDiagramGrid = true;
        }
开发者ID:AleksandarDev,项目名称:Eve,代码行数:31,代码来源:DiagramCanvas.cs


示例13: SaveToPng

        public void SaveToPng( Canvas surface, string file )
        {
            // Save current canvas transform
            var transform = surface.LayoutTransform;
            // reset current transform (in case it is scaled or rotated)
            surface.LayoutTransform = null;

            var size = new Size( 1600, 900 );

            // Attentation: Measure and arrange the surface !
            surface.Measure( size );
            surface.Arrange( new Rect( size ) );

            var renderBitmap = new RenderTargetBitmap( (int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32 );

            var bounds = VisualTreeHelper.GetDescendantBounds( surface );
            var dv = new DrawingVisual();
            using ( var ctx = dv.RenderOpen() )
            {
                var vb = new VisualBrush( surface );
                ctx.DrawRectangle( vb, null, new Rect( new Point(), bounds.Size ) );
            }

            renderBitmap.Render( dv );
            using ( var outStream = new FileStream( file, FileMode.OpenOrCreate, FileAccess.Write ) )
            {
                var encoder = new PngBitmapEncoder();
                encoder.Frames.Add( BitmapFrame.Create( renderBitmap ) );
                encoder.Save( outStream );
            }

            // Restore previously saved layout
            surface.LayoutTransform = transform;
        }
开发者ID:JackWangCUMT,项目名称:Plainion.Whiteboard,代码行数:34,代码来源:PersistenceService.cs


示例14: MouseOnMove

        private void MouseOnMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                endPoint = e.GetPosition(canvas);
                Rect targetRect = new Rect(originPoint, endPoint);
                rect.Width = targetRect.Width;
                rect.Height = targetRect.Height;

                //获取装饰元素作为VisualBrush的来源
                VisualBrush vb = new VisualBrush(DecoratedElement);
                vb.Viewbox = targetRect;
                vb.ViewboxUnits = BrushMappingMode.Absolute;

                rect.Fill = vb;

                Canvas.SetTop(rect, targetRect.Top);
                Canvas.SetLeft(rect, targetRect.Left);
                if (canvas.Children.Count==0)
                {
                    canvas.Children.Add(rect);
                }

               Debug.WriteLine(string.Format("endPoint x:{0},y:{1}", endPoint.X, endPoint.Y));
            }
        }
开发者ID:huanshifeichen,项目名称:Codelib,代码行数:26,代码来源:DrawingCanvas.xaml.cs


示例15: GetRenderTargetBitmap

        public static RenderTargetBitmap GetRenderTargetBitmap(this UIElement source, double scale)
        {
            if (source.RenderSize.Height == 0 || source.RenderSize.Width == 0)
                return null;

            double actualHeight = source.RenderSize.Height;
            double actualWidth = source.RenderSize.Width;

            double renderHeight = actualHeight*scale;
            double renderWidth = actualWidth*scale;

            var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96,
                                                      PixelFormats.Pbgra32);
            var sourceBrush = new VisualBrush(source);

            var drawingVisual = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            using (drawingContext)
            {
                drawingContext.PushTransform(new ScaleTransform(scale, scale));
                drawingContext.DrawRectangle(sourceBrush, null,
                                             new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
            }
            renderTarget.Render(drawingVisual);
            return renderTarget;
        }
开发者ID:afrog33k,项目名称:eAd,代码行数:27,代码来源:Screenshot.cs


示例16: DragAdorner

        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            this.owner  = owner;

            if (useVisualBrush)
            {
                VisualBrush brush   = new VisualBrush(adornElement);
                Rectangle   rect    = new Rectangle();

                brush.Opacity       = opacity;
                rect.RadiusX        = 3;
                rect.RadiusY        = 3;
                rect.Width          = adornElement.DesiredSize.Width;
                rect.Height         = adornElement.DesiredSize.Height;

                this.XCenter        = adornElement.DesiredSize.Width / 2;
                this.YCenter        = adornElement.DesiredSize.Height / 2;

                rect.Fill = brush;

                this.child = rect;
            }
            else
            {
                this.child = adornElement;
            }
        }
开发者ID:cipjota,项目名称:Chronos,代码行数:28,代码来源:DragAdorner.cs


示例17: SetPreviewElement

        public void SetPreviewElement(FrameworkElement element)
        {
            double x = 0;
              double y = 0;
              GetCurrentDPI(out x, out y);

              // Does the DrawingBrush thing seem a little hacky? Yeah, it's a necessary hack.  See:
              // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=364041

              Rect bounds = VisualTreeHelper.GetDescendantBounds(element);

              RenderTargetBitmap r = new RenderTargetBitmap((int)(element.ActualWidth * x / 96), (int)(element.ActualHeight * y / 96), (int)x, (int)y, PixelFormats.Pbgra32);

              DrawingVisual dv = new DrawingVisual();
              using (DrawingContext ctx = dv.RenderOpen()) {
            VisualBrush vb = new VisualBrush(element);

            ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
              }
              r.Render(dv);

              DragImage = r;

              InvalidateMeasure();
        }
开发者ID:edealbag,项目名称:bot,代码行数:25,代码来源:DragPreviewAdorner.cs


示例18: GetJpgImage

        /// 
        /// Gets a JPG "screenshot" of the current UIElement 
        /// 
        /// UIElement to screenshot 
        /// Scale to render the screenshot 
        /// JPG Quality 
        /// Byte array of JPG data 
        public byte[] GetJpgImage(double scale, int quality, int dpi)
        {
            double actualHeight = this.RootVisual.RenderSize.Height;
            double actualWidth = this.RootVisual.RenderSize.Width;

            double renderHeight = actualHeight * scale;
            double renderWidth = actualWidth * scale;

            RenderTargetBitmap renderTarget = new RenderTargetBitmap((int)renderWidth, (int)renderHeight, dpi, dpi, PixelFormats.Pbgra32);
            VisualBrush sourceBrush = new VisualBrush(this.RootVisual);

            DrawingVisual drawingVisual = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            using (drawingContext)
            {
                drawingContext.PushTransform(new ScaleTransform(scale, scale));
                drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
            }

            renderTarget.Render(drawingVisual);
            JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder();
            jpgEncoder.QualityLevel = quality;
            jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));

            Byte[] _imageArray;
            using (MemoryStream outputStream = new MemoryStream())
            {
                jpgEncoder.Save(outputStream);
                _imageArray = outputStream.ToArray();
            }

            return _imageArray;
        }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:41,代码来源:PhotoCard.cs


示例19: GetJpgImage

 /// <summary>
 /// </summary>
 /// <param name="source"> </param>
 /// <param name="scale"> </param>
 /// <param name="quality"> </param>
 /// <returns> </returns>
 public static byte[] GetJpgImage(UIElement source, double scale, int quality)
 {
     var actualHeight = source.RenderSize.Height;
     var actualWidth = source.RenderSize.Width;
     var renderHeight = actualHeight * scale;
     var renderWidth = actualWidth * scale;
     var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96, PixelFormats.Pbgra32);
     var sourceBrush = new VisualBrush(source);
     var drawingVisual = new DrawingVisual();
     var drawingContext = drawingVisual.RenderOpen();
     using (drawingContext)
     {
         drawingContext.PushTransform(new ScaleTransform(scale, scale));
         drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
     }
     renderTarget.Render(drawingVisual);
     var jpgEncoder = new JpegBitmapEncoder
     {
         QualityLevel = quality
     };
     jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
     Byte[] imageArray;
     using (var outputStream = new MemoryStream())
     {
         jpgEncoder.Save(outputStream);
         imageArray = outputStream.ToArray();
     }
     return imageArray;
 }
开发者ID:Yaguar666,项目名称:ffxivapp-common,代码行数:35,代码来源:ScreenCapture.cs


示例20: DragAdorner

        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            _owner = owner;
            if (useVisualBrush)
            {
                VisualBrush _brush = new VisualBrush(adornElement);
                _brush.Opacity = opacity;
                Rectangle r = new Rectangle();
                //r.Stroke = Brushes.Red;
                //r.StrokeThickness = 2;
                r.RadiusX = 3;
                r.RadiusY = 3;
                r.Width = adornElement.DesiredSize.Width;
                r.Height = adornElement.DesiredSize.Height;

                XCenter = adornElement.DesiredSize.Width / 2;
                YCenter = adornElement.DesiredSize.Height / 2;

                r.Fill = _brush;
                _child = r;

            }
            else
                _child = adornElement;
        }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:26,代码来源:DragAdorner.cs



注:本文中的System.Windows.Media.VisualBrush类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Animation.AnimationClock类代码示例发布时间:2022-05-26
下一篇:
C# Media.Visual类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap