VixenModules.Editor.TimedSequenceEditor.TimedSequenceElement.DrawCanvasContent C# (CSharp) Method

DrawCanvasContent() protected method

protected DrawCanvasContent ( Graphics graphics ) : void
graphics System.Drawing.Graphics
return void
        protected override void DrawCanvasContent(Graphics graphics)
        {
            // if our cached copy is old or nonexistant, redraw it and save it
            // TODO: this may not be perfectly accurate, since it's possible for someone else to come along and render
            // the effect, which would make it non-dirty, but we don't know about it yet. Not ideal. Add a serial or GUID to effect rendering, to be able to track it.
            if (EffectNode.Effect.IsDirty || CachedCanvasContent == null ||
                CachedCanvasContent.Width != (int)graphics.VisibleClipBounds.Width ||
                CachedCanvasContent.Height != (int)graphics.VisibleClipBounds.Height)
            {
                CachedCanvasContent = new Bitmap((int)graphics.VisibleClipBounds.Width, (int)graphics.VisibleClipBounds.Height);
                EffectRasterizer effectRasterizer = new EffectRasterizer();
                using (Graphics g = Graphics.FromImage(CachedCanvasContent)) {
                    effectRasterizer.Rasterize(EffectNode.Effect, g);
                }
            }

            graphics.DrawImage(CachedCanvasContent, 0, 0);

            // add text describing the effect
            using (Font f = new Font("Arial", 7))
            using (Brush b = new SolidBrush(TextColor)) {
                graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                graphics.DrawString(EffectNode.Effect.EffectName, f, b, new RectangleF(5, 3, 50, 12));
                graphics.DrawString("Start: " + EffectNode.StartTime.ToString(@"m\:ss\.fff"), f, b, new PointF(60, 3));
                graphics.DrawString("Length: " + EffectNode.TimeSpan.ToString(@"m\:ss\.fff"), f, b, new PointF(60, 16));
            }

            ElementTimeHasChangedSinceDraw = false;
        }