コード例 #1
0
 private void DropHost_HandleUpdated(object sender, EventArgs e)
 {
     clipboardHost.host.LeftMouseStateUpdated += (object s, bool state) => { LeftMouseState = state; };
     clipboardHost.host.DataDropped           += (object s, ClipboardDataBase data) => { DataDropped?.Invoke(this, data); };
     clipboardHost.host.DragDropCancelled     += (object s, EventArgs _) => { DragDropCancelled?.Invoke(this, null); };
     clipboardHost.host.DragDropSuccess       += (object s, EventArgs _) => { DragDropSuccess?.Invoke(this, null); };
     clipboardHost.host.RequestedReadStream   += Host_RequestedReadStream;
     clipboardHost.host.RequestedFileToken    += Host_RequestedFileToken;
 }
コード例 #2
0
 public ServiceDragDropManager(IpcHandle hostDragDrop)
 {
     clipboardHost = hostDragDrop;
     clipboardHost.HandleUpdated += DropHost_HandleUpdated;
     clipboardHost.host.LeftMouseStateUpdated += (object s, bool state) => { LeftMouseState = state; };
     clipboardHost.host.DataDropped           += (object s, ClipboardDataBase data) => { DataDropped?.Invoke(this, data); };
     clipboardHost.host.DragDropCancelled     += (object s, EventArgs _) => { DragDropCancelled?.Invoke(this, null); };;
     clipboardHost.host.DragDropSuccess       += (object s, EventArgs _) => { DragDropSuccess?.Invoke(this, null); };
     clipboardHost.host.RequestedReadStream   += Host_RequestedReadStream;
     clipboardHost.host.RequestedFileToken    += Host_RequestedFileToken;
 }
コード例 #3
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x0201) //left mouse down
            {
                if (dropQueue.Count == 0)
                {
                    ISLogger.Write("Could not start drag drop operation: drop queue is empty");
                    return;
                }

                reportedSuccess = false;

                if (dropQueue.TryDequeue(out IDataObject dropObject))
                {
                    if (dropObject == null)
                    {
                        ISLogger.Write("attempted to drop a null dataobject");
                        this.Hide();
                        return;
                    }

                    int[] droppedValue = new int[1];
                    dropSourceAllowDrop = false;
                    Task.Run(() => { Thread.Sleep(300); dropSourceAllowDrop = true; });
                    registeredDrop = true;

                    Guid operationId = ((InputshareDataObject)dropObject).OperationGuid;

                    Dropping = true;
                    Ole32.DoDragDrop(dropObject, this, (int)DragDropEffects.All, droppedValue);
                    Dropping = false;
                    if (droppedValue[0] == 0)
                    {
                        DragDropCancelled?.Invoke(this, null);
                    }
                    else if (!reportedSuccess)
                    {
                        reportedSuccess = true;
                        DragDropSuccess?.Invoke(this, null);
                    }
                }
                else
                {
                    ISLogger.Write("Failed to get data object");
                }
                return;
            }
            base.WndProc(ref m);
        }
コード例 #4
0
ファイル: NetworkSocket.cs プロジェクト: gezi322/Inputshare
        /// <summary>
        /// Handles messages received from the client/server. Derived
        /// classes must override this method to process messages. Derived
        /// classes should call the base method after processing the message.
        /// </summary>
        /// <param name="rawMessage"></param>
        protected virtual void HandleMessage(byte[] rawMessage)
        {
            MessageType    type         = (MessageType)rawMessage[4];
            NetworkMessage basicMessage = new NetworkMessage(rawMessage);

            //Make sure we don't somehow handle the same request more than once
            if (ProcessedMessageIds.Contains(basicMessage.MessageId))
            {
                ISLogger.Write("Ignoring duplicate message ID");
                return;
            }

            if (CheckAwaitingMessages(basicMessage, rawMessage))
            {
                return;
            }

            if (type == MessageType.ClipboardData)
            {
                HandleClipboardData(new ClipboardDataMessage(rawMessage));
            }
            else if (type == MessageType.DragDropData)
            {
                HandleDragDropMessage(new DragDropDataMessage(rawMessage));
            }
            else if (type == MessageType.DragDropSuccess)
            {
                DragDropSuccess?.Invoke(this, new EventArgs());
            }
            else if (type == MessageType.DragDropCancelled)
            {
                DragDropCancelled?.Invoke(this, new EventArgs());
            }
            else if (type == MessageType.RequestFileGroupToken)
            {
                RequestGroupTokenMessage requestMsg = new RequestGroupTokenMessage(rawMessage);
                RequestedFileToken?.Invoke(this, new FileTokenRequestArgs(requestMsg.MessageId, requestMsg.FileGroupId));
            }
            else if (type == MessageType.FileStreamReadRequest)
            {
                FileStreamReadRequestMessage requestMsg = new FileStreamReadRequestMessage(rawMessage);
                RequestedStreamRead?.Invoke(this, new RequestStreamReadArgs(requestMsg.MessageId, requestMsg.Token, requestMsg.FileRequestId, requestMsg.ReadSize));
            }
        }
