コード例 #1
0
        private void installToolStripButton_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Title            = "Select application to install";
            ofd.Filter           = "Android Application|*.apk|All Files (*.*)|*.*";
            ofd.FilterIndex      = 0;
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                AaptBrandingCommandResult apkInfo = CommandRunner.Instance.GetLocalApkInformation(ofd.FileName);
                apkInfo.LocalApk = ofd.FileName;
                InstallDialog install = new InstallDialog((IPluginHost)this.ParentForm, InstallDialog.InstallMode.Install, apkInfo);
                install.ShowDialog(this);


                /*if ( CommandRunner.Instance.InstallApk ( ofd.FileName ) ) {
                 * try {
                 * TaskDialog.MessageBox ( "Install Complete", string.Format ( "Successfully installed {0}", System.IO.Path.GetFileName ( ofd.FileName ) ),
                 *  string.Empty, TaskDialogButtons.OK, SysIcons.Information );
                 * } catch ( Exception ex ) {
                 *  Console.WriteLine ( "[{0}] {1}", this.GetType ( ).Name, ex.ToString ( ) );
                 *
                 *  TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.InstallErrorMessage, System.IO.Path.GetFileName ( ofd.FileName ) ),
                 *    ex.Message, TaskDialogButtons.OK, SysIcons.Error );
                 * }
                 * } else {
                 * TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.InstallErrorMessage, System.IO.Path.GetFileName ( ofd.FileName ) ),
                 *  Properties.Resources.InstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
                 * }*/
            }
        }
コード例 #2
0
        private void perform_Click(object sender, EventArgs e)
        {
            this.perform.Enabled  = false;
            this.progress.Visible = true;
            this.status.Visible   = true;
            if (InstallThread == null || !InstallThread.IsAlive)
            {
                InstallThread = new Thread(new ThreadStart(delegate {
                    foreach (var item in ApkFiles)
                    {
                        if (this.InvokeRequired)
                        {
                            this.Invoke(new SetIconDelegate(this.SetIcon), CommandRunner.Instance.GetLocalApkIconImage(item));
                            this.Invoke(new SetControlTextDelegate(this.SetControlText), status, System.IO.Path.GetFileName(item));
                        }
                        else
                        {
                            this.SetIcon(CommandRunner.Instance.GetLocalApkIconImage(item));
                            this.SetControlText(status, System.IO.Path.GetFileName(item));
                        }

                        if (this.Mode == InstallDialog.InstallMode.Install)
                        {
                            CommandRunner.Instance.InstallApk(item);
                        }
                        else
                        {
                            AaptBrandingCommandResult result = CommandRunner.Instance.GetLocalApkInformation(item);
                            CommandRunner.Instance.UninstallApk(result.Package);
                        }

                        if (this.InvokeRequired)
                        {
                            this.Invoke(new IncrementDelegate(this.progress.Increment), 1);
                        }
                        else
                        {
                            this.progress.Increment(1);
                        }
                    }

                    if (this.InvokeRequired)
                    {
                        this.Invoke(new SetControlVisibleDelegate(SetControlVisible), finish, true);
                        this.Invoke(new SetControlVisibleDelegate(SetControlVisible), cancel, false);
                    }
                    else
                    {
                        SetControlVisible(finish, true);
                        SetControlVisible(cancel, false);
                    }
                }));
                InstallThread.Start( );
            }
        }
コード例 #3
0
        public ApkPackageListViewItem(AaptBrandingCommandResult apkInfo)
        {
            ApkInformation = apkInfo;
            if (!string.IsNullOrEmpty(this.ApkInformation.Label))
            {
                this.Text = ApkInformation.Label;
            }
            else
            {
                this.Text = ApkInformation.Package;
            }

            this.SubItems.Add(ApkInformation.Package);
            this.SubItems.Add(ApkInformation.DevicePath);
            this.SubItems.Add(ApkInformation.Version);
        }
