Example #1
0
        public void Insert(ClipboardEntry item)
        {
            //check to see if already exist, if so, just update time then save.
            ClipboardEntry oldItem = db.Where<ClipboardEntry>(a => a.clipboardContents == item.clipboardContents).ToList().FirstOrDefault();

            if (oldItem != null)
            {
                oldItem.dateClipped = item.dateClipped;
                db.Save(oldItem);
            }
            else
            {
                db.Save(item);
            }

            if (Properties.Settings.Default.authKey != null)
            {
                App.clipRemoteProxy.Invoke("clientClipped", Properties.Settings.Default.authKey, item.clipboardContents, item.applicationClippedFrom);
            }
        }
Example #2
0
 public void Save(ClipboardEntry item)
 {
     db.Save(item);
 }
Example #3
0
 public void Delete(ClipboardEntry item)
 {
     db.Delete(item);
 }
Example #4
0
        void ch_ClipboardGrabbed(System.Windows.Forms.IDataObject dataObject)
        {
            TimeSpan variable =  DateTime.Now - lastClipTime;
            lastClipTime = DateTime.Now;

            if (skipNextPaste || variable.TotalMilliseconds < 500)
            {
                skipNextPaste = false;
                return;
            }

            var formats = dataObject.GetFormats();

            if (formats.Contains(DataFormats.Text))
            {
                var text = Clipboard.GetText();

                if (String.IsNullOrWhiteSpace(text))
                {
                    return;
                }

                var data = Clipboard.GetDataObject();

                ClipHub.Code.Models.ClipboardEntry newClip = new ClipHub.Code.Models.ClipboardEntry();
                newClip.clipboardContents = text;
                newClip.dateClipped = DateTime.Now;

                String title = GetActiveWindowTitle();
                newClip.applicationClippedFrom = title;

                clipRepository.Insert(newClip);
            }
            else if (formats.Contains(DataFormats.FileDrop))
            {
                //var files = dataObject.GetData(DataFormats.FileDrop) as string[];

                //if (CheckDuplicates(ItemsBox, (obj) =>
                //{
                //    string[] objasfiles = obj as string[];

                //    if (objasfiles != null && objasfiles.Length == files.Length)
                //    {

                //        // we need this since order may nto be preserved
                //        // e.g. when user selects file from l-to-r and
                //        // and then r-to-l
                //        for (int i = 0; i < objasfiles.Length; i++)
                //        {
                //            if (!files.Contains(objasfiles[i]))
                //                return false;
                //        }

                //        return true;
                //    }
                //    return false;
                //}))
                //    return;

                //n = new FileDropsLBI(files);
            }
            else if (System.Windows.Clipboard.ContainsImage())
            {

                //System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
                //System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)clipboardData.GetData(
                //   System.Windows.Forms.DataFormats.Bitmap);

                //if (CheckDuplicates(ItemsBox, (obj) =>
                //{
                //    var taghash = obj as ImageHash;
                //    if (taghash == null)
                //    {
                //        return false;
                //    }

                //    else return ImageHash.Compare(taghash, new ImageHash(bitmap)) == ImageHash.CompareResult.ciCompareOk;
                //}))
                //    return;

                //n = new ImageLBI(bitmap);
            }
        }
Example #5
0
        void ch_ClipboardGrabbed(System.Windows.Forms.IDataObject dataObject)
        {
            TimeSpan variable = DateTime.Now - lastClipTime;

            lastClipTime = DateTime.Now;

            if (skipNextPaste || variable.TotalMilliseconds < 500)
            {
                skipNextPaste = false;
                return;
            }


            var formats = dataObject.GetFormats();

            if (formats.Contains(DataFormats.Text))
            {
                var text = Clipboard.GetText();

                if (String.IsNullOrWhiteSpace(text))
                {
                    return;
                }

                var data = Clipboard.GetDataObject();

                ClipHub.Code.Models.ClipboardEntry newClip = new ClipHub.Code.Models.ClipboardEntry();
                newClip.clipboardContents = text;
                newClip.dateClipped       = DateTime.Now;

                String title = GetActiveWindowTitle();
                newClip.applicationClippedFrom = title;

                clipRepository.Insert(newClip);
            }
            else if (formats.Contains(DataFormats.FileDrop))
            {
                //var files = dataObject.GetData(DataFormats.FileDrop) as string[];

                //if (CheckDuplicates(ItemsBox, (obj) =>
                //{
                //    string[] objasfiles = obj as string[];

                //    if (objasfiles != null && objasfiles.Length == files.Length)
                //    {

                //        // we need this since order may nto be preserved
                //        // e.g. when user selects file from l-to-r and
                //        // and then r-to-l
                //        for (int i = 0; i < objasfiles.Length; i++)
                //        {
                //            if (!files.Contains(objasfiles[i]))
                //                return false;
                //        }

                //        return true;
                //    }
                //    return false;
                //}))
                //    return;

                //n = new FileDropsLBI(files);
            }
            else if (System.Windows.Clipboard.ContainsImage())
            {
                //System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
                //System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)clipboardData.GetData(
                //   System.Windows.Forms.DataFormats.Bitmap);

                //if (CheckDuplicates(ItemsBox, (obj) =>
                //{
                //    var taghash = obj as ImageHash;
                //    if (taghash == null)
                //    {
                //        return false;
                //    }

                //    else return ImageHash.Compare(taghash, new ImageHash(bitmap)) == ImageHash.CompareResult.ciCompareOk;
                //}))
                //    return;

                //n = new ImageLBI(bitmap);
            }
        }
Example #6
0
        private void SetItemPinned(ClipboardEntry item)
        {
            if (item.pinned == true)
            {
                item.pinned = false;
            }
            else
            {
                item.pinned = true;
            }

            App.clipRepository.Save(item);

            this.updateListFilter();
        }