diff --git a/UI/Models/DetailPageModel.cs b/UI/Models/DetailPageModel.cs index 408ba78656cb8082677ee87cf6934c671faf7492..7ca16c93d664002803859e29a8dc56c51c4daa4b 100644 --- a/UI/Models/DetailPageModel.cs +++ b/UI/Models/DetailPageModel.cs @@ -67,5 +67,17 @@ namespace UI.Models private Visibility CancelBlockBtnVisibility_ = Visibility.Collapsed; public Visibility CancelBlockBtnVisibility { get { return CancelBlockBtnVisibility_; } set { CancelBlockBtnVisibility_ = value; OnPropertyChanged(); } } + + private string TodayTime_; + /// + /// 今日使用时长 + /// + public string TodayTime { get { return TodayTime_; } set { TodayTime_ = value; OnPropertyChanged(); } } + + private string Yesterday_; + /// + /// 相比昨日 + /// + public string Yesterday { get { return Yesterday_; } set { Yesterday_ = value; OnPropertyChanged(); } } } } diff --git a/UI/ViewModels/DetailPageVM.cs b/UI/ViewModels/DetailPageVM.cs index 70a3ba01afb4bf2e80d8f96d2d966910ac4be840..234729e33ed6b98ee20623d9974a07806cef71d1 100644 --- a/UI/ViewModels/DetailPageVM.cs +++ b/UI/ViewModels/DetailPageVM.cs @@ -3,9 +3,11 @@ using Core.Models.Config; using Core.Servicers.Interfaces; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using UI.Controls; using UI.Controls.Charts.Model; using UI.Librays; @@ -22,7 +24,7 @@ namespace UI.ViewModels private ConfigModel config; public Command BlockActionCommand { get; set; } public Command ClearSelectMonthDataCommand { get; set; } - + public Command InfoMenuActionCommand { get; set; } public DetailPageVM( IData data, MainViewModel main, IAppConfig appConfig) { @@ -32,7 +34,7 @@ namespace UI.ViewModels BlockActionCommand = new Command(new Action(OnBlockActionCommand)); ClearSelectMonthDataCommand = new Command(new Action(OnClearSelectMonthDataCommand)); - + InfoMenuActionCommand = new Command(new Action(OnInfoMenuActionCommand)); Init(); } @@ -53,6 +55,29 @@ namespace UI.ViewModels await LoadInfo(); } + private void OnInfoMenuActionCommand(object obj) + { + switch (obj.ToString()) + { + case "copy processname": + Clipboard.SetText(ProcessName); + + break; + case "copy process file": + Clipboard.SetText(Process.PopupText); + break; + case "open dir": + if (File.Exists(Process.PopupText)) + { + System.Diagnostics.Process.Start("explorer.exe", "/select, " + Process.PopupText); + } + else + { + main.Toast("进程文件似乎不存在", Controls.Base.IconTypes.Blocked); + } + break; + } + } private async void OnClearSelectMonthDataCommand(object obj) { @@ -98,6 +123,48 @@ namespace UI.ViewModels // 判断是否是忽略的进程 IsIgnore = config.Behavior.IgnoreProcessList.Contains(ProcessName); } + + var today = data.GetProcess(ProcessName, DateTime.Now); + var yesterday = data.GetProcess(ProcessName, DateTime.Now.AddDays(-1)); + + if (today != null) + { + TodayTime = Timer.Fromat(today.Time); + } + else + { + TodayTime = "暂无数据"; + } + + if (yesterday != null) + { + int diffseconds = today != null ? today.Time - yesterday.Time : yesterday.Time; + + string diffText = string.Empty; + if (diffseconds != yesterday.Time) + { + if (diffseconds == 0) + { + // 无变化 + diffText = "持平"; + } + else if (diffseconds > 0) + { + // 增加 + diffText = "增加了" + Timer.Fromat(diffseconds); + } + else + { + // 减少 + diffText = "减少了" + Timer.Fromat(Math.Abs(diffseconds)); + } + } + Yesterday = diffseconds == yesterday.Time ? "减少100%" : diffText; + } + else + { + Yesterday = "昨日未使用"; + } } } ); @@ -158,6 +225,7 @@ namespace UI.ViewModels data.Clear(ProcessName, Process.PopupText, Date); await LoadData(); + await LoadInfo(); main.Toast("已清空"); } } diff --git a/UI/Views/DetailPage.xaml b/UI/Views/DetailPage.xaml index 8b463064d28dd864e878b9e686be372a44ccd4a3..a103de1164e886f3329211e2c0ac04d99e14ee57 100644 --- a/UI/Views/DetailPage.xaml +++ b/UI/Views/DetailPage.xaml @@ -19,6 +19,13 @@ Background="White" CornerRadius="12" Padding="0,20"> + + + + + + + @@ -51,12 +58,35 @@ + + Margin="0,10,0,0"> + + + + + + + + + + + + + + + + + +