コード例 #4
0
        public InstallDialog(IPluginHost pluginHost, InstallMode mode, AaptBrandingCommandResult apkInfo) : base(pluginHost)
        {
            InitializeComponent( );
            this.Mode           = mode;
            this.ApkInformation = apkInfo;
            string name = string.Format("{0}{1}", !string.IsNullOrEmpty(ApkInformation.Label) ? ApkInformation.Label : ApkInformation.Package,
                                        string.IsNullOrEmpty(ApkInformation.Version) ? string.Empty : string.Format(" {0}", ApkInformation.Version));

            this.title.Text   = string.Format(Properties.Resources.InstallDialogWelcomeTitle, name, Mode);
            information.Text  = string.Format(Properties.Resources.InstallDialogInformationLabel, name, mode);
            this.Text         = string.Format("{0} {1}", mode, name);
            this.perform.Text = string.Format("&{0}", Mode.ToString( ));

            this.permissions.Visible = this.permissionsLabel.Visible = mode == InstallMode.Install;
            if (mode == InstallMode.Install)
            {
                this.permissions.DataSource = PluginHost.CommandRunner.GetLocalApkPermissions(string.IsNullOrEmpty(apkInfo.LocalApk) ? apkInfo.DevicePath : apkInfo.LocalApk);
            }

            this.icon.Image = PluginHost.CommandRunner.GetLocalApkIconImage(apkInfo.LocalApk);
        }
コード例 #5
0
        /// <summary>
        /// Sets the dialog values.
        /// </summary>
        private void SetDialogValues( )
        {
            bool isApk = string.Compare(System.IO.Path.GetExtension(FileSystemInfo.Name), ".apk", true) == 0;

            this.filename.Text = FileSystemInfo.Name;

            this.filePathLabel.Text = string.Format(CultureInfo.InvariantCulture, "{0}{1}", FileSystemInfo.FullPath,
                                                    FileSystemInfo.IsLink ? string.Format(CultureInfo.InvariantCulture, " -> {0}", (FileSystemInfo as SymbolicLinkInfo).Link) : string.Empty);
            this.modifiedLabel.Text = FileSystemInfo.LastModificationDateTime.ToString("ddd, MMMM dd, yyyy, h:mm:ss tt");
            this.fileSizeLabel.Text = string.Format(new FileSizeFormatProvider( ), "{0:fs} ({0} bytes)", FileSystemInfo.Size);
            Image img =
                FileSystemInfo.IsDirectory ?
                FileSystemInfo.IsLink ?
                DroidExplorer.Resources.Images.folder_Closed_32xLG_Link :
                DroidExplorer.Resources.Images.folder_Closed_32xLG :
                FileSystemInfo.IsLink ?

                /*FileSystemInfo.IsExecutable ?
                 *      DroidExplorer.Resources.Images.GearSL32 :*/
                DroidExplorer.Resources.Images.document_32_Link :

                /*FileSystemInfo.IsExecutable ?
                 *      DroidExplorer.Resources.Images.Gear :*/
                DroidExplorer.Resources.Images.document_32;

            if (isApk)
            {
                img = CommandRunner.Instance.GetApkIconImage(FileSystemInfo.FullPath);
                if (img == null)
                {
                    img = DroidExplorer.Resources.Images.apk32;
                }
            }
            else
            {
                if (SystemImageListHost.Instance.SystemIcons.ContainsKey(System.IO.Path.GetExtension(FileSystemInfo.Name)))
                {
                    img = SystemImageListHost.Instance.LargeImageList.Images[SystemImageListHost.Instance.SystemIcons[System.IO.Path.GetExtension(FileSystemInfo.Name)]];
                }
            }
            this.fileIcon.Image = img;

            this.fileTypeLabel.Text = FileSystemInfo.IsDirectory ?
                                      FileSystemInfo.IsLink ? "Directory Symbolic Link" :
                                      "Directory" :
                                      FileSystemInfo.IsLink ?
                                      /*FileSystemInfo.IsExecutable ? "Executable" :*/
                                      "Symbolic Link" : "File";
            this.isInstalled.Visible = isApk;

            if (isApk)
            {
                new Thread(new ParameterizedThreadStart(delegate(object o) {
                    this.isInstalled.SetText("Installed (Checking...)");
                    AaptBrandingCommandResult apkInfo = CommandRunner.Instance.GetApkInformation(FileSystemInfo.FullPath);
                    this.isInstalled.SetChecked(CommandRunner.Instance.IsPackageInstalled(apkInfo.Package));
                    this.isInstalled.SetText("Installed");
                })).Start( );
            }

            this.isExecutable.Enabled = !FileSystemInfo.IsDirectory && !isApk;
            this.isExecutable.Checked = FileSystemInfo.IsExecutable;
            this.isLink.Checked       = FileSystemInfo.IsLink;
            this.isPipe.Checked       = FileSystemInfo.IsPipe;
            this.isSocket.Checked     = FileSystemInfo.IsSocket;
        }
