예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        //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();
        }
예제 #4
0
 public TextProcessor(ClipboardData clipData) : base(clipData)
 {
     Data = clipData;
 }
예제 #5
0
 public FileProcessor(ClipboardData clipData) : base(clipData)
 {
     Data = clipData;
 }
예제 #6
0
 public HtmlProcessor(ClipboardData clipData) : base(clipData)
 {
     Data = clipData;
 }
예제 #7
0
 public BaseProcessor(ClipboardData clipData)
 {
     Data = clipData;
 }