コード例 #1
0
ファイル: VFreeBusyDlg.cs プロジェクト: nhaberl/PDI
        /// <summary>
        /// Update the free/busy object with the dialog control values
        /// </summary>
        /// <param name="fb">The free/busy object in which the settings are updated</param>
        public void GetValues(VFreeBusy fb)
        {
            // The unique ID is not changed
            fb.Organizer.Value = txtOrganizer.Text;
            fb.Contact.Value   = txtContact.Text;

            // We'll use the TimeZoneDateTime property on all date/time values so that they are set literally
            // rather than being converted to the time zone as would happen with the DateTimeValue property.
            if (!dtpStartDate.Checked)
            {
                fb.StartDateTime.TimeZoneDateTime = DateTime.MinValue;
            }
            else
            {
                fb.StartDateTime.TimeZoneDateTime = dtpStartDate.Value;
                fb.StartDateTime.ValueLocation    = ValLocValue.DateTime;
            }

            if (!dtpEndDate.Checked)
            {
                fb.EndDateTime.TimeZoneDateTime = DateTime.MinValue;
            }
            else
            {
                fb.EndDateTime.TimeZoneDateTime = dtpEndDate.Value;
                fb.StartDateTime.ValueLocation  = ValLocValue.DateTime;
            }

            fb.Duration.DurationValue = new Duration(txtDuration.Text);
            fb.Url.Value     = txtUrl.Text;
            fb.Comment.Value = txtComments.Text;

            // For the collections, we'll clear the existing items and copy the modified items from the browse
            // control binding sources.
            fb.Attendees.Clear();
            fb.Attendees.CloneRange((AttendeePropertyCollection)ucAttendees.BindingSource.DataSource);

            fb.FreeBusy.Clear();
            fb.FreeBusy.CloneRange((FreeBusyPropertyCollection)ucFreeBusy.BindingSource.DataSource);

            fb.RequestStatuses.Clear();
            fb.RequestStatuses.CloneRange((RequestStatusPropertyCollection)ucRequestStatus.BindingSource.DataSource);

            // Set the time zone in the object after getting all the data.  The "Set" method will not modify the
            // date/times like the "Apply" method does.
            if (cboTimeZone.Enabled && cboTimeZone.SelectedIndex != 0)
            {
                fb.SetTimeZone(VCalendar.TimeZones[cboTimeZone.SelectedIndex - 1]);
            }
            else
            {
                fb.SetTimeZone(null);
            }
        }
コード例 #2
0
ファイル: CalendarBrowser.aspx.cs プロジェクト: ywscr/PDI
        /// <summary>
        /// This is an example of how you can sort calendar object collections
        /// </summary>
        /// <param name="x">The first calendar object</param>
        /// <param name="y">The second calendar object</param>
        /// <remarks>Due to the variety of properties in a calendar object, sorting is left up to the developer
        /// utilizing a comparison delegate.  This example sorts the collection by the start date/time property
        /// and, if they are equal, the summary description.  This is used to handle all of the collection
        /// types.</remarks>
        private static int CalendarSorter(CalendarObject x, CalendarObject y)
        {
            DateTime d1, d2;
            string   summary1, summary2;

            if (x is VEvent)
            {
                VEvent e1 = (VEvent)x, e2 = (VEvent)y;

                d1       = e1.StartDateTime.TimeZoneDateTime;
                d2       = e2.StartDateTime.TimeZoneDateTime;
                summary1 = e1.Summary.Value;
                summary2 = e2.Summary.Value;
            }
            else
            if (x is VToDo)
            {
                VToDo t1 = (VToDo)x, t2 = (VToDo)y;

                d1       = t1.StartDateTime.TimeZoneDateTime;
                d2       = t2.StartDateTime.TimeZoneDateTime;
                summary1 = t1.Summary.Value;
                summary2 = t2.Summary.Value;
            }
            else
            if (x is VJournal)
            {
                VJournal j1 = (VJournal)x, j2 = (VJournal)y;

                d1       = j1.StartDateTime.TimeZoneDateTime;
                d2       = j2.StartDateTime.TimeZoneDateTime;
                summary1 = j1.Summary.Value;
                summary2 = j2.Summary.Value;
            }
            else
            {
                VFreeBusy f1 = (VFreeBusy)x, f2 = (VFreeBusy)y;

                d1       = f1.StartDateTime.TimeZoneDateTime;
                d2       = f2.StartDateTime.TimeZoneDateTime;
                summary1 = f1.Organizer.Value;
                summary2 = f2.Organizer.Value;
            }

            if (d1.CompareTo(d2) == 0)
            {
                if (summary1 == null)
                {
                    summary1 = String.Empty;
                }

                if (summary2 == null)
                {
                    summary2 = String.Empty;
                }

                // For descending order, change this to compare summary 2 to summary 1 instead
                return(String.Compare(summary1, summary2, StringComparison.CurrentCulture));
            }

            // For descending order, change this to compare date 2 to date 1 instead
            return(d1.CompareTo(d2));
        }
