Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dc"></param>
        private void Draw(DrawingContext dc)
        {
            var context = this.DataContext as EditorContext;
            if (context == null
                || context.Editor == null
                || context.Editor.Project == null)
                return;

            // TODO: Disable anti-aliasing.

            var translate = dc.PushPreTransform(Matrix.CreateTranslation(_state.PanX, _state.PanY));
            var scale = dc.PushPreTransform(Matrix.CreateScale(_state.Zoom, _state.Zoom));

            var renderer = context.Editor.Renderers[0];

            if (context.Editor.Project == null)
                return;

            var container = context.Editor.Project.CurrentContainer;
            if (container == null)
                return;

            if (container.Template != null)
            {
                DrawBackground(
                    dc,
                    container.Template.Background,
                    container.Width,
                    container.Height);

                renderer.Draw(
                    dc,
                    container.Template,
                    container.Properties,
                    null);
            }

            DrawBackground(
                dc,
                container.Background,
                container.Width,
                container.Height);

            renderer.Draw(
                dc,
                container,
                container.Properties,
                null);

            if (container.WorkingLayer != null)
            {
                renderer.Draw(
                    dc,
                    container.WorkingLayer,
                    container.Properties,
                    null);
            }

            if (container.HelperLayer != null)
            {
                renderer.Draw(
                    dc,
                    container.HelperLayer,
                    container.Properties,
                    null);
            }

            scale.Dispose();
            translate.Dispose();
        }