コード例 #1
0
        private void DoDragDrop(ClipboardDataBase data)
        {
            InputshareDataObject nativeObject = null;

            try
            {
                nativeObject    = ClipboardTranslatorWindows.ConvertToWindows(data);
                reportedSuccess = false;
                nativeObject.SetData("InputshareData", new bool());
                dropQueue.Enqueue(nativeObject);

                nativeObject.DropComplete += NativeObject_DropComplete;
                nativeObject.DropSuccess  += NativeObject_DropSuccess;
            }
            catch (Exception ex)
            {
                ISLogger.Write("Could not start drag drop operation: " + ex.Message);
                return;
            }


            this.Show();
            this.BringToFront();
            this.TopMost = true;
            GetCurrentCursorMonitorSize(out Size mSize, out Point mPos);
            this.SetDesktopLocation((int)mPos.X, (int)mPos.Y);
            this.Size = mSize;
            outMan.Send(new InputshareLib.Input.ISInputData(InputshareLib.Input.ISInputCode.IS_MOUSELDOWN, 0, 0));
            outMan.Send(new InputshareLib.Input.ISInputData(InputshareLib.Input.ISInputCode.IS_MOUSERUP, 0, 0));
            Task.Run(() => {
                Thread.Sleep(300); this.Invoke(new Action(() => {
                    if (!registeredDrop)
                    {
                        DoDragDrop(data);
                    }
                }));
            });
        }
コード例 #2
0
        private void HookWnd_ClipboardCallback(System.Windows.Forms.IDataObject data)
        {
            try
            {
                //Check to make sure that we didn't set the clipboard data
                if (data.GetDataPresent("InputshareData"))
                {
                    return;
                }

                ClipboardDataBase cb = ClipboardTranslatorWindows.ConvertToGeneric(data);

                if (cb is ClipboardTextData cbText)
                {
                    ISLogger.Write("Copied " + cbText.Text);
                }

                ISLogger.Write("WindowsClipboardManager: Copied type {0}", cb.DataType);
                OnClipboardDataChanged(cb);
            }catch (ClipboardTranslatorWindows.ClipboardTranslationException ex)
            {
                ISLogger.Write("Failed to read clipboard data: " + ex.Message);
            }
        }