Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FinTrack/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Application x:Class="FinTrackForWindows.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FinTrackForWindows">
xmlns:local="clr-namespace:FinTrackForWindows"
ShutdownMode="OnExplicitShutdown">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
13 changes: 13 additions & 0 deletions FinTrack/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
using FinTrackForWindows.Services;
using FinTrackForWindows.Services.Accounts;
using FinTrackForWindows.Services.Api;
using FinTrackForWindows.Services.AppInNotifications;
using FinTrackForWindows.Services.Budgets;
using FinTrackForWindows.Services.Camera;
using FinTrackForWindows.Services.Currencies;
using FinTrackForWindows.Services.Debts;
using FinTrackForWindows.Services.Memberships;
using FinTrackForWindows.Services.Reports;
using FinTrackForWindows.Services.Transactions;
using FinTrackForWindows.Services.Users;
using FinTrackForWindows.ViewModels;
using FinTrackForWindows.Views;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -88,8 +91,12 @@ private void ConfigureServices(IServiceCollection services)
services.AddSingleton<ICurrenciesStore, CurrenciesStore>();
services.AddSingleton<IMembershipStore, MembershipStore>();
services.AddSingleton<IDebtStore, DebtStore>();
services.AddSingleton<IReportStore, ReportStore>();
services.AddSingleton<IUserStore, UserStore>();

services.AddTransient<ICameraService, CameraService>();

services.AddSingleton<IAppInNotificationService, AppInNotificationService>();
}

protected override async void OnStartup(StartupEventArgs e)
Expand Down Expand Up @@ -126,11 +133,17 @@ private void SetupGlobalExceptionHandling()

protected override async void OnExit(ExitEventArgs e)
{
var notificationService = _host.Services.GetService<IAppInNotificationService>();
notificationService?.Dispose();

using (_host)
{
await _host.StopAsync(TimeSpan.FromSeconds(5));
_host.Dispose();
}

base.OnExit(e);
}

}
}
1 change: 1 addition & 0 deletions FinTrack/Dtos/BudgetDtos/BudgetCreateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class BudgetCreateDto
public string? Description { get; set; }
public string Category { get; set; } = null!;
public decimal AllocatedAmount { get; set; }
public decimal? ReachedAmount { get; set; }
public BaseCurrencyType Currency { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
Expand Down
1 change: 1 addition & 0 deletions FinTrack/Dtos/BudgetDtos/BudgetDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class BudgetDto
public string? Description { get; set; }
public string Category { get; set; } = null!;
public decimal AllocatedAmount { get; set; }
public decimal? ReachedAmount { get; set; }
public BaseCurrencyType Currency { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
Expand Down
1 change: 1 addition & 0 deletions FinTrack/Dtos/BudgetDtos/BudgetUpdateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class BudgetUpdateDto
public string? Description { get; set; }
public string Category { get; set; } = null!;
public decimal AllocatedAmount { get; set; }
public decimal? ReachedAmount { get; set; }
public BaseCurrencyType Currency { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions FinTrack/Dtos/BudgetDtos/BudgetUpdateReachedAmountDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace FinTrackForWindows.Dtos.BudgetDtos
{
public class BudgetUpdateReachedAmountDto
{
public int BudgetId { get; set; }
public decimal? ReachedAmount { get; set; }
}
}
3 changes: 1 addition & 2 deletions FinTrack/Dtos/UserProfileDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ public class UserProfileDto
public int Id { get; set; }
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string ProfilePicture { get; set; } = string.Empty;
public string Role { get; set; } = string.Empty;
public string? ProfilePicture { get; set; }
public string MembershipType { get; set; } = string.Empty;
}
}
File renamed without changes.
12 changes: 12 additions & 0 deletions FinTrack/FinTrackForWindows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Services\EmailService\**" />
<Compile Remove="Services\NotificationTemplates\**" />
<EmbeddedResource Remove="Services\EmailService\**" />
<EmbeddedResource Remove="Services\NotificationTemplates\**" />
<None Remove="Services\EmailService\**" />
<None Remove="Services\NotificationTemplates\**" />
<Page Remove="Services\EmailService\**" />
<Page Remove="Services\NotificationTemplates\**" />
</ItemGroup>

<ItemGroup>
<None Remove="Assets\Images\chatbot.png" />
<None Remove="Assets\Images\Icons\add.png" />
Expand Down Expand Up @@ -57,6 +68,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.6.25358.103" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Notifications.Wpf" Version="0.1.1" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="ReactiveUI.WPF" Version="20.4.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.1-dev-02307" />
Expand Down
82 changes: 82 additions & 0 deletions FinTrack/Helpers/AutoScrollBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;

namespace FinTrackForWindows.Helpers
{
public static class AutoScrollBehavior
{
public static readonly DependencyProperty AutoScrollProperty =
DependencyProperty.RegisterAttached(
"AutoScroll",
typeof(bool),
typeof(AutoScrollBehavior),
new PropertyMetadata(false, OnAutoScrollPropertyChanged));

public static void SetAutoScroll(DependencyObject obj, bool value)
{
obj.SetValue(AutoScrollProperty, value);
}

public static bool GetAutoScroll(DependencyObject obj)
{
return (bool)obj.GetValue(AutoScrollProperty);
}

private static void OnAutoScrollPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not ScrollViewer scrollViewer)
{
return;
}

if ((bool)e.NewValue)
{
scrollViewer.ScrollToBottom();

if (FindItemsControl(scrollViewer) is { } itemsControl &&
itemsControl.ItemsSource is INotifyCollectionChanged collection)
{
collection.CollectionChanged += (s, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Add)
{
scrollViewer.ScrollToBottom();
}
};
}
}
}

