private void StopScreenshotProcess() { if (this.IsPreviewing && !this.isStoppingPreview) { this.isStoppingPreview = true; this.mediaCenterProcess.Exited -= new EventHandler(this.MediaCenterProcess_Exited); base.Dispatcher.ShutdownStarted -= new EventHandler(this.Dispatcher_ShutdownStarted); this.themeManager.AppliedThemes.Clear(); foreach (ThemeSummary summary in this.previousThemes) { this.themeManager.AppliedThemes.Add(summary); } IProgressEnabledOperation operation = this.themeManager.ApplyThemesAsync(false, true); operation.Completed += delegate { Action method = delegate { this.IsPreviewing = false; this.isStoppingPreview = false; this.preview.Dispose(); this.preview = null; this.previousThemes = null; this.mediaCenterProcess = null; this.themeManager = null; }; base.Dispatcher.Invoke(DispatcherPriority.Normal, method); }; VmcStudioUtil.Application.ExclusiveOperation = operation; } }
public BitmapSource TakeScreenshot(bool clientOnly) { return(WindowPreview.GetWindowImage(this.sourceHandle, clientOnly)); }
private void StartScreenshotProcess() { if (!this.IsPreviewing && !this.isStartingPreview) { this.isStartingPreview = true; this.themeManager = VmcStudioUtil.Application.ThemeManager; this.previousThemes = new List<ThemeSummary>(this.themeManager.AppliedThemes); this.themeManager.AppliedThemes.Clear(); this.themeManager.AppliedThemes.Add(Enumerable.First<ThemeSummary>(this.themeManager.Themes, (Func<ThemeSummary, bool>)(o => (this.ThemeItem.Theme.ID == o.ID)))); IProgressEnabledOperation operation = this.themeManager.ApplyThemesAsync(true, true); operation.Completed += delegate { Action action2 = null; this.mediaCenterProcess = MediaCenterUtil.LaunchMediaCenter(false, true, true); this.mediaCenterProcess.EnableRaisingEvents = true; this.mediaCenterProcess.Exited += new EventHandler(this.MediaCenterProcess_Exited); base.Dispatcher.ShutdownStarted += new EventHandler(this.Dispatcher_ShutdownStarted); IntPtr windowHandle = IntPtr.Zero; for (int j = 0; (windowHandle == IntPtr.Zero) && (j < 20); j++) { Thread.Sleep(500); windowHandle = MediaCenterUtil.GetMediaCenterWindow(); } if (windowHandle != IntPtr.Zero) { if (action2 == null) { action2 = delegate { this.preview = new WindowPreview(this.previewWindow, windowHandle); this.preview.ClientAreaOnly = true; this.preview.IsVisible = true; this.IsPreviewing = true; this.isStartingPreview = false; }; } Action method = action2; base.Dispatcher.Invoke(DispatcherPriority.Normal, method); } }; VmcStudioUtil.Application.ExclusiveOperation = operation; } }