예제 #1
0
 internal void Share(ClipboardEntry toShare)
 {
     lock (this)
     {
         data = toShare.Serialize();
     }
 }
예제 #2
0
        void copyFormat_Click(object sender, EventArgs e)
        {
            copying = true;
            ClipboardEntry ce = (ClipboardEntry)clips.SelectedItems[0].Tag;

            ce.CopyToClipboard(((ToolStripMenuItem)sender).Text);
            copying = false;
            fetchClipboardEntry();
        }
예제 #3
0
        private void copy_Click(object sender, EventArgs e)
        {
            copying = true;
            ClipboardEntry ce = (ClipboardEntry)clips.SelectedItems[0].Tag;

            ce.CopyToClipboard();
            copying = false;
            fetchClipboardEntry();
        }
예제 #4
0
 private void clips_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (clips.SelectedItems.Count == 0)
     {
         copy.Enabled           = false;
         delete.Enabled         = false;
         share.Enabled          = false;
         clips.ContextMenuStrip = null;
     }
     else
     {
         clips.ContextMenuStrip = copyStrip;
         copy.Enabled           = true;
         delete.Enabled         = true;
         share.Enabled          = true;
         while (copyStrip.Items.Count > 3)
         {
             copyStrip.Items.RemoveAt(3);
         }
         ClipboardEntry ce       = (ClipboardEntry)clips.SelectedItems[0].Tag;
         bool           firstSep = true;
         foreach (String s in ce.Formats)
         {
             if (s == null)
             {
                 copyStrip.Items.Add(new ToolStripSeparator());
                 ToolStripMenuItem i = new ToolStripMenuItem(firstSep ? "Auto-converted formats:" : "Extra conversions:");
                 i.Font    = storedFormatsToolStripMenuItem.Font;
                 i.Enabled = false;
                 copyStrip.Items.Add(i);
                 firstSep = false;
             }
             else
             {
                 ToolStripMenuItem i = new ToolStripMenuItem(s);
                 i.Click += new EventHandler(copyFormat_Click);
                 copyStrip.Items.Add(i);
             }
         }
     }
 }
예제 #5
0
 internal void DoAction(char mychar, ClipboardEntry ce, int index, string format)
 {
     if (mychar == 'x')
     {
         clips.Items.RemoveAt(index);
     }
     else if (mychar == 'X')
     {
         clips.Items.Clear();
     }
     else
     {
         copying = true;
         ce.CopyToClipboard(format);
         copying = false;
         fetchClipboardEntry();
         if (mychar == 'v')
         {
             using (new LockKeyResetter())
             {
                 SendKeys.Send("^v");
             }
         }
     }
 }
예제 #6
0
 private void receive_Click(object sender, EventArgs e)
 {
     while (onReceiveStrip.Items.Count > 2)
     {
         onReceiveStrip.Items.RemoveAt(0);
     }
     byte[] buff = new byte[4096];
     int len;
     foreach (KeyValuePair<string, string> p in servers)
     {
         TcpClient c;
         try
         {
             c = new TcpClient(p.Value, 5120);
         }
         catch (SocketException)
         {
             continue;
         }
         Stream s = c.GetStream();
         MemoryStream ms = new MemoryStream();
         while ((len = s.Read(buff, 0, buff.Length)) != 0)
         {
             ms.Write(buff, 0, len);
         }
         c.Close();
         ClipboardEntry pe = new ClipboardEntry(ms.ToArray(), "[" + p.Key + "] ");
         ToolStripMenuItem mi = new ToolStripMenuItem(pe.Caption, pe.PreviewImage);
         mi.Click += new EventHandler(receivedItem_Click);
         mi.Tag = pe;
         onReceiveStrip.Items.Insert(0, mi);
     }
     onReceiveStrip.Show(receive, new Point(receive.Width, receive.Height), ToolStripDropDownDirection.AboveLeft);
 }
예제 #7
0
        private void fetchClipboardEntry(bool allowDuplicate)
        {
            IDataObject ido = Clipboard.GetDataObject();
            ClipboardEntry ce = new ClipboardEntry(ido);
            byte[] serialized = ce.Serialize();
            byte[] reserialized = new ClipboardEntry(ce.Serialize(), "").Serialize();
            if (!ArrayEquals(serialized, reserialized))
            {
                MessageBox.Show("Warning: Unserializable clipboard entry detected");
            }
            if (!allowDuplicate && clips.Items.Count > 0 &&
                ArrayEquals(serialized, ((ClipboardEntry)clips.Items[0].Tag).Serialize()))
            {
                return;
            }
            string key = "image" + (counter++);
            previewImages.Images.Add(key, ce.PreviewImage);

            ListViewItem lvi = new ListViewItem(ce.Caption, previewImages.Images.IndexOfKey(key));
            lvi.Tag = ce;
            clips.Items.Insert(0, lvi);
        }