public EmulatorConfigurationDialog(EmulatorConfiguration config)
        {
            this.config = config;
            InitializeComponent();
            var propertiesItem = new ToolStripMenuItem {
                Text = "Properties"
            };

            propertiesItem.Click += PropertiesItem_Click;
            contextMenuStrip      = new ContextMenuStrip();
            contextMenuStrip.Items.Add(propertiesItem);
            packages.MouseDown += Packages_MouseDown;
            message.Text        = String.Format(message.Text, config.GetName());
        }
        private async void Download(BackgroundWorker worker)
        {
            tempFolder = Path.GetTempFileName();
            File.Delete(tempFolder);
            Directory.CreateDirectory(tempFolder);
            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += Client_DownloadProgressChanged;
                foreach (Package package in packages.CheckedItems)
                {
                    string file = Path.Combine(tempFolder, package.GetName() + ".zip");
                    try
                    {
                        await client.DownloadFileTaskAsync(package.GetURI(), file);
                    }
                    catch (WebException ex)
                    {
                        MessageBox.Show("Could not download package " + package.GetName() + ".\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                        Enabled = true;
                        return;
                    }
                }
            }
            string buildDir = Path.Combine(tempFolder, "build");

            worker.DoWork += (obj, e) =>
            {
                foreach (Package package in packages.CheckedItems)
                {
                    AddToBuild(Path.Combine(buildDir, package.GetInstallPath()), Path.Combine(tempFolder, package.GetName() + ".zip"));
                }
            };
            string build = Path.Combine(tempFolder, "build.zip");

            worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                ZipFile.CreateFromDirectory(buildDir, build);
                string emulatorsDir = "emulators";
                if (!Directory.Exists(emulatorsDir))
                {
                    Directory.CreateDirectory(emulatorsDir);
                }
                File.Move(build, Path.Combine(emulatorsDir, config.GetName() + ".zip"));
                dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                Close();
            };
            worker.RunWorkerAsync();
        }
        private async void Download(BackgroundWorker worker)
        {
            tempFolder = Path.GetTempFileName();
            File.Delete(tempFolder);
            Directory.CreateDirectory(tempFolder);
            string buildDir = Path.Combine(tempFolder, "build");

            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += Client_DownloadProgressChanged;
                foreach (Package package in packages.CheckedItems)
                {
                    try
                    {
                        await package.Download(client, tempFolder);

                        DirectoryInfo dir = await package.Unpack();

                        AddToBuild(Path.Combine(buildDir, package.GetInstallPath()), dir);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Could not download package " + package.GetName() + ".\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                        Enabled = true;
                        return;
                    }
                }
            }
            string build = Path.Combine(tempFolder, "build.zip");

            ZipFile.CreateFromDirectory(buildDir, build);
            string emulatorsDir = "emulators";

            if (!Directory.Exists(emulatorsDir))
            {
                Directory.CreateDirectory(emulatorsDir);
            }
            File.Move(build, Path.Combine(emulatorsDir, config.GetName() + ".zip"));
            dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
            Close();
        }