コード例 #6
0
        private void PrivateNavigate(DroidExplorer.Core.IO.LinuxDirectoryInfo path)
        {
            this.CurrentPath = path;
            string pathName = DroidExplorer.Core.IO.Path.GetDirectoryName(path.FullName);

            if (string.IsNullOrEmpty(pathName))
            {
                pathName = CommandRunner.Instance.GetSerialNumber( );
            }
            if (this.InvokeRequired)
            {
                this.Invoke(new GenericDelegate(this.files.Items.Clear));
                this.Invoke(new SetComboBoxExDisplayValueDelegate(this.SetComboBoxExDisplayValue), this.selectedPath, pathName);
            }
            else
            {
                this.files.Items.Clear( );
                SetComboBoxExDisplayValue(this.selectedPath, pathName);
            }
            List <DroidExplorer.Core.IO.FileSystemInfo> fsis = CommandRunner.Instance.GetDirectoryContents(path.FullName);

            foreach (var item in fsis)
            {
                FileSystemInfoListViewItem lvi = new FileSystemInfoListViewItem(item);
                if ((item.IsDirectory && !item.IsPipe && !item.IsSocket) || (IsFilterMatch(item, SelectedFilter) && !item.IsPipe && !item.IsSocket))
                {
                    if (!item.IsDirectory && !item.IsExecutable)
                    {
                        string ext     = System.IO.Path.GetExtension(lvi.FileSystemInfo.Name);
                        string keyName = ext.ToLower( );
                        if (keyName.StartsWith("/"))
                        {
                            keyName = keyName.Substring(1);
                        }
                        keyName = keyName.Replace("/", ".");

                        if (!string.IsNullOrEmpty(ext))
                        {
                            if (string.Compare(ext, ".apk", true) == 0)
                            {
                                AaptBrandingCommandResult result = CommandRunner.Instance.GetApkInformation(item.FullPath);
                                lvi = new ApkFileSystemInfoListViewItem(item, result);

                                keyName = lvi.FileSystemInfo.FullPath;
                                if (keyName.StartsWith("/"))
                                {
                                    keyName = keyName.Substring(1);
                                }
                                keyName = keyName.Replace("/", ".");

                                if (!SystemImageListHost.Instance.SystemIcons.ContainsKey(keyName))
                                {
                                    // get apk and extract the app icon
                                    Image img = CommandRunner.Instance.GetLocalApkIconImage(result.LocalApk);

                                    if (img == null)
                                    {
                                        img = DroidExplorer.Resources.Images.package32;
                                    }
                                    else
                                    {
                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream( )) {
                                            string lpath    = System.IO.Path.GetDirectoryName(this.GetType( ).Assembly.Location);
                                            string fileName = System.IO.Path.Combine(System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.APK_IMAGE_CACHE), string.Format("{0}.png", keyName));
                                            img.Save(stream, ImageFormat.Png);
                                            stream.Position = 0;
                                            using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)) {
                                                byte[] buffer    = new byte[2048];
                                                int    readBytes = 0;
                                                while ((readBytes = stream.Read(buffer, 0, buffer.Length)) != 0)
                                                {
                                                    fs.Write(buffer, 0, readBytes);
                                                }
                                            }
                                        }
                                    }
                                    SystemImageListHost.Instance.AddFileTypeImage(keyName, img, img);
                                }
                                if (this.InvokeRequired)
                                {
                                    this.Invoke(new SetListViewItemImageIndexDelegate(SetListViewItemImageIndex), lvi, SystemImageListHost.Instance.SystemIcons[keyName]);
                                }
                                else
                                {
                                    SetListViewItemImageIndex(lvi, SystemImageListHost.Instance.SystemIcons[keyName]);
                                }
                            }
                            else
                            {
                                if (!SystemImageListHost.Instance.SystemIcons.ContainsKey(ext.ToLower( )))                                         // add index and icon
                                {
                                    Image sico;
                                    Image lico;
                                    if (this.InvokeRequired)
                                    {
                                        int iconIndex = (int)this.Invoke(new GetSystemIconIndexDelegate(GetSystemIconIndex), new object[] { SystemImageListHost.Instance.SmallSystemImageList, item.Name });
                                        sico = (Image)this.Invoke(new GetSystemBitmapDelegate(GetSystemBitmap), new object[] { SystemImageListHost.Instance.SmallSystemImageList, iconIndex });
                                        lico = (Image)this.Invoke(new GetSystemBitmapDelegate(GetSystemBitmap), new object[] { SystemImageListHost.Instance.LargeSystemImageList, iconIndex });
                                    }
                                    else
                                    {
                                        int iconIndex = SystemImageListHost.Instance.SmallSystemImageList.IconIndex(item.Name, false);
                                        sico = GetSystemBitmap(SystemImageListHost.Instance.SmallSystemImageList, iconIndex);
                                        lico = GetSystemBitmap(SystemImageListHost.Instance.LargeSystemImageList, iconIndex);
                                    }
                                    SystemImageListHost.Instance.AddFileTypeImage(ext.ToLower( ), sico, lico);
                                }
                            }

                            if (this.InvokeRequired)
                            {
                                this.Invoke(new SetListViewItemImageIndexDelegate(this.SetListViewItemImageIndex), new object[] { lvi, SystemImageListHost.Instance.SystemIcons[keyName] });
                            }
                            else
                            {
                                SetListViewItemImageIndex(lvi, SystemImageListHost.Instance.SystemIcons[keyName]);
                            }
                        }
                    }
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new AddListViewItemDelegate(AddListViewItem), this.files, lvi);
                    }
                    else
                    {
                        AddListViewItem(this.files, lvi);
                    }
                }
            }

            if (this.InvokeRequired)
            {
                this.Invoke(new AutoResizeColumnsDelegate(AutoResizeColumns), this.files, ColumnHeaderAutoResizeStyle.ColumnContent);
            }
            else
            {
                AutoResizeColumns(this.files, ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }
コード例 #7
0
 public ApkFileSystemInfoListViewItem(DroidExplorer.Core.IO.FileSystemInfo fsi, int imageIndex, AaptBrandingCommandResult apkInfo)
     : this(fsi, apkInfo)
 {
     this.ImageIndex = imageIndex;
 }
コード例 #8
0
 public ApkFileSystemInfoListViewItem(DroidExplorer.Core.IO.FileSystemInfo fsi, AaptBrandingCommandResult apkInfo)
     : base(fsi)
 {
     this.ApkInfo = apkInfo;
     if (!string.IsNullOrEmpty(this.ApkInfo.Label))
     {
         this.Text = ApkInfo.Label;
     }
     else
     {
         this.Text = fsi.Name;
     }
     this.FileName = fsi.Name;
 }