-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from DSaladinCH/develop
Develop
- Loading branch information
Showing
23 changed files
with
563 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace DSaladin.SpeedTime.Converter | ||
{ | ||
internal class ListToGenericListConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
// If the value is already a List<object>, just return it | ||
if (value is List<object> objList) | ||
{ | ||
return objList; | ||
} | ||
|
||
// Otherwise, try to convert any IEnumerable to List<object> | ||
return value is IEnumerable enumerable ? enumerable.Cast<object>().ToList() : value; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using DSaladin.SpeedTime.Model.Settings; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace DSaladin.SpeedTime.Converter | ||
{ | ||
internal class SettingCategoryConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return GetEnumDescription((SettingCategory)value); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public static string GetEnumDescription(Enum value) | ||
{ | ||
FieldInfo? fi = value.GetType().GetField(value.ToString()); | ||
|
||
if (fi is not null && fi.GetCustomAttributes(typeof(DescriptionAttribute), false) is DescriptionAttribute[] attributes && attributes.Any()) | ||
return Language.SpeedTime.ResourceManager.GetString(attributes.First().Description, Language.SpeedTime.Culture) ?? value.ToString(); | ||
|
||
return value.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using DSaladin.SpeedTime.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DSaladin.SpeedTime | ||
{ | ||
internal class TimeTrackerContext : DbContext | ||
{ | ||
public DbSet<TrackTime> TrackedTimes { get; set; } | ||
public DbSet<TrackAttribute> TrackAttributes { get; set; } | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
optionsBuilder.UseSqlite("Data Source=timetracker.db"); | ||
optionsBuilder.UseLazyLoadingProxies(); | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
// Define composite primary key for TrackAttribute | ||
modelBuilder.Entity<TrackAttribute>() | ||
.HasKey(t => new { t.TrackTimeId, t.Name }); | ||
|
||
// Define relationship between TrackTime and TrackAttribute | ||
modelBuilder.Entity<TrackAttribute>() | ||
.HasOne(ta => ta.TrackTime) | ||
.WithMany(tt => tt.Attributes) | ||
.HasForeignKey(ta => ta.TrackTimeId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.