Example #1
0
        /// <summary>
        /// Starts the debugger.
        /// </summary>
        internal void DebugLaunch(uint grfLaunch)
        {
            // Open the package
            PackageFile packageFile;
            var packagePath = PackagePath;
            try
            {
                packageFile = new PackageFile(packagePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Failed to open package because: {0}", ex.Message));
                return;
            }

            // Show device selection
            var debuggable = (grfLaunch != (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug);
            var ide = Package.Ide;

#if ANDROID
            int minSdkVersion;
            if (!packageFile.Manifest.TryGetMinSdkVersion(out minSdkVersion))
                minSdkVersion = -1;
            var targetFramework = (minSdkVersion > 0) ? Frameworks.Instance.GetBySdkVersion(minSdkVersion) : null;
            var targetVersion = (targetFramework != null) ? targetFramework.Name : null;
            var runner = new ApkRunner(ide, packagePath, packageFile.Manifest.PackageName, packageFile.Manifest.Activities.Select(x => x.Name).FirstOrDefault(), debuggable, (int) grfLaunch);
#elif BB
            var targetFramework = Frameworks.Instance.FirstOrDefault();
            var targetVersion = (targetFramework != null) ? targetFramework.Name : null;
            var runner = new BarRunner(ide, packagePath, packageFile.Manifest.PackageName, "--default--", debuggable, (int)grfLaunch);
#endif
            
            using (var dialog = new DeviceSelectionDialog(ide, runner.DeviceIsCompatible, targetVersion))
            {
                var rc= dialog.ShowDialog();
                switch (rc)
                {
                    case DialogResult.OK:
                        var device = dialog.SelectedDevice;
                        Package.Ide.LastUsedUniqueId = device.UniqueId;

                        using (var xDialog = new LauncherDialog(packagePath, debuggable))
                        {
                            var stateDialog = xDialog;
                            stateDialog.Cancel += (s, x) => runner.Cancel();
                            stateDialog.Load += (s, x) => runner.Run(device, stateDialog.SetState);
                            stateDialog.ShowDialog();
                        }
                        break;
                    case DialogResult.Retry:
                        // Change project target version
                        try
                        {
                            ChangeAndroidTargetVersion(dialog.NewProjectTargetVersion);
                            MessageBox.Show(string.Format("Changed target framework version to {0}, to match the Android version of your device.", dialog.NewProjectTargetVersion));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("Failed to change target framework version because: {0}", ex.Message));
                        }
                        break;
                }
            }
        }
Example #2
0
        public override void Start(bool withDebugging)
        {
            // Open the package
            ApkFile apkFile;
            var apkPath = ApkPath;
            try
            {
                apkFile = new ApkFile(apkPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Failed to open package because: {0}", ex.Message));
                return;
            }

            // Show device selection
            var ide = Dot42Addin.Ide;
            int minSdkVersion;
            if (!apkFile.Manifest.TryGetMinSdkVersion(out minSdkVersion))
                minSdkVersion = -1;
            var targetFramework = (minSdkVersion > 0) ? Frameworks.Instance.GetBySdkVersion(minSdkVersion) : null;
            var targetVersion = (targetFramework != null) ? targetFramework.Name : null;
            var runner = new ApkRunner(ide, ApkPath, apkFile.Manifest.PackageName, apkFile.Manifest.Activities.Select(x => x.Name).FirstOrDefault(), withDebugging, 0);
            using (var dialog = new DeviceSelectionDialog(ide, IsCompatible, targetVersion)) {
                if (dialog.ShowDialog() == DialogResult.OK) {
                    // Run on the device now
                    var device = dialog.SelectedDevice;
                    ide.LastUsedUniqueId = device.UniqueId;

                    using (var xDialog = new LauncherDialog(apkPath, withDebugging))
                    {
                        var stateDialog = xDialog;
                        stateDialog.Cancel += (s, x) => runner.Cancel();
                        stateDialog.Load += (s, x) => runner.Run(device, stateDialog.SetState);
                        stateDialog.ShowDialog();
                    }
                }
            }
        }