Esempio n. 1
0
        private void paste()
        {
            /*MessageBox.Show("Image: " + Clipboard.ContainsImage()
             + "\nFileDropList: " + Clipboard.ContainsFileDropList()
             + "\nText: " + Clipboard.ContainsText()
             + "\nAudio: " + Clipboard.ContainsAudio());*/
            if (Clipboard.ContainsImage())
            {
                Image  img     = Clipboard.GetImage();
                string imgDir  = currentDir + "/_image/";
                string imgName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".jpg";
                if (!Directory.Exists(imgDir))
                {
                    Directory.CreateDirectory(imgDir);
                }

                img.Save(imgDir + imgName, ImageFormat.Jpeg);
                Clipboard.SetText("![](./_image/" + imgName + ")");
                richTextBox1.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
                Clipboard.SetImage(img);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                StringCollection files         = Clipboard.GetFileDropList();
                string           attachmentDir = currentDir + "/_attachment/";
                if (!Directory.Exists(attachmentDir))
                {
                    Directory.CreateDirectory(attachmentDir);
                }

                foreach (string file in files)
                {
                    string fileName = Path.GetFileName(file).Replace(" ", "");
                    File.Copy(file, attachmentDir + fileName, true);
                    Clipboard.SetText("[" + fileName + "](./_attachment/" + fileName + ")");
                    richTextBox1.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
                }
                Clipboard.SetFileDropList(files);
            }
            else
            {
                richTextBox1.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
            }
        }
Esempio n. 2
0
        public void DrawContent()
        {
            if (Clipboard.ContainsText())
            {
                String content = Clipboard.GetText();
                Console.WriteLine("Cb TEXT : " + content);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                // we have a file drop list in the clipboard
                foreach (String f in Clipboard.GetFileDropList())
                {
                    Console.WriteLine("CB FILEDROPLIST : " + f);
                }
            }
            else if (Clipboard.ContainsImage())
            {
                Console.WriteLine("CB IMMAGINE!!!!!");

                /*
                 * // Because of a known issue in WPF,
                 * // we have to use a workaround to get correct
                 * // image that can be displayed.
                 * // The image have to be saved to a stream and then
                 * // read out to workaround the issue.
                 * MemoryStream ms = new MemoryStream();
                 * BmpBitmapEncoder enc = new BmpBitmapEncoder();
                 * enc.Frames.Add(BitmapFrame.Create(Clipboard.GetImage()));
                 * enc.Save(ms);
                 * ms.Seek(0, SeekOrigin.Begin);
                 *
                 * BmpBitmapDecoder dec = new BmpBitmapDecoder(ms,
                 *   BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                 *
                 * Image img = new Image();
                 * img.Stretch = Stretch.Uniform;
                 * img.Source = dec.Frames[0];
                 * pnlContent.Children.Add(img);*/
            }
            else
            {
                Console.WriteLine("CB FORMATO NON SUPPORTATO");
            }
        }
Esempio n. 3
0
        public static BitmapSource GetClipboardImage(bool containsAlpha = false)
        {
            BitmapSource bitmapSource = null;

            if (Clipboard.ContainsImage())
            {
                bitmapSource = Clipboard.GetImage();
            }
            else if (Clipboard.ContainsFileDropList())
            {
                var fileDropList = Clipboard.GetFileDropList();
                if (fileDropList.Count <= 0)
                {
                    return(null);
                }
                bitmapSource = GetImageFromFile(fileDropList [0]);
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();
                if (!File.Exists(text))
                {
                    return(null);
                }
                bitmapSource = GetImageFromFile(text);
            }
            else
            {
                return(null);
            }

            if (bitmapSource == null)
            {
                return(null);
            }

            bitmapSource = new FormatConvertedBitmap(bitmapSource,
                                                     containsAlpha
                                ? System.Windows.Media.PixelFormats.Bgra32
                                : System.Windows.Media.PixelFormats.Bgr24, null, 0);
            bitmapSource.Freeze();

            return(bitmapSource);
        }
