Esempio n. 1
0
        public VisualCapturer(SilverlightSceneView sceneView, Size targetSize)
            : base(targetSize)
        {
            SilverlightArtboard silverlightArtboard = (SilverlightArtboard)sceneView.Artboard;
            Rect      documentBounds       = silverlightArtboard.DocumentBounds;
            ImageHost silverlightImageHost = silverlightArtboard.SilverlightImageHost;

            if (documentBounds.Width <= 0.0 || documentBounds.Height <= 0.0)
            {
                return;
            }
            using (new VisualCapturer.ImageHostActivator(silverlightImageHost))
            {
                silverlightImageHost.SetTransformMatrix(Matrix.Identity, new Vector(1.0, 1.0));
                silverlightImageHost.Measure(documentBounds.Size);
                silverlightImageHost.Arrange(documentBounds);
                silverlightImageHost.UpdateLayout();
                silverlightImageHost.Redraw(false);
                double proportionalScale = RectExtensions.GetProportionalScale(documentBounds, targetSize);
                documentBounds.Scale(proportionalScale, proportionalScale);
                Image image1 = new Image();
                image1.Source          = silverlightImageHost.InternalSource;
                image1.LayoutTransform = (Transform) new ScaleTransform(proportionalScale, proportionalScale);
                Image image2 = image1;
                image2.Measure(documentBounds.Size);
                image2.Arrange(documentBounds);
                this.DefaultSize = new Size(documentBounds.Width, documentBounds.Height);
                this.visual      = (Visual)image2;
            }
        }
Esempio n. 2
0
        protected override void DetachInternal(SceneView parent)
        {
            SilverlightSceneView silverlightSceneView = parent as SilverlightSceneView;

            if (silverlightSceneView != null)
            {
                this.imageHost.Detach(silverlightSceneView.imageHost);
            }
            base.DetachInternal(parent);
        }
Esempio n. 3
0
            public CrossDocumentUpdateToken(SilverlightSceneView sceneView)
            {
                bool shouldDelay = !sceneView.IsEditingOutOfPlace && sceneView.Document == sceneView.Document.ApplicationSceneDocument;

                if (shouldDelay)
                {
                    this.resourcesHost         = (IResourceDictionaryHost)sceneView.imageHost;
                    this.appResourcesHostToken = sceneView.InstanceBuilderContext.ChangeResourceDictionaryHost(this.resourcesHost);
                    this.resourcesHost.BeginInstanceBuilding(sceneView.InstanceBuilderContext);
                }
                this.updateContext             = new CrossDocumentUpdateContext((IViewRootResolver)sceneView.DesignerContext.ViewRootResolver);
                this.crossDocumentContextToken = sceneView.InstanceBuilderContext.ChangeCrossDocumentUpdateContext((ICrossDocumentUpdateContext)this.updateContext);
                this.updateContext.BeginUpdate(shouldDelay);
            }
Esempio n. 4
0
 public VisualCapturer(SilverlightSceneView sceneView)
     : this(sceneView, ImageCapturer.MaxSize)
 {
 }