public StartTimer(Project project) { InitializeComponent(); player.SoundLocation = "C:\\Windows\\Media\\Alarm03.wav"; player.Load(); dgvProject.AutoGenerateColumns = false; initialize(project); btnDelay.Visible = false; dtpDelayTime.Visible = false; }
private void dgvProject_SelectionChanged(object sender, EventArgs e) { Project project = new Project(); if (dgvProject.CurrentRow != null && dgvProject.CurrentRow.Cells["Id"].Value != null) { string id = dgvProject.CurrentRow.Cells["Id"].Value.ToString(); project = Logic.FindProjectById(id); } if (project != null && project.Remark != null) { txtRemark.Text = project.Remark; } }
public void initialize(Project project) { ProjectList.Add(project); dgvProject.DataSource = new BindingList<Project>(ProjectList); txtRemark.Text = project.Remark; StartTimeDT = DateTime.Now; project.StartTime = DateTime.Now; if (project.AssumeTime != null) { project.FinishedTime = project.StartTime + project.AssumeTime; FinishedTimeDT = (DateTime)project.FinishedTime; } // LeftTime = project.AssumeTime; UsedTime = new TimeSpan(); LeftTime = (TimeSpan)(FinishedTimeDT - DateTime.Now); UsedTime = project.AssumeTime - LeftTime; txtLeftTime.Text = LeftTime.ToString(@"hh\:mm"); txtUsedTime.Text = UsedTime.ToString(@"hh\:mm"); this.project = project; }
public static void CaculateRoutine_AvgAccuTimes(Project project) { var routine = RoutineList.Find(r => r.Id == project.RoutineID); if (routine == null) { return; } var totalTime = routine.AvgTime * routine.Times + project.UsedTime.TotalMinutes; routine.Times++; routine.AvgTime = totalTime / (routine.Times); routine.CaculateAccumulate(); }
static void RTPInsert(DateTime date, Routine routine, Project project, List<Project> projectList) { if (date.Date != DateTime.Today && project.StartLine == null) { project.StartLine = date.Date; } project.Id = ++Project.IDmax; projectList.Add(project); planManager.RoutineHasPlanThenAdd(routine, project); }
public bool ContainsProject(Project project) { return SubProject.Contains(project); }
//拷贝project的所有内容除了id public Project Copy() { Project New = new Project(); New.Name = Name; New.Diff = Diff; New.AssumeTime = AssumeTime; New.RoutineID = RoutineID; New.UsedTime = UsedTime; New.StartTime = StartTime; New.FinishedTime = FinishedTime; New.Status = Status; New.Effect = Effect; New.StartLine = StartLine; New.DeadLine = DeadLine; New.Remark = Remark; New.startRing = startRing; New.position = position; New.toPosition = toPosition; //New.Experience = Experience; return New; }
void SeekDetail() { if (dgvSeek.SelectedRows.Count != 1) { MessageBox.Show("请选择一个项目"); return; } string id = dgvSeek.CurrentRow.Cells["Id2"].Value.ToString(); Project project = Logic.GetSeekListProject(id); if (project == null) return; SetProject setProject = new SetProject { Form1 = this, OldProject = project }; if (project is Relax) { Project tempProject = new Project { Name = "", AssumeTime = project.UsedTime, UsedTime = project.UsedTime, StartTime = project.StartTime, FinishedTime = project.FinishedTime, Status = stat.完成 }; setProject.OldProject = tempProject; setProject.SetBtn("间隔的修改"); } else { setProject.SetBtn("保存"); } setProject.Show(); }
private void dgvSeek_SelectionChanged(object sender, EventArgs e) { Project project = new Project(); if (dgvSeek.CurrentRow.Cells["Id2"].Value == null) { return; } string id = dgvSeek.CurrentRow.Cells["Id2"].Value.ToString(); project = Logic.GetSeekListProject(id); if (project == null) return; txtSeekRemark.Text = project.Remark; }
private void dgvProject_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dgvProject.CurrentCell != null && (this.dgvProject.CurrentCell.ColumnIndex == dgvProject.Columns["startTime"].Index || this.dgvProject.CurrentCell.ColumnIndex == dgvProject.Columns["FinishedTime"].Index)) { Project project = new Project(); string id = dgvProject.CurrentRow.Cells["Id"].Value.ToString(); project = Logic.FindProjectById(Convert.ToInt32(id)); project.UsedTime = (TimeSpan)(project.FinishedTime - project.StartTime); Thread thread = new Thread(CellValueWork); thread.Start(); } }
//查看,修改project/routine时,把项目信息填入窗体 void FormInitByProject(Project project) { txtProjectName.Text = project.Name; cmbDifficulty.SelectedIndex = (int)project.Diff; //txtExperience.Text = project.Experience; txtRemark.Text = project.Remark; cmbEffect.SelectedIndex = cmbEffect.Items.IndexOf(project.Effect.ToString()); cbPosition.SelectedIndex = project.position == null ? 0 : cbPosition.Items.IndexOf(project.position.name); cbTransmitPostion.SelectedIndex = project.toPosition == null ? 0 : cbTransmitPostion.Items.IndexOf(project.toPosition.name); cbRemind.Checked = project.startRing; InitPlanPart(project); #region 时间相关 DateTime datetime = DateTime.Today; if (project is Routine) { btnRoutineSeek.Visible = true; cmbRepeat.SelectedIndex = (int)((Routine)project).RepeatType; if (cmbRepeat.SelectedIndex == 4)//repeatType列表更改后需更改 { dtpGap.Visible = true; labGap.Visible = true; dtpGap.Value = DateTime.Today + ((Routine)project).Gap; } project.StartTime = DateTime.Now; cmbState.Hide(); } else { datetime = (DateTime)project.StartTime; cmbState.SelectedIndex = (int)(project.Status); dtpFinishTime.Value = (DateTime)project.FinishedTime; dtpStartTime.Value = (DateTime)project.StartTime; cbForever.Checked = project.Forever; } dtpAssumeTime.Value = datetime.Date + project.AssumeTime; if (project.StartLine != null) { dtpEarilestStartDate.Value = (DateTime)project.StartLine; dtpEarilestStartTime.Value = (DateTime)project.StartLine; dtpEarilestStartDate.Checked = true; dtpEarilestStartTime.Checked = true; } if (project.DeadLine != null) { dtpLatestFinishDate.Value = (DateTime)project.DeadLine; dtpLatestFinishTime.Value = (DateTime)project.DeadLine; dtpLatestFinishDate.Checked = true; dtpLatestFinishTime.Checked = true; } if (project is Routine) { txtAvgTime.Text = ((Routine)project).AvgTime.ToString(); txtAccumulatedTime.Text = ((Routine)project).AccumulatedTime.ToString(); } #endregion }
private void btnSetFinished_Click(object sender, EventArgs e) { #region 新建或更改的出错提醒 if (txtProjectName.Text == "") { MessageBox.Show("请填写项目名"); return; } if (dtpAssumeTime.Checked == false && dtpLatestFinishTime.Checked == false)//估计时间和最迟结束时间都未填写 { MessageBox.Show("估计时间和最迟结束时间必须填写一个"); return; } #endregion if (btnSetFinished.Text == @"完成" || btnSetFinished.Text == @"间隔的修改") { #region 新建的逻辑 if (cmbRepeat.SelectedIndex == 0) { Project project = new Project(); ProjectGetValue(project, DateTime.Today); Logic.ProjectList.Add(project); Logic.Schedule();//重新计算日程表 project.UsedTime = (TimeSpan)(project.FinishedTime - project.StartTime); project.Id = ++Project.IDmax; Form1.BindProject(); Logic.CheckRoutineAndInsert(project); //如果是计划的项目 if (plan != null) { project.Name = plan.Name + "-" + project.Name; Logic.InsertPlansProject(plan, project); plan.AddSubproject(project); Logic.planManager.SetDirty(plan); } if (btnSetFinished.Text == @"间隔的修改") { project.Remark += ProgressRecorder.GetRecordString(project); Logic.CaculateRoutine_AvgAccuTimes(project); } } else//新建routine { Routine routine = new Routine(); ProjectGetValue(routine, DateTime.Today); Logic.RoutineList.Add(routine); routine.Id = ++Routine.RIDmax; Logic.RoutineToProject(routine, DateTime.Now, Logic.ProjectList); Form1.BindRoutine(); } Close(); #endregion } else if (btnSetFinished.Text == @"修改完成")//修改project { #region 修改的逻辑 stat oldStat = OldProject.Status; //如果是计划 if (plan != null) { Logic.planManager.SetDirty(plan); } ProjectGetValue(OldProject, DateTime.Today); if (oldStat != OldProject.Status && OldProject.Status == stat.完成) { OldProject.Remark += ProgressRecorder.GetRecordString(OldProject); if (OldProject.RoutineID != Routine.IDnull) { Logic.CaculateRoutine_AvgAccuTimes(OldProject); } } if (OldProject.Status != stat.完成) { OldProject.UsedTime = OldProject.AssumeTime; } Logic.Schedule();//重新计算日程表 Close(); #endregion } else if (btnSetFinished.Text == @"修改")//修改routine { ProjectGetValue(OldRoutine, DateTime.Today); Logic.Schedule();//重新计算日程表 Close(); } else if (btnSetFinished.Text == @"保存") #region 查看时的逻辑 { if (plan != null) { Logic.planManager.SetDirty(plan); } ProjectGetValue(OldProject, OldProject.StartTime.Value.Date);//!!!ProjectGetValue(OldProject, Form1.GetDtpSeekerValue()) if (Logic.ProjectList.Any(item => item.Id == OldProject.Id)) { Close(); return; } Logic.ProjectList.Add(OldProject); Logic.Schedule();//重新计算日程表 Close(); return; } #endregion }
public void RoutineHasPlanThenAdd(Routine routine, Project project) { if (routine.Plan != null) { var plan = GetPlanByID(routine.Plan.ToString()); plan.AddSubproject(project); } }
public Plan GetProjectsPlan(Project project) { return planList.FirstOrDefault(plan => plan.ContainsProject(project)); }
public void RemoveSubProject(Project project) { SubProject.Remove(project); PlanProjectPair pair = new PlanProjectPair(); pair.Project = project.Id; pair.Plan = Id; Logic.plansProjectList.Remove(pair); }
public static void CheckRoutineAndInsert(Project project) { var routine = RoutineList.Find(r => r.Id == project.RoutineID); if (routine == null) { return; } }
private void btnSaveStartTime_Click(object sender, EventArgs e) { Project project = new Project(); if (dgvProject.CurrentRow != null && dgvProject.CurrentRow.Cells["Id"].Value != null) { string id = dgvProject.CurrentRow.Cells["Id"].Value.ToString(); project = Logic.FindProjectById(id); } if (project != null) { project.StartLine = dtpEarilestStartTime.Value; } }
void InitPlanPart(Project project) { if (project != null) { if (project is Routine) { plan = ((Routine)project).Plan != null ? Logic.planManager.GetPlanByID(((Routine)project).Plan.ToString()) : null; } else { plan = Logic.planManager.GetProjectsPlan(project); } if (plan != null) { initPlanEffect = true; } } SetTreeView(); }
private void dgvProject_SelectionChanged(object sender, EventArgs e) { Project project = new Project(); if (dgvProject.CurrentRow != null && dgvProject.CurrentRow.Cells["Id"].Value != null) { string id = dgvProject.CurrentRow.Cells["Id"].Value.ToString(); project = Logic.FindProjectById(id); } if (project != null && project.Remark != null) { txtRemark.Text = project.Remark; } if (project != null && project.StartTime != null) { //if (project.StartLine == null) { dtpEarilestStartTime.Value = (DateTime)project.StartTime; } //else //{ // dtpEarilestStartTime.Value = (DateTime)project.StartLine; //} } }
/// <summary> /// 将窗口里设置的值赋给project/routine /// </summary> void ProjectGetValue(Project project, DateTime date) { project.Name = txtProjectName.Text; project.Diff = (difficulty)cmbDifficulty.SelectedIndex; project.Remark = txtRemark.Text; project.Status = (stat)cmbState.SelectedIndex; project.position = cbPosition.SelectedIndex == 0 ? null : Logic.GetPosition(cbPosition.Text); project.toPosition = cbTransmitPostion.SelectedIndex == 0 ? null : Logic.GetPosition(cbTransmitPostion.Text); project.Effect = (effec)Enum.Parse(typeof(effec), cmbEffect.Text); project.Forever = cbForever.Checked; project.startRing = cbRemind.Checked; if (cmbHabitual.SelectedIndex != 0) { foreach (Routine item in Logic.RoutineList) { if (cmbHabitual.Text == item.Name) { project.RoutineID = item.Id; break; } } } if (!(project is Routine)) { if (btnSetFinished.Text != "完成" && btnSetFinished.Text != "间隔的修改") { Logic.InsertPlansProject( planTV_SetProject.SelectedNode != null ? Logic.planManager.GetPlanByID(planTV_SetProject.SelectedNode.Name) : null, project); } if (planTV_SetProject.SelectedNode != null && (btnSetFinished.Text == "完成" || btnSetFinished.Text == "间隔的修改")) { plan = Logic.planManager.GetPlanByID(planTV_SetProject.SelectedNode.Name); } } if (cmbState.SelectedIndex == 0) { project.UsedTime = dtpFinishTime.Value - dtpStartTime.Value; } #region if (project is Routine) { ((Routine)project).RepeatType = (RepeatTYPE)cmbRepeat.SelectedIndex; if (cmbRepeat.SelectedIndex == 4)//repeatType列表更改后需更改 { dtpGap.Value = new DateTime(dtpGap.Value.Year, dtpGap.Value.Month, dtpGap.Value.Day, dtpGap.Value.Hour, dtpGap.Value.Minute, 0, 0); ((Routine)project).Gap = dtpGap.Value.Subtract(date.Date); } if (planTV_SetProject.SelectedNode != null) { var pl = Logic.planManager.GetPlanByID(planTV_SetProject.SelectedNode.Name); ((Routine)project).Plan = pl.Id; } if ((planTV_SetProject.SelectedNode == null) && ((Routine)project).Plan != null) { ((Routine)project).Plan = null; } } else { project.StartTime = dtpStartTime.Value; project.FinishedTime = dtpFinishTime.Value; } if (dtpAssumeTime.Checked) { dtpAssumeTime.Value = new DateTime(date.Date.Year, date.Date.Month, date.Date.Day, dtpAssumeTime.Value.Hour, dtpAssumeTime.Value.Minute, 0, 0); project.AssumeTime = dtpAssumeTime.Value.Subtract(date.Date); } project.StartLine = GetTimeLine(dtpEarilestStartTime, dtpEarilestStartDate); project.DeadLine = GetTimeLine(dtpLatestFinishTime, dtpLatestFinishDate); #endregion }
private void ModifyProject() { if (dgvProject.SelectedRows.Count != 1) { MessageBox.Show("请选择一个项目"); return; } string id = dgvProject.CurrentRow.Cells["Id"].Value.ToString(); string status = dgvProject.CurrentRow.Cells["status"].Value.ToString(); //if (status == "完成") //{ // MessageBox.Show("已完成的项目不能修改"); // return; //} Project project = Logic.FindProjectById(id); SetProject setProject = new SetProject { Form1 = this, OldProject = project }; if (project is Relax) { Project tempProject = new Project { Name = "", AssumeTime = project.UsedTime, UsedTime = project.UsedTime, StartTime = project.StartTime, FinishedTime = project.FinishedTime, Status = stat.完成 }; setProject.OldProject = tempProject; setProject.SetBtn("间隔的修改"); } else setProject.SetBtn("修改完成"); Logic.Schedule(); setProject.Show(); }
public static Plan GetOriginPlan(Project project) { var plan = planManager.GetProjectsPlan(project); return plan?.OriginPlan(); }
public static Plan GetProjectsPlan(Project project) { return planManager.GetProjectsPlan(project); }
//插入新建的plan和project的关系 public static void InsertPlansProject(Plan plan, Project project) { var formerPlan = planManager.GetProjectsPlan(project); formerPlan?.RemoveSubProject(project); plan?.AddSubproject(project); }
public static string GetRecordString(Project project) { var recordList = Logic.progressRecorder.GetRecordsBetweenTime((DateTime)project.StartTime, (DateTime)project.FinishedTime); return GetRecordString(recordList); }
public bool AddSubproject(Project project, bool Init = false) { if (SubProject.Any(p => p.Id == project.Id)) { return false; } //防止重复添加 if (Logic.planManager.GetProjectsPlan(project) == null) { PlanProjectPair pair = new PlanProjectPair { Project = project.Id, Plan = Id }; if (!Init) { Logic.plansProjectList.Add(pair); } SubProject.Add(project); } return true; }