@@ -17,7 +17,6 @@ public partial class ControlPanel : Form
1717 private bool isClosable = false ;
1818
1919 private AppController appController ; //Controller for list and apps.
20- private TimeData timeData ; //The data of current aim.
2120 private bool isLoaded ; //Show the state of initialization.
2221 private bool isChangeable = true ;
2322 private List < Data . Task > tasks ;
@@ -163,8 +162,7 @@ private void EndTaskButton_Click(object sender, EventArgs e)
163162 {
164163 if ( taskListBox . SelectedIndex >= 0 )
165164 {
166- MessageBox . Show ( tasks [ taskListBox . SelectedIndex ] . EndTask ( ) ,
167- "任务结束" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
165+ tasks [ taskListBox . SelectedIndex ] . EndTask ( ) ;
168166 tasks . RemoveAt ( taskListBox . SelectedIndex ) ;
169167 }
170168 RefreshTasks ( ) ;
@@ -174,7 +172,11 @@ private void TaskStartButton_Click(object sender, EventArgs e)
174172 {
175173 if ( taskListBox . SelectedIndex >= 0 )
176174 {
177- tasks [ taskListBox . SelectedIndex ] . RunTask ( ) ;
175+ if ( tasks [ taskListBox . SelectedIndex ] . RunTask ( ) )
176+ {
177+ tasks . RemoveAt ( taskListBox . SelectedIndex ) ;
178+ }
179+ RefreshTasks ( ) ;
178180 }
179181 }
180182
@@ -202,18 +204,11 @@ private void StartLock(string unlockPasswordHash, int minutes = 0)
202204 {
203205 LockHelper . StartLock ( unlockPasswordHash , minutes ) ;
204206 int index = dataGridView . Rows . Add ( ) ;
205- ShowAndSave ( Lock . TempTimeSpan ) ;
206- }
207-
208- private void ShowAndSave ( TimeSpan timeSpan )
209- {
210- ResultWindow resultWindow = new ( timeSpan ) ;
211- resultWindow . ShowDialog ( ) ;
212- if ( ResultWindow . IsSave == true )
213- timeData . AddTime ( timeSpan ) ;
214207 RefreshAndSaveData ( ) ;
215208 }
216209
210+
211+
217212 private void WhiteProcessBox_TextChanged ( object sender , EventArgs e )
218213 {
219214 File . WriteAllText ( TCFile . WhiteAppLocation , whiteProcessBox . Text ) ;
@@ -238,7 +233,7 @@ private void InitializeDeepFocus()
238233 else
239234 {
240235 File . Delete ( TCFile . DeepTempTimeFile ) ;
241- ShowAndSave ( deepFocusTime ) ;
236+ LockHelper . ShowAndSave ( deepFocusTime ) ;
242237 RefreshAndSaveData ( ) ;
243238 }
244239 }
@@ -541,13 +536,13 @@ private void InitializeData()
541536 {
542537 if ( File . Exists ( TCFile . SavedData ) )
543538 {
544- timeData = TCFile . ReadTimeData ( ) ;
539+ LockHelper . TimeData = TCFile . ReadTimeData ( ) ;
545540 RefreshAndSaveData ( ) ;
546541 }
547542 else
548543 {
549544 Directory . CreateDirectory ( TCFile . SavedDataDir ) ;
550- timeData = new ( ) { GoalName = "FirstGoal" } ;
545+ LockHelper . TimeData = new ( ) { GoalName = "FirstGoal" } ;
551546 RefreshAndSaveData ( ) ;
552547 }
553548 }
@@ -557,23 +552,23 @@ private void RefreshAndSaveData()
557552 //刷新列表
558553 //普通屏保
559554 dataGridView . Rows . Clear ( ) ;
560- dataGridView . Rows . Add ( timeData . LockTime , "普通屏保" ) ;
555+ dataGridView . Rows . Add ( LockHelper . TimeData . LockTime , "普通屏保" ) ;
561556 //深度专注屏保
562- dataGridView . Rows . Add ( timeData . DeepLockTime , "深度专注屏保" ) ;
557+ dataGridView . Rows . Add ( LockHelper . TimeData . DeepLockTime , "深度专注屏保" ) ;
563558 //更新进度
564- ShowProgress ( timeData ) ;
559+ ShowProgress ( ) ;
565560 //保存
566- TCFile . SaveTimeData ( timeData ) ;
561+ TCFile . SaveTimeData ( LockHelper . TimeData ) ;
567562 }
568563
569564 #endregion DataPage
570565
571566 #region ProgressPage
572567
573- private void ShowProgress ( TimeData timeData )
568+ private void ShowProgress ( )
574569 {
575- goalLabel . Text = timeData . GoalName ;
576- TimeSpan timeSpan = timeData . GetTimeSum ( ) ;
570+ goalLabel . Text = LockHelper . TimeData . GoalName ;
571+ TimeSpan timeSpan = LockHelper . TimeData . GetTimeSum ( ) ;
577572 int level = 1 ;
578573 TimeSpan targetTimeSpan = new ( 0 , 0 , 0 ) ;
579574 while ( level < 100 )
@@ -593,7 +588,7 @@ private void ShowProgress(TimeData timeData)
593588 progressBar . Value = Convert . ToInt32 ( ( timeSpan / targetTimeSpan ) * 100 ) ;
594589 if ( level == 100 )
595590 {
596- encourageLabel . Text = "恭喜通关!你可以通过删除TimeControl文件夹里的SavedData.xml来重新开始 !" ;
591+ encourageLabel . Text = "恭喜通关!你可以通过新建目标来重新开始 !" ;
597592 progressLabel . Visible = false ;
598593 progressBar . Value = 100 ;
599594 }
0 commit comments