예제 #1
0
        private void uninstallToolStripButton_Click(object sender, EventArgs e)
        {
            if (this.packagesList.SelectedItems.Count == 1)
            {
                ApkPackageListViewItem lvi = packagesList.SelectedItems[0] as ApkPackageListViewItem;
                if (lvi != null && lvi.ApkInformation != null && !string.IsNullOrEmpty(lvi.ApkInformation.Package))
                {
                    InstallDialog install = new InstallDialog((IPluginHost)this.ParentForm, InstallDialog.InstallMode.Uninstall, lvi.ApkInformation);
                    if (install.ShowDialog(this) == DialogResult.OK)
                    {
                        RemoveListViewItem(packagesList.Items, lvi);
                    }

                    /*string package = lvi.ApkInformation.Package;
                     * string name = string.IsNullOrEmpty ( lvi.ApkInformation.Label ) ? lvi.ApkInformation.Package : lvi.ApkInformation.Label;
                     *
                     * if ( CommandRunner.Instance.UninstallApk ( package ) ) {
                     * try {
                     *    RemoveListViewItem ( packagesList.Items, lvi );
                     *    TaskDialog.MessageBox ( "Uninstall Complete", string.Format ( "Successfully uninstalled {0}", name ),
                     *    string.Empty, TaskDialogButtons.OK, SysIcons.Information );
                     * } catch ( Exception ex ) {
                     *  Console.WriteLine ( "[{0}] {1}", this.GetType ( ).Name, ex.ToString ( ) );
                     *
                     *  TaskDialog.MessageBox ( "Uninstall Error", string.Format ( Properties.Resources.UninstallErrorMessage, name ),
                     *    ex.Message, TaskDialogButtons.OK, SysIcons.Error );
                     * }
                     * } else {
                     * TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.UninstallErrorMessage, name ),
                     *  Properties.Resources.UninstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
                     * }*/
                }
            }
        }
예제 #2
0
 public void Close()
 {
     UIInvoke(() =>
     {
         InstallDialog.CloseDialog();
     });
 }
예제 #3
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 );
                 * }*/
            }
        }
예제 #4
0
        /// <summary>
        /// Executes the specified plugin host.
        /// </summary>
        /// <param name="pluginHost">The plugin host.</param>
        /// <param name="currentDirectory">The current directory.</param>
        /// <param name="args">The args.</param>
        public override void Execute(IPluginHost pluginHost, DroidExplorer.Core.IO.LinuxDirectoryInfo currentDirectory, string[] args)
        {
            Arguments arguments = new Arguments(args ?? new string[] { "/install" });
            string    apkFile   = string.Empty;
            var       apkArg    = arguments.Contains("apk") ? arguments["apk"] : string.Empty;

            // check that we have a file, and that it exists.
            if (!string.IsNullOrWhiteSpace(apkArg) && System.IO.File.Exists(apkArg))
            {
                apkFile = apkArg;
            }
            else
            {
                System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog( );
                ofd.Title           = "Select Android Application";
                ofd.Filter          = "Android Applications|*.apk";
                ofd.CheckFileExists = true;
                ofd.Multiselect     = false;
                if (ofd.ShowDialog( ) == DialogResult.OK)
                {
                    apkFile = ofd.FileName;
                }
                else
                {
                    return;
                }
            }

            if (File.Exists(apkFile))
            {
                try {
                    var apkInfo = this.PluginHost.CommandRunner.GetLocalApkInformation(apkFile);
                    var id      = new InstallDialog(this.PluginHost, arguments.Contains("uninstall") ? InstallDialog.InstallMode.Uninstall : InstallDialog.InstallMode.Install, apkInfo);
                    if (pluginHost != null && pluginHost.GetHostWindow() != null)
                    {
                        id.Show( );
                    }
                    else
                    {
                        id.ShowInTaskbar = true;
                        id.ShowDialog( );
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    this.LogError(ex.Message, ex);
                }
            }
        }