Beispiel #1
0
 private void toolStripButtonAddFav_Click(object sender, EventArgs e)
 {
     if (listBoxClips.Focused)
     {
         int Index = listBoxClips.SelectedIndex;
         if (Index != -1)
         {
             ClipItem Clip = listBoxClips.fClips[Index];
             listBoxFavorites.fFavorites.Add(Clip);
             listBoxFavorites.Items.Add(listBoxFavorites.fFavorites.Count.ToString());
         }
         listBoxFavorites.Refresh();
     }
 }
Beispiel #2
0
        public void Paste(ClipItem clip)
        {
            switch (clip.Type)
            {
            case ClipItem.EType.eText:
            {
                fLocalCopy = true;
                DataObject data = new DataObject();
                data.SetData(DataFormats.Text, clip.Content);
                Clipboard.Clear();
                Clipboard.SetDataObject(data);
                if (fCallFromHotkey)
                {
                    fCallFromHotkey = false;
                    Hide();
                    SendKeys.SendWait("^v");
                }
                break;
            }

            case ClipItem.EType.eImage:
            {
                fLocalCopy = true;
                DataObject data = new DataObject();
                data.SetData(DataFormats.Bitmap, clip.Image);
                Clipboard.Clear();
                Clipboard.SetDataObject(data);
                if (fCallFromHotkey)
                {
                    fCallFromHotkey = false;
                    Hide();
                    SendKeys.SendWait("^v");
                }
                break;
            }

            default:
                break;
            }
        }
Beispiel #3
0
        private void InsertClip()
        {
            IDataObject iData = Clipboard.GetDataObject();

            if (iData != null)
            {
                //Handle TXT clipboard
                if (iData.GetDataPresent(DataFormats.Text))
                {
                    IntPtr  hwnd = APIFuncs.GetForegroundWindow();
                    Int32   pid  = APIFuncs.GetWindowProcessID(hwnd);
                    Process p    = Process.GetProcessById(pid);

                    ClipItem Item = new ClipItem(p.MainModule.FileName);
                    Item.Content = iData.GetData(DataFormats.StringFormat).ToString();
                    Item.Type    = ClipItem.EType.eText;
                    if (fLocalCopy == false)
                    {
                        bool foundedDuplicate = false;
                        foreach (ClipItem clip in listBoxClips.fClips)
                        {
                            if (clip.Content == Item.Content)
                            {
                                //Add stats
                                Item.Count = ++clip.Count;
                                bool foundedMFU = false;
                                foreach (ClipItem mfclip in listBoxMFU.fMFU)
                                {
                                    if (mfclip.Content == Item.Content)
                                    {
                                        foundedMFU   = true;
                                        mfclip.Count = Item.Count;
                                        listBoxMFU.fMFU.Remove(mfclip);
                                        listBoxMFU.fMFU.Add(mfclip);
                                        break;
                                    }
                                }
                                if (!foundedMFU)
                                {
                                    listBoxMFU.fMFU.Add(Item);
                                    listBoxMFU.Items.Add(listBoxMFU.fMFU.Count.ToString());
                                }

                                //Duplicate
                                if (Properties.Settings.Default.AvoidDuplicate)
                                {
                                    foundedDuplicate = true;
                                    listBoxClips.fClips.Remove(clip);
                                    listBoxClips.fClips.Add(clip);
                                    break;
                                }
                            }
                        }
                        listBoxMFU.Refresh();
                        //EO Duplicate
                        if (!foundedDuplicate)
                        {
                            listBoxClips.fClips.Add(Item);
                            listBoxClips.Items.Add(listBoxClips.fClips.Count.ToString());
                        }
                        trayIcon.ShowBalloonTip(500, Properties.Resources.ClipOfTypeText, Item.Content, ToolTipIcon.Info);
                    }
                    else
                    {
                        fLocalCopy = false;
                    }
                    listBoxClips.Refresh();
                }

                //Handle Bitmap element
                if (iData.GetDataPresent(DataFormats.Bitmap))
                {
                    IntPtr  hwnd = APIFuncs.GetForegroundWindow();
                    Int32   pid  = APIFuncs.GetWindowProcessID(hwnd);
                    Process p    = Process.GetProcessById(pid);

                    ClipItem Item = new ClipItem(p.MainModule.FileName);
                    Item.Image = (Bitmap)iData.GetData(DataFormats.Bitmap);
                    Item.Type  = ClipItem.EType.eImage;
                    if (fLocalCopy == false)
                    {
                        listBoxClips.fClips.Add(Item);
                        listBoxClips.Items.Add(listBoxClips.fClips.Count.ToString());
                        trayIcon.ShowBalloonTip(500, Properties.Resources.ClipOfTypeImage, Item.Image.Size.ToString(), ToolTipIcon.Info);
                    }
                    else
                    {
                        fLocalCopy = false;
                    }
                }

#warning Handle files element

                /*
                 *      string[] type = iData.GetFormats();
                 *      int a = type.Length;
                 *      if (a == 3)
                 *      {
                 *          int b = 3;
                 *      }
                 */
            }
        }