コード例 #5
0
 protected override void ProcessMessage(IpcMessageType type, byte[] data)
 {
     if (type == IpcMessageType.AnonIpcClipboardData)
     {
         ClipboardDataReceived?.Invoke(this, new AnonIpcClipboardDataMessage(data).Data);
     }
     else if (type == IpcMessageType.AnonIpcEdgeHit)
     {
         EdgeHit?.Invoke(this, new AnonIpcEdgeHitMessage(data).HitEdge);
     }
     else if (type == IpcMessageType.AnonIpcDisplayConfigReply)
     {
         DisplayConfigUpdated?.Invoke(this, new AnonIpcDisplayConfigMessage(data).Config);
     }
     else if (type == IpcMessageType.AnonIpcLMouseStateReply)
     {
         LeftMouseStateUpdated?.Invoke(this, new AnonIpcLMouseStateMessage(data).LeftMouseState);
     }
     else if (type == IpcMessageType.AnonIpcDoDragDrop)
     {
         DataDropped?.Invoke(this, new AnonIpcDoDragDropMessage(data).DropData);
     }
     else if (type == IpcMessageType.AnonIpcDragDropCancelled)
     {
         DragDropCancelled?.Invoke(this, null);
     }
     else if (type == IpcMessageType.AnonIpcDragDropSuccess)
     {
         DragDropSuccess?.Invoke(this, null);
     }
     else if (type == IpcMessageType.AnonIpcDragDropComplete)
     {
         DragDropComplete?.Invoke(this, null);
     }
     else if (type == IpcMessageType.AnonIpcStreamReadRequest)
     {
         HandleReadStreamRequest(new AnonIpcReadStreamRequestMessage(data));
     }
     else if (type == IpcMessageType.AnonIpcRequestFileToken)
     {
         HandleTokenRequest(new AnonIpcRequestFileTokenMessage(data));
     }
 }
コード例 #6
0
        /// <summary>
        /// Handles messages received from the client/server. Derived
        /// classes must override this method to process messages. Derived
        /// classes should call the base method after processing the message.
        /// </summary>
        /// <param name="message"></param>
        protected virtual void HandleMessage(byte[] message)
        {
            MessageType    type = (MessageType)message[4];
            NetworkMessage msg  = new NetworkMessage(message);

            //Make sure we don't somehow handle the same request more than once
            if (ProcessedMessageIds.Contains(msg.MessageId))
            {
                ISLogger.Write("Ignoring duplicate message ID");
                return;
            }

            if (type == MessageType.ClipboardData)
            {
                HandleClipboardData(new ClipboardDataMessage(message));
            }
            else if (type == MessageType.DragDropData)
            {
                HandleDragDropMessage(new DragDropDataMessage(message));
            }
            else if (type == MessageType.DragDropSuccess)
            {
                DragDropSuccessMessage sMsg = new DragDropSuccessMessage(message);
                DragDropSuccess?.Invoke(this, sMsg.OperationId);
            }
            else if (type == MessageType.DragDropCancelled)
            {
                DragDropCancelledMessage cMsg = new DragDropCancelledMessage(message);
                DragDropCancelled?.Invoke(this, cMsg.OperationId);
            }
            else if (type == MessageType.RequestFileGroupToken)
            {
                RequestGroupTokenMessage requestMsg = new RequestGroupTokenMessage(message);
                RequestedFileToken?.Invoke(this, new FileTokenRequestArgs(requestMsg.MessageId, requestMsg.FileGroupId));
            }
            else if (type == MessageType.FileStreamReadRequest)
            {
                FileStreamReadRequestMessage requestMsg = new FileStreamReadRequestMessage(message);
                RequestedStreamRead?.Invoke(this, new RequestStreamReadArgs(requestMsg.MessageId, requestMsg.Token, requestMsg.FileRequestId, requestMsg.ReadSize));
            }
            else if (type == MessageType.FileStreamCloseRequest)
            {
                FileStreamCloseStreamMessage closeMsg = new FileStreamCloseStreamMessage(message);
                RequestedCloseStream?.Invoke(this, new RequestCloseStreamArgs(closeMsg.Token, closeMsg.FileId));
            }
            else if (type == MessageType.DragDropComplete)
            {
                DragDropCompleteMessage ddcMsg = new DragDropCompleteMessage(message);
                DragDropOperationComplete?.Invoke(this, ddcMsg.OperationId);
            }

            lock (awaitingCollectionsLock)
            {
                if (awaitingMessageIds.Contains(msg.MessageId))
                {
                    //TODO
                    if (type == MessageType.RequestFileGroupTokenReponse)
                    {
                        awaitingReturnMessages.Add(msg.MessageId, new RequestGroupTokenResponseMessage(message));
                    }
                    else if (type == MessageType.FileStreamReadResponse)
                    {
                        awaitingReturnMessages.Add(msg.MessageId, new FileStreamReadResponseMessage(message));
                    }
                    else if (type == MessageType.RemoteFileError)
                    {
                        awaitingReturnMessages.Add(msg.MessageId, new FileErrorMessage(message));
                    }

                    awaitingReturnMethods.TryGetValue(msg.MessageId, out AutoResetEvent evt);
                    evt.Set();
                }
            }
        }