public static void PerformScreenCapture(TabControl.TabControl tab) { if (Kohl.Framework.Info.MachineInfo.IsUnixOrMac) { Log.Fatal("Screen caputure is only supported on Windows at the moment."); return; } TerminalTabControlItem activeTab = tab.SelectedItem as TerminalTabControlItem; string name = ""; if (activeTab != null && activeTab.Favorite != null && !string.IsNullOrEmpty(activeTab.Favorite.Name)) { name = activeTab.Favorite.Name + "-"; } string filename = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); string rootPath = Settings.CaptureRoot.NormalizePath(); string tempFile = Path.Combine(rootPath, string.Format("{0}{1}.png", name, filename)); ScreenCapture sc = new ScreenCapture(); Bitmap bmp = sc.CaptureControl(tab, tempFile, ImageFormatTypes.imgPNG); if (Settings.EnableCaptureToClipboard) { Clipboard.SetImage(bmp); } }
public static Capture PerformScreenCapture(TabControl.TabControl tab) { ScreenCapture sc = new ScreenCapture(); string filename = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss"); string tempFile = System.IO.Path.Combine(CaptureManager.CaptureRoot, string.Format("{0}.png", filename)); using (sc.CaptureControl(tab, tempFile, ImageFormatHandler.ImageFormatTypes.imgPNG)); //System.Diagnostics.Process.Start(tempFile); return(null); }
public void NoTab_PerformScreenCapture_TakesScreenShot() { this.ConfigureSettings(); var expectedFiles = this.GetFilesCountInCaptureDirectory() + 1; var tabControl = new TabControl.TabControl(); IFavorite favorite = new Mock <IFavorite>().Object; CaptureManager.PerformScreenCapture(tabControl, favorite); var actualFiles = this.GetFilesCountInCaptureDirectory(); Assert.AreEqual(expectedFiles, actualFiles, "Screen capture should create new file in capture direcotry."); }
public static void PerformScreenCapture(TabControl.TabControl tab) { TerminalTabControlItem activeTab = tab.SelectedItem as TerminalTabControlItem; string name = ""; if (activeTab != null && activeTab.Favorite != null && !string.IsNullOrEmpty(activeTab.Favorite.Name)) { name = activeTab.Favorite.Name + "-"; } string filename = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); string rootPath = Settings.CaptureRoot.NormalizePath(); string tempFile = Path.Combine(rootPath, string.Format("{0}{1}.png", name, filename)); ScreenCapture sc = new ScreenCapture(); Bitmap bmp = sc.CaptureControl(tab, tempFile, ImageFormatTypes.imgPNG); if (Settings.EnableCaptureToClipboard) { Clipboard.SetImage(bmp); } }