//Event handler for selected tabs
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string temppath = GetTemporaryDirectory();

            SevenZip.SevenZipExtractor.SetLibraryPath(@"D:\Program Files (x86)\7-Zip\7z.dll");
            switch ((sender as TabControl).SelectedIndex)
            {
            case 0:
                //Starting tab, twiddle
                break;

            case 1:
                //We've selected the second tab and need to load the package information from the archive
                if (File.Exists(openfile))
                {
                    string tempextract_info = Path.Combine(temppath + "\\packageinfo.bpi");
                    try
                    {
                        using (FileStream myStream = new FileStream(tempextract_info, FileMode.Create))
                        {
                            var packageinfofile = new SevenZip.SevenZipExtractor(openfile);
                            packageinfofile.ExtractFile("packageinfo.bpi", myStream);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The selected package appears to be corrupt.");
                    }
                    try
                    {
                        readpackageinfo(tempextract_info);
                    }
                    catch
                    {
                        MessageBox.Show("Error reading package information.");
                    }
                    //Now extract the image
                    try
                    {
                        string tempextract_image = Path.Combine(temppath + "\\package.png");
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Create))
                        {
                            var packageimage = new SevenZip.SevenZipExtractor(openfile);
                            packageimage.ExtractFile("package.png", myStream);
                        }
                        //Read the package information
                        readpackageinfo(tempextract_info);
                        //Load the image
                        Bitmap tempimage;
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Open))
                        {
                            tempimage = (Bitmap)Image.FromStream(myStream);
                            this.pictureBox1.Image    = tempimage;
                            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                    }
                    catch
                    {
                        //No error prompt, just don't load the image
                    }
                }
                break;

            case 2:
                //Try to load the contents of an archive
                if (ArchiveInfoWorker.IsBusy != true)
                {
                    progress1 = new ReadingPackage();
                    progress1.Show();
                    ArchiveInfoWorker.RunWorkerAsync();
                }
                break;

            case 3:
                //Package extraction
                if (InstallerWorker.IsBusy != true)
                {
                    progress = new InstallProgress();
                    progress.Show();
                    InstallerWorker.RunWorkerAsync();
                }
                break;
            }
        }
        //Event handler for selected tabs
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) {
            string temppath = GetTemporaryDirectory();
            SevenZip.SevenZipExtractor.SetLibraryPath(@"D:\Program Files (x86)\7-Zip\7z.dll");
        switch((sender as TabControl).SelectedIndex) {
            case 0:
                //Starting tab, twiddle
                break;
            case 1:
                //We've selected the second tab and need to load the package information from the archive
                if (File.Exists(openfile))
                {
                    string tempextract_info = Path.Combine(temppath + "\\packageinfo.bpi");
                    try
                    {
                        using (FileStream myStream = new FileStream(tempextract_info, FileMode.Create))
                        {

                            var packageinfofile = new SevenZip.SevenZipExtractor(openfile);
                            packageinfofile.ExtractFile("packageinfo.bpi", myStream);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The selected package appears to be corrupt.");
                    }
                    try
                    {
                        readpackageinfo(tempextract_info);
                    }
                    catch
                    {
                        MessageBox.Show("Error reading package information.");
                    }
                    //Now extract the image
                    try
                    {
                        string tempextract_image = Path.Combine(temppath + "\\package.png");
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Create))
                        {

                            var packageimage = new SevenZip.SevenZipExtractor(openfile);
                            packageimage.ExtractFile("package.png", myStream);
                        }
                        //Read the package information
                        readpackageinfo(tempextract_info);
                        //Load the image
                        Bitmap tempimage;
                        using (FileStream myStream = new FileStream(tempextract_image, FileMode.Open))
                        {
                            tempimage = (Bitmap)Image.FromStream(myStream);
                            this.pictureBox1.Image = tempimage;
                            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                        }
                    }
                    catch
                    {
                        //No error prompt, just don't load the image
                    }
                }
                break;
            case 2:
                //Try to load the contents of an archive
                if (ArchiveInfoWorker.IsBusy != true)
                {
                    progress1 = new ReadingPackage();
                    progress1.Show();
                    ArchiveInfoWorker.RunWorkerAsync();
                }
                break;
            case 3:
                //Package extraction
                if (InstallerWorker.IsBusy != true)
                {
                    progress = new InstallProgress();
                    progress.Show();
                    InstallerWorker.RunWorkerAsync();
                }   
                break;
                
           }   
        }