private static void AppendFileToClipboard(string filePath) { DataObject newDataObject = ClipboardData.CloneDataObject(monitorModeData.Storage); newDataObject.SetData(DataFormats.FileDrop, true, new string[] { filePath }); //ClipboardMonitor.Stop(); Clipboard.SetDataObject(newDataObject, true); //ClipboardMonitor.Start(); }
public static void StartMonitorMode() { // Create temp folder if it does not exist, and clear it PathGenerator.InitMonitorTempFolder(); PathGenerator.ClearMonitorTempFolder(); monitorModeData = new ClipboardData(); // start monitor ClipboardMonitor.OnClipboardChange += ClipboardMonitor_OnClipboardChange; ClipboardMonitor.Start(); }
//public static void StartCollectionMode() //{ //} //public static void StopCollectionMode() //{ //} #endregion #region FastPasteMode public static void QuickPasteEx(string location, string fileName = null) { ManualResetEvent allDone = new ManualResetEvent(false); ClipboardData quickPasteData = new ClipboardData(); quickPasteData.SaveCompleted += () => allDone.Set(); string[] extensions = quickPasteData.Analyze(); if (!string.IsNullOrEmpty(fileName)) { string ext = Path.GetExtension(fileName); extensions = new string[1] { ext }; if (Array.IndexOf(extensions, ext) == -1) { // TODO // maybe need some tips } } if (extensions.Length > 0) { // why the disk root directory has '"' ?? if (location.LastIndexOf('"') == location.Length - 1) { location = location.Substring(0, location.Length - 1); } string currentLocation = location.EndsWith("\\") ? location : location + "\\"; string path = null; if (string.IsNullOrEmpty(fileName)) { path = currentLocation + PathGenerator.GenerateFileName(currentLocation, extensions[0]) + "." + extensions[0]; } else { path = currentLocation + fileName; } Console.WriteLine(fileName); if (!Directory.Exists(currentLocation)) { Console.WriteLine(Resources.Strings.TipTargetPathNotExist); MessageBox.Show(Resources.Strings.TipTargetPathNotExist, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (File.Exists(path)) { DialogResult result = MessageBox.Show(string.Format(Resources.Strings.TipTargetFileExisted, path), Resources.Strings.Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { quickPasteData.Save(path, extensions[0]); } else if (result == DialogResult.No) { return; } } else { quickPasteData.Save(path, extensions[0]); } } } else { Console.WriteLine(Resources.Strings.TipAnalyzeFailedWithoutPrompt); MessageBox.Show(Resources.Strings.TipAnalyzeFailedWithoutPrompt, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } allDone.WaitOne(); }
public TextProcessor(ClipboardData clipData) : base(clipData) { Data = clipData; }
public FileProcessor(ClipboardData clipData) : base(clipData) { Data = clipData; }
public HtmlProcessor(ClipboardData clipData) : base(clipData) { Data = clipData; }
public BaseProcessor(ClipboardData clipData) { Data = clipData; }