From aca39be8d401c400468cc407c4a0d2783de4f7be Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Sat, 11 Mar 2023 15:19:52 +0100 Subject: [PATCH] Move helpers to Helpers/ --- WGneu/App.xaml.cs | 1 + WGneu/Documents/Document.cshtml.cs | 1 + WGneu/Documents/Pdf.cs | 1 + WGneu/{ => Helpers}/Utils.cs | 8 ++++---- WGneu/{ => Helpers}/Validator.cs | 2 +- WGneu/{ => Helpers}/WgContext.cs | 5 ++--- WGneu/Models/AT_Plz.cs | 1 + WGneu/Models/PostalDest.cs | 1 + WGneu/Windows/ContractListWindow.xaml.cs | 1 + WGneu/Windows/DocumentViewerWindow.xaml.cs | 1 + WGneu/Windows/MainWindow.xaml.cs | 1 + WGneu/Windows/MemberListWindow.xaml.cs | 5 +++-- 12 files changed, 18 insertions(+), 10 deletions(-) rename WGneu/{ => Helpers}/Utils.cs (95%) rename WGneu/{ => Helpers}/Validator.cs (99%) rename WGneu/{ => Helpers}/WgContext.cs (96%) diff --git a/WGneu/App.xaml.cs b/WGneu/App.xaml.cs index 36e8165..5afc810 100644 --- a/WGneu/App.xaml.cs +++ b/WGneu/App.xaml.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.IO; +using WGneu.Helpers; namespace WGneu { public partial class App : Application { diff --git a/WGneu/Documents/Document.cshtml.cs b/WGneu/Documents/Document.cshtml.cs index 8863d38..d31e3b8 100644 --- a/WGneu/Documents/Document.cshtml.cs +++ b/WGneu/Documents/Document.cshtml.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.IO; using System.Windows; +using WGneu.Helpers; namespace WGneu.Documents { public abstract class Document : IDisposable { diff --git a/WGneu/Documents/Pdf.cs b/WGneu/Documents/Pdf.cs index 30bb3fb..1c2b404 100644 --- a/WGneu/Documents/Pdf.cs +++ b/WGneu/Documents/Pdf.cs @@ -12,6 +12,7 @@ using PdfSharp.Pdf.IO; using PuppeteerSharp; using PuppeteerSharp.Media; using RazorLight; +using WGneu.Helpers; using WGneu.Windows; namespace WGneu.Documents { diff --git a/WGneu/Utils.cs b/WGneu/Helpers/Utils.cs similarity index 95% rename from WGneu/Utils.cs rename to WGneu/Helpers/Utils.cs index b361b96..f080449 100644 --- a/WGneu/Utils.cs +++ b/WGneu/Helpers/Utils.cs @@ -9,7 +9,7 @@ using System.Windows.Controls; using System.IO; using System.Diagnostics; -namespace WGneu { +namespace WGneu.Helpers { public static class Utils { public static void SetInputChanged(Control input) { input.BorderBrush = Brushes.Orange; @@ -68,9 +68,9 @@ namespace WGneu { private int Usages = 0; public string FilePath { get; private set; } - public TemporaryFile() : this(null) {} + public TemporaryFile() : this(null) { } - public TemporaryFile(string? ext) : this(Path.Combine(Path.GetTempPath(), "Kelwin"), ext) {} + public TemporaryFile(string? ext) : this(Path.Combine(Path.GetTempPath(), "Kelwin"), ext) { } public TemporaryFile(string dir, string? ext) { FilePath = Path.Combine(dir, Path.GetRandomFileName().Replace(".", "") + (ext != null ? $".{ext}" : "")); @@ -95,7 +95,7 @@ namespace WGneu { } private void Create() { - using (File.Create(FilePath)) {}; + using (File.Create(FilePath)) { }; } private void Delete() { diff --git a/WGneu/Validator.cs b/WGneu/Helpers/Validator.cs similarity index 99% rename from WGneu/Validator.cs rename to WGneu/Helpers/Validator.cs index cd64180..cc9e615 100644 --- a/WGneu/Validator.cs +++ b/WGneu/Helpers/Validator.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Controls; -namespace WGneu { +namespace WGneu.Helpers { static class Validator { private static readonly Dictionary PHONE_NRS = new() { diff --git a/WGneu/WgContext.cs b/WGneu/Helpers/WgContext.cs similarity index 96% rename from WGneu/WgContext.cs rename to WGneu/Helpers/WgContext.cs index 9ebf134..73af0ed 100644 --- a/WGneu/WgContext.cs +++ b/WGneu/Helpers/WgContext.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using WGneu.Models; -namespace WGneu { +namespace WGneu.Helpers { public class WgContext : DbContext { public DbSet Countries { get; set; } public DbSet Members { get; set; } @@ -26,8 +26,7 @@ namespace WGneu { public DbSet WineVarieties { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgtest.sqlite3\"; foreign keys=true"); optionsBuilder.UseLazyLoadingProxies(); } diff --git a/WGneu/Models/AT_Plz.cs b/WGneu/Models/AT_Plz.cs index 42222cc..434b828 100644 --- a/WGneu/Models/AT_Plz.cs +++ b/WGneu/Models/AT_Plz.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading.Tasks; +using WGneu.Helpers; namespace WGneu.Models { [Table("AT_plz"), PrimaryKey("Plz", "Okz"), Index("Id", IsUnique = true)] diff --git a/WGneu/Models/PostalDest.cs b/WGneu/Models/PostalDest.cs index 2a49d4a..69a4ad1 100644 --- a/WGneu/Models/PostalDest.cs +++ b/WGneu/Models/PostalDest.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; +using WGneu.Helpers; namespace WGneu.Models { [Table("postal_dest"), PrimaryKey("CountryCode", "Id")] diff --git a/WGneu/Windows/ContractListWindow.xaml.cs b/WGneu/Windows/ContractListWindow.xaml.cs index 4687e03..ab0557b 100644 --- a/WGneu/Windows/ContractListWindow.xaml.cs +++ b/WGneu/Windows/ContractListWindow.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using WGneu.Helpers; using WGneu.Models; namespace WGneu.Windows { diff --git a/WGneu/Windows/DocumentViewerWindow.xaml.cs b/WGneu/Windows/DocumentViewerWindow.xaml.cs index 8174ee7..5376eff 100644 --- a/WGneu/Windows/DocumentViewerWindow.xaml.cs +++ b/WGneu/Windows/DocumentViewerWindow.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using WGneu.Helpers; namespace WGneu.Windows { public partial class DocumentViewerWindow : Window { diff --git a/WGneu/Windows/MainWindow.xaml.cs b/WGneu/Windows/MainWindow.xaml.cs index 465fbfd..68103fb 100644 --- a/WGneu/Windows/MainWindow.xaml.cs +++ b/WGneu/Windows/MainWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using WGneu.Documents; +using WGneu.Helpers; using WGneu.Models; diff --git a/WGneu/Windows/MemberListWindow.xaml.cs b/WGneu/Windows/MemberListWindow.xaml.cs index f5e7c03..4b75116 100644 --- a/WGneu/Windows/MemberListWindow.xaml.cs +++ b/WGneu/Windows/MemberListWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using WGneu.Helpers; using WGneu.Models; @@ -257,7 +258,7 @@ namespace WGneu.Windows { } private void ContractButton_Click(object sender, RoutedEventArgs e) { - var w = new ContractListWindow((Member) MemberList.SelectedItem); + var w = new ContractListWindow((Member)MemberList.SelectedItem); w.Show(); } @@ -517,7 +518,7 @@ namespace WGneu.Windows { } private void TextBox_TextChanged(object sender, RoutedEventArgs e) { - var input = (TextBox)sender; + var input = (TextBox)sender; if (InputHasChanged(input)) { Utils.SetInputChanged(input); } else {