Skip to content

Commit

Permalink
微调数据统计界面的UI
Browse files Browse the repository at this point in the history
  • Loading branch information
noberumotto committed Nov 18, 2021
1 parent b094b89 commit 98f7a9a
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 91 deletions.
1 change: 1 addition & 0 deletions src/Local/ProjectEye/Resources/Language/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,6 @@
<sys:String x:Key="Lang_StatisticsWindow">Statistics window</sys:String>
<sys:String x:Key="Lang_ExportMonthData">Export month data</sys:String>
<sys:String x:Key="Lang_Minimum">Minimum</sys:String>
<sys:String x:Key="Lang_Learnmore">Learn more</sys:String>

</ResourceDictionary>
7 changes: 4 additions & 3 deletions src/Local/ProjectEye/Resources/Language/zh.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@
<sys:String x:Key="Lang_Maximize">最大化</sys:String>
<sys:String x:Key="Lang_Restore">还原</sys:String>

<sys:String x:Key="Lang_Normal">正常</sys:String>
<sys:String x:Key="Lang_Busy">忙碌</sys:String>
<sys:String x:Key="Lang_Overload">超负荷</sys:String>
<sys:String x:Key="Lang_Normal">较少</sys:String>
<sys:String x:Key="Lang_Busy">较长!</sys:String>
<sys:String x:Key="Lang_Overload">超负荷!!!</sys:String>
<sys:String x:Key="Lang_Exhausted">疲劳</sys:String>
<sys:String x:Key="Lang_Goodjob">非常棒!已达成目标</sys:String>
<sys:String x:Key="Lang_Toooften">过于频繁</sys:String>
Expand Down Expand Up @@ -216,5 +216,6 @@
<sys:String x:Key="Lang_StatisticsWindow">数据统计窗口</sys:String>
<sys:String x:Key="Lang_ExportMonthData">导出本月数据</sys:String>
<sys:String x:Key="Lang_Minimum">最低</sys:String>
<sys:String x:Key="Lang_Learnmore">了解更多</sys:String>

</ResourceDictionary>
24 changes: 24 additions & 0 deletions src/Local/ProjectEye/Resources/Themes/Blue/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,28 @@

<Style x:Key="tip_yes" BasedOn="{StaticResource default}" TargetType="{x:Type controls:Project1UIButton}"></Style>
<Style x:Key="tip_no" BasedOn="{StaticResource basic}" TargetType="{x:Type controls:Project1UIButton}"></Style>


<Style x:Key="CustomButton" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<ContentPresenter Name="Presenter" Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
23 changes: 23 additions & 0 deletions src/Local/ProjectEye/Resources/Themes/Dark/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,27 @@

<Style x:Key="tip_yes" BasedOn="{StaticResource default}" TargetType="{x:Type controls:Project1UIButton}"></Style>
<Style x:Key="tip_no" BasedOn="{StaticResource basic}" TargetType="{x:Type controls:Project1UIButton}"></Style>

<Style x:Key="CustomButton" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<ContentPresenter Name="Presenter" Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
166 changes: 81 additions & 85 deletions src/Local/ProjectEye/ViewModels/StatisticViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using ProjectEye.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;

Expand All @@ -28,6 +29,7 @@ public class StatisticViewModel
public Command CloseOnboardingCommand { get; set; }
public Command GenerateMonthlyDataImgCommand { get; set; }
public Command exportDataCommand { get; set; }
public Command openURLCommand { get; set; }


