vendredi 24 mars 2017

Asp.net remote desktop connection

Hi I'm dealing with the remote desktop application. I've done the mouse movements. I think I'll move the application to the web environment.How can I send mouse movements in this format as in the following code?

    private void pbResim_MouseMove(object sender, MouseEventArgs e)
    {
        Point point = pbResim.PointToClient(Cursor.Position);
        Point unscaled_p = new Point();
        if (kontrol==0)
        {
            karsıPcHeight = pbResim.Height;
            karsıPcWidth = pbResim.Width;
            kontrol = 1;
        }
        int w_c =karsıPcWidth;
        int h_c =karsıPcHeight;
        int w_i = pbResim.Width;
        int h_i = pbResim.Height;

        float imageRatio = (w_i) / (float)h_i;
        float containerRatio = w_c / (float)h_c;
        Socket soket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        soket.Connect(IPAddress.Parse(karsiIP), 14533);
        byte[] gonderilcek;
        if (imageRatio >= containerRatio)
        {
            // horizontal image
            float scaleFactor = w_c/(float) w_i;
            float scaledHeight = h_i*scaleFactor;
            // calculate gap between top of container and top of image
            float filler = Math.Abs(h_c - scaledHeight)/2;
            unscaled_p.X = (int) (point.X*scaleFactor);
            unscaled_p.Y = (int) ((point.Y - filler)*scaleFactor);
            gonderilcek =
                Encoding.UTF8.GetBytes(unscaled_p.X.ToString() + ":" + unscaled_p.Y.ToString() + "|MouseMove");

        }
        else
        {
            // vertical image
            float scaleFactor = h_c/(float) h_i;
            float scaleFactorw = w_c / (float)w_i;
            float scaledWidth = w_i*scaleFactor;
            float filler = Math.Abs(w_c - scaledWidth)/2;
            unscaled_p.X = (int)(point.X * scaleFactorw);
            unscaled_p.Y = (int) (point.Y*scaleFactor);
            gonderilcek =
                Encoding.UTF8.GetBytes(unscaled_p.X.ToString() + ":" + unscaled_p.Y.ToString() + "|MouseMove");
        }

        soket.Send(gonderilcek);
        soket.Close();
    }

    private void pbResim_MouseUp(object sender, MouseEventArgs e)
    {
        byte[] gonderilcek = null;

        if (e.Button == System.Windows.Forms.MouseButtons.Left)
            gonderilcek = Encoding.UTF8.GetBytes("Left:MouseUp");

        else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            gonderilcek = Encoding.UTF8.GetBytes("Right:MouseUp");

        else
            return;
        Socket soket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        soket.Connect(IPAddress.Parse(karsiIP), 14533);
        soket.Send(gonderilcek);
        soket.Close();
    }

Aucun commentaire:

Enregistrer un commentaire