Esempio n. 4
0
        public static List <ClipboardFileInfo> GetClipboardFiles()
        {
            var list = new List <ClipboardFileInfo>();

            if (Clipboard.ContainsFileDropList())
            {
                var fileDropList = Clipboard.GetFileDropList();
                if (fileDropList != null && fileDropList.Count != 0)
                {
                    foreach (string item in fileDropList)
                    {
                        var fi = new System.IO.FileInfo(item);
                        if (fi.Exists && (fi.Attributes & FileAttributes.Directory) == 0)    //Only files
                        {
                            list.Add(new ClipboardFileInfo(fi));
                        }
                    }
                }
            }
            else
            {
                var dataObject = (DataObject)Clipboard.GetDataObject();
                List <NativeMethods.FILEDESCRIPTOR> descriptors = GetFileDescriptors(dataObject);
                int fileIndex = -1;
                foreach (var descriptor in descriptors)
                {
                    fileIndex++;

                    if ((descriptor.dwFlags & NativeMethods.FD.FD_ATTRIBUTES) != 0 &&
                        ((FileAttributes)descriptor.dwFileAttributes & FileAttributes.Directory) == 0)    //Only files
                    {
                        if (descriptors.Any(o => descriptor.cFileName.StartsWith(o.cFileName + "\\")))    //File in folder
                        {
                            continue;
                        }

                        long length = ((descriptor.nFileSizeHigh << 0x20) | (descriptor.nFileSizeLow & ((long)0xffffffffL)));
                        list.Add(new ClipboardFileInfo(dataObject, fileIndex, descriptor.cFileName, (FileAttributes)descriptor.dwFileAttributes, length));
                    }
                }
            }

            return(list);
        }
Esempio n. 5
0
        private void FileCopy()
        {
            string desPath = Path.Combine(Environment.CurrentDirectory, "test");

            if (Clipboard.ContainsFileDropList())
            {
                var files = Clipboard.GetFileDropList();

                if (files.Count > 0)
                {
                    FileHelper.CopyFileFromClipbord(desPath);
                    foreach (var file in files)
                    {
                        string newFilePath = Path.Combine(desPath, Path.GetFileName(file));
                        Assert.IsTrue(File.Exists(newFilePath));
                    }
                }
            }
        }
Esempio n. 6
0
        //bool ImagesAreDifferent(System.Drawing.Image img1, System.Drawing.Image img2)
        //{
        //    Bitmap bmp1 = new Bitmap(img1);
        //    Bitmap bmp2 = new Bitmap(img2);

        //    bool different = false;
        //    if (bmp1.Width == bmp2.Width && bmp1.Height == bmp2.Height)
        //    {
        //        for (int i = 0; i < bmp1.Width; i++)
        //        {
        //            for (int j = 0; j < bmp1.Height; j++)
        //            {
        //                System.Drawing.Color col1 = bmp1.GetPixel(i, j);
        //                System.Drawing.Color col2 = bmp2.GetPixel(i, j);
        //                if (col1 != col2)
        //                {
        //                    i = bmp1.Width + 1;
        //                    different = true;
        //                    break;
        //                }
        //            }
        //        }
        //    }
        //    return different;
        //}
        #endregion
        private IDataItem GetClipboardData()
        {
            if (Clipboard.ContainsText())
            {
                return(new TextData());
            }
            else if (Clipboard.ContainsFileDropList())
            {
                return(new FileData());
            }
            else if (Clipboard.ContainsImage())
            {
                return(new ImageData());
            }
            else
            {
                return(new UnknownData());
            }
        }
