Пример #1
0
        public void HandleClientSwitch(ISServerSocket newClient, ISServerSocket oldClient)
        {
            currentInputClient = newClient;

            //if moving from localhost to client, check for drop if not in operation, Only do this if the left mouse button is down
            if (oldClient.IsLocalhost && CurrentOperation?.State != DragDropState.Dragging && ddManager.LeftMouseState)
            {
                ddManager.CheckForDrop();
            }

            ddManager.CancelDrop();

            if (CurrentOperation == null)
            {
                return;
            }

            //If we are dragging a file, make sure that we don't send the dragdrop back to the host
            //as this causes issues
            if (CurrentOperation.DataType == ClipboardDataType.File && CurrentOperation.State == DragDropState.Dragging)
            {
                if (newClient == CurrentOperation.Host)
                {
                    ISLogger.Write("Dragdrop returned to sender... cancelling");
                    OnDropCancel(newClient, CurrentOperation.OperationId);
                    return;
                }
            }

            if (CurrentOperation.State == DragDropState.Dragging)
            {
                if (newClient.IsLocalhost)
                {
                    ddManager.DoDragDrop(CurrentOperation.OperationData, CurrentOperation.OperationId);
                }
            }

            //if we are dragging a file, send the dragdrop data to the client
            if (CurrentOperation.State == DragDropState.Dragging)
            {
                if (!newClient.IsLocalhost)
                {
                    newClient.SendDragDropData(CurrentOperation.OperationData.ToBytes(), CurrentOperation.OperationId);
                }
            }
        }