feat: file metadata
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CarManagerV3.Classes;
|
||||
using CarManagerV3.Manager;
|
||||
|
||||
namespace CarManagerV3
|
||||
{
|
||||
@@ -139,13 +141,19 @@ namespace CarManagerV3
|
||||
/// This is to prevent multiple annoying popups if the user tries to open multiple files that require migration.
|
||||
/// </summary>
|
||||
/// <returns>True if the user has accepted to migrate the file, otherwise False</returns>
|
||||
public static bool askForMigration()
|
||||
public static bool askForMigration(FileMeta meta = null)
|
||||
{
|
||||
if (hasConfirmedMigration)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
DialogResult result = MessageBox.Show("The file you are trying to open is in an older format. Do you want to attempt to migrate it to the new format? If you choose not to migrate, the file will not be opened.", "Migration Needed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
string promptMessage = "The file you are trying to open is in an older format. Do you want to attempt to migrate it to the new format? If you choose not to migrate, the file will not be opened.";
|
||||
if(meta != null)
|
||||
{
|
||||
int nUpdatesNeeded = FileUpdate.GetRequiredUpdates(meta.Version).Count;
|
||||
promptMessage = $"The file you are trying to open is in an older format ({meta.Version}). It requires {nUpdatesNeeded} update(s) to be migrated to your Version ({Updater.GetCurrentVersion(true)}).\nDo you want to attempt to migrate it? If you choose not to migrate, the file will not be opened.";
|
||||
}
|
||||
DialogResult result = MessageBox.Show(promptMessage, "Migration Needed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
hasConfirmedMigration = result == DialogResult.Yes;
|
||||
return hasConfirmedMigration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user