Пример #1
0
 private void DetectSize()
 {
     ADB.DetectAndriodScreenSize();                                  //获取手机分辨率
     if (ADB.CmdStatus == OutputStatus.Success)
     {
         string output = ADB.OutputData;
         if (output.Contains("Physical size"))
         {
             int idx = output.IndexOf("Physical size");
             output = output.Substring(idx + 15, output.Length - idx - 17);
             string[] Resolution = output.Split('x');
             ResolutionX      = GetNumberInt(Resolution[0]);
             ResolutionY      = GetNumberInt(Resolution[1]);
             ResolutionXScale = (double)ResolutionX / pictureBox1.Width;
             ResolutionYScale = (double)ResolutionY / pictureBox1.Height;
         }
         else
         {
             ResolutionX      = 0;
             ResolutionY      = 0;
             ResolutionXScale = 0;
             ResolutionYScale = 0;
         }
     }
     else
     {
         toolStripStatusLabel2.Text = "cmd error: " + ADB.OutputError;
     }
 }
Пример #2
0
        private void DetectSize()
        {
            ResolutionX      = 0;
            ResolutionY      = 0;
            ResolutionXScale = 0;
            ResolutionYScale = 0;

            ADB.DetectAndriodScreenSize();                                  //获取手机分辨率
            if (ADB.CmdStatus == OutputStatus.Success)
            {
                string output = ADB.OutputData;
                if (output.Contains("size"))
                {
                    int idx = output.IndexOf("Override size");
                    if (idx < 0)
                    {
                        idx = output.IndexOf("Physical size");
                    }
                    if (idx >= 0)
                    {
                        output = output.Substring(idx + 15, output.Length - idx - 17);
                        string[] Resolution = output.Split('x');
                        ResolutionX      = GetNumberInt(Resolution[0]);
                        ResolutionY      = GetNumberInt(Resolution[1]);
                        ResolutionXScale = (double)ResolutionX / pictureBox1.Width;
                        ResolutionYScale = (double)ResolutionY / pictureBox1.Height;
                    }
                }
            }
            //有的手机不能用wm size,换一种方式
            if (ResolutionX == 0 || ResolutionY == 0)
            {
                ADB.DetectAndriodWindow();
                if (ADB.CmdStatus == OutputStatus.Success)
                {
                    string output = ADB.OutputData;
                    if (output.Contains("Display"))
                    {
                        //Display: init=540x960 base=540x960 cur=540x960 app=540x960 raw=540x960
                        //app是不是当前游戏的分辨率呢???
                        int idx = output.IndexOf("app=");
                        if (idx >= 0)
                        {
                            output = output.Substring(idx);
                            idx    = output.IndexOf(" ");
                            output = output.Substring(4, idx - 4);  //去掉app=

                            string[] Resolution = output.Split('x');
                            ResolutionX      = GetNumberInt(Resolution[0]);
                            ResolutionY      = GetNumberInt(Resolution[1]);
                            ResolutionXScale = (double)ResolutionX / pictureBox1.Width;
                            ResolutionYScale = (double)ResolutionY / pictureBox1.Height;
                        }
                    }
                }
            }
        }
Пример #3
0
 private void DetectSize()
 {
     ADB.DetectAndriodScreenSize();                                  //获取手机分辨率
     if (ADB.CmdStatus == OutputStatus.Success)
     {
         string   output     = ADB.OutputData;
         string[] Resolution = output.Split('x');
         ResolutionX      = GetNumberInt(Resolution[0]);
         ResolutionY      = GetNumberInt(Resolution[1]);
         ResolutionXScale = (double)ResolutionX / pictureBox1.Width;
         ResolutionYScale = (double)ResolutionY / pictureBox1.Height;
     }
     else
     {
         toolStripStatusLabel2.Text = "cmd error: " + ADB.OutputError;
     }
 }