Initial commit
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
public class Car
|
public class Car
|
||||||
{
|
{
|
||||||
|
|||||||
2
CarManagerV2/CarCard.Designer.cs
generated
2
CarManagerV2/CarCard.Designer.cs
generated
@@ -1,4 +1,4 @@
|
|||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
partial class CarCard
|
partial class CarCard
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
public partial class CarCard : UserControl
|
public partial class CarCard : UserControl
|
||||||
{
|
{
|
||||||
|
|||||||
2
CarManagerV2/CarDetailsForm.Designer.cs
generated
2
CarManagerV2/CarDetailsForm.Designer.cs
generated
@@ -1,4 +1,4 @@
|
|||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
partial class CarDetailsForm
|
partial class CarDetailsForm
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
public partial class CarDetailsForm : Form
|
public partial class CarDetailsForm : Form
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
internal class ImageManager
|
internal class ImageManager
|
||||||
{
|
{
|
||||||
|
|||||||
115
CarManagerV2/MainForm.Designer.cs
generated
115
CarManagerV2/MainForm.Designer.cs
generated
@@ -1,4 +1,4 @@
|
|||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
partial class MainForm
|
partial class MainForm
|
||||||
{
|
{
|
||||||
@@ -34,33 +34,45 @@
|
|||||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
this.tbxSearch = new System.Windows.Forms.TextBox();
|
this.tbxSearch = new System.Windows.Forms.TextBox();
|
||||||
this.btnNewCar = new System.Windows.Forms.Button();
|
this.btnNewCar = new System.Windows.Forms.Button();
|
||||||
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.recentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.revealInFileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.tableLayoutPanel1.SuspendLayout();
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
this.tableLayoutPanel2.SuspendLayout();
|
this.tableLayoutPanel2.SuspendLayout();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// tableLayoutPanel1
|
// tableLayoutPanel1
|
||||||
//
|
//
|
||||||
this.tableLayoutPanel1.ColumnCount = 1;
|
this.tableLayoutPanel1.ColumnCount = 1;
|
||||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel1.Controls.Add(this.flpCars, 0, 1);
|
this.tableLayoutPanel1.Controls.Add(this.flpCars, 0, 2);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
|
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.menuStrip1, 0, 0);
|
||||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
this.tableLayoutPanel1.RowCount = 2;
|
this.tableLayoutPanel1.RowCount = 3;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(800, 450);
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(802, 458);
|
||||||
this.tableLayoutPanel1.TabIndex = 0;
|
this.tableLayoutPanel1.TabIndex = 0;
|
||||||
|
this.tableLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel1_Paint);
|
||||||
//
|
//
|
||||||
// flpCars
|
// flpCars
|
||||||
//
|
//
|
||||||
this.flpCars.AutoScroll = true;
|
this.flpCars.AutoScroll = true;
|
||||||
this.flpCars.AutoScrollMargin = new System.Drawing.Size(0, 200);
|
this.flpCars.AutoScrollMargin = new System.Drawing.Size(0, 200);
|
||||||
this.flpCars.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.flpCars.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.flpCars.Location = new System.Drawing.Point(3, 43);
|
this.flpCars.Location = new System.Drawing.Point(3, 67);
|
||||||
this.flpCars.Name = "flpCars";
|
this.flpCars.Name = "flpCars";
|
||||||
this.flpCars.Size = new System.Drawing.Size(794, 404);
|
this.flpCars.Size = new System.Drawing.Size(796, 412);
|
||||||
this.flpCars.TabIndex = 1;
|
this.flpCars.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// tableLayoutPanel2
|
// tableLayoutPanel2
|
||||||
@@ -71,12 +83,12 @@
|
|||||||
this.tableLayoutPanel2.Controls.Add(this.tbxSearch, 0, 0);
|
this.tableLayoutPanel2.Controls.Add(this.tbxSearch, 0, 0);
|
||||||
this.tableLayoutPanel2.Controls.Add(this.btnNewCar, 1, 0);
|
this.tableLayoutPanel2.Controls.Add(this.btnNewCar, 1, 0);
|
||||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
|
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 27);
|
||||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||||
this.tableLayoutPanel2.RowCount = 1;
|
this.tableLayoutPanel2.RowCount = 1;
|
||||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F));
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F));
|
||||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(794, 34);
|
this.tableLayoutPanel2.Size = new System.Drawing.Size(796, 34);
|
||||||
this.tableLayoutPanel2.TabIndex = 2;
|
this.tableLayoutPanel2.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// tbxSearch
|
// tbxSearch
|
||||||
@@ -84,13 +96,13 @@
|
|||||||
this.tbxSearch.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tbxSearch.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tbxSearch.Location = new System.Drawing.Point(3, 3);
|
this.tbxSearch.Location = new System.Drawing.Point(3, 3);
|
||||||
this.tbxSearch.Name = "tbxSearch";
|
this.tbxSearch.Name = "tbxSearch";
|
||||||
this.tbxSearch.Size = new System.Drawing.Size(391, 22);
|
this.tbxSearch.Size = new System.Drawing.Size(392, 22);
|
||||||
this.tbxSearch.TabIndex = 3;
|
this.tbxSearch.TabIndex = 3;
|
||||||
this.tbxSearch.TextChanged += new System.EventHandler(this.tbxSearch_TextChanged);
|
this.tbxSearch.TextChanged += new System.EventHandler(this.tbxSearch_TextChanged);
|
||||||
//
|
//
|
||||||
// btnNewCar
|
// btnNewCar
|
||||||
//
|
//
|
||||||
this.btnNewCar.Location = new System.Drawing.Point(400, 3);
|
this.btnNewCar.Location = new System.Drawing.Point(401, 3);
|
||||||
this.btnNewCar.Name = "btnNewCar";
|
this.btnNewCar.Name = "btnNewCar";
|
||||||
this.btnNewCar.Size = new System.Drawing.Size(75, 23);
|
this.btnNewCar.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnNewCar.TabIndex = 4;
|
this.btnNewCar.TabIndex = 4;
|
||||||
@@ -98,19 +110,88 @@
|
|||||||
this.btnNewCar.UseVisualStyleBackColor = true;
|
this.btnNewCar.UseVisualStyleBackColor = true;
|
||||||
this.btnNewCar.Click += new System.EventHandler(this.btnNewCar_Click);
|
this.btnNewCar.Click += new System.EventHandler(this.btnNewCar_Click);
|
||||||
//
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.fileToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(802, 24);
|
||||||
|
this.menuStrip1.TabIndex = 3;
|
||||||
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// fileToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.openToolStripMenuItem,
|
||||||
|
this.saveToolStripMenuItem,
|
||||||
|
this.saveAsToolStripMenuItem,
|
||||||
|
this.importToolStripMenuItem,
|
||||||
|
this.recentFilesToolStripMenuItem,
|
||||||
|
this.revealInFileExplorerToolStripMenuItem});
|
||||||
|
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||||
|
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||||
|
this.fileToolStripMenuItem.Text = "File";
|
||||||
|
//
|
||||||
|
// openToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||||
|
this.openToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.openToolStripMenuItem.Text = "Open";
|
||||||
|
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// saveToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
|
this.saveToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.saveToolStripMenuItem.Text = "Save";
|
||||||
|
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// saveAsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||||
|
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.saveAsToolStripMenuItem.Text = "Save as";
|
||||||
|
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// importToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
|
||||||
|
this.importToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.importToolStripMenuItem.Text = "Import";
|
||||||
|
this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// recentFilesToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.recentFilesToolStripMenuItem.Name = "recentFilesToolStripMenuItem";
|
||||||
|
this.recentFilesToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.recentFilesToolStripMenuItem.Text = "Recent Files";
|
||||||
|
this.recentFilesToolStripMenuItem.Click += new System.EventHandler(this.recentFilesToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// revealInFileExplorerToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.revealInFileExplorerToolStripMenuItem.Name = "revealInFileExplorerToolStripMenuItem";
|
||||||
|
this.revealInFileExplorerToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||||
|
this.revealInFileExplorerToolStripMenuItem.Text = "Reveal in File Explorer";
|
||||||
|
this.revealInFileExplorerToolStripMenuItem.Click += new System.EventHandler(this.revealInFileExplorerToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(802, 458);
|
||||||
this.Controls.Add(this.tableLayoutPanel1);
|
this.Controls.Add(this.tableLayoutPanel1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
this.MinimumSize = new System.Drawing.Size(818, 497);
|
this.MinimumSize = new System.Drawing.Size(818, 497);
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.Text = "Carmanager 2";
|
this.Text = "Carmanager 3";
|
||||||
this.tableLayoutPanel1.ResumeLayout(false);
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.PerformLayout();
|
||||||
this.tableLayoutPanel2.ResumeLayout(false);
|
this.tableLayoutPanel2.ResumeLayout(false);
|
||||||
this.tableLayoutPanel2.PerformLayout();
|
this.tableLayoutPanel2.PerformLayout();
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -122,5 +203,13 @@
|
|||||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||||
private System.Windows.Forms.TextBox tbxSearch;
|
private System.Windows.Forms.TextBox tbxSearch;
|
||||||
private System.Windows.Forms.Button btnNewCar;
|
private System.Windows.Forms.Button btnNewCar;
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem recentFilesToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem revealInFileExplorerToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,25 +8,36 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
List<Car> cars = new List<Car>();
|
List<Car> cars = new List<Car>();
|
||||||
|
string filepath = "cars.csv";
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SafeManager.InitializeFile("cars.csv");
|
|
||||||
List<Car> _cars = SafeManager.ReadCars("cars.csv");
|
List<string> recentFiles = SafeManager.GetRecentPaths();
|
||||||
|
if(recentFiles.Count > 0)
|
||||||
|
{
|
||||||
|
filepath = recentFiles[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
SafeManager.InitializeFile(filepath);
|
||||||
|
List<Car> _cars = SafeManager.ReadCars(filepath);
|
||||||
|
|
||||||
refreshCars(_cars);
|
refreshCars(_cars);
|
||||||
|
refreshRecents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void refreshCars(List<Car> _cars, bool updateGlobal = true)
|
private async void refreshCars(List<Car> _cars, bool updateGlobal = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
this.Text = "Car Manager - " + System.IO.Path.GetFileName(filepath);
|
||||||
|
|
||||||
// Sort by Car.Order. If equal, sort by ID
|
// Sort by Car.Order. If equal, sort by ID
|
||||||
_cars = _cars.Count > 0 ? _cars.OrderBy(c => c.Order).ThenBy(c => c.Id).ToList() : _cars;
|
_cars = _cars.Count > 0 ? _cars.OrderBy(c => c.Order).ThenBy(c => c.Id).ToList() : _cars;
|
||||||
|
|
||||||
@@ -83,7 +94,7 @@ namespace CarManagerV2
|
|||||||
Console.WriteLine("Car details form closed.");
|
Console.WriteLine("Car details form closed.");
|
||||||
// refresh cars
|
// refresh cars
|
||||||
Console.WriteLine("Refreshing cars...");
|
Console.WriteLine("Refreshing cars...");
|
||||||
List<Car> __cars = await Task.Run(() => SafeManager.ReadCars("cars.csv"));
|
List<Car> __cars = await Task.Run(() => SafeManager.ReadCars(filepath));
|
||||||
if (tbxSearch.Text.Length > 0)
|
if (tbxSearch.Text.Length > 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Search box has text, applying search filter.");
|
Console.WriteLine("Search box has text, applying search filter.");
|
||||||
@@ -126,7 +137,7 @@ namespace CarManagerV2
|
|||||||
{
|
{
|
||||||
// refresh cars
|
// refresh cars
|
||||||
Console.WriteLine("Refreshing cars...");
|
Console.WriteLine("Refreshing cars...");
|
||||||
List<Car> cars_ = SafeManager.ReadCars("cars.csv");
|
List<Car> cars_ = SafeManager.ReadCars(filepath);
|
||||||
refreshCars(cars_, false);
|
refreshCars(cars_, false);
|
||||||
};
|
};
|
||||||
detailsForm.ShowDialog();
|
detailsForm.ShowDialog();
|
||||||
@@ -166,5 +177,207 @@ namespace CarManagerV2
|
|||||||
searchList(query);
|
searchList(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog dlgOpen = new OpenFileDialog();
|
||||||
|
dlgOpen.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
|
||||||
|
dlgOpen.Title = "Open Car Data File";
|
||||||
|
// Default to users documents
|
||||||
|
dlgOpen.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||||
|
|
||||||
|
DialogResult result = dlgOpen.ShowDialog();
|
||||||
|
if (result == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Car> importedCars = SafeManager.ReadCars(dlgOpen.FileName);
|
||||||
|
if(importedCars.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("File doesn't contain valid Cars.");
|
||||||
|
}
|
||||||
|
filepath = dlgOpen.FileName;
|
||||||
|
|
||||||
|
cars = importedCars;
|
||||||
|
StateManager.setFilePath(filepath);
|
||||||
|
// Refresh display
|
||||||
|
refreshCars(cars);
|
||||||
|
MessageBox.Show("File loaded successfully.", "Load File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
SafeManager.AddRecentPath(filepath);
|
||||||
|
refreshRecents();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error loading file: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
refreshCars(cars);
|
||||||
|
SafeManager.SaveCars(filepath, cars);
|
||||||
|
MessageBox.Show("File saved successfully.", "Save File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog dlgSave = new SaveFileDialog();
|
||||||
|
dlgSave.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
|
||||||
|
dlgSave.Title = "Save Car Data File As";
|
||||||
|
// Default to users documents
|
||||||
|
dlgSave.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||||
|
DialogResult result = dlgSave.ShowDialog();
|
||||||
|
|
||||||
|
if (result == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// does file already exist?
|
||||||
|
/*if (System.IO.File.Exists(dlgSave.FileName))
|
||||||
|
{
|
||||||
|
var overwriteResult = MessageBox.Show("File already exists. Overwrite?", "Overwrite File", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||||
|
if (overwriteResult != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
// Windows already handles this lmao
|
||||||
|
filepath = dlgSave.FileName;
|
||||||
|
this.Text = "Car Manager - " + System.IO.Path.GetFileName(filepath);
|
||||||
|
StateManager.setFilePath(filepath);
|
||||||
|
SafeManager.SaveCars(filepath, cars);
|
||||||
|
SafeManager.AddRecentPath(filepath);
|
||||||
|
}
|
||||||
|
refreshRecents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("Importing will add cars from another file to this file. This action cannot be undone. Continue?", "Import Cars", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||||
|
if (result == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
OpenFileDialog dlgOpen = new OpenFileDialog();
|
||||||
|
dlgOpen.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
|
||||||
|
dlgOpen.Title = "Import Car Data File";
|
||||||
|
// Default to users documents
|
||||||
|
dlgOpen.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||||
|
DialogResult dlgResult = dlgOpen.ShowDialog();
|
||||||
|
if (dlgResult == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Starting merge...");
|
||||||
|
List<Car> importedCars = SafeManager.ReadCars(dlgOpen.FileName);
|
||||||
|
if(importedCars.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("File doesn't contain valid Cars.");
|
||||||
|
}
|
||||||
|
// merge cars
|
||||||
|
foreach (Car car in importedCars)
|
||||||
|
{
|
||||||
|
// check if car with same ID exists
|
||||||
|
if (cars.Any(c => c.Id == car.Id))
|
||||||
|
{
|
||||||
|
// assign new ID
|
||||||
|
int newId = cars.Count > 0 ? cars.Max(c => c.Id) + 1 : 1;
|
||||||
|
car.Id = newId;
|
||||||
|
}
|
||||||
|
cars.Add(car);
|
||||||
|
}
|
||||||
|
DialogResult mergeAsNewFileResult = MessageBox.Show("Do you want to save the merged cars as a new file?", "Save As New File", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
|
if (mergeAsNewFileResult == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
SaveFileDialog dlgSave = new SaveFileDialog();
|
||||||
|
dlgSave.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
|
||||||
|
dlgSave.Title = "Save Merged Car Data File As";
|
||||||
|
// Default to users documents
|
||||||
|
dlgSave.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||||
|
DialogResult saveResult = dlgSave.ShowDialog();
|
||||||
|
if (saveResult == DialogResult.OK)
|
||||||
|
{
|
||||||
|
filepath = dlgSave.FileName;
|
||||||
|
StateManager.setFilePath(filepath);
|
||||||
|
SafeManager.SaveCars(filepath, cars);
|
||||||
|
SafeManager.AddRecentPath(filepath);
|
||||||
|
refreshRecents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// save to current file
|
||||||
|
SafeManager.SaveCars(filepath, cars);
|
||||||
|
}
|
||||||
|
// Refresh display
|
||||||
|
refreshCars(cars);
|
||||||
|
MessageBox.Show("File imported successfully.", "Import File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error importing file: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Import cancelled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recentFilesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshRecents()
|
||||||
|
{
|
||||||
|
recentFilesToolStripMenuItem.DropDownItems.Clear();
|
||||||
|
List<string> recentFiles = SafeManager.GetRecentPaths();
|
||||||
|
recentFilesToolStripMenuItem.Enabled = recentFiles.Count > 0;
|
||||||
|
recentFilesToolStripMenuItem.ToolTipText = recentFiles.Count > 0 ? "" : "No recent files.";
|
||||||
|
foreach (string path in recentFiles)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem item = new ToolStripMenuItem(path);
|
||||||
|
item.Click += (s, e2) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Car> importedCars = SafeManager.ReadCars(path);
|
||||||
|
if(importedCars.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("File doesn't contain valid Cars.");
|
||||||
|
}
|
||||||
|
filepath = path;
|
||||||
|
cars = importedCars;
|
||||||
|
StateManager.setFilePath(filepath);
|
||||||
|
// Refresh display
|
||||||
|
refreshCars(cars);
|
||||||
|
MessageBox.Show("File loaded successfully.", "Load File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error loading file: " + ex.Message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
recentFilesToolStripMenuItem.DropDownItems.Add(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revealInFileExplorerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Open File Explorer at the location of the current filepath
|
||||||
|
if (System.IO.File.Exists(filepath))
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process.Start("explorer.exe", "/select,\"" + filepath + "\"");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("File does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,9 @@
|
|||||||
<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="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|||||||
2
CarManagerV2/PleaseWait.Designer.cs
generated
2
CarManagerV2/PleaseWait.Designer.cs
generated
@@ -1,4 +1,4 @@
|
|||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
partial class PleaseWait
|
partial class PleaseWait
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
public partial class PleaseWait : Form
|
public partial class PleaseWait : Form
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("CarManagerV2")]
|
[assembly: AssemblyTitle("CarManagerV3")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("CarManagerV2")]
|
[assembly: AssemblyProduct("CarManagerV3")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
internal class SafeManager
|
internal class SafeManager
|
||||||
{
|
{
|
||||||
|
private static readonly string recentPathsFile = "recent_paths.txt";
|
||||||
|
|
||||||
public static void InitializeFile(string path)
|
public static void InitializeFile(string path)
|
||||||
{
|
{
|
||||||
if (!File.Exists(@path))
|
if (!File.Exists(@path))
|
||||||
@@ -48,5 +50,54 @@ namespace CarManagerV2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddRecentPath(string path)
|
||||||
|
{
|
||||||
|
// Read the file, if the path is not already in the file, add it to the top.
|
||||||
|
// If it is already in the file, move it to the top.
|
||||||
|
// Keep only the 5 most recent paths.
|
||||||
|
List<string> paths = new List<string>();
|
||||||
|
if (File.Exists(recentPathsFile))
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(recentPathsFile))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
paths.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paths.Remove(path);
|
||||||
|
paths.Insert(0, path);
|
||||||
|
if (paths.Count > 5)
|
||||||
|
{
|
||||||
|
paths = paths.Take(5).ToList();
|
||||||
|
}
|
||||||
|
using (StreamWriter writer = new StreamWriter(recentPathsFile))
|
||||||
|
{
|
||||||
|
foreach (string p in paths)
|
||||||
|
{
|
||||||
|
writer.WriteLine(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> GetRecentPaths()
|
||||||
|
{
|
||||||
|
List<string> paths = new List<string>();
|
||||||
|
if (File.Exists(recentPathsFile))
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(recentPathsFile))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
paths.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,17 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CarManagerV2
|
namespace CarManagerV3
|
||||||
{
|
{
|
||||||
internal class StateManager
|
internal class StateManager
|
||||||
{
|
{
|
||||||
|
|
||||||
static List<Car> cars = new List<Car>();
|
static List<Car> cars = new List<Car>();
|
||||||
|
static string filePath = "cars.csv";
|
||||||
|
|
||||||
public static Car GetCarById(int id)
|
public static Car GetCarById(int id)
|
||||||
{
|
{
|
||||||
cars = SafeManager.ReadCars("cars.csv");
|
cars = SafeManager.ReadCars(filePath);
|
||||||
return cars.FirstOrDefault(c => c.Id == id);
|
return cars.FirstOrDefault(c => c.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,18 +22,18 @@ namespace CarManagerV2
|
|||||||
|
|
||||||
public static void AddCar(Car car)
|
public static void AddCar(Car car)
|
||||||
{
|
{
|
||||||
cars = SafeManager.ReadCars("cars.csv");
|
cars = SafeManager.ReadCars(filePath);
|
||||||
cars.Add(car);
|
cars.Add(car);
|
||||||
SafeManager.SaveCars("cars.csv", cars);
|
SafeManager.SaveCars(filePath, cars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveCar(Car car)
|
public static void RemoveCar(Car car)
|
||||||
{
|
{
|
||||||
cars = SafeManager.ReadCars("cars.csv");
|
cars = SafeManager.ReadCars(filePath);
|
||||||
Car existingCar = GetCarById(car.Id);
|
Car existingCar = GetCarById(car.Id);
|
||||||
if (existingCar == null) return;
|
if (existingCar == null) return;
|
||||||
cars.Remove(existingCar);
|
cars.Remove(existingCar);
|
||||||
SafeManager.SaveCars("cars.csv", cars);
|
SafeManager.SaveCars(filePath, cars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateCar(Car car)
|
public static void UpdateCar(Car car)
|
||||||
@@ -43,17 +44,22 @@ namespace CarManagerV2
|
|||||||
int index = cars.IndexOf(existingCar);
|
int index = cars.IndexOf(existingCar);
|
||||||
cars[index] = car;
|
cars[index] = car;
|
||||||
Console.WriteLine("Updated car: " + existingCar.Id);
|
Console.WriteLine("Updated car: " + existingCar.Id);
|
||||||
SafeManager.SaveCars("cars.csv", cars);
|
SafeManager.SaveCars(filePath, cars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Car CreateCar(string make, string model, int year, string color, int mileage, decimal price)
|
public static Car CreateCar(string make, string model, int year, string color, int mileage, decimal price)
|
||||||
{
|
{
|
||||||
cars = SafeManager.ReadCars("cars.csv");
|
cars = SafeManager.ReadCars(filePath);
|
||||||
int newId = cars.Count > 0 ? cars.Max(c => c.Id) + 1 : 1;
|
int newId = cars.Count > 0 ? cars.Max(c => c.Id) + 1 : 1;
|
||||||
Car newCar = new Car(newId, make, model, year, color, mileage, price);
|
Car newCar = new Car(newId, make, model, year, color, mileage, price);
|
||||||
AddCar(newCar);
|
AddCar(newCar);
|
||||||
return newCar;
|
return newCar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setFilePath(string path)
|
||||||
|
{
|
||||||
|
filePath = path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.14.36414.22 d17.14
|
VisualStudioVersion = 17.14.36414.22
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarManagerV2", "CarManagerV2\CarManagerV2.csproj", "{93CA258B-A645-41A8-A24F-59036ABC173F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarManagerV3", "CarManagerV2\CarManagerV3.csproj", "{93CA258B-A645-41A8-A24F-59036ABC173F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
BIN
IAF42_Kaulmann_CarmanagerV2old.zip
Normal file
BIN
IAF42_Kaulmann_CarmanagerV2old.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user