Exemple #1
0
        /// <summary>
        /// Handles data arrived event
        /// </summary>
        unsafe static partial void Behavior_HandleDataArrived(ISciterBehavior behavior, IntPtr he, IntPtr prms, ref bool handled)
        {
            var datantf = (DATA_ARRIVED_PARAMS *)prms;
            var e       = new DataArrivedEventArgs(Element.Create(he));

            behavior.ProcessDataArrived(e);

            handled = e.Handled;
        }
Exemple #2
0
        private void DataArrivedHandler(object sender, DataArrivedEventArgs e)
        {
            try
            {
                var vncServer = (VncServer)sender;
                var message   = vncServer.Encoding.GetString(e.Response);

                while (message.Contains(VncCommand.GetScreen))
                {
                    clientSocket = e.Socket;
                    message      = message.Remove(VncCommand.GetScreen);
                }

                if (message == VncCommand.SendScreenSize)
                {
                    var screenSizeMessage = $"{VncCommand.ScreenSize}{VncCommand.Separator}{Screen.PrimaryScreen.Bounds.Width}x{Screen.PrimaryScreen.Bounds.Height}";
                    vncServer.Send(e.Socket, screenSizeMessage);
                }
                else if (message.StartsWith($"{VncCommand.KillApp} "))
                {
                    ProcessUtils.KillProcesses(message.Substring(8));
                }
                else if (message.IndexOf(VncCommand.Mouse) > Constants.NOT_FOUND)
                {
                    MouseHandler.ProcessMessage(message);
                }
                else if (message.StartsWith(VncCommand.KeyPressed))
                {
                    var data = message.Split(' ');
                    SendKeys.SendWait(data[1]);
                }
                else if (message.StartsWith(VncCommand.Scrool))
                {
                    var values = message.Split(new string[] { $"{VncCommand.Scrool} " }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var value in values)
                    {
                        var scroolValue = Convert.ToInt32(value);
                        // scroolValue < 0 => scrools down
                        WinAPI.MouseEvent(WinAPI.MOUSEEVENTF_WHEEL, 0, 0, scroolValue, 0);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(message))
                    {
                        var command    = message.GetProgramAndParameters();
                        var parameters = String.Join(" ", command.Skip(1).Select(param => param.Contains(' ') && !param.StartsWith("\"") ? $"\"{param}\"" : param));
                        ProcessUtils.RunProgramOrFile(command[0], parameters);
                    }
                }
            }
            catch (Exception ex)
            {
                OnErrorOccurred(ex);
            }
        }
        public void DataArrivedHandler(object sender, DataArrivedEventArgs e)
        {
            var message = GetMessage(sender, e);

            switch (message)
            {
            case "Unknown command":
                ErrorBox.Show("Command execution error", "Server could not recognize the sent command");
                break;

            default:
                ErrorBox.Show("Unknown message arrived", "Server sent an unexpected message");
                break;
            }
        }
        private void VncClient_DataArrived(object sender, DataArrivedEventArgs e)
        {
            var message = VncClient.GetMessage(sender, e);

            if (message.StartsWith(VncCommand.ScreenSize))
            {
                var data   = message.Split(VncCommand.Separator, 'x');
                var width  = Convert.ToInt32(data[1]);
                var height = Convert.ToInt32(data[2]);

                cb_Computer.Invoke((MethodInvoker) delegate
                {
                    var mcf = new MouseControlForm(cb_Computer.Text, width, height);
                    mcf.Show();
                });
            }
        }
        private void DataArrivedHandler(object sender, DataArrivedEventArgs e)
        {
            try
            {
                var serverSocket = (ServerSocket)sender;
                var message      = serverSocket.Encoding.GetString(e.Response);

                foreach (ICommand command in Commands)
                {
                    if (command.Name == message)
                    {
                        ProcessUtils.Start(command);
                    }
                }
            }
            catch (Exception ex)
            {
                OnErrorOccurred(ex);
            }
        }
        private void DataArrivedHandler(object sender, DataArrivedEventArgs e)
        {
            var newData   = rawImageData == null || rawImageData.Length == 0;
            var vncClient = (VncClient)sender;

            rawImageData = newData ? e.Response : rawImageData.AppendArrays(e.Response);
            var begining = vncClient.Encoding.GetString(rawImageData.Take(21).ToArray());

            if (begining.StartsWith(VncCommand.ImageSize))
            {
                var data = begining.Split(VncCommand.Separator);
                expectedImageSize = Convert.ToInt32(data[1]);
                rawImageData      = rawImageData.Skip(VncCommand.ImageSize.Length + 2 + data[1].Length).ToArray();
            }

            if (rawImageData.Length >= expectedImageSize && expectedImageSize > 0)
            {
                try
                {
                    var imageBytes = rawImageData.Take(expectedImageSize).ToArray();
                    rawImageData = rawImageData.Skip(expectedImageSize).ToArray();
                    if (imageBytes[0] == 0xFF && imageBytes[1] == 0xD8)                     // It's a JPEG! Hurray! :)
                    {
                        var image = ImageUtils.ByteArrayToImage(imageBytes);
                        BackgroundImage = image;
                    }
                    else
                    {
                        rawImageData = null;
                    }
                }
                catch
                {
                    rawImageData = null;
                }
            }
        }
 protected virtual void OnDataArrived(DataArrivedEventArgs e)
 {
     DataArrived?.Invoke(this, e);
 }
        private static unsafe int gate_event_callbackPro(int nethandle, int devhandle, int gate_id, IntPtr pevent, int event_cnt, int event_handle)
        {
            int num;
            DataArrivedEventArgs args;
            ROADGATE_INFO_STRUCT roadgate_info_struct = new ROADGATE_INFO_STRUCT();

            if (devhandle >= 0)
            {
                byte[] source      = new byte[] { 0, 4, 0, 0 };
                IntPtr ptr         = Marshal.AllocHGlobal(0x400);
                IntPtr valuetype   = Marshal.AllocHGlobal(4);
                IntPtr destination = Marshal.AllocHGlobal(4);
                Marshal.Copy(source, 0, destination, 4);
                lnk_sdk_interface.LNX_SDK_Interface_X64.read_device_handle(devhandle, 3, valuetype, ptr, destination);
                num = Marshal.ReadInt32(destination);
                byte[] buffer2 = new byte[num];
                Marshal.Copy(ptr, buffer2, 0, num);
                roadgate_info_struct.ip = Encoding.Default.GetString(buffer2).Trim();
                Marshal.FreeHGlobal(ptr);
                Marshal.FreeHGlobal(valuetype);
                Marshal.FreeHGlobal(destination);
            }
            if (event_cnt > 0)
            {
                int[] numArray = new int[event_cnt];
                Marshal.Copy(pevent, numArray, 0, event_cnt);
                for (int i = 0; i < event_cnt; i++)
                {
                    DeviceMonitorEventArgs args2;
                    if ((numArray[i] == 4) || (numArray[i] == 5))
                    {
                        roadgate_info_struct.isManual = true;
                        args = new DataArrivedEventArgs(roadgate_info_struct);
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(3, args);
                    }
                    if (numArray[i] == 14)
                    {
                        args2           = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP        = roadgate_info_struct.ip;
                        args2.IsPressed = true;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 15)
                    {
                        args2           = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP        = roadgate_info_struct.ip;
                        args2.IsPressed = false;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 0x18)
                    {
                        args2       = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP    = roadgate_info_struct.ip;
                        args2.State = 0;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 0x1c)
                    {
                        args2       = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP    = roadgate_info_struct.ip;
                        args2.State = 1;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                }
            }
            if (event_handle >= 0)
            {
                int num4;
                int num3 = 0;
                num = 4;
                if ((lnk_sdk_interface.LNX_SDK_Interface_X64.read_gate_event(nethandle, devhandle, gate_id, event_handle, 11, &num3, (void *)&num4, &num) == 0) && ((num3 == 1) && (num == 4)))
                {
                    roadgate_info_struct.Counter = num4;
                    args = new DataArrivedEventArgs(roadgate_info_struct);
                    LNK_BARRIER_ISDK_X64.ExuteDelegate(3, args);
                }
            }
            return(0);
        }
        public static string GetMessage(object sender, DataArrivedEventArgs e)
        {
            var vncClient = (VncClient)sender;

            return(vncClient.Encoding.GetString(e.Response));
        }