Exemplo n.º 1
0
 /// <summary>
 /// Constructor for addGoalForm. Takes in a model to get data relating to existing goals.
 /// </summary>
 /// <param name="model"> Perfection model</param>
 public addGoalForm(PerfectionModel model)
 {
     InitializeComponent();
     _model = model;
     _submitted = false;
     _goalToAdd = null;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds the inputed goal to the profile, returns a string explaining events
 /// </summary>
 /// <param name="toAdd">Goal</param>
 /// <returns></returns>
 public string AddGoal(Goal toAdd)
 {
     _user.AddGoal(toAdd);
     return Environment.NewLine + toAdd.Name + " was saved.";
 }
Exemplo n.º 3
0
 /// <summary>
 /// Removes the inputed goal, but none of its required goals
 /// </summary>
 /// <param name="toRem"></param>
 /// <returns></returns>
 public string RemoveGoalSolo(Goal toRem)
 {
     _user.RemoveGoalSolo(toRem);
     return Environment.NewLine + toRem.Name + " was removed.";
 }
Exemplo n.º 4
0
 /// <summary>
 /// Removes the inputed goal and all its required goals
 /// </summary>
 /// <param name="toRem">Goal</param>
 /// <returns></returns>
 public string RemoveGoal(Goal toRem)
 {
     _user.RemoveGoal(toRem);
     return Environment.NewLine + toRem.Name + " and all its children were removed.";
 }
Exemplo n.º 5
0
 /// <summary>
 /// Removes this goal but NOT its children from the profile. Does disconnect it from any parent goals.
 /// </summary>
 /// <param name="toRem">Goal</param>
 public void RemoveGoalSolo(Goal toRem)
 {
     _goals.Remove(toRem);
     if (toRem is ShortTermGoal)
     {
         ShortTermGoal tempShort = toRem as ShortTermGoal;
         foreach (Goal g in _goals)
         {
             if (g is LongTermGoal)
             {
                 LongTermGoal tempG = g as LongTermGoal;
                 if (tempG.ReqShort.Contains(tempShort))
                 {
                     tempG.ReqShort.Remove(tempShort);
                 }
             }
         }
     } else if (toRem is TaskGoal)
     {
         TaskGoal tempTask = toRem as TaskGoal;
         foreach(Goal g in _goals)
         {
             if (g is ShortTermGoal)
             {
                 ShortTermGoal tempShort = g as ShortTermGoal;
                 if (tempShort.ReqTasks.Contains(tempTask))
                 {
                     tempShort.ReqTasks.Remove(tempTask);
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Removes the inputed goal from the profile and all it's children. Also, the inputed goal is disconnected form any parent goals
 /// </summary>
 /// <param name="toRem">Goal</param>
 public void RemoveGoal(Goal toRem)
 {
     if (toRem is LongTermGoal)
     {
         LongTermGoal tempLong = toRem as LongTermGoal;
         while(tempLong.ReqShort.Count > 0)
         {
             RemoveGoal(tempLong.ReqShort[0]);
         }
     }
     else if (toRem is ShortTermGoal)
     {
         ShortTermGoal tempShort = toRem as ShortTermGoal;
         foreach (Goal g in _goals)
         {
             if (g is LongTermGoal)
             {
                 LongTermGoal tempG = g as LongTermGoal;
                 if (tempG.ReqShort.Contains(tempShort))
                 {
                     tempG.ReqShort.Remove(tempShort);
                 }
             }
         }
         while(tempShort.ReqTasks.Count > 0)
         {
             RemoveGoal(tempShort.ReqTasks[0]);
         }
     }
     else
     {
         TaskGoal tempTask = toRem as TaskGoal;
         foreach(Goal g in _goals)
         {
             if (g is ShortTermGoal)
             {
                 ShortTermGoal tempShort = g as ShortTermGoal;
                 if (tempShort.ReqTasks.Contains(tempTask))
                 {
                     tempShort.ReqTasks.Remove(tempTask);
                 }
             }
         }
     }
     _goals.Remove(toRem);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Attempts to complete the inputed goal and returns a string explaining the events
        /// </summary>
        /// <param name="toComp">Goal</param>
        /// <returns>String</returns>
        public string CompleteGoal(Goal toComp)
        {
            string result = "";

            foreach (Goal g in _goals)
            {
                if (g == toComp)
                {
                    result = g.Complete(ref _exp);
                }
            }

            if (result == "")
            {
                result = Environment.NewLine + "No goal was found";
            }

            while ((_exp >= _expReq) && (_level < MAX_LEVEL))
            {
                result += LevelUp();
            }
            return result;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Adds a goal and all its children to this profile. If a child goal is already part of the profile, it is not added.
 /// </summary>
 /// <param name="toAdd">Goal</param>
 public void AddGoal(Goal toAdd)
 {
     if (toAdd is LongTermGoal)
     {
         LongTermGoal tempLong = toAdd as LongTermGoal;
         foreach (ShortTermGoal s in tempLong.ReqShort)
         {
             if (!(_goals.Contains(s)))
             {
                 AddGoal(s);
             }
         }
     }
     else if (toAdd is ShortTermGoal)
     {
         ShortTermGoal tempShort = toAdd as ShortTermGoal;
         foreach (TaskGoal t in tempShort.ReqTasks)
         {
             if (!(_goals.Contains(t)))
             {
                 AddGoal(t);
             }
         }
     }
     _goals.Add(toAdd);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Checks all the data entry is acceptable. If it is, sets _goalToAdd with that data.
        /// If long or short term goal, user can select goals from a list of possible children. All checked items are added.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void submitBtn_Click(object sender, EventArgs e)
        {
            bool goalNameUsed = false;
            foreach (Goal g in _model.User.Goals)
            {
                if (g.Name == goalNameBx.Text)
                {
                    goalNameUsed = true;
                    break;
                }
            }

            if (goalNameBx.Text == "")
            {
                MessageBox.Show("Please enter a goal name");
            }
            else if (goalDescBx.Text == "")
            {
                MessageBox.Show("Please enter a goal description");
            } else if (goalNameUsed)
            {
                MessageBox.Show("Please use a unique name");
            }
            else
            {
                try
                {
                    GoalCategory gc;
                    if (cateComboBx.SelectedItem.ToString() == "Career")
                    {
                        gc = GoalCategory.Career;
                    }
                    else if (cateComboBx.SelectedItem.ToString() == "Health")
                    {
                        gc = GoalCategory.Health;
                    }
                    else if (cateComboBx.SelectedItem.ToString() == "Interpersonal")
                    {
                        gc = GoalCategory.Interpersonal;
                    }
                    else if (cateComboBx.SelectedItem.ToString() == "Hobby")
                    {
                        gc = GoalCategory.Hobby;
                    }
                    else
                    {
                        throw new NullReferenceException();
                    }

                    if (shortRad.Checked)
                    {

                        List<TaskGoal> tgToAdd = new List<TaskGoal>();

                        foreach (Goal g in goalListChkBx.CheckedItems)
                        {
                            foreach (Goal pg in _model.User.Goals)
                            {
                                if (g.Name == pg.Name)
                                {
                                    if (pg is TaskGoal)
                                    {
                                        tgToAdd.Add(pg as TaskGoal);
                                        break;
                                    }
                                }
                            }
                        }

                        if (estHoursUpDwn.Value <= 0)
                        {
                            _goalToAdd = new ShortTermGoal(goalNameBx.Text, goalDescBx.Text, gc, tgToAdd);
                        }
                        else
                        {
                            _goalToAdd = new ShortTermGoal(goalNameBx.Text, goalDescBx.Text, gc, tgToAdd, Convert.ToInt32(estHoursUpDwn.Value));
                        }
                    }
                    else if (longRad.Checked)
                    {
                        List<ShortTermGoal> sgToAdd = new List<ShortTermGoal>();
                        foreach (Goal g in goalListChkBx.CheckedItems)
                        {
                            foreach (Goal pg2 in _model.User.Goals)
                            {
                                if (g.Name == pg2.Name)
                                {
                                    if (pg2 is ShortTermGoal)
                                    {
                                        sgToAdd.Add(pg2 as ShortTermGoal);
                                        break;
                                    }
                                }
                            }
                        }

                        if (estHoursUpDwn.Value <= 0)
                        {
                            _goalToAdd = new LongTermGoal(goalNameBx.Text, goalDescBx.Text, gc, sgToAdd);
                        }
                        else
                        {
                            _goalToAdd = new LongTermGoal(goalNameBx.Text, goalDescBx.Text, gc, sgToAdd, Convert.ToInt32(estHoursUpDwn.Value));
                        }
                    }
                    else
                    {
                        if (estHoursUpDwn.Value <= 0)
                        {
                            _goalToAdd = new TaskGoal(goalNameBx.Text, goalDescBx.Text, gc);
                        }
                        else
                        {
                            _goalToAdd = new TaskGoal(goalNameBx.Text, goalDescBx.Text, gc, Convert.ToInt32(estHoursUpDwn.Value));
                        }
                    }
                    _submitted = true;
                    this.Close();
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Please select a goal category");
                }
            }
        }