private DrawLayers ( |
||
g | The graphics to draw on | |
renderLayers | IEnumerable |
The layers to render |
dataModel | IDataModel | The data model to base the layer's properties on |
rect | Rect | A rectangle matching the current keyboard's size on a scale of 4, used for clipping |
preview | bool | Indicates wheter the layer is drawn as a preview, ignoring dynamic properties |
updateAnimations | bool | Wheter or not to update the layer's animations |
return | void |
internal void DrawLayers(Graphics g, IEnumerable<LayerModel> renderLayers, IDataModel dataModel, Rect rect,
bool preview, bool updateAnimations)
{
var visual = new DrawingVisual();
using (var c = visual.RenderOpen())
{
// Setup the DrawingVisual's size
c.PushClip(new RectangleGeometry(rect));
c.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, rect);
// Draw the layers
foreach (var layerModel in renderLayers)
{
layerModel.Update(dataModel, preview, updateAnimations);
layerModel.Draw(dataModel, c, preview, updateAnimations);
}
// Remove the clip
c.Pop();
}
using (var bmp = ImageUtilities.DrawingVisualToBitmap(visual, rect))
{
g.DrawImage(bmp, new PointF(0, 0));
}
}