Esempio n. 7
0
 //
 public static bool ClipBoardContainsDropFileImg()
 {
     if (Clipboard.ContainsFileDropList())
     {
         string[] imgExtensions = new string[6] {
             "PNG", "JPEG", "jpeg", "png", "jpg", "JPG"
         };
         foreach (var imgExt in Clipboard.GetFileDropList())
         {
             //MessageBox.Show(imgExt);
             //MessageBox.Show(imgExt.Substring(imgExt.LastIndexOf(".")));
             if (imgExtensions.Contains(imgExt.Substring(imgExt.LastIndexOf(".") + 1)))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 8
0
 //Вставка клавиатурная
 public void KeyboardPaste(String Path)
 {
     if (Clipboard.ContainsFileDropList())
     {
         var Res = Clipboard.GetFileDropList();
         foreach (var x in Res)
         {
             String FileName   = FileProcessor.ExecuteFileName(x);
             String FileFolder = FileProcessor.ExecuteFileFolder(x, FileName);
             try
             {
                 FilesCopyQueue.Add(new CopyInform(FileFolder, Path, FileName, System.IO.Directory.Exists(x) ? "Folder" : (new FileInfo(x)).Length.ToString(), FilesCopyQueue, Mode.Copy, Checker));
             }
             catch (Exception)
             {
             }
         }
     }
 }
Esempio n. 9
0
        private void CopyFilesLoggerAction(string mapName, FileStream fileStream)
        {
            if (Clipboard.ContainsFileDropList())
            {
                var currentCopiedFiles = Clipboard.GetFileDropList().Cast <string>().ToList();

                if (!currentCopiedFiles.SequenceEqual(lastCopiedFiles))
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        var formatter = new BinaryFormatter();

                        formatter.Serialize(memoryStream, copyFilesLog);

                        using (var map = MemoryMappedFile.CreateFromFile(fileStream, mapName, memoryStream.Length, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.None, false))
                        {
                            using (var viewStream = map.CreateViewStream())
                            {
                                var currentCopiedFilesInfo = new List <SuncatFileInfo>();

                                foreach (var copiedFile in currentCopiedFiles)
                                {
                                    var fileInfo = new FileInfo(copiedFile);
                                    currentCopiedFilesInfo.Add(new SuncatFileInfo()
                                    {
                                        FileInfo = fileInfo, IsDirectory = fileInfo.Attributes.HasFlag(FileAttributes.Directory)
                                    });
                                }

                                copyFilesLog.Event      = SuncatLogEvent.CopyFile;
                                copyFilesLog.DataObject = currentCopiedFilesInfo;

                                formatter.Serialize(fileStream, copyFilesLog);
                                fileStream.Position = 0;

                                copyFilesLog.Event = SuncatLogEvent.None;
                                lastCopiedFiles    = currentCopiedFiles;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case 0x0300:

                writeLog("Cut");
                SendMessage(_ClipboardViewerNext, m.Msg, m.WParam, m.LParam);
                break;

            case 0x0301:
                SendMessage(_ClipboardViewerNext, m.Msg, m.WParam, m.LParam);
                writeLog("Copy");
                break;

            case 0x0308:

                writeLog(Clipboard.ContainsFileDropList().ToString());
                getData();
                SendMessage(_ClipboardViewerNext, m.Msg, m.WParam, m.LParam);
                break;

            case 0x030D:
                if (m.WParam == _ClipboardViewerNext)
                {
                    //
                    // If wParam is the next clipboard viewer then it
                    // is being removed so update pointer to the next
                    // window in the clipboard chain
                    //
                    _ClipboardViewerNext = m.LParam;
                }
                else
                {
                    SendMessage(_ClipboardViewerNext, m.Msg, m.WParam, m.LParam);
                }
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Esempio n. 11
0
        private void Time_Tick(object sender, EventArgs e)
        {
            if (Clipboard.ContainsFileDropList())
            {
                clipList.Clear();
                int    length = Clipboard.GetFileDropList().Count;
                string txt2   = "";
                for (int i = 0; i < length; i++)
                {
                    clipList.Add(Clipboard.GetFileDropList()[i]);
                    txt2 += clipList[i].ToString() + "\t";
                    //MessageBox.Show(txt[i].ToString());
                }
                Clipboard.Clear();

                MessageBox.Show(txt2, "Все файлы в буфере", MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            }
        }
Esempio n. 12
0
        public static bool PasteFromClipboard(NoteEditor editor, PersistentTree tree)
        {
            if (Clipboard.ContainsImage())
            {
                Image image = Clipboard.GetImage();

                var imagePath = ImageLocalPath.CreateNewLocalPath("png");

                MemoryStream ms = new MemoryStream();
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                tree.SetByteArray(imagePath.FileName, ms.ToArray());

                var htmlImage = new HtmlImageCreator(editor);
                htmlImage.InsertImage(imagePath.Url, "");

                return(true);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                var fileList  = Clipboard.GetFileDropList();
                var imageList = FilterImageFiles(fileList);
                if (imageList.Any())
                {
                    imageList.ForEach(i =>
                    {
                        var localPath = ImageLocalPath.CreateNewLocalPath(Path.GetExtension(i).Substring(1));
                        tree.SetByteArray(localPath.FileName, File.ReadAllBytes(i));

                        var htmlImage = new HtmlImageCreator(editor);
                        htmlImage.InsertImage(localPath.Url, "");
                    });
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Esempio n. 13
0
        public static string[] GetFileDropList(bool checkContainsFileDropList = false)
        {
            try
            {
                lock (ClipboardLock)
                {
                    if (!checkContainsFileDropList || Clipboard.ContainsFileDropList())
                    {
                        return(Clipboard.GetFileDropList().Cast <string>().ToArray());
                    }
                }
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e, "Clipboard get file drop list failed.");
            }

            return(null);
        }
Esempio n. 14
0
        protected override void Execute(object parameter)
        {
            if (Clipboard.ContainsImage())
            {
                // TODO: できれば画像データ(byte配列など)で取得したい
                var attachment = UploadMedia.FromBitmapSource(Clipboard.GetImage(), UploadMedia.DisplayExtensions.Clipboard);

                this._viewModel.PostParameters.Attachments.Add(attachment);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                var files = Clipboard.GetFileDropList();


                this._viewModel.PostParameters.Attachments.AddRange(
                    GetEnableMediaFiles(files)
                    .Select(file => UploadMedia.FromFile(file)));
            }
        }
Esempio n. 15
0
        private void _btnConfirmClipboardUpload_Click(object sender, EventArgs e)
        {
            // Check to see if the user has disabled verification of upload.
            if (show_clipboard_confirmation == true)
            {
                hideConfirmMenu();
            }

            if (Clipboard.ContainsFileDropList())
            {
                foreach (string file in Clipboard.GetFileDropList())
                {
                    uploadFile(file);
                }
            }
            else if (Clipboard.ContainsImage())
            {
                uploadImage(Clipboard.GetImage(), "Clipboard_");
            }
            else if (Clipboard.ContainsText())
            {
                string       temp_file = Path.GetTempFileName();
                StreamWriter sw        = new StreamWriter(temp_file);
                sw.Write(Clipboard.GetText());
                sw.Close();

                int    total_text   = getAndIncrementConfig("uploads.total_text_files");
                string new_filename = Path.GetTempPath() + "\\Clipboard_Text_" + total_text.ToString() + ".txt";

                File.Move(temp_file, new_filename);
                FileInfo fi = new FileInfo(new_filename);

                DC_FileInformation file_info = new DC_FileInformation()
                {
                    file_name           = Path.GetFileName(new_filename),
                    delete_after_upload = true,
                    file_size           = fi.Length,
                    local_file_location = new_filename
                };

                uploadFile(file_info);
            }
        }
Esempio n. 16
0
        public void OnButtonClick()
        {
            bool fFilesInClipboard = false;

            try {
                fFilesInClipboard = Clipboard.ContainsFileDropList();
            }
            catch {
            }

            if (fFilesInClipboard)
            {
                FileOps.FileOperation(FileOpActions.Paste, this.pluginServer.ExplorerHandle, null);
            }
            else
            {
                System.Media.SystemSounds.Beep.Play();
            }
        }
Esempio n. 17
0
 public void FromClipboard()
 {
     if (Clipboard.ContainsAudio())
     {
         stream = Clipboard.GetAudioStream();
     }
     else if (Clipboard.ContainsFileDropList())
     {
         stringCollection = Clipboard.GetFileDropList();
     }
     else if (Clipboard.ContainsImage())
     {
         image = Clipboard.GetImage();
     }
     else if (Clipboard.ContainsText())
     {
         text = Clipboard.GetText();
     }
 }
Esempio n. 18
0
        private void tmrCheckNewClipboardContent_Tick(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                AddToTextListBox();
            }


            if (Clipboard.ContainsImage())
            {
                AddToPictureBox();
            }


            if (Clipboard.ContainsFileDropList())
            {
                AddToFileListBox();
            }
        }
Esempio n. 19
0
 public List <object> LoadClipboardObjects()
 {
     return(LockIfNeeded(() =>
     {
         List <object> result = new List <object>();
         if (Clipboard.ContainsImage())
         {
             result.Add(Clipboard.GetImage());
         }
         if (Clipboard.ContainsFileDropList())
         {
             result.Add(Clipboard.GetFileDropList());
         }
         if (Clipboard.ContainsText())
         {
             result.Add(Clipboard.GetText());
         }
         return result;
     }));
 }
Esempio n. 20
0
        private void txtMessage_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && (e.KeyCode == Keys.V))
            {
                if (Clipboard.ContainsFileDropList())
                {
                    List <string> fileNames = new List <string>();

                    foreach (string filePath in Clipboard.GetFileDropList())
                    {
                        if (File.Exists(filePath))
                        {
                            fileNames.Add(filePath);
                        }
                    }

                    ShareFiles(fileNames.ToArray());
                }
            }
        }
Esempio n. 21
0
        public static ClipboardContent GetContents()
        {
            if (Clipboard.ContainsFileDropList())
            {
                return(new ClipboardContent
                {
                    Files = Clipboard.GetFileDropList().Cast <string>().ToList()
                });
            }

            if (Clipboard.ContainsText(TextDataFormat.Text))
            {
                return(new ClipboardContent
                {
                    Text = Clipboard.GetText()
                });
            }

            return(new ClipboardContent());
        }
Esempio n. 22
0
 static void Main(string[] args)
 {
     if (Clipboard.ContainsImage())
     {
         Output(UploadImage(Clipboard.GetImage() as Bitmap));
     }
     else if (Clipboard.ContainsFileDropList())
     {
         Output(UploadFile(new FileInfo(Clipboard.GetFileDropList()[0])));
     }
     else if (Clipboard.ContainsText())
     {
         Thread.Sleep(100);                 // Sometimes there are issue with focus if we do this too fast
         Output(Clipboard.GetText(TextDataFormat.UnicodeText));
     }
     else
     {
         Debug.WriteLine("no clipboard data");
     }
 }
        /// returns the string representation of clipboard data
        private static string GetClipboard()
        {
            string result    = "";        //The result to return
            Thread STAThread = new Thread //Create a new thread
                               (
                delegate()
            {
                if (Clipboard.ContainsAudio())
                {
                    result = "System.IO.Stream [Clipboard Data is Audio Stream]";                                    //Clipboard is audio data
                }
                else if (Clipboard.ContainsImage())
                {
                    result = "System.Drawing.Image [Clipboard data is Image]";                                               //Clipboard is image data
                }
                else if (Clipboard.ContainsFileDropList())                                                                   //Clipboard is a filed list
                {
                    System.Collections.Specialized.StringCollection files = Clipboard.GetFileDropList();                     //Get the file list
                    result = "System.Collections.Specialized.StringCollection [Clipboard Data is File Drop List]\nFiles:\n"; //Set the header
                    foreach (string file in files)                                                                           //Go through the stored files
                    {
                        result += file + "\n";                                                                               //Appends the path of the file
                    }
                }
                else if (Clipboard.ContainsText())
                {
                    result = "System.String [Clipboard Data is Text]\nText:\n" + Clipboard.GetText();                                        //Clipboard is text
                }
                else
                {
                    result = "Clipboard Data Not Retrived!\nPerhaps no data was selected when ctrl+c was pressed :("; //No clibpoard data
                }
                string text = obj.GetData(DataFormats.Text).ToString();                                               //Get the text data in the clipboard
            }
                               );

            STAThread.SetApartmentState(ApartmentState.STA); //Create a new STA thread
            STAThread.Start();                               //Start the thread
            STAThread.Join();                                //Join the thread (block execution)
            return(result);                                  //Return the result of the thread
        }
Esempio n. 24
0
        /// <summary>
        /// Set CapturedImage.Image as the image/image file copied to clipboard
        /// </summary>
        public static void GetFromClipboard()
        {
            // Load the image from a copied image
            if (Clipboard.ContainsImage())
            {
                CapturedImage.Image = Clipboard.GetImage();
            }
            // Load the image from a copied image file
            else if (Clipboard.ContainsFileDropList())
            {
                CapturedImage.Image = Image.FromFile(Clipboard.GetFileDropList()[0]);
            }
            // Load the image from a copied image url
            else if (Common.ImageUrlInClipboard)
            {
                CapturedImage.Image = GetFromUrl(Clipboard.GetText());
            }

            // Prevent null reference exception
            if (CapturedImage.Image == null)
            {
                return;
            }

            Common.OtherFormOpen = true;
            // Generate a random name for the file
            Common.Random      = Common.RandomString(Common.Profile.FileLenght);
            CapturedImage.Name = Common.Random + Common.GetFormat(CapturedImage.Image.RawFormat);

            // Get the image link, copy (?) to clipboard
            CapturedImage.Link = Common.GetLink();
            if (Common.CopyLink)
            {
                Clipboard.SetText(CapturedImage.Link);
            }

            // If the user's account works, start uploading
            CheckStartUpload();
            // raise UploadComplete to start looking for software updates
            UploadComplete(null, EventArgs.Empty);
        }
Esempio n. 25
0
        private void toolStripMenuItemPaste_Click(object sender, EventArgs e)
        {
            if (treeView.SelectedNode != null)
            {
                bool copy = false;
                try
                {
                    DirectoryInfo[] directories = directoryInfo.GetDirectories();
                    if (directories.Length > 0)
                    {
                        foreach (DirectoryInfo directory in directories)
                        {
                            if (directory.Name == treeView.SelectedNode.Text && Clipboard.ContainsFileDropList())
                            {
                                foreach (string file in Clipboard.GetFileDropList())
                                {
                                    string targetDir = directoryInfo.FullName + @"\" + directory.Name;
                                    File.Copy(Path.Combine(file.Replace(Path.GetFileName(file), ""), Path.GetFileName(file)), Path.Combine(targetDir, Path.GetFileName(file)), true);
                                }
                                copy = true;
                            }
                        }
                    }

                    if (copy)
                    {
                        foreach (string file in Clipboard.GetFileDropList())
                        {
                            TreeNode node = treeView.Nodes[0].Nodes[treeView.SelectedNode.Index].Nodes.Add(Path.GetFileName(file));
                            SetImageExtension(file, node);
                        }
                        copy = false;
                    }
                }
                catch (Exception ex)
                {
                    copy = false;
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 26
0
        private string RtnClipboard()
        {
            string rtn = "";

            if (Clipboard.ContainsText())
            {
                rtn = Regex.Replace(Clipboard.GetText(), RgxNL, NL);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                List <string> l1 = new List <string>();
                foreach (string _s1 in Clipboard.GetFileDropList())
                {
                    l1.Add(_s1);
                }
                l1.Sort();
                rtn = RtnShortPath(l1);
            }

            return(rtn);
        }
Esempio n. 27
0
        public void Execute(object parameter)
        {
            try
            {
                new CopyHelper(_workspace).CopySelectionToClipboard();
                var target = _workspace.CommanderTargetLayoutDocument;
                if (!(target.Content is FileLister lister) || !Clipboard.ContainsFileDropList())
                {
                    return;
                }

                var items = Clipboard.GetFileDropList();
                Task.Factory.StartNew(() => { new FilesystemAction(_workspace.NotificationHost).Move(lister.Path, items); });
                Clipboard.Clear();
                _workspace.FocusCurrentOrFirst();
            }
            catch (Exception ex)
            {
                throw new Exception("Error Moving", ex);
            }
        }
Esempio n. 28
0
        public static string[] GetImageFilenames()
        {
            if (Clipboard.ContainsFileDropList())
            {
                var files = Clipboard.GetFileDropList();
                var list  = files.Cast <string>().Where(IsImageFile).ToArray();
                return(list.Length == 0 ? null : list);
            }

            if (Clipboard.ContainsText())
            {
                var text = Clipboard.GetText();
                if (IsImageFile(text))
                {
                    return new [] { text }
                }
                ;
            }

            return(null);
        }
Esempio n. 29
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == (Keys.C | Keys.Control))
     {
         ListBox listBox = GetCurrentListBox();
         CorePathWithSubFolder[] path = GetCurrentPath();
         if (listBox != null && path != null && listBox.SelectedIndex >= 0 && listBox.SelectedIndex < path.Length)
         {
             Clipboard.SetDataObject(path[listBox.SelectedIndex]);
         }
     }
     else if (e.KeyData == (Keys.V | Keys.Control))
     {
         ListBox listBox = GetCurrentListBox();
         if (listBox != null)
         {
             if (Clipboard.ContainsFileDropList())
             {
                 StringCollection fileDropList = Clipboard.GetFileDropList();
                 string[]         path         = new string[fileDropList.Count];
                 fileDropList.CopyTo(path, 0);
                 AddPath(path);
             }
             else if (Clipboard.ContainsText())
             {
                 string[] path = new string[1];
                 path[0] = Clipboard.GetText();
                 AddPath(path);
             }
         }
     }
     else if (e.KeyData == (Keys.X | Keys.Control))
     {
         RemovePath(true);
     }
     else if (e.KeyData == Keys.Delete)
     {
         RemovePath(false);
     }
 }
Esempio n. 30
0
        private void DoPaste()
        {
            try
            {
                if (Clipboard.ContainsImage())
                {
                    string filePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".jpg");
                    using (var fileStream = new FileStream(filePath, FileMode.Create))
                    {
                        var image   = Clipboard.GetImage();
                        var encoder = new JpegBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(image));
                        encoder.Save(fileStream);
                    }

                    SendFile(filePath);
                }
                else if (Clipboard.ContainsFileDropList())
                {
                    var files = Clipboard.GetFileDropList();

                    foreach (var file in files)
                    {
                        SendFile(file);
                        // Задержка нужна для корректной работы DateTime.Now,
                        // по которому определяется ID сообщения
                        Thread.Sleep(25);
                    }
                }
                else if (Clipboard.ContainsText())
                {
                    string text = Clipboard.GetText();
                    AppendText(text);
                }
            }
            catch (Exception ex)
            {
                ex.Process(ErrorHandlingLevels.Tray);
            }
        }