private void RenderElement(Brush brush, float x, float y, float width, float height) { var ellipse = new Ellipse(new PointF(x + (width/2), y+ (height/2)), width, height); m_rotateTransform.CenterX = ellipse.Center.X; m_rotateTransform.CenterY = ellipse.Center.Y; m_presenter.FillEllipse(brush, ellipse, m_rotateTransform); m_presenter.DrawText(m_solidColorBrush, brush.Alignment.ToString(), x - width / 2, y - height / 2); }
private void InitMediaPlayer() { m_player = m_presenter.Factory.CreateMediaPlayer(); m_player.Open(VIDEO_FILENAME); var videoBrush = m_presenter.Factory.CreateVideoBrush(m_player); videoBrush.HorizontalExtendMode = ExtendMode.Wrap; videoBrush.VerticalExtendMode = ExtendMode.Wrap; m_paintingBrush = videoBrush; }
static public void PrepareBrush(Brush brush, DrawingLayer drawingLayer, RectangleF bounds, Matrix3x2 localTransform, Matrix3x2 worldTransform) { var alignment = brush.Alignment; var brushSize = brush.BrushSize; Matrix3x2 currentBrushTransform = Matrix3x2.Identity; if (brush.Transform != null) { switch (alignment) { case BrushAlignment.DrawingLayerAbsolute: currentBrushTransform = brush.Transform.GetTransform(); break; case BrushAlignment.DrawingLayerRelative: currentBrushTransform = brush.Transform.GetTransformRelative(new RectangleF(0,0, drawingLayer.Width, drawingLayer.Height)); break; case BrushAlignment.GeometryAbsolute: currentBrushTransform = brush.Transform.GetTransform(); break; case BrushAlignment.GeometryRelative: currentBrushTransform = brush.Transform.GetTransformRelative(bounds); break; default: throw new ArgumentOutOfRangeException(); } } switch (alignment) { case BrushAlignment.DrawingLayerAbsolute: brush.InternalBrush.Transform = currentBrushTransform * Matrix3x2.Invert(worldTransform); break; case BrushAlignment.DrawingLayerRelative: { var scaleMatrix = Matrix3x2.Scale(drawingLayer.Width / brushSize.Width, drawingLayer.Height / brushSize.Height); brush.InternalBrush.Transform = scaleMatrix * currentBrushTransform * Matrix3x2.Invert(worldTransform); } break; case BrushAlignment.GeometryAbsolute: { var translate = Matrix3x2.Translation(bounds.InternalRectangleF.Location); brush.InternalBrush.Transform = translate * localTransform * currentBrushTransform; } break; case BrushAlignment.GeometryRelative: { var scaleMatrix = Matrix3x2.Scale(bounds.Width / brushSize.Width, bounds.Height / brushSize.Height); var translate = Matrix3x2.Translation(bounds.InternalRectangleF.Location); brush.InternalBrush.Transform = scaleMatrix * translate * localTransform * currentBrushTransform; } break; default: throw new ArgumentOutOfRangeException(); } }
public void InitLayers(Size ImageSize) { hoverBrush = Factory.CreateSolidColorBrush(new Color4(.4f, 0, 0, 0)); contactBrush = Factory.CreateSolidColorBrush(new Color4(.8f, 0, 0, 0)); DepthPresenter = new WPFPresenter(Factory, ImageSize.Width, ImageSize.Height); intermediateLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height); rawDepthLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height); DepthBrush = Factory.CreateDrawingLayerBrush(DepthPresenter); DepthBrush.Alignment = DirectCanvas.Brushes.BrushAlignment.DrawingLayerAbsolute; }
protected override bool VerifyInitOverride() { if (DepthFrame == null) { return false; } if (effectLayer == null) { effectLayer = Factory.CreateDrawingLayer(DepthFrame.Width, DepthFrame.Height); } if (effectLayer2 == null) { effectLayer2 = Factory.CreateDrawingLayer(DepthFrame.Width, DepthFrame.Height); } if (unpackEffect == null) { unpackEffect = new UnpackDepthEffect(Factory); } if (colorMapEffect == null) { colorMapEffect = new ColorMapDepthEffect(Factory); } if (rectBrushForeground == null) { rectBrushForeground = Factory.CreateSolidColorBrush(new Color4(1, 1, 1, 1)); } if (rectBrushBackground == null) { rectBrushBackground = Factory.CreateSolidColorBrush(new Color4(1, 0, 0, 0)); } return base.VerifyInitOverride(); }