public void checkDevice() { if (DeviceInformation.GetDevices().FirstOrDefault() != null) { base.DialogResult = DialogResult.OK; } }
static void GetDevices(HttpListenerContext ctx) { // Save current devices try { lock (Devices) Devices = DeviceInformation.GetDevices(); } catch (Exception e) { SetResponse(ctx, new { error = e.Message }); } // No devices could be read, sent error if (Devices == null) { SetResponse(ctx, new { error = "Unable to retrieve connected devices. Ensure iTunes is installed and can detect your device(s)." }); } else { // Write devices to output SetResponse(ctx, Devices.Select(d => new { name = d.Name, display_name = d.ToString(), udid = d.UDID }) ); } }
public void initToolStripStatus() { try { DeviceInformation deviceInformation = DeviceInformation.GetDevices().FirstOrDefault(); if (deviceInformation != null) { appendTextBox("连接到设备:" + deviceInformation.Name); toolStripStatusLabel2.Text = deviceInformation.Name; DeviceStatus status = HttpHelper.GetStatus(deviceInformation.UDID); if (status.Success) { if (status.Available) { Convert.ToDateTime("2099-1-1"); if (DateTime.Compare(Convert.ToDateTime("2099-1-1"), status.EndTime) < 0) { toolStripStatusLabel5.Text = "无限期"; } else { toolStripStatusLabel5.Text = status.EndTime.ToString(); if (status.Trial) { toolStripStatusLabel5.Text += "【试用】"; } } } else { toolStripStatusLabel5.Text = status.Msg; } } else { toolStripStatusLabel5.Text = status.Msg; } } else { toolStripStatusLabel2.Text = "未找到设备"; toolStripStatusLabel5.Text = "卡密已过期,请重新购买"; appendTextBox("已断开设备"); } } catch (Exception) { appendTextBox("服务器无法连接"); } }
private void button2_Click(object sender, EventArgs e) { try { DeviceInformation deviceInformation = DeviceInformation.GetDevices().FirstOrDefault(); if (deviceInformation != null) { deviceInformation.StopLocation(); appendTextBox("还原成功"); } else { appendTextBox("还原失败"); } } catch (Exception ex) { Console.WriteLine(ex.Message); appendTextBox("还原失败"); } }
private void toolStripStatusLabel3_Click(object sender, EventArgs e) { DeviceInformation deviceInformation = DeviceInformation.GetDevices().FirstOrDefault(); if (deviceInformation != null) { DeviceStatus status; try { status = HttpHelper.GetStatus(deviceInformation.UDID); } catch (Exception) { appendTextBox("服务器无法连接"); return; } if (status.Success) { string deviceName = deviceInformation.Properties["DeviceName"].ToString(); string productType = deviceInformation.Properties["ProductType"].ToString(); string productVersion = deviceInformation.Properties["ProductVersion"].ToString(); string uDID = deviceInformation.UDID; string text = (!string.IsNullOrEmpty(status.Msg)) ? status.Msg : ((DateTime.Compare(Convert.ToDateTime("2099-1-1"), status.EndTime) >= 0) ? status.EndTime.ToString() : "无限期"); if (status.Trial && status.Available) { text += "【试用】"; } new ActiveForm(deviceName, productType, productVersion, uDID, text, this).ShowDialog(); } else { appendTextBox("网络异常"); } } else { appendTextBox("未找到设备"); } }
private void button1_Click(object sender, EventArgs e) { if (lng == 0.0 || lat == 0.0) { appendTextBox("请先选择位置"); return; } DeviceInformation deviceInformation = DeviceInformation.GetDevices().FirstOrDefault(); if (deviceInformation == null) { appendTextBox("修改失败:未找到设备"); return; } if (!HttpHelper.verifyDevice(deviceInformation.UDID)) { System.Windows.Forms.MessageBox.Show("卡密已过期,请重新购买"); return; } appendTextBox("正在修改定位"); if (deviceInformation.SetLocation(new PointLatLng { Lat = lat, Lng = lng })) { appendTextBox("修改成功"); return; } button1.Enabled = false; string[] paths; if (!DeveloperImageHelper.HasImageForDevice(deviceInformation, out paths)) { string text = HttpHelper.downLoadImage(paths, textBox2); if (!(text == "")) { appendTextBox(text); button1.Enabled = true; return; } appendTextBox("正在安装驱动程序"); } try { deviceInformation.EnableDeveloperMode(paths[0], paths[1]); if (deviceInformation.SetLocation(new PointLatLng { Lat = lat, Lng = lng })) { appendTextBox("修改成功"); button1.Enabled = true; } else { appendTextBox("修改失败:请解锁手机重试"); button1.Enabled = true; } } catch (Exception) { appendTextBox("安装失败:请解锁手机重试"); button1.Enabled = true; } }