예제 #1
0
 public void CopyToBoard(ClipBoardModel model)
 {
     ClipBoardSource.Remove(model);
     if (model != null)
     {
         _lastModel = null;
         if (!string.IsNullOrEmpty(model.Value))
         {
             Clipboard.SetText(model.Value);
         }
     }
 }
예제 #2
0
        private void DealEnter()
        {
            ClipBoardModel model = (ClipBoardModel)dataGrid.SelectedItem;

            clipBoardManager.CopyToBoard(model);

            CreateSystemTray();
            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(200);
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    IntPtr myPtr = ClipUnit.GetForegroundWindow();
                    ClipUnit.keybd_event(Keys.ControlKey, 0, 0, 0);
                    ClipUnit.keybd_event(Keys.V, 0, 0, 0);
                    ClipUnit.keybd_event(Keys.ControlKey, 0, 2, 0);
                }));
            });
        }
예제 #3
0
        /// <summary> 剪贴板内容改变 </summary>
        public void ClipboardChanged()
        {
            string text = Clipboard.GetText();

            if (!string.IsNullOrEmpty(text))
            {
                if (_lastModel != null && _lastModel.Value == text)
                {
                    return;
                }

                if (ClipBoardSource == null)
                {
                    Id++;
                    _lastModel = new ClipBoardModel()
                    {
                        Id = Id, Value = text
                    };

                    ClipBoardSource = new ObservableCollection <ClipBoardModel>()
                    {
                        _lastModel
                    };
                }
                else
                {
                    Id++;
                    _lastModel = new ClipBoardModel()
                    {
                        Id = Id, Value = text
                    };

//                    ClipBoardSource.Add(_lastModel);
                    ClipBoardSource.Insert(0, _lastModel);
                    //                    ClipBoardSource = new ObservableCollection<ClipBoardModel>
                    //                        (ClipBoardSource.OrderByDescending(item => item.Id));

                    MoveSource();
                }
            }
        }