Exemplo n.º 1
0
 public GeometryManager(D2D.Factory factory)
 {
     if (factory != null)
         this.factory = factory;
     else
         throw new ArgumentNullException();
 }
Exemplo n.º 2
0
 public Path(D2D.Factory factory)
 {
     if(factory==null)
     {
         throw new ArgumentNullException();
     }
     _path = new D2D.PathGeometry(factory);
 }
Exemplo n.º 3
0
 protected Path(D2D.PathGeometry geometry)
 {
     if(geometry ==null)
     {
         throw new ArgumentNullException();
     }
     _path = geometry;
 }
Exemplo n.º 4
0
			protected override sd.Brush Create(sd.RenderTarget target)
			{
				var brush = new sd.BitmapBrush(target, Image.ToDx(target));
				brush.ExtendModeX = brush.ExtendModeY = sd.ExtendMode.Wrap;
				if (Transform != null)
					brush.Transform = Transform.ToDx();
				return brush;
			}
Exemplo n.º 5
0
 public PathBuilder(D2D.GeometrySink sink)
 {
     if(sink==null)
     {
         throw new ArgumentNullException();
     }
     _sink = sink;
 }
Exemplo n.º 6
0
 public SolidColorBrush(D2D.RenderTarget target, Color color)
 {
     if (target != null)
     {
         d2dBrush = new D2D.SolidColorBrush(target, color.ToD2D());
     }
     else
         throw new ArgumentNullException();
 }
        public void CleanUp(D2D1.RenderTarget target, GDI.Graphics g, Map map)
        {
            target.EndDraw();
            using (var sc = TakeScreenshotGdi(map.Size))
                g.DrawImage(sc, new GDI.Point(0, 0));
            
            target.Dispose();

            //Monitor.Exit(_syncRoot);
        }
Exemplo n.º 8
0
		public sd.Brush Get(sd.RenderTarget target)
		{
			if (Brush == null || !ReferenceEquals(Brush.Tag, target))
			{
				Brush = Create(target);
				Brush.Opacity = Alpha;
				Brush.Tag = target;
				OnCreated();
			}
			return Brush;
		}
Exemplo n.º 9
0
        public RenderTarget(D2D.Factory factory,IntPtr hwnd, int width, int height)
        {

            D2D.RenderTargetProperties renderTargetProperties = new D2D.RenderTargetProperties
            {
            };

            D2D.HwndRenderTargetProperties hwndProperties = new D2D.HwndRenderTargetProperties
            {
                Hwnd = hwnd,
                PixelSize = new SharpDX.Size2(width, height),
                PresentOptions = D2D.PresentOptions.Immediately
            };

            _renderTarget = new D2D.WindowRenderTarget(
                factory,
                renderTargetProperties,
                hwndProperties);
        }
Exemplo n.º 10
0
        public static D2D.StrokeStyle GetStrokeStyle(this Jupiter.Shapes.Shape shape, D2D.Factory factory)
        {
            var properties = new D2D.StrokeStyleProperties();

            properties.StartCap = shape.StrokeStartLineCap.ToSharpDX();
            properties.EndCap = shape.StrokeEndLineCap.ToSharpDX();
            properties.LineJoin = shape.StrokeLineJoin.ToSharpDX();
            properties.MiterLimit = (float)shape.StrokeMiterLimit;

            if (shape.StrokeDashArray.Count > 0)
            {
                properties.DashCap = shape.StrokeDashCap.ToSharpDX();
                properties.DashOffset = (float)shape.StrokeDashOffset;
                properties.DashStyle = D2D.DashStyle.Custom;
                return new D2D.StrokeStyle(factory, properties, shape.StrokeDashArray.Select(d => (float)d).ToArray());
            }

            properties.DashStyle = D2D.DashStyle.Solid;
            return new D2D.StrokeStyle(factory, properties);
        }
        public D2D1.RenderTarget Create(D2D1.Factory factory, GDI.Graphics g, Map map)
        {
            //Monitor.Enter(_syncRoot);

            // Dispose the _renderTexture if it is instantiated and not of the required size
            CheckTexture(ref _renderTexture, map.Size);

            // Create a new render texture if one is needed
            if (_renderTexture == null)
            {
                _renderTexture = CreateRenderTargetTexture(_d3d11Device, map.Size.Width, map.Size.Height);
            }

            // Get the surface
            var surface = _renderTexture.QueryInterface<DXGI.Surface>();
            
            var res = new D2D1.RenderTarget(factory, surface, new D2D1.RenderTargetProperties(
                D2D1.RenderTargetType.Hardware, new D2D1.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D1.AlphaMode.Premultiplied),
                g.DpiX, g.DpiY, D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT));

            res.BeginDraw();

            return res;
        }
Exemplo n.º 12
0
			protected override sd.Brush Create(sd.RenderTarget target)
			{
				return new sd.SolidColorBrush(target, Color.ToDx());
			}
Exemplo n.º 13
0
		protected abstract sd.Brush Create(sd.RenderTarget target);
 public void Compose(D2D.RenderTarget renderTarget, FrameworkElement fe)
 {
     renderTarget.BeginDraw();
     renderTarget.Clear(new SharpDX.Color(0, 0, 0, 0));
     this.Render(renderTarget, fe, fe);
     renderTarget.EndDraw();
 }
        public void Render(D2D.RenderTarget renderTarget, FrameworkElement rootElement, FrameworkElement fe)
        {
            var textBlock = fe as TextBlock;

            if (textBlock != null)
            {
                TextBlockRenderer.Render(this, renderTarget, rootElement, textBlock);
                return;
            }

            var rectangle = fe as Rectangle;

            if (rectangle != null)
            {
                RectangleRenderer.Render(this, renderTarget, rootElement, rectangle);
                return;
            }

            var border = fe as Border;

            if (border != null)
            {
                BorderRenderer.Render(this, renderTarget, rootElement, border);
                return;
            }

            var ellipse = fe as Ellipse;

            if (ellipse != null)
            {
                EllipseRenderer.Render(this, renderTarget, rootElement, ellipse);
                return;
            }

            var line = fe as Line;

            if (line != null)
            {
                LineRenderer.Render(this, renderTarget, rootElement, line);
                return;
            }

            var path = fe as Path;

            if (path != null)
            {
                PathRenderer.Render(this, renderTarget, rootElement, path);
                return;
            }

            FrameworkElementRenderer.Render(this, renderTarget, rootElement, fe);
        }
        internal void RenderChildren(D2D.RenderTarget renderTarget, FrameworkElement rootElement, FrameworkElement fe)
        {
            var children = fe.GetChildrenByZIndex();

            foreach (var dependencyObject in children)
            {
                var child = dependencyObject as FrameworkElement;

                Debug.Assert(child != null);

                if (child != null)
                {
                    this.Render(renderTarget, rootElement, child);
                }
            }
        }
Exemplo n.º 17
0
 public DrawingContext(D2D.RenderTarget renderTarget)
 {
     _renderTarget = renderTarget;
     brush = new D2D.SolidColorBrush(_renderTarget, Colors.Gray.ToD2D());
     fbrush = new D2D.SolidColorBrush(_renderTarget, Colors.LightGray.ToD2D());
 }