Example #1
0
        /// <summary>
        /// Date Selected behavior for the calendar.
        /// Updates the selected date when it changes and updates the 'agenda' panel to show that day's events
        /// </summary>
        /// <param name="sender">The sending winforms object.</param>
        /// <param name="e">Winforms event arguments.</param>
        private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
            getEventsForTheDay(e.Start);
            currentDateLabel.Text = e.Start.ToShortDateString();

            for (int i = 0; i < 48; i++)
            {
                AgendaTextBox text = TextBoxArray[i];
                text.Text = "";
                text.associatedEvents.Clear();
                String eventText   = "";
                int    eventsAdded = 0;

                DateTime selectedDate = monthCalendar1.SelectionStart;
                DateTime associatedDT = text.associatedDateTime;
                int      hour         = associatedDT.Hour;
                int      minute       = associatedDT.Minute;

                text.associatedDateTime = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, hour, minute, 0);

                for (int j = 0; j < dayEvents.Count; j++)
                {
                    for (int k = 0; k < dayEvents[j].dateTimes.Count; k++)
                    {
                        if (text.associatedDateTime < dayEvents[j].dateTimes[k].Item2 && text.associatedDateTime >= dayEvents[j].dateTimes[k].Item1)
                        {
                            if (!text.associatedEvents.Contains(dayEvents[j]))
                            {
                                text.associatedEvents.Add(dayEvents[j]);
                            }
                        }
                    }
                }
                foreach (Event ev in text.associatedEvents)
                {
                    if (text.Text.Length + ev.ToString().Length > 94)
                    {
                        if (eventsAdded == 0)
                        {
                            text.Text += "Event text too long to display. Click for details.";
                            break;
                        }
                        else
                        {
                            text.Text += "...";
                        }
                    }
                    else
                    {
                        text.Text += ev.ToString() + " ";
                    }
                    eventsAdded++;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Click behavior for the Agenda text boxes.
        /// Opens the addavailabilitywindow so the user can flag themselves available for events.
        /// </summary>
        /// <param name="sender">The sending winforms object.</param>
        /// <param name="e">Winforms event arguments.</param>
        private void Text_Click(object sender, EventArgs e)
        {
            AgendaTextBox send = sender as AgendaTextBox;

            if (send.associatedEvents != null && send.associatedEvents.Count != 0)
            {
                AddAvailabilityWindow addAvail = new AddAvailabilityWindow(send.associatedEvents, userName, evtList, use24Hour);
                addAvail.ShowDialog();
            }
            else
            {
                MessageBox.Show("This time slot has no events.");
            }
        }
Example #3
0
        //add 48 textboxes to a panel, one for each time slot
        //todo - load events from file to associate with these and displayt heir names
        /// <summary>
        /// Load behavior for the user window.
        /// Populates the 'agenda' panel of textboxes and loads the events from the day selected in MainWindow into them.
        /// </summary>
        /// <param name="sender">The sending winforms object.</param>
        /// <param name="e">Winforms event arguments.</param>
        private void UserWindow_Load(object sender, EventArgs e)
        {
            DateTime currentTime = startingDate;

            if (File.Exists(path))
            {
                pullEventsFromJSON();
                if (evtList != null)
                {
                    getEventsForTheDay(currentTime);
                }
            }

            for (int i = 0; i < 48; i++)
            {
                int           eventsAdded = 0;
                AgendaTextBox text        = new AgendaTextBox();
                text.associatedDateTime = currentTime;

                for (int j = 0; j < dayEvents.Count; j++)
                {
                    for (int k = 0; k < dayEvents[j].dateTimes.Count; k++)
                    {
                        if (text.associatedDateTime < dayEvents[j].dateTimes[k].Item2 && text.associatedDateTime >= dayEvents[j].dateTimes[k].Item1)
                        {
                            if (!text.associatedEvents.Contains(dayEvents[j]))
                            {
                                text.associatedEvents.Add(dayEvents[j]);
                            }
                        }
                    }
                }

                text.GotFocus += hideTextBoxCursor;
                foreach (Event ev in text.associatedEvents)
                {
                    if (text.Text.Length + ev.ToString().Length > 94)
                    {
                        if (eventsAdded == 0)
                        {
                            text.Text += "Event text too long to display. Click for details.";
                        }
                        else
                        {
                            text.Text += "others...";
                        }
                        break;
                    }
                    else
                    {
                        text.Text += ev.ToString();
                        if (eventsAdded < text.associatedEvents.Count - 1)
                        {
                            text.Text += ", ";
                        }
                    }
                    eventsAdded++;
                }
                Label timeLabel = new Label();
                timeLabel.Anchor = (AnchorStyles.Right);
                if (!use24Hour)
                {
                    timeLabel.Text = "              " + currentTime.ToShortTimeString();
                }
                else
                {
                    String twentyFourFormat = "HH:mm";
                    timeLabel.Text = "              " + currentTime.ToString(twentyFourFormat);
                }
                text.ReadOnly  = true;
                text.Multiline = true;

                text.Click += Text_Click;

                TextBoxArray[i]  = text;
                text.Name        = "text" + i.ToString();
                text.MaximumSize = new Size(200, 300);
                text.Size        = new Size(300, 50);
                flowLayoutPanel1.Controls.Add(timeLabel);
                flowLayoutPanel1.Controls.Add(text);
                currentTime = currentTime.AddMinutes(30);
            }
            monthCalendar1.SelectionStart = startingDate;
            monthCalendar1.SelectionEnd   = startingDate;
            currentDateLabel.Text         = startingDate.ToShortDateString();
        }