Compare commits
2 Commits
1.4.3.1
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
| adaa6256cd | |||
| d0f54655b8 |
@@ -358,15 +358,15 @@
|
|||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:Car Manager 3"
|
"ProductName" = "8:Car Manager 3"
|
||||||
"ProductCode" = "8:{019F61F2-9751-4419-A752-CB720325E3A7}"
|
"ProductCode" = "8:{C464F09B-4ED2-46D4-A17B-49BD0F6E6566}"
|
||||||
"PackageCode" = "8:{831DA8BC-D3ED-4690-AA5B-7974A8D73953}"
|
"PackageCode" = "8:{D55B03D7-E738-48F7-B6BD-87113014326E}"
|
||||||
"UpgradeCode" = "8:{6FF57925-465E-4DB9-85DA-CE933191A3DD}"
|
"UpgradeCode" = "8:{6FF57925-465E-4DB9-85DA-CE933191A3DD}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
"RemovePreviousVersions" = "11:TRUE"
|
"RemovePreviousVersions" = "11:TRUE"
|
||||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||||
"InstallAllUsers" = "11:FALSE"
|
"InstallAllUsers" = "11:FALSE"
|
||||||
"ProductVersion" = "8:1.4.3.1"
|
"ProductVersion" = "8:1.4.4"
|
||||||
"Manufacturer" = "8:Jaro Digital"
|
"Manufacturer" = "8:Jaro Digital"
|
||||||
"ARPHELPTELEPHONE" = "8:"
|
"ARPHELPTELEPHONE" = "8:"
|
||||||
"ARPHELPLINK" = "8:"
|
"ARPHELPLINK" = "8:"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Global
|
|||||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Debug|Any CPU.ActiveCfg = Debug
|
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Debug|Any CPU.ActiveCfg = Debug
|
||||||
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.ActiveCfg = Release
|
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.ActiveCfg = Release
|
||||||
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.Build.0 = Release
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.4.3.1</ApplicationVersion>
|
<ApplicationVersion>1.4.4</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<ApplicationIcon>CarMgm_Icon.ico</ApplicationIcon>
|
<ApplicationIcon>CarMgm_Icon.ico</ApplicationIcon>
|
||||||
<AssemblyTitle>CarManager3</AssemblyTitle>
|
<AssemblyTitle>CarManager3</AssemblyTitle>
|
||||||
<Product>CarManager3</Product>
|
<Product>CarManager3</Product>
|
||||||
<Version>1.4.3.1</Version>
|
<Version>1.4.4</Version>
|
||||||
<Authors>Jaro Digital</Authors>
|
<Authors>Jaro Digital</Authors>
|
||||||
<Company>Jaro Digital</Company>
|
<Company>Jaro Digital</Company>
|
||||||
<Title>Car Manager 3</Title>
|
<Title>Car Manager 3</Title>
|
||||||
|
|||||||
@@ -178,22 +178,7 @@ namespace CarManagerV3
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string[] parts = csv.Split(';');
|
string[] parts = csv.Split(';');
|
||||||
// is part 7 a valid int? if not set it to 0 and log a warning.
|
System.Diagnostics.Debug.WriteLine(csv);
|
||||||
if (parts.Length == 7)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine($"Warning: CSV string has only 7 fields, expected 8. Setting Order to 0. CSV: {csv}");
|
|
||||||
if (!StateManager.askForMigration())
|
|
||||||
{
|
|
||||||
throw new Exception("User declined migration. Cannot parse CSV string with missing Order field.");
|
|
||||||
}
|
|
||||||
Array.Resize(ref parts, 8);
|
|
||||||
parts[7] = "0";
|
|
||||||
}
|
|
||||||
else if (parts.Length != 8)
|
|
||||||
{
|
|
||||||
throw new FormatException($"CSV string has {parts.Length} fields, expected 8. CSV: {csv}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Car temp = new Car(parts[0], parts[1], parts[2], int.Parse(parts[3]), parts[4], int.Parse(parts[5]), decimal.Parse(parts[6]), int.Parse(parts[7]));
|
Car temp = new Car(parts[0], parts[1], parts[2], int.Parse(parts[3]), parts[4], int.Parse(parts[5]), decimal.Parse(parts[6]), int.Parse(parts[7]));
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|||||||
74
CarManagerV3/Classes/FileMeta.cs
Normal file
74
CarManagerV3/Classes/FileMeta.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CarManagerV3.Manager;
|
||||||
|
|
||||||
|
namespace CarManagerV3.Classes
|
||||||
|
{
|
||||||
|
internal class FileMeta
|
||||||
|
{
|
||||||
|
private string version;
|
||||||
|
private DateTime lastModified;
|
||||||
|
|
||||||
|
public string Version { get { return version; } set { version = value; } }
|
||||||
|
public DateTime LastModified { get { return lastModified; } }
|
||||||
|
|
||||||
|
public FileMeta(string version)
|
||||||
|
{
|
||||||
|
this.version = version;
|
||||||
|
this.lastModified = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileMeta FromCSV(string csv)
|
||||||
|
{
|
||||||
|
string[] parts = csv.Split(';');
|
||||||
|
if (parts.Length < 3)
|
||||||
|
{
|
||||||
|
throw new FormatException("CSV format is incorrect. Expected format: product;version;lastModified");
|
||||||
|
}
|
||||||
|
return new FileMeta(parts[1]) { lastModified = DateTime.Parse(parts[2]) };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileMeta Generate()
|
||||||
|
{
|
||||||
|
string version = Updater.GetCurrentVersion();
|
||||||
|
return new FileMeta(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsFileMeta(string csv)
|
||||||
|
{
|
||||||
|
return csv.StartsWith("CarManager3;");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsOlderVersion(FileMeta meta)
|
||||||
|
{
|
||||||
|
string version = Updater.GetCurrentVersion();
|
||||||
|
return Updater.IsNewerVersion(version, meta.Version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool NeedsUpdate(FileMeta meta)
|
||||||
|
{
|
||||||
|
string version = Updater.GetCurrentVersion();
|
||||||
|
return Updater.IsNewerVersion(version, meta.Version) && FileUpdate.GetRequiredUpdates(meta.Version).Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Modify()
|
||||||
|
{
|
||||||
|
lastModified = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToCSV()
|
||||||
|
{
|
||||||
|
return $"CarManager3;{version};{lastModified}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"File Version: {version}, Last Modified: {lastModified}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
102
CarManagerV3/Classes/FileUpdate.cs
Normal file
102
CarManagerV3/Classes/FileUpdate.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CarManagerV3.Manager;
|
||||||
|
|
||||||
|
namespace CarManagerV3.Classes
|
||||||
|
{
|
||||||
|
internal class FileUpdate
|
||||||
|
{
|
||||||
|
public string version;
|
||||||
|
public bool needUpdate;
|
||||||
|
public Func<string, string> updateAction;
|
||||||
|
|
||||||
|
public static List<FileUpdate> GetUpdates()
|
||||||
|
{
|
||||||
|
return new List<FileUpdate>
|
||||||
|
{
|
||||||
|
new FileUpdate {
|
||||||
|
version = "1.4.3.0",
|
||||||
|
needUpdate = true,
|
||||||
|
updateAction = (fileContent) =>
|
||||||
|
{
|
||||||
|
// Implement the logic to update the file content for version
|
||||||
|
List<string> parts = fileContent.Split(";").ToList();
|
||||||
|
parts[4] = "Black";
|
||||||
|
return string.Join(";", parts);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new FileUpdate {
|
||||||
|
version = "1.4.4.0",
|
||||||
|
needUpdate = false
|
||||||
|
}
|
||||||
|
// Add more FileUpdate instances for other versions as needed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<FileUpdate> GetRequiredUpdates(string fromVersion)
|
||||||
|
{
|
||||||
|
string currentVersion = Updater.GetCurrentVersion();
|
||||||
|
// Get all updates whos version is greater than fromVersion
|
||||||
|
return GetUpdates().Where(update => string.Compare(update.version, fromVersion) > 0 && string.Compare(update.version, currentVersion) <= 0 && update.needUpdate && update.updateAction != null).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ApplyUpdates(string fileContent, string fileVersion)
|
||||||
|
{
|
||||||
|
List<FileUpdate> updates = GetRequiredUpdates(fileVersion);
|
||||||
|
foreach (var update in updates)
|
||||||
|
{
|
||||||
|
if (update.needUpdate && update.updateAction != null)
|
||||||
|
{
|
||||||
|
fileContent = update.updateAction(fileContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> ApplyUpdatesToALl(List<string> fileContents, string fileVersion)
|
||||||
|
{
|
||||||
|
List<FileUpdate> updates = GetRequiredUpdates(fileVersion);
|
||||||
|
List<string> updatedContents = new List<string>();
|
||||||
|
foreach (var content in fileContents)
|
||||||
|
{
|
||||||
|
string updatedContent = content;
|
||||||
|
foreach (var update in updates)
|
||||||
|
{
|
||||||
|
if (update.needUpdate && update.updateAction != null)
|
||||||
|
{
|
||||||
|
updatedContent = update.updateAction(updatedContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatedContents.Add(updatedContent);
|
||||||
|
}
|
||||||
|
return updatedContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string PerformOldLegacyUpdate(string fileContent)
|
||||||
|
{
|
||||||
|
string[] parts = fileContent.Split(';');
|
||||||
|
// is part 7 a valid int? if not set it to 0 and log a warning.
|
||||||
|
if (parts.Length == 7)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Warning: CSV string has only 7 fields, expected 8. Setting Order to 0. CSV: {fileContent}");
|
||||||
|
if (!StateManager.askForMigration())
|
||||||
|
{
|
||||||
|
throw new Exception("User declined migration. Cannot parse CSV string with missing Order field.");
|
||||||
|
}
|
||||||
|
Array.Resize(ref parts, 8);
|
||||||
|
parts[7] = "0";
|
||||||
|
return string.Join(";", parts);
|
||||||
|
}
|
||||||
|
else if (parts.Length != 8)
|
||||||
|
{
|
||||||
|
throw new FormatException($"CSV string has {parts.Length} fields, expected 8. CSV: {fileContent}");
|
||||||
|
}
|
||||||
|
return fileContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
105
CarManagerV3/Forms/MainForm.Designer.cs
generated
105
CarManagerV3/Forms/MainForm.Designer.cs
generated
@@ -30,7 +30,7 @@
|
|||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
tlpWrapper = new System.Windows.Forms.TableLayoutPanel();
|
||||||
flpCars = new System.Windows.Forms.FlowLayoutPanel();
|
flpCars = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
tlpControls = new System.Windows.Forms.TableLayoutPanel();
|
tlpControls = new System.Windows.Forms.TableLayoutPanel();
|
||||||
btnNewCar = new System.Windows.Forms.Button();
|
btnNewCar = new System.Windows.Forms.Button();
|
||||||
@@ -53,35 +53,40 @@
|
|||||||
toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
openWelcomeScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
openWelcomeScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
clearRecentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
clearRecentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
imageList1 = new System.Windows.Forms.ImageList(components);
|
|
||||||
aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
gitRepositoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
gitRepositoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
tableLayoutPanel1.SuspendLayout();
|
tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
lblFileInfo = new System.Windows.Forms.Label();
|
||||||
|
imageList1 = new System.Windows.Forms.ImageList(components);
|
||||||
|
tlpWrapper.SuspendLayout();
|
||||||
tlpControls.SuspendLayout();
|
tlpControls.SuspendLayout();
|
||||||
tlpSearch.SuspendLayout();
|
tlpSearch.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pbxSearch).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pbxSearch).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
|
tableLayoutPanel2.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// tableLayoutPanel1
|
// tlpWrapper
|
||||||
//
|
//
|
||||||
tableLayoutPanel1.ColumnCount = 1;
|
tlpWrapper.ColumnCount = 1;
|
||||||
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
tlpWrapper.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
tableLayoutPanel1.Controls.Add(flpCars, 0, 2);
|
tlpWrapper.Controls.Add(flpCars, 0, 2);
|
||||||
tableLayoutPanel1.Controls.Add(tlpControls, 0, 1);
|
tlpWrapper.Controls.Add(tlpControls, 0, 1);
|
||||||
tableLayoutPanel1.Controls.Add(menuStrip1, 0, 0);
|
tlpWrapper.Controls.Add(menuStrip1, 0, 0);
|
||||||
tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
tlpWrapper.Controls.Add(tableLayoutPanel2, 0, 3);
|
||||||
tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
tlpWrapper.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
tlpWrapper.Location = new System.Drawing.Point(0, 0);
|
||||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
tlpWrapper.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
tableLayoutPanel1.RowCount = 3;
|
tlpWrapper.Name = "tlpWrapper";
|
||||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
tlpWrapper.RowCount = 4;
|
||||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
|
tlpWrapper.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
tlpWrapper.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
|
||||||
tableLayoutPanel1.Size = new System.Drawing.Size(902, 653);
|
tlpWrapper.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
tableLayoutPanel1.TabIndex = 0;
|
tlpWrapper.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
tableLayoutPanel1.Paint += tableLayoutPanel1_Paint;
|
tlpWrapper.Size = new System.Drawing.Size(902, 653);
|
||||||
|
tlpWrapper.TabIndex = 0;
|
||||||
|
tlpWrapper.Paint += tableLayoutPanel1_Paint;
|
||||||
//
|
//
|
||||||
// flpCars
|
// flpCars
|
||||||
//
|
//
|
||||||
@@ -91,7 +96,7 @@
|
|||||||
flpCars.Location = new System.Drawing.Point(3, 82);
|
flpCars.Location = new System.Drawing.Point(3, 82);
|
||||||
flpCars.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
flpCars.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
flpCars.Name = "flpCars";
|
flpCars.Name = "flpCars";
|
||||||
flpCars.Size = new System.Drawing.Size(896, 567);
|
flpCars.Size = new System.Drawing.Size(896, 541);
|
||||||
flpCars.TabIndex = 1;
|
flpCars.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// tlpControls
|
// tlpControls
|
||||||
@@ -292,14 +297,6 @@
|
|||||||
clearRecentFilesToolStripMenuItem.Text = "Clear recent files";
|
clearRecentFilesToolStripMenuItem.Text = "Clear recent files";
|
||||||
clearRecentFilesToolStripMenuItem.Click += clearRecentFilesToolStripMenuItem_Click;
|
clearRecentFilesToolStripMenuItem.Click += clearRecentFilesToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// imageList1
|
|
||||||
//
|
|
||||||
imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
|
||||||
imageList1.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageList1.ImageStream");
|
|
||||||
imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
|
||||||
imageList1.Images.SetKeyName(0, "Icon_Search.png");
|
|
||||||
imageList1.Images.SetKeyName(1, "Icon_Add.png");
|
|
||||||
//
|
|
||||||
// aboutToolStripMenuItem
|
// aboutToolStripMenuItem
|
||||||
//
|
//
|
||||||
aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { checkForUpdatesToolStripMenuItem, gitRepositoryToolStripMenuItem });
|
aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { checkForUpdatesToolStripMenuItem, gitRepositoryToolStripMenuItem });
|
||||||
@@ -310,23 +307,57 @@
|
|||||||
// checkForUpdatesToolStripMenuItem
|
// checkForUpdatesToolStripMenuItem
|
||||||
//
|
//
|
||||||
checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
|
checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
|
||||||
checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(213, 26);
|
||||||
checkForUpdatesToolStripMenuItem.Text = "Check for Updates";
|
checkForUpdatesToolStripMenuItem.Text = "Check for Updates";
|
||||||
checkForUpdatesToolStripMenuItem.Click += checkForUpdatesToolStripMenuItem_Click;
|
checkForUpdatesToolStripMenuItem.Click += checkForUpdatesToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// gitRepositoryToolStripMenuItem
|
// gitRepositoryToolStripMenuItem
|
||||||
//
|
//
|
||||||
gitRepositoryToolStripMenuItem.Name = "gitRepositoryToolStripMenuItem";
|
gitRepositoryToolStripMenuItem.Name = "gitRepositoryToolStripMenuItem";
|
||||||
gitRepositoryToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
gitRepositoryToolStripMenuItem.Size = new System.Drawing.Size(213, 26);
|
||||||
gitRepositoryToolStripMenuItem.Text = "Git Repository";
|
gitRepositoryToolStripMenuItem.Text = "Git Repository";
|
||||||
gitRepositoryToolStripMenuItem.Click += gitRepositoryToolStripMenuItem_Click;
|
gitRepositoryToolStripMenuItem.Click += gitRepositoryToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// tableLayoutPanel2
|
||||||
|
//
|
||||||
|
tableLayoutPanel2.AutoSize = true;
|
||||||
|
tableLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
|
tableLayoutPanel2.ColumnCount = 2;
|
||||||
|
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||||
|
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
tableLayoutPanel2.Controls.Add(lblFileInfo, 0, 0);
|
||||||
|
tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
tableLayoutPanel2.Location = new System.Drawing.Point(3, 630);
|
||||||
|
tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||||
|
tableLayoutPanel2.RowCount = 1;
|
||||||
|
tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
tableLayoutPanel2.Size = new System.Drawing.Size(896, 20);
|
||||||
|
tableLayoutPanel2.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// lblFileInfo
|
||||||
|
//
|
||||||
|
lblFileInfo.AutoSize = true;
|
||||||
|
lblFileInfo.ForeColor = System.Drawing.SystemColors.ActiveBorder;
|
||||||
|
lblFileInfo.Location = new System.Drawing.Point(3, 0);
|
||||||
|
lblFileInfo.Name = "lblFileInfo";
|
||||||
|
lblFileInfo.Size = new System.Drawing.Size(150, 20);
|
||||||
|
lblFileInfo.TabIndex = 0;
|
||||||
|
lblFileInfo.Text = "No File info available";
|
||||||
|
//
|
||||||
|
// imageList1
|
||||||
|
//
|
||||||
|
imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
||||||
|
imageList1.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("imageList1.ImageStream");
|
||||||
|
imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||||
|
imageList1.Images.SetKeyName(0, "Icon_Search.png");
|
||||||
|
imageList1.Images.SetKeyName(1, "Icon_Add.png");
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
ClientSize = new System.Drawing.Size(902, 653);
|
ClientSize = new System.Drawing.Size(902, 653);
|
||||||
Controls.Add(tableLayoutPanel1);
|
Controls.Add(tlpWrapper);
|
||||||
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||||||
MainMenuStrip = menuStrip1;
|
MainMenuStrip = menuStrip1;
|
||||||
Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
@@ -334,21 +365,23 @@
|
|||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
Text = "Carmanager 3";
|
Text = "Carmanager 3";
|
||||||
tableLayoutPanel1.ResumeLayout(false);
|
tlpWrapper.ResumeLayout(false);
|
||||||
tableLayoutPanel1.PerformLayout();
|
tlpWrapper.PerformLayout();
|
||||||
tlpControls.ResumeLayout(false);
|
tlpControls.ResumeLayout(false);
|
||||||
tlpSearch.ResumeLayout(false);
|
tlpSearch.ResumeLayout(false);
|
||||||
tlpSearch.PerformLayout();
|
tlpSearch.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pbxSearch).EndInit();
|
((System.ComponentModel.ISupportInitialize)pbxSearch).EndInit();
|
||||||
menuStrip1.ResumeLayout(false);
|
menuStrip1.ResumeLayout(false);
|
||||||
menuStrip1.PerformLayout();
|
menuStrip1.PerformLayout();
|
||||||
|
tableLayoutPanel2.ResumeLayout(false);
|
||||||
|
tableLayoutPanel2.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
private System.Windows.Forms.TableLayoutPanel tlpWrapper;
|
||||||
private System.Windows.Forms.FlowLayoutPanel flpCars;
|
private System.Windows.Forms.FlowLayoutPanel flpCars;
|
||||||
private System.Windows.Forms.TableLayoutPanel tlpControls;
|
private System.Windows.Forms.TableLayoutPanel tlpControls;
|
||||||
private System.Windows.Forms.TextBox tbxSearch;
|
private System.Windows.Forms.TextBox tbxSearch;
|
||||||
@@ -375,5 +408,7 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem gitRepositoryToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem gitRepositoryToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||||
|
private System.Windows.Forms.Label lblFileInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Data;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using CarManagerV3.Classes;
|
||||||
using CarManagerV3.Forms;
|
using CarManagerV3.Forms;
|
||||||
using CarManagerV3.Manager;
|
using CarManagerV3.Manager;
|
||||||
using CarManagerV3.Util;
|
using CarManagerV3.Util;
|
||||||
@@ -265,6 +266,16 @@ namespace CarManagerV3
|
|||||||
flpCars.Refresh();
|
flpCars.Refresh();
|
||||||
flpCars.Invalidate();
|
flpCars.Invalidate();
|
||||||
flpCars.Update();
|
flpCars.Update();
|
||||||
|
refreshMeta();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshMeta()
|
||||||
|
{
|
||||||
|
FileMeta meta = SafeManager.GetFileMeta(filepath);
|
||||||
|
string version = Updater.GetCurrentVersion(true);
|
||||||
|
lblFileInfo.Text = $"Car Manager 3 v.{version}, " + meta.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -377,6 +388,7 @@ namespace CarManagerV3
|
|||||||
refreshCars(cars);
|
refreshCars(cars);
|
||||||
SafeManager.SaveCars(filepath, cars);
|
SafeManager.SaveCars(filepath, cars);
|
||||||
MessageBox.Show("File saved successfully.", "Save File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("File saved successfully.", "Save File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
refreshMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -117,9 +117,6 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="btnNewCar.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="btnNewCar.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
@@ -142,6 +139,9 @@
|
|||||||
VXs21p8MAVc2KdQAvwAAAABJRU5ErkJggg==
|
VXs21p8MAVc2KdQAvwAAAABJRU5ErkJggg==
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>153, 17</value>
|
<value>153, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
@@ -150,15 +150,15 @@
|
|||||||
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||||
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||||
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAYAQAAAJNU0Z0AUkBTAIBAQIB
|
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAYAQAAAJNU0Z0AUkBTAIBAQIB
|
||||||
AAGYAQABmAEAARQBAAEUAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABUAMAARQDAAEBAQABIAYAARn/
|
AAGwAQABsAEAARQBAAEUAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABUAMAARQDAAEBAQABIAYAARn/
|
||||||
AP8AzAADCAEKAyMBMgMuAUYDFgEe/wAtAAMIAQoDIwEyAk8BTgGXAlYBVAGrAy4BRv8ALQADIwEyAk8B
|
AP8AzAADCAEKAyMBMgMuAUYDFgEe/wAtAAMIAQoDIwEyAk8BTgGXAlYBVAGrAy4BRv8ALQADIwEyAk8B
|
||||||
TgGXAf8BmQEzAf8DTgGWAyMBMiwAA10BzAT/9AADKAE8Ak8BTgGXAl8BWwHTA04BlgMjATIDCAEKLAAD
|
TgGXAf8BmQEzAf8DTgGWAyMBMiwAA10BzAT/9AADKAE8Ak8BTgGXAl8BWwHTA04BlgMjATIDCAEKLAAD
|
||||||
XQHMBP/UAAMDAQQDDwETA0QBewJPAU4BlwNNAZIDQAFuAwYBBwMpAT0DTgGYAlsBWQHAAk8BTgGXAyMB
|
XQHMBP/UAAMDAQQDDwETA0QBewJPAU4BlwNNAZIDQAFuAwYBBwMpAT0DTgGYAlsBWQHAAk8BTgGXAyMB
|
||||||
MgMIAQowAANdAcwE/9AAAxMBGgMxAU0DRAF5AlwBWQHBAmEBXQHPAl0BWwHKAlcBVQG0Az8BbQNSAaMC
|
MgMIAQowAANdAcwE/9AAAxMBGgMxAU0DRAF5AlwBWQHBAmEBXQHPAl0BWwHKAlcBVQG0Az8BbQNSAaMC
|
||||||
WwFZAcADTgGYAygBPDgAA10BzAT/zAADAwEEAzEBTQJZAVcBvAJgAV0BzgNLAYwDQAFvA0ABbwNLAYwC
|
WwFZAcADTgGYAygBPDgAA10BzAT/zAADAwEEAzEBTQJZAVcBvAJgAV0BzgNLAYwDQAFvA0ABbwNLAYwC
|
||||||
YAFdAc4BfAFtAVMB9AJTAVEBogMpAT08AANdAcwE/8wAAw8BEwNEAXkCYAFdAc4DBgEIBAIIAAQCAwYB
|
YAFdAc4BeAFoAVMB9AJTAVEBogMpAT08AANdAcwE/8wAAw8BEwNEAXkCYAFdAc4DBgEIBAIIAAQCAwYB
|
||||||
CAJgAV0BzgM+AWsDBAEFKAADXQHMLP+4AANEAXkDWgG/A0sBjAQCEAAEAgNLAYwCWgFYAbcDQQFxKAAD
|
CAJgAV0BzgM+AWsDBAEFKAADXQHMLP+4AANEAXkDWgG/A0sBjAQCEAAEAgNLAYwCWgFYAbcDQQFxKAAD
|
||||||
UgGjA10BzANdAcwDXQHMA10BzAOFAfUE/wNdAcwDXQHMA10BzANdAcwDXQHMuAACTwFOAZcCYAFdAc4D
|
UgGjA10BzANdAcwDXQHMA10BzAN/AfUE/wNdAcwDXQHMA10BzANdAcwDXQHMuAACTwFOAZcCYAFdAc4D
|
||||||
QAFvGAADQAFvAl8BXAHLA04BlDwAA10BzAT/zAACTwFOAZcCYAFdAc4DQAFvGAADQAFvAl4BWwHNA04B
|
QAFvGAADQAFvAl8BXAHLA04BlDwAA10BzAT/zAACTwFOAZcCYAFdAc4DQAFvGAADQAFvAl4BWwHNA04B
|
||||||
ljwAA10BzAT/zAADRAF6AlsBWQHAA0sBjAQCEAAEAgNLAYwCWgFYAb0CRAFDAXc8AANdAcwE/8wAAw4B
|
ljwAA10BzAT/zAADRAF6AlsBWQHAA0sBjAQCEAAEAgNLAYwCWgFYAb0CRAFDAXc8AANdAcwE/8wAAw4B
|
||||||
EgNEAXgCYAFdAc4DBgEIBAIIAAQCAwYBCAJgAV0BzgJDAUIBdQMMAQ88AANdAcwE/8wAAwMBBAMxAU0C
|
EgNEAXgCYAFdAc4DBgEIBAIIAAQCAwYBCAJgAV0BzgJDAUIBdQMMAQ88AANdAcwE/8wAAwMBBAMxAU0C
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using CarManagerV3.Classes;
|
||||||
|
using CarManagerV3.Manager;
|
||||||
|
|
||||||
|
|
||||||
namespace CarManagerV3
|
namespace CarManagerV3
|
||||||
@@ -95,6 +97,7 @@ namespace CarManagerV3
|
|||||||
{
|
{
|
||||||
List<Car> cars = new List<Car>();
|
List<Car> cars = new List<Car>();
|
||||||
List<string> failedLines = new List<string>();
|
List<string> failedLines = new List<string>();
|
||||||
|
FileMeta meta = null;
|
||||||
bool isLegacy = false;
|
bool isLegacy = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -103,6 +106,27 @@ namespace CarManagerV3
|
|||||||
string line;
|
string line;
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
|
if (FileMeta.IsFileMeta(line))
|
||||||
|
{
|
||||||
|
meta = FileMeta.FromCSV(line);
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
if (FileMeta.NeedsUpdate(meta))
|
||||||
|
{
|
||||||
|
if (!StateManager.askForMigration(meta))
|
||||||
|
{
|
||||||
|
MessageBox.Show($"The file you are trying to open is from an older version that is no longer supported. Please select a different file.\nRunning:{Updater.GetCurrentVersion()}, File:{meta.Version}", "Unsupported Version", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
throw new LegacyException();
|
||||||
|
//Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isLegacy = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Process the line
|
// Process the line
|
||||||
if (line == "") continue;
|
if (line == "") continue;
|
||||||
if (Car.isLegacyCsvString(line))
|
if (Car.isLegacyCsvString(line))
|
||||||
@@ -116,8 +140,10 @@ namespace CarManagerV3
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
isLegacy = true;
|
isLegacy = true;
|
||||||
|
line = FileUpdate.PerformOldLegacyUpdate(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isLegacy && meta != null) line = FileUpdate.ApplyUpdates(line, meta.Version);
|
||||||
Car tmp = Car.FromCsvString(line);
|
Car tmp = Car.FromCsvString(line);
|
||||||
if (tmp == null)
|
if (tmp == null)
|
||||||
{
|
{
|
||||||
@@ -166,6 +192,8 @@ namespace CarManagerV3
|
|||||||
{
|
{
|
||||||
using (StreamWriter writer = new StreamWriter(@path))
|
using (StreamWriter writer = new StreamWriter(@path))
|
||||||
{
|
{
|
||||||
|
FileMeta meta = FileMeta.Generate();
|
||||||
|
writer.WriteLine(meta.ToCSV());
|
||||||
foreach (Car car in cars)
|
foreach (Car car in cars)
|
||||||
{
|
{
|
||||||
writer.WriteLine(car.ToCsvString());
|
writer.WriteLine(car.ToCsvString());
|
||||||
@@ -285,5 +313,31 @@ namespace CarManagerV3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static FileMeta GetFileMeta(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(@path))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (FileMeta.IsFileMeta(line))
|
||||||
|
{
|
||||||
|
reader.Close();
|
||||||
|
return FileMeta.FromCSV(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Error getting file meta: {ex.Message}");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using CarManagerV3.Classes;
|
||||||
|
using CarManagerV3.Manager;
|
||||||
|
|
||||||
namespace CarManagerV3
|
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.
|
/// This is to prevent multiple annoying popups if the user tries to open multiple files that require migration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if the user has accepted to migrate the file, otherwise False</returns>
|
/// <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)
|
if (hasConfirmedMigration)
|
||||||
{
|
{
|
||||||
return true;
|
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;
|
hasConfirmedMigration = result == DialogResult.Yes;
|
||||||
return hasConfirmedMigration;
|
return hasConfirmedMigration;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user