Esempio n. 1
0
 public void Load(string pszFileName, int dwMode)
 {
     sFileName = pszFileName;
     if (curApk == null) curApk = AndroidPackage2.GetAndroidPackage(sFileName);
 }
Esempio n. 2
0
        public void InvokeCommand(IntPtr pici)
        {
            //bool isUnicode = false;

            // Determine which structure is being passed in, CMINVOKECOMMANDINFO or 
            // CMINVOKECOMMANDINFOEX based on the cbSize member of lpcmi. Although 
            // the lpcmi parameter is declared in Shlobj.h as a CMINVOKECOMMANDINFO 
            // structure, in practice it often points to a CMINVOKECOMMANDINFOEX 
            // structure. This struct is an extended version of CMINVOKECOMMANDINFO 
            // and has additional members that allow Unicode strings to be passed.
            CMINVOKECOMMANDINFO ici = (CMINVOKECOMMANDINFO)Marshal.PtrToStructure(
                pici, typeof(CMINVOKECOMMANDINFO));
            #region unicode
            //CMINVOKECOMMANDINFOEX iciex = new CMINVOKECOMMANDINFOEX();
            //if (ici.cbSize == Marshal.SizeOf(typeof(CMINVOKECOMMANDINFOEX)))
            //{
            //    if ((ici.fMask & CMIC.CMIC_MASK_UNICODE) != 0)
            //    {
            //        isUnicode = true;
            //        iciex = (CMINVOKECOMMANDINFOEX)Marshal.PtrToStructure(pici,
            //            typeof(CMINVOKECOMMANDINFOEX));
            //    }
            //}
            #endregion
            // Is the command identifier offset supported by this context menu 
            // extension?
            int id = NativeMethods.LowWord(ici.verb.ToInt32());

            if (id == MenuConnectWIFI_ID)
            {
                string s = "";
                string lastipfile = Path.GetTempPath() + "lastip.txt";
                if (File.Exists(lastipfile))
                {
                    FileStream fs = new FileStream(lastipfile, FileMode.Open);
                    StreamReader sr = new StreamReader(fs);
                    s = sr.ReadLine();
                    sr.Close();
                    fs.Close();
                }
                s = Microsoft.VisualBasic.Interaction.InputBox(Properties.Resources.prompt_ConnectViaWIFI,
                     Properties.Resources.menu_ConnectViaWIFI,
                     s);
                if (!String.IsNullOrEmpty(s))
                {
                    if (NativeMethods.isIPAddress(s))
                    {
                        File.Delete(lastipfile);
                        FileStream fs = new FileStream(lastipfile, FileMode.CreateNew);
                        StreamWriter sw = new StreamWriter(fs);
                        sw.WriteLine(s);
                        sw.Close();
                        fs.Close();

                        (new AndroidToolAdb()).Connect(s);
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show(Properties.Resources.prompt_NotAnIP);
                    }
                }
            }
            else
            {
                for (int i = 0; i < devices.Count; i++) {
                    AndroidDevice d = (AndroidDevice)devices[i];
                    AndroidToolAdb adb = new AndroidToolAdb();
                    if (MenuInstall2Memory_ID[i] == id) {
                        adb.install(d.Serialno, sFileName);
                    } else if (MenuInstall2SD_ID[i] == id) {
                        adb.install(d.Serialno, sFileName, true);
                    } else if (MenuUninstall_ID[i] == id ) {
                        if (curApk == null) curApk = AndroidPackage2.GetAndroidPackage(sFileName);
                        adb.uninstall(d.Serialno, curApk.PackageName);
                    } else if (MenuDisconnect_ID[i] == id ) {
                        adb.Disconnect(d.Serialno);
                    }
                }
            }
        }
Esempio n. 3
0
 public uint GetInfoTip(uint dwFlags, out IntPtr pszInfoTip)
 {
     try
     {
         if (curApk == null) curApk = AndroidPackage2.GetAndroidPackage(sFileName);
         string tip = "Package Name : " + curApk.PackageName +"\nVersion Code : " + curApk.VersionCode +"\nVersion Name : " + curApk.VersionName;
         pszInfoTip = Marshal.StringToCoTaskMemUni(tip);
     }
     catch
     {
         pszInfoTip = IntPtr.Zero;
     }
     return WinError.S_OK;
 }
Esempio n. 4
0
 public uint Extract(string pszFile, uint nIconIndex, out IntPtr phiconLarge, out IntPtr phiconSmall, uint nIconSize)
 {
     NativeMethods.Log("Extract: sFilename = " + sFileName);
     NativeMethods.Log("Extract: pszFile = " + pszFile);
     NativeMethods.Log("Extract: nIconIndex = " + nIconIndex.ToString());
     if (curApk == null) curApk = AndroidPackage2.GetAndroidPackage(sFileName);
     //AndroidPackage.default_icon = Icon.FromHandle(Properties.Resources.deficon.GetHicon());
     int s_size = (int)nIconSize >> 16;
     int l_size = (int)nIconSize & 0xffff;
     phiconLarge = (new Icon(curApk.icon, l_size, l_size)).Handle;
     phiconSmall = (new Icon(curApk.icon, s_size, s_size)).Handle;
     NativeMethods.Log("Extract: Get icon and return");
     return WinError.S_OK;
 }