diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..a0fc7a0
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,26 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/dealer/bin/Debug/net8.0-windows/dealer.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/dealer",
+ // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
+ "console": "internalConsole",
+ "stopAtEntry": false
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..3c01c35
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/dealer/dealer.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/dealer/dealer.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "${workspaceFolder}/dealer/dealer.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/dealer/App.xaml b/dealer/App.xaml
index 3c9ecaf..ad83905 100644
--- a/dealer/App.xaml
+++ b/dealer/App.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:dealer"
- StartupUri="MainWindow.xaml">
+ StartupUri="windows/MainWindow.xaml">
diff --git a/dealer/App.xaml.cs b/dealer/App.xaml.cs
index 28e6a80..1fe67fd 100644
--- a/dealer/App.xaml.cs
+++ b/dealer/App.xaml.cs
@@ -1,14 +1,12 @@
using System.Configuration;
using System.Data;
-using System.Windows;
namespace dealer
{
///
/// Interaction logic for App.xaml
///
- public partial class App : Application
+ public partial class App : System.Windows.Application
{
}
-
}
diff --git a/dealer/DataManager.cs b/dealer/DataManager.cs
new file mode 100644
index 0000000..822dbad
--- /dev/null
+++ b/dealer/DataManager.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace dealer
+{
+ public class DataManager
+ {
+ private List vehicles = new List();
+
+ public void AddVehicle(Vehicle vehicle)
+ {
+ vehicles.Add(vehicle);
+ }
+
+ public IEnumerable GetAllVehicles()
+ {
+ return vehicles;
+ }
+
+ public void RemoveVehicle(Vehicle vehicle)
+ {
+ vehicles.Remove(vehicle);
+ }
+
+ public void Save()
+ {
+ // Implementace ukládání dat do souboru - JSON
+ var json = System.Text.Json.JsonSerializer.Serialize(vehicles);
+ System.IO.File.WriteAllText("vehicles.json", json);
+ }
+
+ public void Load()
+ {
+ string path = "vehicles.json";
+
+ // Implementace načítání dat ze souboru - JSON
+ if (System.IO.File.Exists(path))
+ {
+ var json = System.IO.File.ReadAllText(path);
+ vehicles = System.Text.Json.JsonSerializer.Deserialize>(json) ?? new List();
+ }
+ }
+ }
+}
diff --git a/dealer/MainWindow.xaml b/dealer/MainWindow.xaml
deleted file mode 100644
index d38fe50..0000000
--- a/dealer/MainWindow.xaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/dealer/MainWindow.xaml.cs b/dealer/MainWindow.xaml.cs
deleted file mode 100644
index c9b7cea..0000000
--- a/dealer/MainWindow.xaml.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace dealer
-{
- ///
- /// Interaction logic for MainWindow.xaml
- ///
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/dealer/Vehicle.cs b/dealer/Vehicle.cs
new file mode 100644
index 0000000..04d2650
--- /dev/null
+++ b/dealer/Vehicle.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace dealer
+{
+ public class Vehicle
+ {
+ public string? Spz { get; set; }
+ public string? Model { get; set; }
+ public string? Barva { get; set; }
+ public int? RokVyroby { get; set; }
+ public int? NajeteKm { get; set; }
+ public decimal? Cena { get; set; }
+ public string? Fotografie { get; set; }
+ }
+}
diff --git a/dealer/dealer.csproj b/dealer/dealer.csproj
index e3e33e3..4adf208 100644
--- a/dealer/dealer.csproj
+++ b/dealer/dealer.csproj
@@ -6,6 +6,7 @@
enable
enable
true
+ true
diff --git a/dealer/windows/AddVehicleWindow.xaml b/dealer/windows/AddVehicleWindow.xaml
new file mode 100644
index 0000000..1d3462e
--- /dev/null
+++ b/dealer/windows/AddVehicleWindow.xaml
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dealer/windows/AddVehicleWindow.xaml.cs b/dealer/windows/AddVehicleWindow.xaml.cs
new file mode 100644
index 0000000..1eaf9e3
--- /dev/null
+++ b/dealer/windows/AddVehicleWindow.xaml.cs
@@ -0,0 +1,106 @@
+using Microsoft.Win32;
+using System.IO;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media;
+using WinForms = System.Windows.Forms;
+
+namespace dealer
+{
+ public partial class AddVehicleWindow : Window
+ {
+ public string? SelectedPhotoPath { get; private set; }
+ public System.Windows.Media.Color SelectedColor { get; private set; } = Colors.White;
+
+ private DataManager dataManager;
+
+ public AddVehicleWindow(DataManager dataManager)
+ {
+ InitializeComponent();
+
+ this.dataManager = dataManager;
+ }
+
+ private void SelectPhotoButton_Click(object sender, RoutedEventArgs e)
+ {
+ Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Title = "Vyberte fotografii vozidla",
+ Filter = "Obrazky|*.jpg;*.jpeg;*.png;*.bmp;*.gif|Vsechny soubory|*.*",
+ FilterIndex = 1
+ };
+
+ if (openFileDialog.ShowDialog() == true)
+ {
+ SelectedPhotoPath = openFileDialog.FileName;
+ PhotoPathTextBlock.Text = SelectedPhotoPath;
+ }
+ }
+
+ private void SelectColorButton_Click(object sender, RoutedEventArgs e)
+ {
+ WinForms.ColorDialog colorDialog = new WinForms.ColorDialog
+ {
+ AllowFullOpen = true,
+ FullOpen = true
+ };
+
+ if (colorDialog.ShowDialog() == WinForms.DialogResult.OK)
+ {
+ SelectedColor = System.Windows.Media.Color.FromArgb(
+ colorDialog.Color.A,
+ colorDialog.Color.R,
+ colorDialog.Color.G,
+ colorDialog.Color.B);
+
+ ColorPreviewBorder.Background = new SolidColorBrush(SelectedColor);
+ ColorNameTextBlock.Text = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}";
+ ColorNameTextBlock.FontStyle = FontStyles.Normal;
+ ColorNameTextBlock.Foreground = System.Windows.Media.Brushes.Black;
+ }
+ }
+
+ private void NumericOnly_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ e.Handled = !int.TryParse(e.Text, out _);
+ }
+
+ private void DecimalOnly_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ var textBox = sender as System.Windows.Controls.TextBox;
+ string newText = textBox?.Text.Insert(textBox.SelectionStart, e.Text) ?? e.Text;
+ e.Handled = !decimal.TryParse(newText, out _);
+ }
+
+ private void SaveButton_Click(object sender, RoutedEventArgs e)
+ {
+ string? base64Image = null;
+ if (!string.IsNullOrEmpty(SelectedPhotoPath) && File.Exists(SelectedPhotoPath))
+ {
+ byte[] imageBytes = File.ReadAllBytes(SelectedPhotoPath);
+ base64Image = Convert.ToBase64String(imageBytes);
+ }
+
+ var vehicle = new Vehicle
+ {
+ Spz = SpzTextBox.Text,
+ Model = ModelTextBox.Text,
+ Barva = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}",
+ RokVyroby = int.TryParse(YearTextBox.Text, out int rok) ? rok : (int?)null,
+ NajeteKm = int.TryParse(MileageTextBox.Text, out int km) ? km : (int?)null,
+ Cena = decimal.TryParse(PriceTextBox.Text, out decimal cena) ? cena : (decimal?)null,
+ Fotografie = base64Image
+ };
+
+ this.dataManager.AddVehicle(vehicle);
+ this.dataManager.Save();
+
+ this.Close();
+ }
+
+ private void CancelButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/dealer/windows/MainWindow.xaml b/dealer/windows/MainWindow.xaml
new file mode 100644
index 0000000..869f026
--- /dev/null
+++ b/dealer/windows/MainWindow.xaml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dealer/windows/MainWindow.xaml.cs b/dealer/windows/MainWindow.xaml.cs
new file mode 100644
index 0000000..d6a18fd
--- /dev/null
+++ b/dealer/windows/MainWindow.xaml.cs
@@ -0,0 +1,46 @@
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace dealer
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ private DataManager dataManager = new DataManager();
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ this.dataManager.Load();
+
+ this.VehiclesListView.ItemsSource = this.dataManager.GetAllVehicles();
+ }
+
+ private void AddButton_Click(object sender, RoutedEventArgs e)
+ {
+ var window = new AddVehicleWindow(this.dataManager);
+ window.ShowDialog();
+ }
+
+ private void EditButton_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void DeleteButton_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+ }
+}
\ No newline at end of file