private void InstallZipBtn_Click(object sender, EventArgs e) { FileInfo Zip; using (OpenFileDialog PackageDialog = new OpenFileDialog { Filter = "Zip File|*.zip|All Files|*.*", Title = "Select a Zip File!" }) { if (PackageDialog.ShowDialog() != DialogResult.OK) { return; } Zip = new FileInfo(PackageDialog.FileName); } using (QuickPackageCreation creation = new QuickPackageCreation(Zip)) { if (creation.ShowDialog() != DialogResult.OK) { return; } switch (CheckPackages(creation.Pkg, out Package Outdated)) { default: case -1: return; case 0: InstallPackage(creation.Pkg, creation.Resources); return; case 1: RemovePackage(Packages.Single(p => p.Key.name == Outdated.name)); InstallPackage(creation.Pkg, creation.Resources); return; } } }
private void InstallZipWebBtn_Click(object sender, EventArgs e) { string input = Interaction.InputBox("Input URL"); if (input == string.Empty) { return; } Uri uri; try { uri = new Uri(input); } catch { MessageBox.Show("Invalid URL", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileInfo Zip; using (WebClient wc = new WebClient()) { Zip = new DirectoryInfo(Path.GetTempPath()).GetDirectory("FM").GetFile(uri.Segments.Last()); try { wc.DownloadFile(uri, Zip.FullName); } catch (Exception ex) { MessageBox.Show($"Download Failed: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } using (QuickPackageCreation creation = new QuickPackageCreation(Zip)) { if (creation.ShowDialog() != DialogResult.OK) { return; } switch (CheckPackages(creation.Pkg, out Package Outdated)) { default: case -1: return; case 0: InstallPackage(creation.Pkg, creation.Resources); return; case 1: RemovePackage(Packages.Single(p => p.Key.name == Outdated.name)); InstallPackage(creation.Pkg, creation.Resources); return; } } }