Implemented new dialog.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
bin
|
||||
obj
|
||||
.idea
|
||||
.vs
|
||||
*.user
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30128.74
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ucalc", "ucalc\ucalc.csproj", "{E565705A-BAF4-4653-99A1-199C314A21EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E565705A-BAF4-4653-99A1-199C314A21EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E565705A-BAF4-4653-99A1-199C314A21EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E565705A-BAF4-4653-99A1-199C314A21EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E565705A-BAF4-4653-99A1-199C314A21EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C5D953C3-5DB1-48E7-BC85-31079EB37F26}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="UCalc.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:UCalc"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,15 @@
|
||||
using UCalc.Data;
|
||||
|
||||
namespace UCalc
|
||||
{
|
||||
public partial class App
|
||||
{
|
||||
private readonly RecentlyOpenedList _recentlyOpenedList;
|
||||
public static RecentlyOpenedList RecentlyOpenedList => ((App) Current)._recentlyOpenedList;
|
||||
|
||||
public App()
|
||||
{
|
||||
_recentlyOpenedList = new RecentlyOpenedList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
@@ -0,0 +1,10 @@
|
||||
<Window x:Class="UCalc.BillingWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:UCalc"
|
||||
mc:Ignorable="d"
|
||||
Title="BillingWindow" Height="450" Width="800">
|
||||
<Grid />
|
||||
</Window>
|
||||
@@ -0,0 +1,17 @@
|
||||
using UCalc.Data;
|
||||
|
||||
namespace UCalc
|
||||
{
|
||||
public partial class BillingWindow
|
||||
{
|
||||
private readonly Billing _savedBilling;
|
||||
public Billing Billing { get; }
|
||||
|
||||
public BillingWindow(Billing savedBilling, Billing billing)
|
||||
{
|
||||
_savedBilling = savedBilling;
|
||||
Billing = billing;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace UCalc
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly SolidColorBrush MainColor = Brushes.White;
|
||||
public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#pragma warning disable 659
|
||||
|
||||
namespace UCalc.Data
|
||||
{
|
||||
public enum Salutation
|
||||
{
|
||||
Sir,
|
||||
SirDr,
|
||||
Madam,
|
||||
MadamDr,
|
||||
SirAndMadam,
|
||||
Family
|
||||
}
|
||||
|
||||
public static class Salutations
|
||||
{
|
||||
public static string AsString(this Salutation salutation)
|
||||
{
|
||||
switch (salutation)
|
||||
{
|
||||
case Salutation.Sir:
|
||||
return "Herr";
|
||||
case Salutation.SirDr:
|
||||
return "Herr Dr.";
|
||||
case Salutation.Madam:
|
||||
return "Frau";
|
||||
case Salutation.MadamDr:
|
||||
return "Frau Dr.";
|
||||
case Salutation.SirAndMadam:
|
||||
return "Herr und Frau";
|
||||
case Salutation.Family:
|
||||
return "Familie";
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Address
|
||||
{
|
||||
public string Street { get; set; }
|
||||
public string HouseNumber { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Postcode { get; set; }
|
||||
|
||||
public Address()
|
||||
{
|
||||
Street = "";
|
||||
HouseNumber = "";
|
||||
City = "";
|
||||
Postcode = "";
|
||||
}
|
||||
|
||||
private bool Equals(Address other)
|
||||
{
|
||||
return Street == other.Street && HouseNumber == other.HouseNumber && City == other.City &&
|
||||
Postcode == other.Postcode;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Address) obj);
|
||||
}
|
||||
|
||||
public Address Clone()
|
||||
{
|
||||
return new Address
|
||||
{
|
||||
Street = Street,
|
||||
HouseNumber = HouseNumber,
|
||||
City = City,
|
||||
Postcode = Postcode
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class BankAccount
|
||||
{
|
||||
public string Iban { get; set; }
|
||||
public string Bic { get; set; }
|
||||
public string BankName { get; set; }
|
||||
|
||||
public BankAccount()
|
||||
{
|
||||
Iban = "";
|
||||
Bic = "";
|
||||
BankName = "";
|
||||
}
|
||||
|
||||
private bool Equals(BankAccount other)
|
||||
{
|
||||
return Iban == other.Iban && Bic == other.Bic && BankName == other.BankName;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((BankAccount) obj);
|
||||
}
|
||||
|
||||
public BankAccount Clone()
|
||||
{
|
||||
return new BankAccount
|
||||
{
|
||||
Iban = Iban,
|
||||
Bic = Bic,
|
||||
BankName = BankName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Flat
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public int Size { get; set; }
|
||||
|
||||
public Flat()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
Name = "";
|
||||
}
|
||||
|
||||
private bool Equals(Flat other)
|
||||
{
|
||||
return Id.Equals(other.Id) && Name == other.Name && Size == other.Size;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Flat) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// ReSharper disable NonReadonlyMemberInGetHashCode
|
||||
return Id.GetHashCode();
|
||||
// ReSharper restore NonReadonlyMemberInGetHashCode
|
||||
}
|
||||
|
||||
public Flat Clone()
|
||||
{
|
||||
return new Flat
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Size = Size
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Tenant
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public Salutation Salutation { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int PersonCount { get; set; }
|
||||
public BankAccount BankAccount { get; private set; }
|
||||
public DateTime? EntryDate { get; set; }
|
||||
public DateTime? DepatureDate { get; set; }
|
||||
public HashSet<Flat> RentedFlats { get; private set; }
|
||||
public decimal PaidRent { get; set; }
|
||||
public string CustomMessage1 { get; set; }
|
||||
public string CustomMessage2 { get; set; }
|
||||
|
||||
public Tenant()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
Name = "";
|
||||
BankAccount = new BankAccount();
|
||||
RentedFlats = new HashSet<Flat>();
|
||||
}
|
||||
|
||||
private bool Equals(Tenant other)
|
||||
{
|
||||
return Id.Equals(other.Id) && Salutation == other.Salutation && Name == other.Name &&
|
||||
PersonCount == other.PersonCount && Equals(BankAccount, other.BankAccount) &&
|
||||
Nullable.Equals(EntryDate, other.EntryDate) && Nullable.Equals(DepatureDate, other.DepatureDate) &&
|
||||
RentedFlats.SequenceEqual(other.RentedFlats) && PaidRent == other.PaidRent &&
|
||||
CustomMessage1 == other.CustomMessage1 && CustomMessage2 == other.CustomMessage2;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Tenant) obj);
|
||||
}
|
||||
|
||||
public Tenant Clone(Dictionary<Flat, Flat> flatMapper)
|
||||
{
|
||||
return new Tenant
|
||||
{
|
||||
Id = Id,
|
||||
Salutation = Salutation,
|
||||
Name = Name,
|
||||
PersonCount = PersonCount,
|
||||
BankAccount = BankAccount.Clone(),
|
||||
EntryDate = EntryDate,
|
||||
DepatureDate = DepatureDate,
|
||||
RentedFlats = new HashSet<Flat>(RentedFlats.Select(flat => flatMapper[flat])),
|
||||
PaidRent = PaidRent,
|
||||
CustomMessage1 = CustomMessage1,
|
||||
CustomMessage2 = CustomMessage2
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Landlord
|
||||
{
|
||||
public Salutation Salutation { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string MailAddress { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public Address Address { get; private set; }
|
||||
public BankAccount BankAccount { get; private set; }
|
||||
|
||||
public Landlord()
|
||||
{
|
||||
Name = "";
|
||||
MailAddress = "";
|
||||
Phone = "";
|
||||
Address = new Address();
|
||||
BankAccount = new BankAccount();
|
||||
}
|
||||
|
||||
private bool Equals(Landlord other)
|
||||
{
|
||||
return Salutation == other.Salutation && Name == other.Name && MailAddress == other.MailAddress &&
|
||||
Phone == other.Phone && Equals(Address, other.Address) && Equals(BankAccount, other.BankAccount);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Landlord) obj);
|
||||
}
|
||||
|
||||
public Landlord Clone()
|
||||
{
|
||||
return new Landlord
|
||||
{
|
||||
Salutation = Salutation,
|
||||
Name = Name,
|
||||
MailAddress = MailAddress,
|
||||
Phone = Phone,
|
||||
Address = Address.Clone(),
|
||||
BankAccount = BankAccount.Clone()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class House
|
||||
{
|
||||
public Address Address { get; private set; }
|
||||
public List<Flat> Flats { get; private set; }
|
||||
|
||||
public House()
|
||||
{
|
||||
Address = new Address();
|
||||
Flats = new List<Flat>();
|
||||
}
|
||||
|
||||
private bool Equals(House other)
|
||||
{
|
||||
return Equals(Address, other.Address) && Flats.SequenceEqual(other.Flats);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((House) obj);
|
||||
}
|
||||
|
||||
public House Clone()
|
||||
{
|
||||
return new House
|
||||
{
|
||||
Address = Address.Clone(),
|
||||
Flats = new List<Flat>(Flats.Select(flat => flat.Clone()))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class CostEntryDetails
|
||||
{
|
||||
public decimal TotalPrice { get; set; }
|
||||
public decimal UnitCount { get; set; }
|
||||
public List<decimal> DiscountsInUnits { get; private set; }
|
||||
|
||||
public CostEntryDetails()
|
||||
{
|
||||
DiscountsInUnits = new List<decimal>();
|
||||
}
|
||||
|
||||
private bool Equals(CostEntryDetails other)
|
||||
{
|
||||
return TotalPrice == other.TotalPrice && UnitCount == other.UnitCount &&
|
||||
DiscountsInUnits.SequenceEqual(other.DiscountsInUnits);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((CostEntryDetails) obj);
|
||||
}
|
||||
|
||||
public CostEntryDetails Clone()
|
||||
{
|
||||
return new CostEntryDetails
|
||||
{
|
||||
TotalPrice = TotalPrice,
|
||||
UnitCount = UnitCount,
|
||||
DiscountsInUnits = new List<decimal>(DiscountsInUnits)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class CostEntry
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public CostEntryDetails Details { get; set; }
|
||||
|
||||
public CostEntry()
|
||||
{
|
||||
Details = new CostEntryDetails();
|
||||
}
|
||||
|
||||
private bool Equals(CostEntry other)
|
||||
{
|
||||
return StartDate.Equals(other.StartDate) && EndDate.Equals(other.EndDate) && Price == other.Price &&
|
||||
Details.Equals(other.Details);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((CostEntry) obj);
|
||||
}
|
||||
|
||||
public CostEntry Clone()
|
||||
{
|
||||
return new CostEntry
|
||||
{
|
||||
StartDate = StartDate,
|
||||
EndDate = EndDate,
|
||||
Price = Price,
|
||||
Details = Details?.Clone()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum CostDivision
|
||||
{
|
||||
Person,
|
||||
Flat,
|
||||
Size
|
||||
}
|
||||
|
||||
public class Cost
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public CostDivision Division { get; set; }
|
||||
public bool AffectsAll { get; set; }
|
||||
public bool IncludeUnrented { get; set; }
|
||||
public HashSet<Flat> AffectedFlats { get; private set; }
|
||||
public List<CostEntry> Entries { get; private set; }
|
||||
public bool DisplayInBill { get; set; }
|
||||
|
||||
public Cost()
|
||||
{
|
||||
Name = "";
|
||||
AffectedFlats = new HashSet<Flat>();
|
||||
Entries = new List<CostEntry>();
|
||||
}
|
||||
|
||||
private bool Equals(Cost other)
|
||||
{
|
||||
return Name == other.Name && Division == other.Division && AffectsAll == other.AffectsAll &&
|
||||
IncludeUnrented == other.IncludeUnrented && AffectedFlats.SequenceEqual(other.AffectedFlats) &&
|
||||
Entries.SequenceEqual(other.Entries) && DisplayInBill == other.DisplayInBill;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Cost) obj);
|
||||
}
|
||||
|
||||
public Cost Clone(Dictionary<Flat, Flat> flatMapper)
|
||||
{
|
||||
return new Cost
|
||||
{
|
||||
Name = Name,
|
||||
Division = Division,
|
||||
AffectsAll = AffectsAll,
|
||||
IncludeUnrented = IncludeUnrented,
|
||||
AffectedFlats = new HashSet<Flat>(AffectedFlats.Select(flat => flatMapper[flat])),
|
||||
Entries = new List<CostEntry>(Entries.Select(entry => entry.Clone())),
|
||||
DisplayInBill = DisplayInBill
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Billing
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public Landlord Landlord { get; private set; }
|
||||
public House House { get; private set; }
|
||||
public List<Tenant> Tenants { get; private set; }
|
||||
public List<Cost> Costs { get; private set; }
|
||||
|
||||
public Billing()
|
||||
{
|
||||
Landlord = new Landlord();
|
||||
House = new House();
|
||||
Tenants = new List<Tenant>();
|
||||
Costs = new List<Cost>();
|
||||
}
|
||||
|
||||
private bool Equals(Billing other)
|
||||
{
|
||||
return StartDate.Equals(other.StartDate) && EndDate.Equals(other.EndDate) &&
|
||||
Landlord.Equals(other.Landlord) && House.Equals(other.House) &&
|
||||
Tenants.SequenceEqual(other.Tenants) && Costs.SequenceEqual(other.Costs);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((Billing) obj);
|
||||
}
|
||||
|
||||
public Billing Clone()
|
||||
{
|
||||
var house = House.Clone();
|
||||
var flatMapper = new Dictionary<Flat, Flat>(new ObjectReferenceEqualityComparer<Flat>());
|
||||
|
||||
for (var i = 0; i < House.Flats.Count; ++i)
|
||||
{
|
||||
flatMapper.Add(House.Flats[i], house.Flats[i]);
|
||||
}
|
||||
|
||||
return new Billing
|
||||
{
|
||||
StartDate = StartDate,
|
||||
EndDate = EndDate,
|
||||
Landlord = Landlord.Clone(),
|
||||
House = House,
|
||||
Tenants = new List<Tenant>(Tenants.Select(tenant => tenant.Clone(flatMapper))),
|
||||
Costs = new List<Cost>(Costs.Select(cost => cost.Clone(flatMapper)))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class ObjectReferenceEqualityComparer<T> : EqualityComparer<T>
|
||||
where T : class
|
||||
{
|
||||
public override bool Equals(T x, T y)
|
||||
{
|
||||
return ReferenceEquals(x, y);
|
||||
}
|
||||
|
||||
public override int GetHashCode(T obj)
|
||||
{
|
||||
return RuntimeHelpers.GetHashCode(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UCalc.Data
|
||||
{
|
||||
public class RecentlyOpenedItem
|
||||
{
|
||||
public string DisplayText { get; }
|
||||
public string Path { get; }
|
||||
|
||||
public RecentlyOpenedItem(string path)
|
||||
{
|
||||
DisplayText = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
Path = path;
|
||||
}
|
||||
|
||||
private bool Equals(RecentlyOpenedItem other)
|
||||
{
|
||||
return DisplayText == other.DisplayText && Path == other.Path;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj.GetType() == GetType() && Equals((RecentlyOpenedItem) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(DisplayText, Path);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return DisplayText;
|
||||
}
|
||||
}
|
||||
|
||||
public class RecentlyOpenedList : ICollection<RecentlyOpenedItem>
|
||||
{
|
||||
private readonly List<RecentlyOpenedItem> _list;
|
||||
|
||||
public RecentlyOpenedList()
|
||||
{
|
||||
_list = new List<RecentlyOpenedItem>();
|
||||
}
|
||||
|
||||
public IEnumerator<RecentlyOpenedItem> GetEnumerator()
|
||||
{
|
||||
return _list.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _list.GetEnumerator();
|
||||
}
|
||||
|
||||
public void Add(RecentlyOpenedItem item)
|
||||
{
|
||||
var index = _list.IndexOf(item);
|
||||
if (index != -1)
|
||||
{
|
||||
_list.RemoveAt(index);
|
||||
}
|
||||
|
||||
_list.Insert(0, item);
|
||||
|
||||
if (_list.Count > 10)
|
||||
{
|
||||
_list.RemoveAt(10);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_list.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(RecentlyOpenedItem item)
|
||||
{
|
||||
return _list.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(RecentlyOpenedItem[] array, int arrayIndex)
|
||||
{
|
||||
_list.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public bool Remove(RecentlyOpenedItem item)
|
||||
{
|
||||
return _list.Remove(item);
|
||||
}
|
||||
|
||||
public int Count => _list.Count;
|
||||
public bool IsReadOnly => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<Window x:Class="UCalc.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:UCalc"
|
||||
mc:Ignorable="d"
|
||||
Title="MietRechner"
|
||||
Height="400"
|
||||
Width="500"
|
||||
ResizeMode="CanMinimize">
|
||||
|
||||
<Grid>
|
||||
<Viewbox Grid.Row="0" Grid.Column="0" Stretch="Fill">
|
||||
<Canvas Width="100" Height="100">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0" />
|
||||
</Canvas.RenderTransform>
|
||||
<Canvas>
|
||||
<Path Fill="{x:Static local:Constants.SubMainColor}"
|
||||
StrokeThickness="0.799393">
|
||||
<Path.Data>
|
||||
<PathGeometry
|
||||
Figures="M 82.566406 153.03906 A 165.91754 70.963213 0 0 0 0 162.45312 L 0 285.55078 L 0 377.85742 L 377.95312 377.85742 L 377.95312 193.28125 A 165.91754 70.963214 0 0 1 323.16016 197.26367 A 165.91754 70.963214 0 0 1 200.41016 174.04297 A 165.91754 70.963213 0 0 0 82.580078 153.03906 A 165.91754 70.963213 0 0 0 82.566406 153.03906 z "
|
||||
FillRule="NonZero" />
|
||||
</Path.Data>
|
||||
<Path.RenderTransform>
|
||||
<ScaleTransform ScaleX="0.26458333" ScaleY="0.26458333" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Canvas>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Margin="100, 180, 100, 0">
|
||||
|
||||
<Button MinHeight="40"
|
||||
Margin="0, 0, 0, 12"
|
||||
Click="OnNewClick">
|
||||
|
||||
<DockPanel>
|
||||
<Viewbox DockPanel.Dock="Left" Width="16" Height="16" Stretch="Uniform">
|
||||
<Canvas Width="384" Height="512">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0" />
|
||||
</Canvas.RenderTransform>
|
||||
<Path Fill="{x:Static local:Constants.SubMainColor}">
|
||||
<Path.Data>
|
||||
<PathGeometry
|
||||
Figures="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"
|
||||
FillRule="NonZero" />
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
|
||||
<Label Content="Neue Abrechnung anlegen"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}"/>
|
||||
</DockPanel>
|
||||
|
||||
</Button>
|
||||
|
||||
<Button MinHeight="40"
|
||||
PreviewMouseUp="OnOpenClick">
|
||||
|
||||
<DockPanel>
|
||||
<Viewbox DockPanel.Dock="Left" Width="16" Height="16" Stretch="Uniform">
|
||||
<Canvas Width="576" Height="512">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0" />
|
||||
</Canvas.RenderTransform>
|
||||
<Path Fill="{x:Static local:Constants.SubMainColor}">
|
||||
<Path.Data>
|
||||
<PathGeometry
|
||||
Figures="M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"
|
||||
FillRule="NonZero" />
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
|
||||
<Label Content="Abrechnung öffnen"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}"/>
|
||||
</DockPanel>
|
||||
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<ContextMenu.ItemsSource>
|
||||
<CompositeCollection>
|
||||
<MenuItem Header="Computer durchsuchen"
|
||||
Click="OnOpenFromDiskClick" />
|
||||
<MenuItem Header="- Zuletzt geöffnet -" IsEnabled="False" />
|
||||
|
||||
<CollectionContainer
|
||||
Collection="{Binding Source={x:Static local:App.RecentlyOpenedList}}" />
|
||||
</CompositeCollection>
|
||||
</ContextMenu.ItemsSource>
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem">
|
||||
<EventSetter Event="Click" Handler="OnOpenRecentClick" />
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
|
||||
</Button>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace UCalc
|
||||
{
|
||||
public partial class MainWindow
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnNewClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newWindow = new NewWindow {Owner = this};
|
||||
|
||||
if (newWindow.ShowDialog() == true)
|
||||
{
|
||||
new BillingWindow(newWindow.SavedBilling, newWindow.Billing).Show();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOpenClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.RecentlyOpenedList.Count == 0)
|
||||
{
|
||||
OnOpenFromDiskClick(null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var button = (Button) sender;
|
||||
var contextMenu = button.ContextMenu;
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
contextMenu.PlacementTarget = button;
|
||||
contextMenu.Placement = PlacementMode.Bottom;
|
||||
contextMenu.IsOpen = true;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnOpenFromDiskClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog {Filter = "MietRechner Datei (*.mr) | *.mr"};
|
||||
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (e != null)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOpenRecentClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<Window x:Class="UCalc.NewWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:UCalc"
|
||||
mc:Ignorable="d"
|
||||
Title="Neue Abrechnung anlegen"
|
||||
SizeToContent="WidthAndHeight"
|
||||
ShowInTaskbar="False"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
PreviewMouseUp="OnPreviewMouseUp">
|
||||
|
||||
<StackPanel Margin="12">
|
||||
|
||||
<Label Content="Geben Sie den Zeitraum ein, für den die neue Abrechnung gelten soll."
|
||||
Margin="0, 0, 0, 12"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
|
||||
<Grid Margin="0, 0, 0, 12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0"
|
||||
Margin="0, 0, 6, 0">
|
||||
<Label Content="Startdatum:"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
<Calendar Name="StartCalendar"
|
||||
IsTodayHighlighted="False" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1"
|
||||
Margin="6, 0, 0, 0">
|
||||
<Label Content="Enddatum:"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
<Calendar Name="EndCalendar"
|
||||
IsTodayHighlighted="False" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Name="ReuseDataCheckBox"
|
||||
Content="Daten von bereits vorhandener Abrechnung übernehmen"
|
||||
Margin="0, 0, 0, 12"
|
||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||
|
||||
<DockPanel Margin="22, 0, 22, 12">
|
||||
<Button DockPanel.Dock="Right"
|
||||
Content="..."
|
||||
Margin="6, 0, 0, 0"
|
||||
Width="30"
|
||||
IsEnabled="{Binding IsChecked, ElementName=ReuseDataCheckBox}"
|
||||
Click="OnBrowseClick"/>
|
||||
|
||||
<ComboBox Name="ReuseDataComboBox"
|
||||
IsEnabled="{Binding IsChecked, ElementName=ReuseDataCheckBox}"
|
||||
ItemsSource="{x:Static local:App.RecentlyOpenedList}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Content="{Binding DisplayText}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</DockPanel>
|
||||
|
||||
<Separator Margin="0, 0, 0, 12" />
|
||||
|
||||
<DockPanel LastChildFill="False">
|
||||
<Button DockPanel.Dock="Right"
|
||||
MinWidth="100"
|
||||
MinHeight="24"
|
||||
Content="Erstellen"
|
||||
Click="OnCreateClick"/>
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Window>
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Win32;
|
||||
using UCalc.Data;
|
||||
|
||||
namespace UCalc
|
||||
{
|
||||
public partial class NewWindow
|
||||
{
|
||||
public Billing SavedBilling { get; private set; }
|
||||
public Billing Billing { get; private set; }
|
||||
|
||||
public NewWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnBrowseClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog {Filter = "MietRechner Datei (*.mr) | *.mr"};
|
||||
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
App.RecentlyOpenedList.Add(new RecentlyOpenedItem(dialog.FileName));
|
||||
ReuseDataComboBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCreateClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (StartCalendar.SelectedDate == null)
|
||||
{
|
||||
MessageBox.Show("Wählen Sie ein Startdatum für die Abrechnung aus!", "Fehlende Eingabe",
|
||||
MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (EndCalendar.SelectedDate == null)
|
||||
{
|
||||
MessageBox.Show("Wählen Sie ein Enddatum für die Abrechnung aus!", "Fehlende Eingabe",
|
||||
MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (StartCalendar.SelectedDate >= EndCalendar.SelectedDate)
|
||||
{
|
||||
MessageBox.Show("Das Enddatum ist ungültig!", "Ungültige Eingabe", MessageBoxButton.OK,
|
||||
MessageBoxImage.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ReuseDataCheckBox.IsChecked == true)
|
||||
{
|
||||
if (ReuseDataComboBox.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Wählen Sie die Abrechnung, von der Daten übernommen werden sollen!",
|
||||
"Ungültige Eingabe", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
/*billing = new Billing();
|
||||
string fileName = (string) ((ComboBoxItem) LoadCombobox.SelectedItem).Tag;
|
||||
if (!billing.LoadFromFile(fileName))
|
||||
{
|
||||
MessageBox.Show("Die Datei \"" + fileName + "\" konnte nicht geladen werden!", "Fehler!",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
billing = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove depatured renters and costs that were only paid once
|
||||
string summary = "";
|
||||
billing.StartDate = (DateTime) StartCalendar.SelectedDate;
|
||||
billing.EndDate = (DateTime) EndCalendar.SelectedDate;
|
||||
|
||||
for (int i = 0; i < billing.Renters.Count;)
|
||||
{
|
||||
Renter renter = billing.Renters[i];
|
||||
if (renter.DepartureDate != null && renter.DepartureDate < billing.StartDate)
|
||||
{
|
||||
summary += "- Mieter \"" + renter.Name + "\" wurde entfernt, da er ausgezogen ist.\n";
|
||||
foreach (Cost cost in billing.Costs)
|
||||
{
|
||||
cost.AffectedRenters.Remove(renter);
|
||||
}
|
||||
|
||||
billing.Renters.Remove(renter);
|
||||
continue;
|
||||
}
|
||||
else if (renter.EntryDate != null && renter.EntryDate <= billing.StartDate)
|
||||
{
|
||||
summary += "- Das Einzugsdatum von Mieter \"" + renter.Name + "\" wurde entfernt.\n";
|
||||
renter.EntryDate = null;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (summary != "")
|
||||
MessageBox.Show("Die folgenden Änderungen wurden beim Übernehmen vorgenommen:\n" + summary,
|
||||
"Information", MessageBoxButton.OK, MessageBoxImage.Information);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
SavedBilling = new Billing();
|
||||
Billing = new Billing
|
||||
{
|
||||
StartDate = StartCalendar.SelectedDate.Value,
|
||||
EndDate = EndCalendar.SelectedDate.Value
|
||||
};
|
||||
}
|
||||
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseUp(e);
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
if (Mouse.Captured is Calendar || Mouse.Captured is System.Windows.Controls.Primitives.CalendarItem)
|
||||
{
|
||||
Mouse.Capture(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controls"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="BillingWindow.xaml">
|
||||
<Generator></Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="BillingWindow.xaml.cs">
|
||||
<DependentUpon>BillingWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user