Exemplo n.º 1
0
        private void campaignTree_MouseDown(object sender, MouseEventArgs e)
        {
            campaignTree.SelectedNode = campaignTree.GetNodeAt(e.X, e.Y);
            if (e.Button == MouseButtons.Right)
            {
                DetermineTreeContextMenu(campaignTree.SelectedNode);
            }

            if (measuring)
            {
                switch (campaignTree.SelectedNode.Level)
                {
                case 0:     // Take the name of the selected node (which is the campaign name), find the current date of that campaign
                    timeDiffTool.GiveDate(currentCalendar.CampaignList.Find(x => x.Name.Equals(parseCampaignName(campaignTree.SelectedNode.Text))).CurrentDate);
                    break;

                case 1:     //
                    timeDiffTool.GiveDate(CalendarType.ReturnGivenDateFromName(campaignTree.SelectedNode.Text));
                    break;

                case 2:
                    timeDiffTool.GiveDate(
                        currentCalendar.CampaignList.Find(
                            x => x.Name.Equals(
                                parseCampaignName(     // take the node's parent's parent, which is the campaign name. Find the note in that campaign, give date to timedifftool
                                    campaignTree.SelectedNode.Parent.Parent.Text))).findNote(campaignTree.SelectedNode.Text).Date);
                    break;
                }
            }
        }
Exemplo n.º 2
0
 private void Calculate()
 {
     if(CalendarType.FarthestInTime(date1, date2) == 1)
         differenceLabel.Text = CalendarType.daysBetween(date2, date1).ToString() + " days";
     else
         differenceLabel.Text = CalendarType.daysBetween(date1, date2).ToString() + " days";
 }
Exemplo n.º 3
0
 public void Pause(CalendarType currentCalendar)
 {
     if (pausedTime == 0)
     {
         pausedTime = currentCalendar.daysTo(month, day, year);
     }
 }
Exemplo n.º 4
0
        public string returnDateString()
        {
            string monthString = CalendarType.enforceMonthFormat(month.ToString());
            string yearString  = CalendarType.enforceYearFormat(year.ToString());
            string dayString   = CalendarType.enforceDayFormat(monthString, day.ToString(), yearString);

            return(monthString + dayString + yearString);
        }
Exemplo n.º 5
0
        private void importCalButton_Click(object sender, EventArgs e)
        {
            ImportCalendarDialog importCalendar = new ImportCalendarDialog();

            importCalendar.ShowDialog(this);
            calendarType = importCalendar.newCalendar;
            if (calendarType != null)
            {
                newCalendarButton.Enabled = true;
            }
        }
Exemplo n.º 6
0
 public TreeNode FindExistingDateNode(TreeNodeCollection nodes, string dateString)
 {
     foreach (TreeNode n in nodes)
     {
         if (n.Text == CalendarType.returnConciseGivenDate(dateString))
         {
             return(n);
         }
     }
     return(null);
 }
Exemplo n.º 7
0
 public void TogglePause(CalendarType currentCalendar)
 {
     if (pausedTime == 0)
     {
         Pause(currentCalendar);
     }
     else
     {
         Unpause(currentCalendar);
     }
 }
