예제 #1
0
 public Event Find_Child_Event(Event parent_event,string Child_Name)
 {
     foreach (Event child_event in parent_event.Child_Events)
     {
         if (child_event.Title == Child_Name)
         {
             return (child_event);
         }
     }
     return (null);
 }
예제 #2
0
 public Event(bool done, bool due_date, DateTime created, DateTime completed, DateTime due, string title, string description, float completion, Event parent_event)
 {
     Done = done;
     Due_Date = due_date;
     Created = created;
     Completed = completed;
     Due = due;
     Title = title;
     Description = description;
     Completion = completion;
     Parent_Event = parent_event;
 }
예제 #3
0
 public Event Find_Event(Event some_event, string name)
 {
     if (some_event.Title == name)
     {
         return (some_event);
     }
     else
     {
         foreach (Event eve in some_event.Child_Events)
         {
             Event temp = Find_Event(eve, name);
             if (temp != null)
             {
                 return temp;
             }
         }
     }
     return (null);
 }
예제 #4
0
 public Add_Event(Event new_event)
 {
     InitializeComponent();
     done = new_event.Done;
     due_date = new_event.Due_Date;
     Day = new_event.Created;
     dtp_Complete_Date.Value = new_event.Completed;
     dtp_Day.Value = new_event.Due;
     txt_Title.Text = new_event.Title;
     rtb_Description.Text = new_event.Description;
     edit_event = new_event;
     Parent_Event = new_event.Parent_Event;
     Write_Tree(trv_All_Events, Day);
     editing = true;
     //need to write to treeview
     //and select parent event and check checkbox
     if (new_event.Parent_Event != null)
     {
         chk_Project.Checked = true;
         txt_Project.Text = new_event.Parent_Event.Title;
     }
 }
예제 #5
0
 public void Delete_Event(Event events)
 {
     Child_Events.Remove(events);
 }
예제 #6
0
 public void Add_Events(Event events)
 {
     Child_Events.Add(events);
 }
예제 #7
0
        public void Write_Node(TreeView Tree_View, Event write_event, DateTime Dat)
        {
            foreach (Event ev in write_event.Child_Events)
            {

                TreeNode node = new TreeNode();
                if (ev.Done == true)
                {
                    node.BackColor = Color.LightGray;
                }
                else if (ev.Due_Date)
                {
                    node.BackColor = Color.LightCoral;
                }
                else if (ev.Completion != 0)
                {
                    node.BackColor = Color.LightBlue;
                }
                else
                {
                    node.BackColor = Color.LightGreen;
                }

                node.Text = ev.Title;
                node.Tag = node.BackColor;
                node.Name = "trn_" + ev.Title;

                if (Dat > ev.Completed && ev.Done)
                {
                }
                else
                {
                    Tree_View.SelectedNode.Nodes.Add(node);
                    if (ev.Child_Events.Count != 0)
                    {
                        Tree_View.SelectedNode = node;
                    }
                    else
                    {

                    }
                }
                Write_Node(Tree_View, ev, Dat);
                if (ev.Child_Events.Count != 0)
                    Tree_View.SelectedNode = Tree_View.SelectedNode.Parent;
            }
        }
예제 #8
0
        public void Write_List(ListView List_View, Event selected_event = null)
        {
            if (selected_event == null)
            {
                foreach (Event e in file.All_Events)
                {
                    ListViewItem item = new ListViewItem();
                    item.Text = e.Title;
                    item.Name = "lsi_" + e.Title;
                    if (e.Due_Date == true)
                        item.SubItems.Add(e.Completed.ToString("MM/dd/yyyy - hh:00 tt"));
                    List_View.Items.Add(item);

                }
            }
            else
            {
                foreach (Event ev in selected_event.Child_Events)
                {
                    ListViewItem item = new ListViewItem();
                    item.Text = ev.Title;
                    item.Name = "lsi_" + ev.Title;
                    if (ev.Due_Date == true)
                        item.SubItems.Add(ev.Completed.ToString("MM/dd/yyyy - hh:00 tt"));
                    List_View.Items.Add(item);
                }
            }
        }
예제 #9
0
 public void Show_Edit_Event(Event new_event)
 {
     Form ae = Application.OpenForms["Add_Event"];
     var new_Add_Event = new Add_Event(new_event);
     if (ae == null)
     {
         new_Add_Event.Show();
     }
     else
     {
         ae.Activate();
     }
 }
