Skip to content

Commit

Permalink
UI appearence changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Keugon committed May 14, 2024
1 parent a0a5a1e commit dc820bb
Show file tree
Hide file tree
Showing 8 changed files with 396 additions and 134 deletions.
68 changes: 53 additions & 15 deletions Data/Invoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ namespace Essensausgleich.Data
/// </summary>
public class Invoices : System.Collections.Generic.List<Invoice>
{

}
/// <summary>
/// Object to handle one Invoice including 2 Inhabitants
/// </summary>
public class Invoice
public partial class Invoice : INotifyPropertyChanged
{


/// <summary>
/// <summary>
/// Path of the Folder where all Invoice Objects get read from
/// </summary>
public static string? FolderPath { get; set; }
Expand All @@ -38,15 +35,11 @@ public ObservableCollection<string> InhabitantsNameList
{
get
{

System.Diagnostics.Debug.WriteLine($"InhabitantsNameList Get");
return this._InhabitantsNameList;
}
set
{

this._InhabitantsNameList = value;
System.Diagnostics.Debug.WriteLine($"InhabitantsNameList got Set");
}
}
private Inhabitants _Inhabitants = null!;
Expand Down Expand Up @@ -78,15 +71,51 @@ public Inhabitants Inhabitants
public string InvoiceComment
{
get => this._InvoiceComment;
set => this._InvoiceComment = value;
set
{
this._InvoiceComment = value;
OnPropertyChanged(nameof(InvoiceComment));
}
}


private string? _FileName;
/// <summary>
/// FileName gets set on load from File
/// </summary>
public string? FileName { get; set; }

public string? FileName
{
get => this._FileName;
set
{
this._FileName = value;
OnPropertyChanged(nameof(FileName));
}
}
private DateTime? _DateTimeCreation;
/// <summary>
/// Gets or Set the First Time this Invoice was Saved to File
/// </summary>
public DateTime? DateTimeCreation
{
get => this._DateTimeCreation;
set
{
this._DateTimeCreation = value;
OnPropertyChanged(nameof(DateTimeCreation));
}
}
private DateTime? _DateTimeChanged;
/// <summary>
/// Gets or Set the Last Time this Invoice was Saved to File
/// </summary>
public DateTime? DateTimeChanged
{
get => this._DateTimeChanged;
set
{
this._DateTimeChanged = value;
OnPropertyChanged(nameof(DateTimeChanged));
}
}
/// <summary>
/// Adds a Inhabitant to the End of the Inhabitants List
/// </summary>
Expand All @@ -95,7 +124,16 @@ public void AddInhabitantToList(Inhabitant inhabitantToAdd)
{
this.Inhabitants.Add(inhabitantToAdd);
}

#region WPF über Änderungen Informieren
public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

System.Diagnostics.Debug.WriteLine($"OnPropertyChanged Called in InvoiceManager:{propertyName}");
}
#endregion WPF über Änderungen Informieren
}


Expand Down
48 changes: 16 additions & 32 deletions InvoiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Essensausgleich.Infra;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -13,7 +15,7 @@ namespace Essensausgleich
/// <summary>
/// Manages Invoices
/// </summary>
public class InvoiceManager :AppObjekt
public class InvoiceManager :AppObjekt ,INotifyPropertyChanged
{
#region Invoice and List
/// <summary>
Expand All @@ -31,11 +33,14 @@ public Invoices Invoices
{
this._Invoices = new Invoices();
}
return this._Invoices;
return this._Invoices;
}
set
{
this._Invoices = value;
this._Invoices = value;
this.OnPropertyChanged(nameof(this.Invoices));


}
}
/// <summary>
Expand Down Expand Up @@ -88,6 +93,7 @@ public void Save(Invoice invoiceToSave)
try
{
this.InvoiceController.Save(invoiceToSave.FileName!, invoiceToSave);


System.Diagnostics.Debug.WriteLine($"This Invoice got saved to:{invoiceToSave.FileName}") ;
}
Expand Down Expand Up @@ -122,37 +128,15 @@ public Invoice Load(string pathWithFileName)
return Invoice;
}
}
/*
/// <summary>
/// Intern cache for filename
/// </summary>
private string _JsonFileName = $"abrechnung.json";
//$"abrechnung_{General.GetCurrentDate()}.json";
/// <summary>
/// Gets the XMLFilename in String
/// </summary>
public string JsonFileName
{
get
{
return _JsonFileName;
}
set
{
if (!string.IsNullOrEmpty(value))
{
_JsonFileName = value;
Log.WriteLine("FileName changed");
Log.WriteLine($"NewFileName: {value}");
#region WPF über Änderungen Informieren
public event PropertyChangedEventHandler PropertyChanged;

}
else
{
Log.WriteLine("FileName Missing or Null");
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

System.Diagnostics.Debug.WriteLine($"OnPropertyChanged Called in InvoiceManager:{propertyName}");
}
*/
#endregion WPF über Änderungen Informieren
}
}
19 changes: 19 additions & 0 deletions Tools/General.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Essensausgleich.Tools
{
Expand All @@ -26,4 +29,20 @@ public static string GetCurrentDate()
}

}
public class FilePathToFileNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string filePath)
{
return Path.GetFileName(filePath);
}
return value; // Return original value if it's not a string
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit dc820bb

Please sign in to comment.