Exemplo n.º 8
0
 private void createCalendarButton_Click(object sender, EventArgs e)
 {
     try
     {
         newCalendar = new CalendarType(textBox.Text, calendarNameBox.Text);
         MessageBox.Show(this, "Calendar imported successfully", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 9
0
        public Calendar(dynamic json) : this()
        {
            calendar = new CalendarType(json);

            foreach (var campaign in json["CampaignList"])
            {
                AddCampaign(new Campaign(campaign));
            }

            foreach (var note in json["GeneralNoteList"])
            {
                Note loadedNote = new Note(note);
                loadedNote.Campaign = null;
                AddGeneralNote(loadedNote);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// If a timer is paused, when days are incremented, the timer's alarm date should also be incremented to reflect the pause
        /// </summary>
        /// <param name="currentCalendar"></param>
        public void AdjustForPause(CalendarType currentCalendar)
        {
            if (pausedTime == 0)
            {
                return;
            }
            else
            {
                string newDate;
                newDate = currentCalendar.dateIn(pausedTime);

                month = Int32.Parse(newDate.Substring(0, 2));
                day   = Int32.Parse(newDate.Substring(2, 2));
                year  = Int32.Parse(newDate.Substring(4, 4));
            }
        }
Exemplo n.º 11
0
        public static Calendar ReadInFile(System.IO.StreamReader sr)
        {
            CalendarType calendarType   = new CalendarType(sr);
            Calendar     loadedCalendar = new Calendar(calendarType);

            int numOfGenNotes;

            if (Int32.TryParse(sr.ReadLine(), out numOfGenNotes))
            {
                for (int i = 0; i < numOfGenNotes; i++)
                {
                    loadedCalendar.AddNote(ReadInNote(sr));
                }

                int numOfCampaigns;
                if (Int32.TryParse(sr.ReadLine(), out numOfCampaigns))
                {
                    for (int i = 0; i < numOfCampaigns; i++)
                    {
                        Campaign loadedCampaign = new Campaign();

                        loadedCampaign.Name        = sr.ReadLine();
                        loadedCampaign.Tag         = sr.ReadLine();
                        loadedCampaign.CurrentDate = sr.ReadLine();

                        int numOfTimers = Int32.Parse(sr.ReadLine());
                        for (int j = 0; j < numOfTimers; j++)
                        {
                            string timerMessage = sr.ReadLine();
                            bool   trackTimer   = Convert.ToBoolean(sr.ReadLine());
                            string timerDate    = sr.ReadLine();
                            loadedCampaign.addTimer(new Timer(timerDate, trackTimer, timerMessage));
                        }

                        int numOfNotes = Int32.Parse(sr.ReadLine());
                        for (int j = 0; j < numOfNotes; j++)
                        {
                            loadedCampaign.addNote(ReadInNote(sr));
                        }

                        loadedCalendar.AddCampaign(loadedCampaign);
                    }
                }
            }
            return(loadedCalendar);
        }
Exemplo n.º 12
0
        public void AddNoteToTree(Note noteToAdd, int campNum, ref int noteNum)
        {
            string noteDate = noteToAdd.Date.ToString();

            // Find existing date node checks if there is already a note with that same date, so it can be put in that node
            TreeNode existingNode = FindExistingDateNode(campaignTree.Nodes[campNum].Nodes, noteDate);

            if (existingNode != null)
            {
                existingNode.Nodes.Add(new TreeNode(noteToAdd.NoteContent));
            }
            else
            {
                campaignTree.Nodes[campNum].Nodes.Add(new TreeNode(CalendarType.returnConciseGivenDate(noteToAdd.Date))); // ADD DATE OF NOTE
                campaignTree.Nodes[campNum].Nodes[noteNum].Nodes.Add(new TreeNode(noteToAdd.NoteContent));                // ADD NOTE CONTENT UNDER IT
                noteNum++;
            }
        }
Exemplo n.º 13
0
        public void checkIfTimerPassed()
        {
            if (currentCalendar.activeCampaign != null)
            {
                foreach (Timer t in currentCalendar.activeCampaign.timers)
                {
                    t.AdjustForPause(currentCalendar.calendar); // If paused, adjust timer

                    // If the current date is same date a timer (0 means same date)
                    if (CalendarType.FarthestInTime(t.returnDateString(), currentCalendar.calendar.ToString()) == 0)
                    {
                        if (MessageBox.Show(this, t.message + "\n\nCreate a note?", "Timer Reached", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            new EditNotesDialog(new Note(t.returnDateString(), AlertScope.campaign, t.message, currentCalendar.activeCampaign), currentCalendar).ShowDialog(this);
                        }

                        // Remove, then restart updating (can't remove and iterate)
                        currentCalendar.activeCampaign.timers.Remove(t);
                        checkIfTimerPassed();
                        return;
                    }
                    else if (CalendarType.FarthestInTime(t.returnDateString(), currentCalendar.calendar.ToString()) < 0)
                    {
                        if (MessageBox.Show(this, t.message + " (" + CalendarType.returnGivenDateWithWeekday(t.returnDateString()) + ")" + "\n\nCreate a note?", "Timer Passed", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            new EditNotesDialog(new Note(t.returnDateString(), AlertScope.campaign, t.message, currentCalendar.activeCampaign), currentCalendar).ShowDialog(this);
                        }
                        if (MessageBox.Show(this, "Go to date? (" + CalendarType.returnGivenDateWithWeekday(t.returnDateString()) + ")", "Go to date", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            currentCalendar.calendar.setDate(t.returnDateString());
                        }
                        // Remove, then restart updating (can't remove and iterate)
                        currentCalendar.activeCampaign.timers.Remove(t);
                        checkIfTimerPassed();
                        return;
                    }
                }
            }
        }
Exemplo n.º 14
0
 private void currY_Leave(object sender, EventArgs e)
 {
     currY.Text = CalendarType.enforceYearFormat(currY.Text);
 }
Exemplo n.º 15
0
 private void year_Leave(object sender, EventArgs e)
 {
     year.Text = CalendarType.enforceYearFormat(year.Text);
 }
Exemplo n.º 16
0
 private void startD_Leave(object sender, EventArgs e)
 {
     startD.Text = CalendarType.enforceDayFormat(startM.Text, startD.Text, startY.Text);
 }
Exemplo n.º 17
0
 // Returns 1 if x happened after y, -1 if y happened after x, 0 if same date
 public static int compareNotes(Note x, Note y)
 {
     return(CalendarType.FarthestInTime(x.date, y.date));
 }
Exemplo n.º 18
0
 private void startM_Leave(object sender, EventArgs e)
 {
     startM.Text = CalendarType.enforceMonthFormat(startM.Text);
 }
Exemplo n.º 19
0
 public Calendar(CalendarType calendarType) : this()
 {
     calendar = calendarType;
 }
Exemplo n.º 20
0
 private void currD_Leave(object sender, EventArgs e)
 {
     currD.Text = CalendarType.enforceDayFormat(currM.Text, currD.Text, currY.Text);
 }
Exemplo n.º 21
0
 private void day_Leave(object sender, EventArgs e)
 {
     day.Text = CalendarType.enforceDayFormat(month.Text, day.Text, year.Text);
 }
Exemplo n.º 22
0
 public void Unpause(CalendarType currentCalendar)
 {
     pausedTime = 0;
 }
Exemplo n.º 23
0
 private void startY_Leave(object sender, EventArgs e)
 {
     startY.Text = CalendarType.enforceYearFormat(startY.Text);
 }
Exemplo n.º 24
0
 private void currM_Leave(object sender, EventArgs e)
 {
     currM.Text = CalendarType.enforceMonthFormat(currM.Text);
 }
Exemplo n.º 25
0
 private void month_Leave(object sender, EventArgs e)
 {
     month.Text = CalendarType.enforceMonthFormat(month.Text);
 }