示例#1
0
        private void VideoPlayerForm_MouseDown(object sender, MouseEventArgs e)
        {
            Trace.WriteLine("MouseDown: X = " + e.X + "; Y = " + e.Y);
            // Trace.WriteLine("oriWidth: = " + oriWidth + " ; oriheight = " + oriheight);
            Trace.WriteLine("VideoPlayerFormWidth: = " + this.Width + " ; VideoPlayerFormHeight = " + this.Height);
            RECT in_rect  = new RECT(1, 1, 1, 1);
            RECT out_rect = new RECT(1, 1, 1, 1);

            DR2API.DR2_GetDrawRect(ViewModelBase.ApiHandle, ref in_rect, ref out_rect);


            Trace.WriteLine("in_rect:  " + in_rect.left + " " + in_rect.top + " " + in_rect.right + " " + in_rect.bottom + " ");
            Trace.WriteLine("out_rect: " + out_rect.left + " " + out_rect.top + " " + out_rect.right + " " + out_rect.bottom + " ");


            int in_X = (int)e.X;
            int in_Y = (int)e.Y;

            int isVertical = _host.getIsVertical();


            if (isVertical == 1)
            {
                VideoPlayerForm.PHONE_HEIGHT = VideoPlayerForm.PHONE_HEIGHT_FIRST_SCREEN;
                VideoPlayerForm.PHONE_WIDTH  = VideoPlayerForm.PHONE_WIDTH_FIRST_SCREEN;
            }
            else
            {
                VideoPlayerForm.PHONE_HEIGHT = VideoPlayerForm.PHONE_HEIGHT_SECOND_SCREEN;
                VideoPlayerForm.PHONE_WIDTH  = VideoPlayerForm.PHONE_WIDTH_SECOND_SCREEN;
            }


            var pt = e.Location;

            if (e.Button == MouseButtons.Left)
            {
                {
                    byte[] data = new byte[12];

                    data[0] = 0; // mouseDown
                    data[1] = 0;
                    data[2] = 0;
                    data[3] = 0;

                    int sendX = 0;
                    sendX = (int)((float)((in_X) - out_rect.left) * (VideoPlayerForm.PHONE_WIDTH / (float)(out_rect.Width)));

                    byte[] X = BitConverter.GetBytes(sendX);

                    X.CopyTo(data, 4);

                    int sendY = 0;
                    sendY = (int)((float)((in_Y) - out_rect.top) * (VideoPlayerForm.PHONE_HEIGHT / (float)(out_rect.Height)));;

                    byte[] Y = BitConverter.GetBytes(sendY);
                    Y.CopyTo(data, 8);

                    if ((sendX >= 0 && (sendX < VideoPlayerForm.PHONE_WIDTH)) && (sendY >= 0 && (sendY < VideoPlayerForm.PHONE_HEIGHT)))
                    {
                        Trace.WriteLine("send mouse down : X = " + sendX + "; Y = " + sendY);
                        DataManager.sendMouseData(data);
                    }
                    else
                    {
                        Trace.WriteLine(" invalid mouse down : X = " + sendX + "; Y = " + sendY);
                    }
                }

                //Debug.WriteLine("OnMouseLeftButtonDown: width:{0}, height:{1}, x:{2}, y{3}", Width, Height, pt.X, pt.Y);
                if (Program.IsRun)
                {
                    DR2API.DR2_OnMouseLeftButtonDown(ViewModelBase.ApiHandle, e.Clicks, Width, Height, pt.X, pt.Y);
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                //Debug.WriteLine("OnMouseRightButtonDown: width:{0}, height:{1}, x:{2}, y{3}", Width, Height, pt.X, pt.Y);
                if (Program.IsRun)
                {
                    DR2API.DR2_OnMouseRightButtonDown(ViewModelBase.ApiHandle, Width, Height, pt.X, pt.Y);
                }
            }
        }