mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
project: reorganize the structure of the project.
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
parent
96e60da7ad
commit
96d4150d26
319 changed files with 37 additions and 53 deletions
74
src/ViewModels/Statistics.cs
Normal file
74
src/ViewModels/Statistics.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia.Threading;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Statistics : ObservableObject
|
||||
{
|
||||
public bool IsLoading
|
||||
{
|
||||
get => _isLoading;
|
||||
private set => SetProperty(ref _isLoading, value);
|
||||
}
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get => _selectedIndex;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _selectedIndex, value))
|
||||
RefreshReport();
|
||||
}
|
||||
}
|
||||
|
||||
public Models.StatisticsReport SelectedReport
|
||||
{
|
||||
get => _selectedReport;
|
||||
private set => SetProperty(ref _selectedReport, value);
|
||||
}
|
||||
|
||||
public Statistics(string repo)
|
||||
{
|
||||
_repo = repo;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var result = new Commands.Statistics(_repo).Result();
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
_data = result;
|
||||
RefreshReport();
|
||||
IsLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void RefreshReport()
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
|
||||
switch (_selectedIndex)
|
||||
{
|
||||
case 0:
|
||||
SelectedReport = _data.Year;
|
||||
break;
|
||||
case 1:
|
||||
SelectedReport = _data.Month;
|
||||
break;
|
||||
default:
|
||||
SelectedReport = _data.Week;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string _repo = string.Empty;
|
||||
private bool _isLoading = true;
|
||||
private Models.Statistics _data = null;
|
||||
private Models.StatisticsReport _selectedReport = null;
|
||||
private int _selectedIndex = 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue