Skip to content

Commit

Permalink
Merge pull request #17 from DSaladinCH/develop
Browse files Browse the repository at this point in the history
Work Hours Statistics
  • Loading branch information
DominicSaladin authored Oct 18, 2023
2 parents e478344 + da608e0 commit a81f86b
Show file tree
Hide file tree
Showing 15 changed files with 530 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# time-tracker
# Speed Time
20 changes: 16 additions & 4 deletions speed-time/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using DSaladin.SpeedTime.Dialogs;
using DSaladin.SpeedTime.Model;
using GlobalHotKey;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using Microsoft.EntityFrameworkCore;
using Microsoft.Win32;
using System;
Expand Down Expand Up @@ -73,6 +75,11 @@ protected override async void OnStartup(StartupEventArgs e)

base.OnStartup(e);

LiveCharts.Configure(config =>
{
config.AddDarkTheme();
});

MainWindow mainWindow = new();
mainWindow.Show();
}
Expand Down Expand Up @@ -165,11 +172,16 @@ internal static async Task CheckForUpdate()
if (File.Exists(exeFile))
File.Delete(exeFile);

HttpRequestMessage requestMessage = new(HttpMethod.Get, $"https://api.dsaladin.dev/v1/product/{ProductId}/versions?fromVersion={Assembly.GetExecutingAssembly().GetName().Version!}");
HttpResponseMessage responseMessage = await new HttpClient().SendAsync(requestMessage);
if (!responseMessage.IsSuccessStatusCode)
return;
HttpRequestMessage requestMessage = new(HttpMethod.Get, $"https://apii.dsaladin.dev/v1/product/{ProductId}/versions?fromVersion={Assembly.GetExecutingAssembly().GetName().Version!}");

HttpResponseMessage responseMessage;
try
{
responseMessage = await new HttpClient().SendAsync(requestMessage);
if (!responseMessage.IsSuccessStatusCode)
return;
}
catch { return; }

List<AppVersion>? versions = await System.Text.Json.JsonSerializer.DeserializeAsync<List<AppVersion>>(responseMessage.Content.ReadAsStream());
if (versions is null || versions.Count == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

namespace DSaladin.SpeedTime.Converter
{
internal class SettingCategoryConverter : IValueConverter
internal class TranslatedEnumConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return GetEnumDescription((SettingCategory)value);
return GetEnumDescription((Enum)value);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
66 changes: 66 additions & 0 deletions speed-time/Dialogs/TimeStatistics.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<potato:DSDialogControl x:Class="DSaladin.SpeedTime.Dialogs.TimeStatistics"
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:potato="https://dsaladin.dev/products/fancypotato/wpf/xaml"
xmlns:fa="https://dsaladin.dev/products/fontawesome/wpf/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:language="clr-namespace:DSaladin.SpeedTime.Language"
xmlns:converter="clr-namespace:DSaladin.SpeedTime.Converter"
xmlns:local="clr-namespace:DSaladin.SpeedTime.Dialogs"
d:DataContext="{d:DesignInstance local:TimeStatistics}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" MinHeight="300" MinWidth="400" MaxHeight="600">
<potato:DSDialogControl.Resources>
<converter:TranslatedEnumConverter x:Key="TranslatedEnumConverter" />
</potato:DSDialogControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="25" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="60" />
</Grid.ColumnDefinitions>

<potato:DSButton Grid.Column="0" fa:Content.Icon="SolidArrowLeft" FontSize="15" FontWeight="Bold"
HorizontalAlignment="Center" Style="{DynamicResource TransparentButton}" Click="Close_Click" />
<Label Grid.Column="1" Content="{x:Static language:SpeedTime.statistics_title}" FontSize="20" FontWeight="Bold" HorizontalAlignment="Center" />
</Grid>
<Grid Grid.Row="1" Width="250">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="35" />
</Grid.ColumnDefinitions>
<potato:DSButton Grid.Column="0" fa:Content.Icon="SolidChevronLeft" Style="{DynamicResource TransparentAccentButton}" Padding="0,0,0,0"
Command="{Binding GroupingBackCommand}" FontSize="10" />
<Label Grid.Column="1" Content="{Binding RangeGrouping, Converter={StaticResource TranslatedEnumConverter}}" Style="{DynamicResource Title5Label}" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center" Padding="0,0,0,0" />
<potato:DSButton Grid.Column="2" fa:Content.Icon="SolidChevronRight" Style="{DynamicResource TransparentAccentButton}" Padding="0,0,0,0"
Command="{Binding GroupingNextCommand}" FontSize="10" />
</Grid>
<Grid Grid.Row="2" Width="350">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="35" />
</Grid.ColumnDefinitions>
<potato:DSButton Grid.Column="0" fa:Content.Icon="SolidChevronLeft" Style="{DynamicResource TransparentAccentButton}" Padding="0,0,0,0"
Command="{Binding RangeBackCommand}" />
<Label Grid.Column="1" Content="{Binding RangeDisplay}" Style="{DynamicResource Title4Label}" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center" Padding="0,0,0,0" />
<potato:DSButton Grid.Column="2" fa:Content.Icon="SolidChevronRight" Style="{DynamicResource TransparentAccentButton}" Padding="0,0,0,0"
Command="{Binding RangeNextCommand}" />
</Grid>
<Grid Grid.Row="3">
<lvc:CartesianChart Series="{Binding Series}" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}" />
</Grid>
</Grid>
</potato:DSDialogControl>
Loading

0 comments on commit a81f86b

Please sign in to comment.