public StatisticViewModel(
Expand All @@ -44,6 +46,7 @@ public StatisticViewModel(
CloseOnboardingCommand = new Command(new Action<object>(OnCloseOnboardingCommand));
GenerateMonthlyDataImgCommand = new Command(new Action<object>(OnGenerateMonthlyDataImgCommand));
exportDataCommand = new Command(new Action<object>(OnExportDataCommand));
openURLCommand = new Command(new Action<object>(OnOpenURLCommand));

Data = new StatisticModel();
Data.Year = DateTime.Now.Year;
Expand Down Expand Up @@ -93,6 +96,10 @@ private void OnCloseOnboardingCommand(object obj)
Data.IsShowOnboarding = false;
statistic.MigrateDone();
}
private void OnOpenURLCommand(object obj)
{
Process.Start(new ProcessStartInfo(obj.ToString()));
}

private void Data_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Expand Down Expand Up @@ -310,110 +317,99 @@ private void HandleWeekData()

private void Analysis()
{
//if (!config.options.General.IsWeekDataAnalysis)
//{
// //关闭了数据建议
// return;
//}
//本周天数
//int weekNum = (int)DateTime.Now.DayOfWeek;
int weekNum = Data.WeekTrueWorkDays;
//int weekNum = Data.WeekTrueWorkDays > 1 ? Data.WeekTrueWorkDays - 1 : Data.WeekTrueWorkDays;
////减去今日的数据
//var todayData = statistic.GetTodayData();
//Data.WeekWork = Data.WeekWork - todayData.WorkingTime;
//Data.WeekRest = Data.WeekRest - todayData.ResetTime;
//Data.WeekSkip = Data.WeekSkip - todayData.SkipCount;

Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
//本周平均每天工作时间

// 本周已过天数
//int weekNum = Data.WeekTrueWorkDays;
int weekNum = (int)DateTime.Now.DayOfWeek;
if (weekNum == 0)
{
weekNum = 7;
}

//本周平均工作时间
double weekWorkAverage = weekNum > 0 ? Data.WeekWork / weekNum : 0;

//工作时间
if (weekWorkAverage >= 3)
if (weekWorkAverage <= 8)
{
// 正常
Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
Data.WeekWorkLevel = 0;
}
else if (weekWorkAverage > 8 && weekWorkAverage < 10)
{
// 较长
Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Busy"]}";
Data.WeekWorkLevel = 1;

}
else
{
// 超负荷工作
Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Overload"]}";
Data.WeekWorkLevel = 2;
}


// 休息时间
if (weekWorkAverage <= 0)
{
Data.RestAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
Data.WeekRestLevel = 0;
}
else
{
// 按照20-20-20规则为基准每1小时至少休息1分钟
double avgRest = Data.WeekRest / Data.WeekWork;

//误差值
double errValue = 0;
//工作占用了生活时间的百分比
double worklifep = Math.Round((11 - (24 - 6 - weekWorkAverage)) / 11 * 100, 0);
//质量值,越小越好
double x = weekWorkAverage / 24 - errValue;

//非常健康
//double l1 = (double)3 / 24;
//很健康
double l2 = (double)5 / 24;
//普通正常人
double l3 = (double)7 / 24;
//较忙
double l4 = (double)9 / 24;
//很忙
double l5 = (double)11 / 24;
//非常忙
double l6 = (double)13 / 24;
//危险
double l7 = (double)15 / 24;

if (x >= l7)
if (avgRest >= 1)
{
Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Overload"]}";
// 达成目标
Data.RestAnalysis = $"{Application.Current.Resources["Lang_Goodjob"]}";
Data.WeekRestLevel = 3;
}
else if (x >= l4)
else if (avgRest >= 0.8)
{
Data.WorkAnalysis = $"{Application.Current.Resources["Lang_Busy"]}";
// 较少
Data.RestAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
Data.WeekRestLevel = 0;
}
else if (avgRest >= 0.6)
{
// 注意休息
Data.RestAnalysis = $"{Application.Current.Resources["Lang_Haveagoodrest"]}";
Data.WeekRestLevel = 1;
}
else
{
// 疲劳
Data.RestAnalysis = $"{Application.Current.Resources["Lang_Exhausted"]}";
Data.WeekRestLevel = 2;
}






}

Data.RestAnalysis = weekWorkAverage > 3 ? $"{Application.Current.Resources["Lang_Exhausted"]}" : $"{Application.Current.Resources["Lang_Normal"]}";
//休息时间
if (Data.WeekRest > 0 && weekWorkAverage > 0)
// 跳过次数,每1小时建议有3次休息

if (weekWorkAverage <= 0 || Data.WeekSkip <= 0)
{
//根据选项设置每日应休息时间(分钟)
double optionDayRestM = (int)((weekWorkAverage * 60) / config.options.General.WarnTime * config.options.General.RestTime / 60);
//本周的平均每日休息时间(分钟)
double dayRestM = Data.WeekRest / weekNum;
//是否达成目标
bool isReached = dayRestM >= optionDayRestM;
//百分比
//double reachedTTTP = Math.Round(dayRestM / optionDayRestM * 100, 0);
Data.RestAnalysis = isReached ? $"{Application.Current.Resources["Lang_Goodjob"]}" : $"{Application.Current.Resources["Lang_Haveagoodrest"]}";
//if (reachedTTTP < 100)
//{
// Data.RestAnalysis += $"根据20-20-20规则来看,您只达到了{reachedTTTP}%。";
//}
// 保持现状
Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Keepnow"]}";
Data.WeekSkipLevel = 2;
}

Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
//跳过次数
if (weekWorkAverage >= 1 && Data.WeekSkip > 0)
else
{
//根据设置每天应该休息的次数
double optionDayRestNum = (weekWorkAverage * 60) / config.options.General.WarnTime;
//根据设置每天建议休息至少一半的次数
double optionRecommendDayRestNum = optionDayRestNum / 2;
//当前每天跳过次数
double daySkipCount = Data.WeekSkip / Data.WeekTrueWorkDays;
//跳过的次数基于建议的百分比
double skipP = Math.Round(daySkipCount / optionRecommendDayRestNum * 100, 0);
if (daySkipCount > optionRecommendDayRestNum)
double skipRate = Data.WeekSkip / (Data.WeekWork * 3 / 2);
if (skipRate >= 0.45)
{
// 过于频繁
Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Toooften"]}";
}
else if (skipP < 10)
{
Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Keepnow"]}";
Data.WeekSkipLevel = 1;
}
else
{
//Data.SkipAnalysis = $"较为频繁,请减少跳过次数!您已接近建议的跳过次数{skipP}%,根据设置以及本周的工作时间,建议您每天的跳过次数应不超过{optionRecommendDayRestNum}次。";
Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Toooften"]}";
// 较少
Data.SkipAnalysis = $"{Application.Current.Resources["Lang_Normal"]}";
Data.WeekSkipLevel = 0;
}
}

Expand Down
Loading

0 comments on commit 98f7a9a

Please sign in to comment.