/// <summary> /// Sets Clipboard text and returns the content /// </summary> /// <returns></returns> public static string SetClipboardText(WorkerTask task, bool showDialog) { string clipboardText = ""; switch (task.JobCategory) { case JobCategoryType.PICTURES: case JobCategoryType.SCREENSHOTS: case JobCategoryType.BINARY: ScreenshotsHistory = task.LinkManager; if (GraphicsMgr.IsValidImage(task.LocalFilePath)) { if (Engine.conf.ShowClipboardModeChooser || showDialog) { ClipboardOptions cmp = new ClipboardOptions(task); cmp.Icon = Resources.zss_main; if (showDialog) { cmp.ShowDialog(); } else { cmp.Show(); } } if (task.MyImageUploader == ImageDestType.FILE) { clipboardText = task.LocalFilePath; } else { clipboardText = ScreenshotsHistory.GetUrlByType(Engine.conf.ClipboardUriMode).ToString().Trim(); if (task.MakeTinyURL) { string tinyUrl = ScreenshotsHistory.GetUrlByType(ClipboardUriType.FULL_TINYURL); if (!string.IsNullOrEmpty(tinyUrl)) { clipboardText = tinyUrl.Trim(); } } } } break; case JobCategoryType.TEXT: switch (task.Job) { case WorkerTask.Jobs.LANGUAGE_TRANSLATOR: if (null != task.TranslationInfo) { clipboardText = task.TranslationInfo.Result.TranslatedText; } break; default: if (!string.IsNullOrEmpty(task.RemoteFilePath)) { clipboardText = task.RemoteFilePath; } else if (null != task.MyText) { clipboardText = task.MyText.LocalString; } else { clipboardText = task.LocalFilePath; } break; } break; } // after all this the clipboard text can be null if (!string.IsNullOrEmpty(clipboardText)) { Engine.ClipboardUnhook(); FileSystem.AppendDebug("Setting Clipboard with URL: " + clipboardText); Clipboard.SetText(clipboardText); // optional deletion link string linkdel = ScreenshotsHistory.GetDeletionLink(); if (!string.IsNullOrEmpty(linkdel)) { FileSystem.AppendDebug("Deletion Link: " + linkdel); } Engine.zClipboardText = clipboardText; Engine.ClipboardHook(); } return clipboardText; }
/// <summary> /// Sets Clipboard text and returns the content /// </summary> /// <returns></returns> public static void ShowUploadResults(WorkerTask task, bool showDialog) { if (!task.WorkflowConfig.ClipboardOverwrite && !Clipboard.ContainsFileDropList() && !Clipboard.ContainsImage() && !Clipboard.ContainsText() || task.WorkflowConfig.ClipboardOverwrite) { if (task.UploadResults.Count > 0) { if (task.WorkflowConfig.DestConfig.TaskClipboardContent.Count > 1 || Engine.ConfigUI.ShowUploadResultsWindow || showDialog) { ClipboardOptions cmp = new ClipboardOptions(task); cmp.Icon = Resources.zss_main; if (showDialog) { cmp.ShowDialog(); } else { NativeMethods.ShowWindow(cmp.Handle, (int)WindowShowStyle.ShowNoActivate); } showDialog = true; } } if (task.WorkflowConfig.DestConfig.Outputs.Contains(OutputEnum.Clipboard)) { StringBuilder clipboardText = new StringBuilder(); if (task.JobIsImageToClipboard()) { Adapter.CopyImageToClipboard(task.TempImage, task.WorkflowConfig.ClipboardForceBmp); } else if (task.WorkflowConfig.DestConfig.TaskClipboardContent.Contains(ClipboardContentEnum.Local)) { foreach (UploadResult ur in task.UploadResults) { if (Engine.ConfigUI.ConfLinkFormat.Count > 0) { clipboardText.AppendLine(ur.GetUrlByType((LinkFormatEnum)task.WorkflowConfig.DestConfig.LinkFormat[0], ur.LocalFilePath)); } if (!Engine.ConfigUI.ClipboardAppendMultipleLinks && clipboardText.Length > 0) { break; } } } else if (task.WorkflowConfig.DestConfig.TaskClipboardContent.Contains(ClipboardContentEnum.OCR)) { if (!string.IsNullOrEmpty(task.OCRText)) { clipboardText.Append(task.OCRText); } } // If the user requests for the full image URL, preference is given for the Shortened URL is exists else if (task.Job1 == EDataType.Image && task.WorkflowConfig.DestConfig.LinkFormat.Contains((int)LinkFormatEnum.FULL)) { if (task.Job3 == WorkerTask.JobLevel3.ShortenURL && !string.IsNullOrEmpty(task.UploadResults[0].ShortenedURL)) { foreach (UploadResult ur in task.UploadResults) { if (!string.IsNullOrEmpty(ur.ShortenedURL)) { clipboardText.AppendLine(ur.ShortenedURL); if (!Engine.ConfigUI.ClipboardAppendMultipleLinks && clipboardText.Length > 0) { break; } } } } // If no shortened URL exists then default full URL will be used else { foreach (UploadResult ur in task.UploadResults) { if (!string.IsNullOrEmpty(ur.URL)) { clipboardText.AppendLine(FileSystem.GetBrowserFriendlyUrl(ur.URL)); if (!Engine.ConfigUI.ClipboardAppendMultipleLinks && clipboardText.Length > 0) { break; } } } if (clipboardText.Length == 0 && task.WorkflowConfig.DestConfig.TaskClipboardContent.Contains(ClipboardContentEnum.Local)) { foreach (UploadResult ur in task.UploadResults) { if (!string.IsNullOrEmpty(ur.LocalFilePath)) { clipboardText.AppendLine(ur.LocalFilePath); if (!Engine.ConfigUI.ClipboardAppendMultipleLinks && clipboardText.Length > 0) { break; } } } } } } else { // From this point onwards app needs to respect all other Clipboard URL modes for Images if (task.UploadResults.Count > 0 && task.Job1 == EDataType.Image) { foreach (UploadResult ur in task.UploadResults) { if (task.WorkflowConfig.DestConfig.LinkFormat.Count > 0) { clipboardText.AppendLine(ur.GetUrlByType((LinkFormatEnum)task.WorkflowConfig.DestConfig.LinkFormat[0], ur.URL)); } if (!Engine.ConfigUI.ClipboardAppendMultipleLinks && clipboardText.Length > 0) { break; } } } // Text and File catagories are still left to process. Exception for Google Translate else if (task.Job1 == EDataType.Text && task.Job2 == WorkerTask.JobLevel2.Translate) { if (task.TranslationInfo != null) { clipboardText.AppendLine(task.TranslationInfo.Result); } } // Text and File catagories are still left to process. If shortened URL exists, preference is given to that else if (task.UploadResults.Count > 0 && task.Job3 == WorkerTask.JobLevel3.ShortenURL && !string.IsNullOrEmpty(task.UploadResults[0].ShortenedURL)) { foreach (UploadResult ur in task.UploadResults) { if (!string.IsNullOrEmpty(ur.ShortenedURL)) { clipboardText.AppendLine(ur.ShortenedURL); break; } } } // Otherwise full URL for Text or File is used else if (task.UploadResults.Count > 0) { clipboardText.AppendLine(FileSystem.GetBrowserFriendlyUrl(task.UploadResults[0].URL)); } } if (clipboardText.Length > 0) { bool bClipboardFormatOnLongUrl = Engine.ConfigUI.EnableClipboardFormatForLongURLs && task.Job1 == EDataType.URL; bool bClipboardFormat = bClipboardFormatOnLongUrl || task.Job1 != EDataType.URL; var np = new NameParser(NameParserType.Clipboard) { Link = clipboardText.ToString().Trim(), FileSize = task.Info.FileSize, FileName = task.Info.FileName }; if (bClipboardFormat) { np.WindowText = task.Info.WindowTitleText; } string tempText = bClipboardFormat ? np.Convert(Engine.ConfigUI.ClipboardFormat) : clipboardText.ToString().Trim(); if (!string.IsNullOrEmpty(tempText)) { DebugHelper.WriteLine("Setting Clipboard with URL: " + tempText); Clipboard.SetText(tempText); // auto Engine.zPreviousSetClipboardText = tempText; Engine.IsClipboardUploading = false; // optional deletion link if (task.UploadResults != null) { foreach (UploadResult ur in task.UploadResults) { string linkdel = ur.DeletionURL; if (!string.IsNullOrEmpty(linkdel)) { DebugHelper.WriteLine("Deletion Link: " + linkdel); } } } } } } if (!showDialog) { task.Dispose(); } } }
/// <summary> /// Sets Clipboard text and returns the content /// </summary> /// <returns></returns> public static string SetClipboardText(WorkerTask task, bool showDialog) { string clipboardText = ""; switch (task.JobCategory) { case JobCategoryType.PICTURES: case JobCategoryType.SCREENSHOTS: case JobCategoryType.BINARY: ScreenshotsHistory = task.LinkManager; if (GraphicsMgr.IsValidImage(task.LocalFilePath)) { if (Engine.conf.ShowClipboardModeChooser || showDialog) { ClipboardOptions cmp = new ClipboardOptions(task); cmp.Icon = Resources.zss_main; if (showDialog) { cmp.ShowDialog(); } else { cmp.Show(); } } if (task.MyImageUploader == ImageDestType.FILE) { clipboardText = task.LocalFilePath; } else { clipboardText = ScreenshotsHistory.GetUrlByType(Engine.conf.ClipboardUriMode).ToString().Trim(); if (task.MakeTinyURL) { string tinyUrl = ScreenshotsHistory.GetUrlByType(ClipboardUriType.FULL_TINYURL); if (!string.IsNullOrEmpty(tinyUrl)) { clipboardText = tinyUrl.Trim(); } } } } break; case JobCategoryType.TEXT: switch (task.Job) { case WorkerTask.Jobs.LANGUAGE_TRANSLATOR: if (null != task.TranslationInfo) { clipboardText = task.TranslationInfo.Result.TranslatedText; } break; default: if (!string.IsNullOrEmpty(task.RemoteFilePath)) { clipboardText = task.RemoteFilePath; } else if (null != task.MyText) { clipboardText = task.MyText.LocalString; } else { clipboardText = task.LocalFilePath; } break; } break; } // after all this the clipboard text can be null if (!string.IsNullOrEmpty(clipboardText)) { Engine.ClipboardUnhook(); FileSystem.AppendDebug("Setting Clipboard with URL: " + clipboardText); Clipboard.SetText(clipboardText); // optional deletion link string linkdel = ScreenshotsHistory.GetDeletionLink(); if (!string.IsNullOrEmpty(linkdel)) { FileSystem.AppendDebug("Deletion Link: " + linkdel); } Engine.zClipboardText = clipboardText; Engine.ClipboardHook(); } return(clipboardText); }