Example #1
0
        protected override BitmapSource[] CaptureFrames(ISnapshotProvider snapshotProvider, Rect clippingRectangle, Color shadeColor, IProgressScope progress, Func <bool> getIsCancelled)
        {
            var frame1 = this.PrintVersionTag(snapshotProvider.Snapshot(clippingRectangle, this.SampleFactor, shadeColor),
                                              this.Owner.Owner.TankInstance);

            var frame2 = this.PrintVersionTag(this.Owner.Owner.AlternativeSnapshotProvider.Snapshot(clippingRectangle, this.SampleFactor, shadeColor),
                                              this.Owner.Owner.AlternativeTankInstance);

            return(new[] { frame1, frame2 });
        }
Example #2
0
        public override void BeginCapture(ISnapshotProvider snapshotProvider, TankInstance tank, Rect clippingRectangle, Color shadeColor, string outputFilename)
        {
            DialogManager.Instance.ShowProgressAsync(this.CapturingDialogTitle,
                                                     string.Format(this.CapturingDialogMessage, tank.Name),
                                                     isCancellable: false)
            .ContinueWith(t =>
            {
                t.Result.SetIndeterminate();

                var captureCompleted = false;

                var dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background,
                                                          Application.Current.Dispatcher);
                dispatcherTimer.Interval = TimeSpan.FromSeconds(0.5);
                dispatcherTimer.Tick    +=
                    (o, e) =>
                {
                    dispatcherTimer.Stop();

                    var bitmapSource = snapshotProvider.Snapshot(clippingRectangle, (float)this.SampleFactor, StaticCapturerBase.GetStaticShadeColor(shadeColor));
                    using (var file = File.OpenWrite(outputFilename))
                    {
                        var encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
                        encoder.Save(file);
                    }

                    captureCompleted = true;
                };

                dispatcherTimer.Start();


                while (!captureCompleted)
                {
                    Thread.Sleep(100);
                }

                t.Result.SetTitle(this.CaptureCompletedDialogTitle);
                t.Result.SetMessage(string.Format(this.CaptureCompletedDialogMessage, outputFilename));
                Thread.Sleep(1000);
                t.Result.CloseAsync();
            });
        }