예제 #1
0
파일: StartTimer.cs 프로젝트: wHo2/1000H
 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;
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
파일: StartTimer.cs 프로젝트: wHo2/1000H
        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;
        }
예제 #4
0
파일: Logic.cs 프로젝트: wHo2/1000H
 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();
 }
예제 #5
0
파일: Logic.cs 프로젝트: wHo2/1000H
 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);
 }
예제 #6
0
파일: Plan.cs 프로젝트: wHo2/1000H
 public bool ContainsProject(Project project)
 {
     return SubProject.Contains(project);
 }
예제 #7
0
파일: Project.cs 프로젝트: wHo2/1000H
 //拷贝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;
 }
예제 #8
0
파일: Form1.cs 프로젝트: wHo2/1000H
        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();
        }
예제 #9
0
파일: Form1.cs 프로젝트: wHo2/1000H
 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;
 }
예제 #10
0
파일: Form1.cs 프로젝트: wHo2/1000H
 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();
     }
 }
예제 #11
0
파일: SetProject.cs 프로젝트: wHo2/1000H
        //查看,修改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
        }
예제 #12
0
파일: SetProject.cs 프로젝트: wHo2/1000H
        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
        }
예제 #13
0
파일: PlanManager.cs 프로젝트: wHo2/1000H
 public void RoutineHasPlanThenAdd(Routine routine, Project project)
 {
     if (routine.Plan != null)
     {
         var plan = GetPlanByID(routine.Plan.ToString());
         plan.AddSubproject(project);
     }
 }
예제 #14
0
파일: PlanManager.cs 프로젝트: wHo2/1000H
 public Plan GetProjectsPlan(Project project)
 {
     return planList.FirstOrDefault(plan => plan.ContainsProject(project));
 }
예제 #15
0
파일: Plan.cs 프로젝트: wHo2/1000H
 public void RemoveSubProject(Project project)
 {
     SubProject.Remove(project);
     PlanProjectPair pair = new PlanProjectPair();
     pair.Project = project.Id;
     pair.Plan = Id;
     Logic.plansProjectList.Remove(pair);
 }
예제 #16
0
파일: Logic.cs 프로젝트: wHo2/1000H
 public static void CheckRoutineAndInsert(Project project)
 {
     var routine = RoutineList.Find(r => r.Id == project.RoutineID);
     if (routine == null)
     {
         return;
     }
 }
예제 #17
0
파일: Form1.cs 프로젝트: wHo2/1000H
 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;
     }
 }
예제 #18
0
파일: SetProject.cs 프로젝트: wHo2/1000H
 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();
 }
예제 #19
0
파일: Form1.cs 프로젝트: wHo2/1000H
 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;
         //}
     }
 }
예제 #20
0
파일: SetProject.cs 프로젝트: wHo2/1000H
 /// <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
 }
예제 #21
0
파일: Form1.cs 프로젝트: wHo2/1000H
        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();
        }
예제 #22
0
파일: Logic.cs 프로젝트: wHo2/1000H
 public static Plan GetOriginPlan(Project project)
 {
     var plan = planManager.GetProjectsPlan(project);
     return plan?.OriginPlan();
 }
예제 #23
0
파일: Logic.cs 프로젝트: wHo2/1000H
 public static Plan GetProjectsPlan(Project project)
 {
     return planManager.GetProjectsPlan(project);
 }
예제 #24
0
파일: Logic.cs 프로젝트: wHo2/1000H
 //插入新建的plan和project的关系
 public static void InsertPlansProject(Plan plan, Project project)
 {
     var formerPlan = planManager.GetProjectsPlan(project);
     formerPlan?.RemoveSubProject(project);
     plan?.AddSubproject(project);
 }
예제 #25
0
 public static string GetRecordString(Project project)
 {
     var recordList = Logic.progressRecorder.GetRecordsBetweenTime((DateTime)project.StartTime, (DateTime)project.FinishedTime);
     return GetRecordString(recordList);
 }
예제 #26
0
파일: Plan.cs 프로젝트: wHo2/1000H
        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;
        }