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); }