private static ItemsControl? FindItemsControl(DependencyObject parent)
{
if (parent == null) return null;

if (parent is ItemsControl itemsControl)
{
return itemsControl;
}

if (parent is ContentPresenter contentPresenter)
{
if (contentPresenter.Content is ItemsControl ic)
{
return ic;
}
}

if (parent is Panel panel)
{
foreach (var child in panel.Children)
{
if (child is ItemsControl ic)
{
return ic;
}
}
}

return null;
}
}
}
26 changes: 24 additions & 2 deletions FinTrack/Helpers/BooleanToVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@

namespace FinTrackForWindows.Helpers
{
[ValueConversion(typeof(bool), typeof(Visibility))]
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (value is bool b && b) ? Visibility.Collapsed : Visibility.Visible;
bool boolValue = false;
if (value is bool b)
{
boolValue = b;
}

if (parameter != null && (parameter.ToString().Equals("invert", StringComparison.OrdinalIgnoreCase) ||
parameter.ToString().Equals("true", StringComparison.OrdinalIgnoreCase)))
{
boolValue = !boolValue;
}

return boolValue ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
if (value is Visibility visibility && visibility == Visibility.Visible)
{
if (parameter != null && (parameter.ToString().Equals("invert", StringComparison.OrdinalIgnoreCase) ||
parameter.ToString().Equals("true", StringComparison.OrdinalIgnoreCase)))
{
return false;
}
return true;
}
return false;
}
}
}
14 changes: 12 additions & 2 deletions FinTrack/Helpers/EqualityToBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
Expand All @@ -7,10 +8,19 @@ public class EqualityToBooleanConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null || values.Length < 2 || values[0] == null || values[1] == null)
if (values.Any(v => v == null || v == DependencyProperty.UnsetValue))
{
return false;
}

return values[0].Equals(values[1]);
for (int i = 1; i < values.Length; i++)
{
if (!object.Equals(values[0], values[i]))
{
return false;
}
}
return true;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
Expand Down
23 changes: 23 additions & 0 deletions FinTrack/Helpers/ValueToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
{
public class ValueToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double number && number > 0)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
22 changes: 22 additions & 0 deletions FinTrack/Helpers/VideoStatusConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Globalization;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
{
public class VideoStatusConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int?)
{
return (int?)value != null ? "Uploaded" : "Not Uploaded";
}
return "Unknown";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
35 changes: 31 additions & 4 deletions FinTrack/Models/Budget/BudgetModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ public partial class BudgetModel : ObservableObject
private decimal currentAmount;

[ObservableProperty]
private BaseCurrencyType currency = BaseCurrencyType.USD;
[NotifyPropertyChangedFor(nameof(ProgressValue))]
[NotifyPropertyChangedFor(nameof(ProgressText))]
private decimal? reachedAmount;

[ObservableProperty]
private bool isEditingReachedAmount = false;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressText))]
[NotifyPropertyChangedFor(nameof(ReachedAmountDisplayText))]
private BaseCurrencyType currency;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(RemainingTimeText))]
Expand All @@ -39,14 +49,31 @@ public partial class BudgetModel : ObservableObject
[NotifyPropertyChangedFor(nameof(RemainingTimeText))]
private DateTime endDate = DateTime.Today.AddMonths(1);

public double ProgressValue => AllocatedAmount <= 0 ? 0 : Math.Max(0, Math.Min(100, (double)(CurrentAmount / AllocatedAmount) * 100));
public double ProgressValue => AllocatedAmount <= 0 ? 0 : Math.Max(0, Math.Min(100, (double)((ReachedAmount ?? 0) / AllocatedAmount) * 100));

public string ProgressText
{
get
{
var culture = new CultureInfo("tr-TR");
return $"{CurrentAmount.ToString("C", culture)} / {AllocatedAmount.ToString("C", culture)}";
var current = ReachedAmount ?? 0;
string currencyCode = Currency.ToString();
var culture = CultureInfo.CurrentCulture;

string currentText = current.ToString("N2", culture);
string allocatedText = AllocatedAmount.ToString("N2", culture);

return $"{currentText} {currencyCode} / {allocatedText} {currencyCode}";
}
}

public string ReachedAmountDisplayText
{
get
{
var current = ReachedAmount ?? 0;
string currencyCode = Currency.ToString();
var culture = CultureInfo.CurrentCulture;
return $"{current.ToString("N2", culture)} {currencyCode}";
}
}

Expand Down
Loading
Loading