Esempio n. 1
0
        public static Process GetProcessLockingClipboard()
        {
            int processId;

            SystemUtilities.GetWindowThreadProcessId(SystemUtilities.GetOpenClipboardWindow(), out processId);
            return(Process.GetProcessById(processId));
        }
Esempio n. 2
0
 public static bool CopyStringToClipboard(string textToCopy)
 {
     for (int i = 1; i <= 3; i++)
     {
         try
         {
             Clipboard.SetText(textToCopy);
             return(true);
         }
         catch (System.Runtime.InteropServices.COMException exception)
         {
             if (i == 3)
             {
                 Process processLockingClipboard = SystemUtilities.GetProcessLockingClipboard();
                 string  message = string.Concat(new string[]
                 {
                     LocalizationProvider.GetLocalizedString("Error_ClipboardLockedMessage", false, "MarkdownPadStrings"),
                     StringUtilities.GetNewLines(2),
                     LocalizationProvider.GetLocalizedString("Error_ClipboardLockedBy", true, "MarkdownPadStrings"),
                     processLockingClipboard.ProcessName,
                     " (",
                     LocalizationProvider.GetLocalizedString("Error_ClipboardLockedWindowTitle", true, "MarkdownPadStrings"),
                     processLockingClipboard.MainWindowTitle,
                     ")"
                 });
                 MessageBoxHelper.ShowErrorMessageBox(message, LocalizationProvider.GetLocalizedString("Error_CopyToClipboardTitle", false, "MarkdownPadStrings"), exception, string.Format("Process Name: {0} Process Title: {1}", processLockingClipboard.ProcessName, processLockingClipboard.MainWindowTitle));
             }
         }
         catch (System.Exception exception2)
         {
             if (i == 3)
             {
                 MessageBoxHelper.ShowErrorMessageBox(LocalizationProvider.GetLocalizedString("Error_CopyToClipboardMessage", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("Error_CopyToClipboardTitle", false, "MarkdownPadStrings"), exception2, "");
             }
         }
     }
     return(false);
 }