コード例 #3
0
ファイル: VFreeBusyDlg.cs プロジェクト: nhaberl/PDI
        //=====================================================================

        /// <summary>
        /// Initialize the dialog controls using the specified VFreeBusy object
        /// </summary>
        /// <param name="fb">The free/busy object from which to get the settings</param>
        public void SetValues(VFreeBusy fb)
        {
            string timeZoneId = fb.StartDateTime.TimeZoneId;

            txtUniqueId.Text  = fb.UniqueId.Value;
            txtOrganizer.Text = fb.Organizer.Value;
            txtContact.Text   = fb.Contact.Value;

            if (fb.StartDateTime.TimeZoneDateTime == DateTime.MinValue)
            {
                dtpStartDate.Checked = false;
            }
            else
            {
                dtpStartDate.Value   = fb.StartDateTime.TimeZoneDateTime;
                dtpStartDate.Checked = true;
            }

            if (fb.EndDateTime.TimeZoneDateTime == DateTime.MinValue)
            {
                dtpEndDate.Checked = false;
            }
            else
            {
                dtpEndDate.Value   = fb.EndDateTime.TimeZoneDateTime;
                dtpEndDate.Checked = true;
            }

            if (fb.Duration.DurationValue != Duration.Zero)
            {
                txtDuration.Text = fb.Duration.DurationValue.ToString(Duration.MaxUnit.Weeks);
            }

            txtUrl.Text      = fb.Url.Value;
            txtComments.Text = fb.Comment.Value;

            // We could bind directly to the existing collections but that would modify them.  To preserve the
            // original items, we'll pass a copy of the collections instead.
            ucAttendees.BindingSource.DataSource     = new AttendeePropertyCollection().CloneRange(fb.Attendees);
            ucFreeBusy.BindingSource.DataSource      = new FreeBusyPropertyCollection().CloneRange(fb.FreeBusy);
            ucRequestStatus.BindingSource.DataSource = new RequestStatusPropertyCollection().CloneRange(fb.RequestStatuses);

            // We use the start date's time zone ID for the combo box.  It should represent the time zone used
            // throughout the component.
            if (timeZoneId == null)
            {
                cboTimeZone.SelectedIndex = timeZoneIdx = 0;
            }
            else
            {
                timeZoneIdx = cboTimeZone.Items.IndexOf(timeZoneId);

                if (timeZoneIdx != -1)
                {
                    cboTimeZone.SelectedIndex = timeZoneIdx;
                }
                else
                {
                    cboTimeZone.SelectedIndex = timeZoneIdx = 0;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Add a calendar item
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            switch (cboComponents.SelectedIndex)
            {
            case 0:
                using (CalendarObjectDlg dlg = new CalendarObjectDlg())
                {
                    VEvent evt = new VEvent();
                    evt.UniqueId.AssignNewId(true);
                    evt.DateCreated.TimeZoneDateTime  = DateTime.Now;
                    evt.LastModified.TimeZoneDateTime = evt.DateCreated.TimeZoneDateTime;
                    dlg.SetValues(evt);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        dlg.GetValues(evt);

                        // Create a unique ID for the new item
                        evt.UniqueId.AssignNewId(true);

                        vCal.Events.Add(evt);
                    }
                }
                break;

            case 1:
                using (CalendarObjectDlg dlg = new CalendarObjectDlg())
                {
                    VToDo td = new VToDo();
                    td.DateCreated.TimeZoneDateTime  = DateTime.Now;
                    td.LastModified.TimeZoneDateTime = td.DateCreated.TimeZoneDateTime;
                    dlg.SetValues(td);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        dlg.GetValues(td);

                        // Create a unique ID for the new item
                        td.UniqueId.AssignNewId(true);

                        vCal.ToDos.Add(td);
                    }
                }
                break;

            case 2:
                using (CalendarObjectDlg dlg = new CalendarObjectDlg())
                {
                    VJournal j = new VJournal();
                    j.DateCreated.TimeZoneDateTime  = DateTime.Now;
                    j.LastModified.TimeZoneDateTime = j.DateCreated.TimeZoneDateTime;
                    dlg.SetValues(j);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        dlg.GetValues(j);

                        // Create a unique ID for the new item
                        j.UniqueId.AssignNewId(true);

                        vCal.Journals.Add(j);
                    }
                }
                break;

            case 3:
                using (VFreeBusyDlg dlg = new VFreeBusyDlg())
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        VFreeBusy fb = new VFreeBusy();
                        dlg.GetValues(fb);

                        // Create a unique ID for the new item
                        fb.UniqueId.AssignNewId(true);

                        vCal.FreeBusys.Add(fb);
                    }
                }
                break;
            }
        }
