public void Draw(LayerModel layer, DrawingContext c)
{
var props = (KeyboardPropertiesModel) layer.Properties;
if (string.IsNullOrEmpty(props.GifFile))
return;
if (!File.Exists(props.GifFile))
return;
// Only reconstruct GifImage if the underlying source has changed
if (layer.GifImage == null)
layer.GifImage = new GifImage(props.GifFile);
if (layer.GifImage.Source != props.GifFile)
layer.GifImage = new GifImage(props.GifFile);
var rect = new Rect(layer.AppliedProperties.X*4,
layer.AppliedProperties.Y*4,
layer.AppliedProperties.Width*4,
layer.AppliedProperties.Height*4);
lock (layer.GifImage)
{
var draw = layer.GifImage.GetNextFrame();
c.DrawImage(ImageUtilities.BitmapToBitmapImage(new Bitmap(draw)), rect);
}
}