Add MgdbForm

This commit is contained in:
Manu 2023-12-01 16:13:36 +01:00
parent ea2547caf9
commit cf6b480f90
15 changed files with 1607 additions and 198 deletions

4
.gitignore vendored
View File

@ -4,4 +4,6 @@
**/bin
**/obj
**.user
**.config
**.config
**.pubxml
**.pubxml.user

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\linux-x64\publish\linux-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-10-13T16:57:47.3580476Z;True|2023-08-14T13:07:02.3531810+02:00;True|2023-08-14T13:06:52.0751528+02:00;True|2023-06-06T22:09:41.5267582+02:00;True|2023-04-30T17:57:44.3876690+02:00;True|2023-04-10T17:40:35.1800594+02:00;True|2023-01-28T16:02:21.7075281+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\osx-x64\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-10-13T16:58:13.5143672Z;True|2023-08-14T13:05:42.5425714+02:00;True|2023-08-14T13:05:32.4788643+02:00;True|2023-06-06T22:11:28.7924159+02:00;True|2023-04-30T17:56:58.4384691+02:00;True|2023-04-10T17:37:41.8202016+02:00;True|2023-01-28T16:02:13.7381611+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\win-x64\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-10-13T16:58:34.5453703Z;True|2023-08-14T13:04:24.9139762+02:00;True|2023-06-06T22:12:34.4117725+02:00;True|2023-04-30T17:55:35.6583516+02:00;True|2023-04-10T17:35:59.0886698+02:00;False|2023-04-10T17:35:45.4776987+02:00;True|2023-01-28T16:02:06.8383516+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -493,72 +493,10 @@ public partial class MainWindow : Form
cmbRedemptionMethod.Enabled = false;
}
private void MenuItemMGDB_Click(object sender, EventArgs e) =>
Task.Run(async () => await DownloadRepoMGDB()).Wait();
private static async Task DownloadRepoMGDB()
{
var url = "https://github.com/projectpokemon/EventsGallery/archive/refs/heads/master.zip";
using (var client = new HttpClient())
{
var path = Path.Combine(Environment.CurrentDirectory, "tmp");
var mgdbPath = Path.Combine(Environment.CurrentDirectory, "mgdb");
//Delete old residual files if exist
if (Directory.Exists(path))
Directory.Delete(path, true);
if (Directory.Exists(mgdbPath))
Directory.Delete(mgdbPath, true);
Directory.CreateDirectory(path);
var zipPath = Path.Combine(path, "tmp.zip");
using (var response = await client.GetAsync(url))
{
using (var content = await response.Content.ReadAsStreamAsync())
{
using (var stream = new FileStream(zipPath, FileMode.Create, FileAccess.Write, FileShare.None))
{
await content.CopyToAsync(stream);
}
}
}
ZipFile.ExtractToDirectory(zipPath, path);
File.Delete(zipPath);
var tmpMgbdPath = Path.Combine(path, "EventsGallery-master");
File.Delete(Path.Combine(tmpMgbdPath, ".gitignore"));
Directory.Delete(Path.Combine(tmpMgbdPath, "Extras"), true);
Directory.Delete(Path.Combine(tmpMgbdPath, "Unreleased"), true);
Directory.Delete(Path.Combine(tmpMgbdPath, "PKHeX Legality"), true);
var genPath = Path.Combine(tmpMgbdPath, "Released");
Directory.Delete(Path.Combine(genPath, "Gen 1"), true);
Directory.Delete(Path.Combine(genPath, "Gen 2"), true);
Directory.Delete(Path.Combine(genPath, "Gen 3"), true);
Directory.Delete(Path.Combine(genPath, "Gen 4"), true);
Directory.Delete(Path.Combine(genPath, "Gen 5"), true);
Directory.Delete(Path.Combine(genPath, "Gen 6"), true);
var gen7Path = Path.Combine(genPath, "Gen 7");
Directory.Delete(Path.Combine(gen7Path, "3DS"), true);
Directory.Delete(Path.Combine(Path.Combine(gen7Path, "Switch"), "Wondercard Records"), true);
var swshPath = Path.Combine(Path.Combine(genPath, "Gen 8"), "SwSh");
Directory.Delete(Path.Combine(swshPath, "Wild Area Events"), true);
var gen9Path = Path.Combine(genPath, "Gen 9");
Directory.Delete(Path.Combine(gen9Path, "Raid Events"), true);
Directory.Delete(Path.Combine(gen9Path, "Outbreak Events"), true);
Directory.Move(tmpMgbdPath, mgdbPath);
Directory.Delete(path, true);
MessageBox.Show($"The Mystery Gift Database has been downloaded in {mgdbPath}", "MGDB",
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
}
private void MenuItemMGDB_Click(object sender, EventArgs e)
{
var form = new MgdbForm();
form.Location = this.Location;
form.Show();
}
}

View File

@ -0,0 +1,66 @@
namespace SwitchGiftDataManager.WinForm
{
partial class MgdbForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MgdbForm));
lblMessage = new Label();
SuspendLayout();
//
// lblMessage
//
lblMessage.AutoSize = true;
lblMessage.Location = new Point(94, 9);
lblMessage.Name = "lblMessage";
lblMessage.Size = new Size(190, 20);
lblMessage.TabIndex = 0;
lblMessage.Text = "Downloading, please wait...";
//
// MgdbForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(392, 37);
ControlBox = false;
Controls.Add(lblMessage);
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
MinimizeBox = false;
Name = "MgdbForm";
ShowInTaskbar = false;
StartPosition = FormStartPosition.Manual;
Text = "Mystery Gift Database";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label lblMessage;
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Compression;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SwitchGiftDataManager.WinForm;
public partial class MgdbForm : Form
{
public MgdbForm()
{
InitializeComponent();
this.Shown += (s, e) => Task.Run(async () => await DownloadRepoMGDB()).Wait();
}
private async Task DownloadRepoMGDB()
{
var url = "https://github.com/projectpokemon/EventsGallery/archive/refs/heads/master.zip";
using (var client = new HttpClient())
{
var path = Path.Combine(Environment.CurrentDirectory, "tmp");
var mgdbPath = Path.Combine(Environment.CurrentDirectory, "mgdb");
//Delete old residual files if exist
if (Directory.Exists(path))
Directory.Delete(path, true);
if (Directory.Exists(mgdbPath))
Directory.Delete(mgdbPath, true);
Directory.CreateDirectory(path);
var zipPath = Path.Combine(path, "tmp.zip");
using (var response = await client.GetAsync(url))
{
using (var content = await response.Content.ReadAsStreamAsync())
{
using (var stream = new FileStream(zipPath, FileMode.Create, FileAccess.Write, FileShare.None))
{
await content.CopyToAsync(stream);
}
}
}
ZipFile.ExtractToDirectory(zipPath, path);
File.Delete(zipPath);
var tmpMgbdPath = Path.Combine(path, "EventsGallery-master");
File.Delete(Path.Combine(tmpMgbdPath, ".gitignore"));
Directory.Delete(Path.Combine(tmpMgbdPath, "Extras"), true);
Directory.Delete(Path.Combine(tmpMgbdPath, "Unreleased"), true);
Directory.Delete(Path.Combine(tmpMgbdPath, "PKHeX Legality"), true);
var genPath = Path.Combine(tmpMgbdPath, "Released");
Directory.Delete(Path.Combine(genPath, "Gen 1"), true);
Directory.Delete(Path.Combine(genPath, "Gen 2"), true);
Directory.Delete(Path.Combine(genPath, "Gen 3"), true);
Directory.Delete(Path.Combine(genPath, "Gen 4"), true);
Directory.Delete(Path.Combine(genPath, "Gen 5"), true);
Directory.Delete(Path.Combine(genPath, "Gen 6"), true);
var gen7Path = Path.Combine(genPath, "Gen 7");
Directory.Delete(Path.Combine(gen7Path, "3DS"), true);
Directory.Delete(Path.Combine(Path.Combine(gen7Path, "Switch"), "Wondercard Records"), true);
var swshPath = Path.Combine(Path.Combine(genPath, "Gen 8"), "SwSh");
Directory.Delete(Path.Combine(swshPath, "Wild Area Events"), true);
var gen9Path = Path.Combine(genPath, "Gen 9");
Directory.Delete(Path.Combine(gen9Path, "Raid Events"), true);
Directory.Delete(Path.Combine(gen9Path, "Outbreak Events"), true);
Directory.Move(tmpMgbdPath, mgdbPath);
Directory.Delete(path, true);
this.FormClosed += (s, e) => MessageBox.Show($"The Mystery Gift Database has been downloaded in {mgdbPath}", "MGDB",
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
this.Close();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0-windows\publish\win-x86\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0-windows</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-10-13T17:01:40.9505642Z;True|2023-08-14T13:01:52.2006498+02:00;True|2023-06-06T22:08:02.8282040+02:00;True|2023-04-30T17:53:05.5959766+02:00;False|2023-04-30T17:52:03.7561171+02:00;True|2023-04-30T17:51:26.5642099+02:00;False|2023-04-30T17:50:29.6287729+02:00;False|2023-04-30T17:49:48.8628113+02:00;False|2023-04-30T17:49:13.6423153+02:00;False|2023-04-30T17:49:07.1768896+02:00;True|2023-04-10T17:45:17.0563608+02:00;False|2023-04-10T17:45:05.3801595+02:00;True|2023-04-10T17:44:52.3050457+02:00;False|2023-04-10T17:43:42.2422643+02:00;False|2023-04-10T17:42:40.9947818+02:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0-windows</TargetFramework>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-10-13T17:00:41.7783875Z;True|2023-10-13T18:58:55.8792041+02:00;True|2023-08-14T21:28:20.2713749+02:00;True|2023-08-14T21:25:34.3082675+02:00;True|2023-08-14T21:25:27.1522351+02:00;True|2023-08-14T21:00:06.6523582+02:00;True|2023-08-14T20:58:07.2152740+02:00;True|2023-08-14T20:57:44.9836572+02:00;True|2023-08-14T13:02:48.6507319+02:00;True|2023-06-06T22:06:44.0906717+02:00;True|2023-04-30T17:47:33.6719153+02:00;False|2023-04-30T17:47:20.2017341+02:00;True|2023-04-10T17:33:26.3077827+02:00;False|2023-04-10T17:32:43.9169969+02:00;True|2023-01-28T16:01:40.5830936+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>