コード例 #5
0
ファイル: FreeBusyDetails.aspx.cs プロジェクト: ywscr/PDI
        /// <summary>
        /// Save changes and return to the calendar browser
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DateTime startDate = DateTime.MinValue, endDate = DateTime.MinValue;
            Duration dur = Duration.Zero;

            if (!Page.IsValid)
            {
                return;
            }

            lblMsg.Text = null;

            // Perform some edits
            if (txtStartDate.Text.Trim().Length != 0 && !DateTime.TryParse(txtStartDate.Text,
                                                                           CultureInfo.CurrentCulture, DateTimeStyles.None, out startDate))
            {
                lblMsg.Text = "Invalid start date format<br>";
            }

            if (txtEndDate.Text.Trim().Length != 0 && !DateTime.TryParse(txtEndDate.Text,
                                                                         CultureInfo.CurrentCulture, DateTimeStyles.None, out endDate))
            {
                lblMsg.Text += "Invalid end date format<br>";
            }

            if (txtDuration.Text.Trim().Length != 0 && !Duration.TryParse(txtDuration.Text, out dur))
            {
                lblMsg.Text += "Invalid duration format<br>";
            }

            if (startDate != DateTime.MinValue && endDate != DateTime.MinValue && startDate > endDate)
            {
                lblMsg.Text += "Start date must be less than or equal to end date<br>";
            }

            if (!String.IsNullOrWhiteSpace(lblMsg.Text))
            {
                return;
            }

            VCalendar cal = (VCalendar)Session["VCalendar"];

            // Not very friendly, but it's just a demo
            if (cal == null)
            {
                Response.Redirect("CalendarBrowser.aspx");
                return;
            }

            VFreeBusy fb = cal.FreeBusys[(int)this.ViewState["FreeBusyIndex"]];

            // The unique ID is not changed
            fb.Organizer.Value = txtOrganizer.Text;
            fb.Contact.Value   = txtContact.Text;

            // We'll use the TimeZoneDateTime property on all date/time values so that they are set literally
            // rather than being converted to the time zone as would happen with the DateTimeValue property.
            fb.StartDateTime.TimeZoneDateTime = startDate;
            fb.StartDateTime.ValueLocation    = ValLocValue.DateTime;

            fb.EndDateTime.TimeZoneDateTime = endDate;
            fb.StartDateTime.ValueLocation  = ValLocValue.DateTime;

            fb.Duration.DurationValue = dur;
            fb.Url.Value     = txtUrl.Text;
            fb.Comment.Value = txtComments.Text;

            Response.Redirect("CalendarBrowser.aspx");
        }