예제 #10
0
 public void Save_Event(Event new_event)
 {
     if (new_event.Parent_Event == null)
     {
         file.All_Events.Add(new_event);
     }
     else
     {
         new_event.Parent_Event.Child_Events.Add(new_event);
         int i = 0;
         float j = 0;
         foreach (Event e in new_event.Parent_Event.Child_Events)
         {
             j += e.Completion;
             i++;
         }
         new_event.Parent_Event.Completion_Children = (j / i);
     }
 }
예제 #11
0
 public void Move_Event(Event ev, bool Up)
 {
     List<Event> current_list;
     int index;
     if (ev.Parent_Event != null)
     {
         current_list = ev.Parent_Event.Child_Events;
     }
     else
     {
         current_list = file.All_Events;
     }
     index = current_list.IndexOf(ev);
     int len = current_list.Count();
     if (Up && index != 0)
     {
         Event old = current_list[index - 1];
         current_list[index - 1] = current_list[index];
         current_list[index] = old;
     }
     else if (!Up && index < len-1)
     {
         Event old = current_list[index + 1];
         current_list[index + 1] = current_list[index];
         current_list[index] = old;
     }
 }
예제 #12
0
 private bool Check_Duplicate(Event some_event, string name)
 {
     if (some_event.Title == name)
     {
         edit_event = some_event;
         return (true);
     }
     else
     {
         foreach (Event eve in some_event.Child_Events)
         {
             if (Check_Duplicate(eve, name))
             {
                 return (true);
             }
         }
     }
     return (false);
 }
예제 #13
0
        private void btn_Save_Event_Click(object sender, EventArgs e)
        {
            if (txt_Title.Text == "")
            {
                MessageBox.Show("Event Title is blank","Title ERROR");
                return;
            }
            Event parent_event = null;
            string pname;

            bool duplicate = false;

            if (editing)
            {
                duplicate = true;
            }
            else
            {
                foreach (Event test_event in file.All_Events)
                {
                    duplicate = Check_Duplicate(test_event, txt_Title.Text);
                    if (duplicate == true)
                    {
                        break;
                    }
                }
            }

            if (trv_All_Events.SelectedNode != null && chk_Project.Checked)
            {
                pname = txt_Project.Text;

                if (pname == txt_Title.Text)
                {
                    MessageBox.Show("Event has parent's name", "Title ERROR");
                    return;
                }

                foreach (Event eve in file.All_Events)
                {
                    parent_event = Find_Event(eve, pname);
                    if (parent_event != null)
                    {
                        break;
                    }
                }
            }

            if (duplicate)
            {
                DialogResult dr = MessageBox.Show("Overwrite Event?", "Event Title is not unique", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    //edit_event = new Event(done, due_date, Day, dtp_Complete_Date.Value, dtp_Day.Value, txt_Title.Text, rtb_Description.Text, Completion, parent_event);
                    if (edit_event.Parent_Event != null)
                    {
                        edit_event.Parent_Event.Child_Events.Remove(edit_event);
                    }
                    else
                    {
                        file.All_Events.Remove(edit_event);
                    }
                    edit_event.Done = done;
                    edit_event.Due_Date = due_date;
                    edit_event.Created = Day;
                    edit_event.Completed = dtp_Complete_Date.Value;
                    edit_event.Due = dtp_Day.Value;
                    edit_event.Title = txt_Title.Text;
                    edit_event.Description = rtb_Description.Text;
                    edit_event.Completion = Completion;
                    if (edit_event == parent_event)
                    {
                        parent_event = null;
                    }
                    edit_event.Parent_Event = parent_event;
                    if (parent_event != null)
                    {
                        edit_event.Parent_Event.Child_Events.Add(edit_event);
                    }
                    else
                    {
                        file.All_Events.Add(edit_event);
                    }
                    this.Close();
                }
                else
                {
                    return;
                }
            }
            else
            {
                Event ev = new Event(done, due_date, Day, dtp_Complete_Date.Value, dtp_Day.Value, txt_Title.Text, rtb_Description.Text, Completion, parent_event);
                Save_Event(ev);
                this.Close();
            }
            data_changed();
        }