Add project files.
This commit is contained in:
25
CarManagerV2.sln
Normal file
25
CarManagerV2.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36414.22 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarManagerV2", "CarManagerV2\CarManagerV2.csproj", "{93CA258B-A645-41A8-A24F-59036ABC173F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {017AFAA8-0048-47CA-9F97-98C532E2D820}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
CarManagerV2/App.config
Normal file
6
CarManagerV2/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
56
CarManagerV2/Car.cs
Normal file
56
CarManagerV2/Car.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
public class Car
|
||||
{
|
||||
int id;
|
||||
string make;
|
||||
string model;
|
||||
int year;
|
||||
string color;
|
||||
int mileage;
|
||||
decimal price;
|
||||
|
||||
public Car(int id, string make, string model, int year, string color, int mileage, decimal price)
|
||||
{
|
||||
this.make = make;
|
||||
this.model = model;
|
||||
this.year = year;
|
||||
this.color = color;
|
||||
this.mileage = mileage;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int Id { get { return id; } set { id = value; } }
|
||||
public string Make { get { return make; } set { make = value; } }
|
||||
public string Model { get { return model; } set { model = value; } }
|
||||
public int Year { get { return year; } set { year = value; } }
|
||||
public string Color { get { return color; } set { color = value; } }
|
||||
public int Mileage { get { return mileage; } set { mileage = value; } }
|
||||
public decimal Price { get { return price; } set { price = value; } }
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{make} {model} ({year})";
|
||||
}
|
||||
|
||||
public string toCsvString()
|
||||
{
|
||||
return $"{id};{make};{model};{year};{color};{mileage};{price}";
|
||||
}
|
||||
|
||||
public static Car fromCsvString(string csv)
|
||||
{
|
||||
Console.WriteLine(csv);
|
||||
string[] parts = csv.Split(';');
|
||||
Console.WriteLine(parts.Length);
|
||||
return new Car(int.Parse(parts[0]), parts[1], parts[2], int.Parse(parts[3]), parts[4], int.Parse(parts[5]), decimal.Parse(parts[6]));
|
||||
}
|
||||
}
|
||||
}
|
||||
94
CarManagerV2/CarCard.Designer.cs
generated
Normal file
94
CarManagerV2/CarCard.Designer.cs
generated
Normal file
@@ -0,0 +1,94 @@
|
||||
namespace CarManagerV2
|
||||
{
|
||||
partial class CarCard
|
||||
{
|
||||
/// <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 Component 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(CarCard));
|
||||
this.pbxCar = new System.Windows.Forms.PictureBox();
|
||||
this.lblCarName = new System.Windows.Forms.Label();
|
||||
this.lblCarDetails = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCar)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pbxCar
|
||||
//
|
||||
this.pbxCar.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pbxCar.Image = ((System.Drawing.Image)(resources.GetObject("pbxCar.Image")));
|
||||
this.pbxCar.ImageLocation = "";
|
||||
this.pbxCar.Location = new System.Drawing.Point(3, 3);
|
||||
this.pbxCar.Name = "pbxCar";
|
||||
this.pbxCar.Size = new System.Drawing.Size(204, 130);
|
||||
this.pbxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pbxCar.TabIndex = 0;
|
||||
this.pbxCar.TabStop = false;
|
||||
//
|
||||
// lblCarName
|
||||
//
|
||||
this.lblCarName.AutoSize = true;
|
||||
this.lblCarName.Font = new System.Drawing.Font("Arial", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblCarName.Location = new System.Drawing.Point(3, 136);
|
||||
this.lblCarName.Name = "lblCarName";
|
||||
this.lblCarName.Size = new System.Drawing.Size(148, 27);
|
||||
this.lblCarName.TabIndex = 1;
|
||||
this.lblCarName.Text = "Skoda Fabia";
|
||||
//
|
||||
// lblCarDetails
|
||||
//
|
||||
this.lblCarDetails.AutoSize = true;
|
||||
this.lblCarDetails.Location = new System.Drawing.Point(5, 163);
|
||||
this.lblCarDetails.Name = "lblCarDetails";
|
||||
this.lblCarDetails.Size = new System.Drawing.Size(101, 16);
|
||||
this.lblCarDetails.TabIndex = 2;
|
||||
this.lblCarDetails.Text = "2009 - 13.000km";
|
||||
//
|
||||
// CarCard
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.Controls.Add(this.lblCarDetails);
|
||||
this.Controls.Add(this.lblCarName);
|
||||
this.Controls.Add(this.pbxCar);
|
||||
this.Name = "CarCard";
|
||||
this.Size = new System.Drawing.Size(210, 192);
|
||||
this.Load += new System.EventHandler(this.CarCard_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCar)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pbxCar;
|
||||
private System.Windows.Forms.Label lblCarName;
|
||||
private System.Windows.Forms.Label lblCarDetails;
|
||||
}
|
||||
}
|
||||
53
CarManagerV2/CarCard.cs
Normal file
53
CarManagerV2/CarCard.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
public partial class CarCard : UserControl
|
||||
{
|
||||
public string CarName
|
||||
{
|
||||
get { return lblCarName.Text; }
|
||||
set { lblCarName.Text = value; }
|
||||
}
|
||||
public string CarDetails
|
||||
{
|
||||
get { return lblCarDetails.Text; }
|
||||
set { lblCarDetails.Text = value; }
|
||||
}
|
||||
|
||||
public Image CarImage
|
||||
{
|
||||
get { return pbxCar.Image; }
|
||||
set { pbxCar.Image = value; }
|
||||
}
|
||||
|
||||
public CarCard()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Cursor = Cursors.Hand;
|
||||
this.Click += (s, e) => this.OnCardClicked();
|
||||
}
|
||||
|
||||
public event EventHandler CardClicked;
|
||||
private void OnCardClicked()
|
||||
{
|
||||
if (this.CardClicked != null)
|
||||
{
|
||||
this.CardClicked(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void CarCard_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
8548
CarManagerV2/CarCard.resx
Normal file
8548
CarManagerV2/CarCard.resx
Normal file
File diff suppressed because it is too large
Load Diff
318
CarManagerV2/CarDetailsForm.Designer.cs
generated
Normal file
318
CarManagerV2/CarDetailsForm.Designer.cs
generated
Normal file
@@ -0,0 +1,318 @@
|
||||
namespace CarManagerV2
|
||||
{
|
||||
partial class CarDetailsForm
|
||||
{
|
||||
/// <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(CarDetailsForm));
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.pbxCarImage = new System.Windows.Forms.PictureBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tbxMake = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.tbxModel = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.btnDelete = new System.Windows.Forms.Button();
|
||||
this.nudYear = new System.Windows.Forms.NumericUpDown();
|
||||
this.tbxColor = new System.Windows.Forms.TextBox();
|
||||
this.nudMileage = new System.Windows.Forms.NumericUpDown();
|
||||
this.nudPrice = new System.Windows.Forms.NumericUpDown();
|
||||
this.lblID = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCarImage)).BeginInit();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudYear)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudMileage)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudPrice)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.AutoSize = true;
|
||||
this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.Controls.Add(this.pbxCarImage, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tbxMake, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tbxModel, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label4, 0, 4);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label5, 0, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label6, 0, 6);
|
||||
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 7);
|
||||
this.tableLayoutPanel1.Controls.Add(this.nudYear, 1, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tbxColor, 1, 4);
|
||||
this.tableLayoutPanel1.Controls.Add(this.nudMileage, 1, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.nudPrice, 1, 6);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 8;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 200F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(536, 450);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// pbxCarImage
|
||||
//
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.pbxCarImage, 2);
|
||||
this.pbxCarImage.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pbxCarImage.Image = ((System.Drawing.Image)(resources.GetObject("pbxCarImage.Image")));
|
||||
this.pbxCarImage.Location = new System.Drawing.Point(3, 3);
|
||||
this.pbxCarImage.Name = "pbxCarImage";
|
||||
this.pbxCarImage.Size = new System.Drawing.Size(538, 194);
|
||||
this.pbxCarImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pbxCarImage.TabIndex = 0;
|
||||
this.pbxCarImage.TabStop = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(3, 200);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(44, 16);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Make:";
|
||||
//
|
||||
// tbxMake
|
||||
//
|
||||
this.tbxMake.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tbxMake.Location = new System.Drawing.Point(68, 203);
|
||||
this.tbxMake.Name = "tbxMake";
|
||||
this.tbxMake.Size = new System.Drawing.Size(473, 22);
|
||||
this.tbxMake.TabIndex = 2;
|
||||
this.tbxMake.TextChanged += new System.EventHandler(this.tbxMake_TextChanged);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(3, 230);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(48, 16);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Model:";
|
||||
//
|
||||
// tbxModel
|
||||
//
|
||||
this.tbxModel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tbxModel.Location = new System.Drawing.Point(68, 233);
|
||||
this.tbxModel.Name = "tbxModel";
|
||||
this.tbxModel.Size = new System.Drawing.Size(473, 22);
|
||||
this.tbxModel.TabIndex = 4;
|
||||
this.tbxModel.TextChanged += new System.EventHandler(this.tbxModel_TextChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(3, 260);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(39, 16);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Year:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(3, 290);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(42, 16);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "Color:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(3, 320);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(59, 16);
|
||||
this.label5.TabIndex = 7;
|
||||
this.label5.Text = "Mileage:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(3, 350);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(41, 16);
|
||||
this.label6.TabIndex = 8;
|
||||
this.label6.Text = "Price:";
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel1, 2);
|
||||
this.flowLayoutPanel1.Controls.Add(this.btnSave);
|
||||
this.flowLayoutPanel1.Controls.Add(this.btnDelete);
|
||||
this.flowLayoutPanel1.Controls.Add(this.lblID);
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 383);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(538, 64);
|
||||
this.flowLayoutPanel1.TabIndex = 9;
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Location = new System.Drawing.Point(450, 8);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSave.TabIndex = 0;
|
||||
this.btnSave.Text = "Save";
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// btnDelete
|
||||
//
|
||||
this.btnDelete.Location = new System.Drawing.Point(369, 8);
|
||||
this.btnDelete.Name = "btnDelete";
|
||||
this.btnDelete.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnDelete.TabIndex = 1;
|
||||
this.btnDelete.Text = "Delete";
|
||||
this.btnDelete.UseVisualStyleBackColor = true;
|
||||
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
|
||||
//
|
||||
// nudYear
|
||||
//
|
||||
this.nudYear.Location = new System.Drawing.Point(68, 263);
|
||||
this.nudYear.Maximum = new decimal(new int[] {
|
||||
3000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudYear.Name = "nudYear";
|
||||
this.nudYear.Size = new System.Drawing.Size(120, 22);
|
||||
this.nudYear.TabIndex = 10;
|
||||
this.nudYear.ValueChanged += new System.EventHandler(this.nudYear_ValueChanged);
|
||||
//
|
||||
// tbxColor
|
||||
//
|
||||
this.tbxColor.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tbxColor.Location = new System.Drawing.Point(68, 293);
|
||||
this.tbxColor.Name = "tbxColor";
|
||||
this.tbxColor.Size = new System.Drawing.Size(473, 22);
|
||||
this.tbxColor.TabIndex = 11;
|
||||
this.tbxColor.TextChanged += new System.EventHandler(this.tbxColor_TextChanged);
|
||||
//
|
||||
// nudMileage
|
||||
//
|
||||
this.nudMileage.Location = new System.Drawing.Point(68, 323);
|
||||
this.nudMileage.Maximum = new decimal(new int[] {
|
||||
999999,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudMileage.Name = "nudMileage";
|
||||
this.nudMileage.Size = new System.Drawing.Size(120, 22);
|
||||
this.nudMileage.TabIndex = 12;
|
||||
this.nudMileage.ThousandsSeparator = true;
|
||||
this.nudMileage.ValueChanged += new System.EventHandler(this.nudMileage_ValueChanged);
|
||||
//
|
||||
// nudPrice
|
||||
//
|
||||
this.nudPrice.DecimalPlaces = 2;
|
||||
this.nudPrice.Location = new System.Drawing.Point(68, 353);
|
||||
this.nudPrice.Maximum = new decimal(new int[] {
|
||||
999999,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudPrice.Name = "nudPrice";
|
||||
this.nudPrice.Size = new System.Drawing.Size(120, 22);
|
||||
this.nudPrice.TabIndex = 13;
|
||||
this.nudPrice.ThousandsSeparator = true;
|
||||
this.nudPrice.ValueChanged += new System.EventHandler(this.nudPrice_ValueChanged);
|
||||
//
|
||||
// lblID
|
||||
//
|
||||
this.lblID.AutoSize = true;
|
||||
this.lblID.Location = new System.Drawing.Point(343, 5);
|
||||
this.lblID.Name = "lblID";
|
||||
this.lblID.Size = new System.Drawing.Size(20, 16);
|
||||
this.lblID.TabIndex = 2;
|
||||
this.lblID.Text = "ID";
|
||||
//
|
||||
// CarDetailsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(536, 450);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "CarDetailsForm";
|
||||
this.Text = "Details";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCarImage)).EndInit();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudYear)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudMileage)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudPrice)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox tbxMake;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox tbxModel;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.Button btnDelete;
|
||||
private System.Windows.Forms.NumericUpDown nudYear;
|
||||
private System.Windows.Forms.TextBox tbxColor;
|
||||
private System.Windows.Forms.NumericUpDown nudMileage;
|
||||
private System.Windows.Forms.NumericUpDown nudPrice;
|
||||
private System.Windows.Forms.PictureBox pbxCarImage;
|
||||
private System.Windows.Forms.Label lblID;
|
||||
}
|
||||
}
|
||||
|
||||
87
CarManagerV2/CarDetailsForm.cs
Normal file
87
CarManagerV2/CarDetailsForm.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
public partial class CarDetailsForm : Form
|
||||
{
|
||||
|
||||
Car car;
|
||||
|
||||
public CarDetailsForm(Car car)
|
||||
{
|
||||
InitializeComponent();
|
||||
Console.WriteLine(car.Id);
|
||||
this.car = car;
|
||||
tbxMake.Text = car.Make;
|
||||
tbxModel.Text = car.Model;
|
||||
nudYear.Value = car.Year;
|
||||
tbxColor.Text = car.Color;
|
||||
nudMileage.Value = car.Mileage;
|
||||
nudPrice.Value = car.Price;
|
||||
pbxCarImage.Image = ImageManager.GetImage(car);
|
||||
lblID.Text = $"ID: {car.Id}";
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void tbxMake_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Make = tbxMake.Text;
|
||||
}
|
||||
|
||||
private void tbxModel_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Model = tbxModel.Text;
|
||||
}
|
||||
|
||||
private void nudYear_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Year = (int)nudYear.Value;
|
||||
}
|
||||
|
||||
private void tbxColor_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Color = tbxColor.Text;
|
||||
}
|
||||
|
||||
private void nudMileage_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Mileage = (int)nudMileage.Value;
|
||||
}
|
||||
|
||||
private void nudPrice_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.car.Price = nudPrice.Value;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
// save car to cars.csv and close form
|
||||
StateManager.updateCar(this.car);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//are you sure?
|
||||
var result = MessageBox.Show("Are you sure you want to delete this car?", "Delete Car", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
StateManager.removeCar(this.car);
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
8548
CarManagerV2/CarDetailsForm.resx
Normal file
8548
CarManagerV2/CarDetailsForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
105
CarManagerV2/CarManagerV2.csproj
Normal file
105
CarManagerV2/CarManagerV2.csproj
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{93CA258B-A645-41A8-A24F-59036ABC173F}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>CarManagerV2</RootNamespace>
|
||||
<AssemblyName>CarManagerV2</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Car.cs" />
|
||||
<Compile Include="CarCard.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CarCard.Designer.cs">
|
||||
<DependentUpon>CarCard.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CarDetailsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CarDetailsForm.Designer.cs">
|
||||
<DependentUpon>CarDetailsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ImageManager.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SafeManager.cs" />
|
||||
<Compile Include="StateManager.cs" />
|
||||
<EmbeddedResource Include="CarCard.resx">
|
||||
<DependentUpon>CarCard.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="CarDetailsForm.resx">
|
||||
<DependentUpon>CarDetailsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
75
CarManagerV2/ImageManager.cs
Normal file
75
CarManagerV2/ImageManager.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
internal class ImageManager
|
||||
{
|
||||
|
||||
public static void initializeImageFolder()
|
||||
{
|
||||
string path = "images";
|
||||
if (!System.IO.Directory.Exists(path))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
public static string getImagePath(Car car)
|
||||
{
|
||||
string basePath = "images/";
|
||||
string fileName = $"{car.Make}_{car.Model}_{car.Year}_{car.Color}.png";
|
||||
return basePath + fileName;
|
||||
}
|
||||
|
||||
public static Image GetImage(Car car)
|
||||
{
|
||||
initializeImageFolder();
|
||||
fetchImage(car);
|
||||
string path = getImagePath(car);
|
||||
// does image exist?
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
return Image.FromFile(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Image.FromFile("images/no_image_available.png");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void fetchImage(Car car)
|
||||
{
|
||||
// Fetch the image from https://cdn.imagin.studio/getimage and save it to images/Make_Model_Year.webp
|
||||
// use params like this: ?customer=hrjavascript-mastery&zoomType=fullscreen&make={make}&modelFamily={model}&modelYear={year}&angle=front&paintDescription={color}&fileType=png
|
||||
|
||||
// check if the image already exists
|
||||
string path = getImagePath(car);
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string url = $"https://cdn.imagin.studio/getimage?customer=hrjavascript-mastery&zoomType=fullscreen&make={car.Make}&modelFamily={car.Model}&modelYear={car.Year}&angle=front&paintDescription={car.Color}&fileType=png";
|
||||
//add Referer header
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
client.Headers.Add("Referer", "http://localhost");
|
||||
try
|
||||
{
|
||||
client.DownloadFile(url, path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// if error, use no_image_available.png
|
||||
System.IO.File.Copy("images/no_image_available.png", path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
59
CarManagerV2/MainForm.Designer.cs
generated
Normal file
59
CarManagerV2/MainForm.Designer.cs
generated
Normal file
@@ -0,0 +1,59 @@
|
||||
namespace CarManagerV2
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.flpCars = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// flpCars
|
||||
//
|
||||
this.flpCars.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flpCars.Location = new System.Drawing.Point(0, 0);
|
||||
this.flpCars.Name = "flpCars";
|
||||
this.flpCars.Size = new System.Drawing.Size(800, 450);
|
||||
this.flpCars.TabIndex = 0;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.flpCars);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "CarDetailsForm";
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.FlowLayoutPanel flpCars;
|
||||
}
|
||||
}
|
||||
59
CarManagerV2/MainForm.cs
Normal file
59
CarManagerV2/MainForm.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
List<Car> cars = new List<Car>();
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
SafeManager.initializeFile("cars.csv");
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
refreshCars(cars);
|
||||
}
|
||||
|
||||
private void refreshCars(List<Car> cars)
|
||||
{
|
||||
flpCars.Controls.Clear();
|
||||
foreach (Car car in cars)
|
||||
{
|
||||
CarCard card = new CarCard();
|
||||
card.CarName = $"{car.Make} {car.Model}";
|
||||
card.CarDetails = $"{car.Year}, {car.Mileage} km, ${car.Price}";
|
||||
card.CarImage = ImageManager.GetImage(car);
|
||||
card.CardClicked += (s, e) =>
|
||||
{
|
||||
CarDetailsForm detailsForm = new CarDetailsForm(car);
|
||||
detailsForm.FormClosed += (s2, e2) =>
|
||||
{
|
||||
// refresh cars
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
refreshCars(cars);
|
||||
};
|
||||
detailsForm.ShowDialog();
|
||||
};
|
||||
flpCars.Controls.Add(card);
|
||||
}
|
||||
}
|
||||
|
||||
private void CarDetailsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
120
CarManagerV2/MainForm.resx
Normal file
120
CarManagerV2/MainForm.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
22
CarManagerV2/Program.cs
Normal file
22
CarManagerV2/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
33
CarManagerV2/Properties/AssemblyInfo.cs
Normal file
33
CarManagerV2/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CarManagerV2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CarManagerV2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("93ca258b-a645-41a8-a24f-59036abc173f")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
CarManagerV2/Properties/Resources.Designer.cs
generated
Normal file
71
CarManagerV2/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CarManagerV2.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CarManagerV2.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
CarManagerV2/Properties/Resources.resx
Normal file
117
CarManagerV2/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
CarManagerV2/Properties/Settings.Designer.cs
generated
Normal file
30
CarManagerV2/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CarManagerV2.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
CarManagerV2/Properties/Settings.settings
Normal file
7
CarManagerV2/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
52
CarManagerV2/SafeManager.cs
Normal file
52
CarManagerV2/SafeManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
internal class SafeManager
|
||||
{
|
||||
public static void initializeFile(string path)
|
||||
{
|
||||
if (!File.Exists(@path))
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(@path))
|
||||
{
|
||||
// Create the file, empty
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Car> readCars(string path)
|
||||
{
|
||||
List<Car> cars = new List<Car>();
|
||||
using (StreamReader reader = new StreamReader(@path))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
// Process the line
|
||||
if (line == "") continue;
|
||||
cars.Add(Car.fromCsvString(line));
|
||||
}
|
||||
}
|
||||
return cars;
|
||||
}
|
||||
|
||||
public static void saveCars(string path, List<Car> cars)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(@path))
|
||||
{
|
||||
foreach (Car car in cars)
|
||||
{
|
||||
writer.WriteLine(car.toCsvString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
CarManagerV2/StateManager.cs
Normal file
56
CarManagerV2/StateManager.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarManagerV2
|
||||
{
|
||||
internal class StateManager
|
||||
{
|
||||
|
||||
static List<Car> cars = new List<Car>();
|
||||
|
||||
public static Car getCarById(int id)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
return cars.FirstOrDefault(c => c.Id == id);
|
||||
}
|
||||
|
||||
public static List<Car> Cars { get { return cars; } set { cars = value; } }
|
||||
|
||||
public static void addCar(Car car)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
cars.Add(car);
|
||||
SafeManager.saveCars("cars.csv", cars);
|
||||
}
|
||||
|
||||
public static void removeCar(Car car)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
Console.WriteLine(cars);
|
||||
cars.Remove(car);
|
||||
Console.WriteLine(cars);
|
||||
SafeManager.saveCars("cars.csv", cars);
|
||||
}
|
||||
|
||||
public static void updateCar(Car car)
|
||||
{
|
||||
Car existingCar = getCarById(car.Id);
|
||||
if (existingCar != null)
|
||||
{
|
||||
cars.Remove(existingCar);
|
||||
cars.Add(car);
|
||||
}
|
||||
}
|
||||
|
||||
public static void createCar(string make, string model, int year, string color, int mileage, decimal price)
|
||||
{
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
int newId = cars.Count > 0 ? cars.Max(c => c.Id) + 1 : 1;
|
||||
Car newCar = new Car(newId, make, model, year, color, mileage, price);
|
||||
cars.Add(newCar);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user