Beispiel #1
0
        public void Copy()
        {
            if (Clipboard.ContainsText())
            {
                ClipboardData newElement = new ClipboardData(Clipboard.GetText(), false);
                RemoveDuplicates(newElement);
                ExtendedClipboard.AddFirst(newElement);
            }

            else if (Clipboard.ContainsFileDropList())
            {
                string fileNames = string.Empty;
                foreach (var fileName in Clipboard.GetFileDropList())
                {
                    fileNames += fileName + '\n';
                }

                ClipboardData newElement = new ClipboardData(Clipboard.GetDataObject(), true, fileNames);
                RemoveDuplicates(newElement);
                ExtendedClipboard.AddFirst(newElement);
            }

            while (ExtendedClipboard.Count > _generalSettingsModel.MaxSize)
            {
                ExtendedClipboard.RemoveLast();
            }
        }
Beispiel #2
0
        public void PasteStop()
        {
            if (!IsPastingStarted() || ExtendedClipboard.Count == 0)
            {
                return;
            }
            _timer.Reset();

            UnregisterAll();

            IClipboardData currentElement = null;

            if (_clipboardIndex >= 0)
            {
                currentElement = ExtendedClipboard.ElementAt(_clipboardIndex);
                if (!ExtendedClipboard.ElementAt(_clipboardIndex).IsLinkOrLinks())
                {
                    Clipboard.SetText((string)currentElement.GetData());
                }
                else
                {
                    Clipboard.SetDataObject(currentElement.GetData());
                }
            }

            _inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);

            RegisterAll();

            ClipboardDisplayer.CloseClipboard();
            ClipboardDisplayer.ClearBackground();

            if (currentElement != null)
            {
                ExtendedClipboard.Remove(currentElement);
                ExtendedClipboard.AddFirst(currentElement);
            }
            _clipboardIndex = 0;
        }