in Office365APIEditor/UI/CreateEventForm.cs [44:205]
private async void CreateEventForm_LoadAsync(object sender, EventArgs e)
{
Icon = Properties.Resources.DefaultIcon;
attachments = new List<ViewerHelper.Data.AttachmentAPI.AttachmentBase>();
// Display the window in the center of the parent window.
Location = new Point(Owner.Location.X + (Owner.Width - Width) / 2, Owner.Location.Y + (Owner.Height - Height) / 2);
viewerRequestHelper = new ViewerRequestHelper();
groupBox_Recurring_Pattern.Enabled = false;
groupBox_Recurring_Range.Enabled = false;
radioButton_Recurring_Pattern_Daily.Checked = true;
groupBox_Recurring_Pattern_Weekly.Enabled = false;
groupBox_Recurring_Pattern_Monthly.Enabled = false;
groupBox_Recurring_Pattern_Yearly.Enabled = false;
comboBox_Recurring_Pattern_Monthly_DayOfWeekIndex.Items.Add("First");
comboBox_Recurring_Pattern_Monthly_DayOfWeekIndex.Items.Add("Second");
comboBox_Recurring_Pattern_Monthly_DayOfWeekIndex.Items.Add("Third");
comboBox_Recurring_Pattern_Monthly_DayOfWeekIndex.Items.Add("Fourth");
comboBox_Recurring_Pattern_Monthly_DayOfWeekIndex.Items.Add("Last");
comboBox_Recurring_Pattern_Yearly_Relative_DayOfWeekIndex.Items.Add("First");
comboBox_Recurring_Pattern_Yearly_Relative_DayOfWeekIndex.Items.Add("Second");
comboBox_Recurring_Pattern_Yearly_Relative_DayOfWeekIndex.Items.Add("Third");
comboBox_Recurring_Pattern_Yearly_Relative_DayOfWeekIndex.Items.Add("Fourth");
comboBox_Recurring_Pattern_Yearly_Relative_DayOfWeekIndex.Items.Add("Last");
for (int i = 1; i <= 100 ; i++)
{
comboBox_Recurring_Pattern_Daily_Interval.Items.Add(i);
comboBox_Recurring_Pattern_Weekly_Interval.Items.Add(i);
comboBox_Recurring_Pattern_Monthly_Interval.Items.Add(i);
comboBox_Recurring_Pattern_Yearly_Interval.Items.Add(i);
comboBox_Recurring_Range_NumberOfConcurrences.Items.Add(i);
}
comboBox_Recurring_Pattern_Daily_Interval.SelectedItem = 1;
comboBox_Recurring_Pattern_Weekly_Interval.SelectedItem = 1;
comboBox_Recurring_Pattern_Monthly_Interval.SelectedItem = 1;
comboBox_Recurring_Pattern_Yearly_Interval.SelectedItem = 1;
comboBox_Recurring_Range_NumberOfConcurrences.SelectedItem = 10;
radioButton_Recurring_Pattern_Monthly_MonthlyPattern.Checked = true;
ToggleMonthlyPatternUI(true);
for (int i = 1; i <= 31; i++)
{
comboBox_Recurring_Pattern_Monthly_DayOfTheMonth.Items.Add(i);
comboBox_Recurring_Pattern_Yearly_Absolute_Day.Items.Add(i);
}
for (int i = 1; i <= 12; i++)
{
string monthName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[i - 1];
comboBox_Recurring_Pattern_Yearly_Absolute_Month.Items.Add(monthName);
comboBox_Recurring_Pattern_Yearly_Relative_Month.Items.Add(monthName);
}
comboBox_Recurring_Pattern_Monthly_DayOfTheMonth.SelectedItem = 1;
radioButton_Recurring_Pattern_Yearly_OnSpecificDay.Checked = true;
ToggleYearlyPatternUI(true);
radioButton_Recurring_Range_NoEnd.Checked = true;
DateTime now = DateTime.Now; // Use local time;
DateTime tempStartDateTime = now;
if (tempStartDateTime.Minute < 30)
{
tempStartDateTime = tempStartDateTime.AddMinutes(30 - tempStartDateTime.Minute);
}
else if (tempStartDateTime.Minute == 30)
{
tempStartDateTime = tempStartDateTime.AddMinutes(30);
}
else if (30 < tempStartDateTime.Minute && tempStartDateTime.Minute < 60)
{
tempStartDateTime = tempStartDateTime.AddMinutes(60 - tempStartDateTime.Minute);
}
dateTimePicker_Basic_StartDate.Value = tempStartDateTime;
dateTimePicker_Basic_StartTime.Value = tempStartDateTime;
DateTime tempEndDateTime = tempStartDateTime.AddMinutes(30);
dateTimePicker_Basic_EndDate.Value = tempEndDateTime;
dateTimePicker_Basic_EndTime.Value = tempEndDateTime;
string localTimeZone = Util.LocalTimeZoneId;
// Load all system time zones and add them to the combo box.
var timeZoneCollection = TimeZoneInfo.GetSystemTimeZones();
foreach (var timeZone in timeZoneCollection)
{
var matches = Regex.Matches(timeZone.DisplayName, @"^\(UTC.*\)\s");
if (matches.Count == 1)
{
comboBox_Basic_TimeZone.Items.Add($"{matches[0]} {timeZone.Id}");
}
else
{
comboBox_Basic_TimeZone.Items.Add(timeZone.Id);
}
if (timeZone.Id == localTimeZone)
{
// Select local time zone.
comboBox_Basic_TimeZone.SelectedIndex = comboBox_Basic_TimeZone.Items.Count - 1;
}
}
// Load all calendar API supported time zones and add them to the combo box.
foreach (var timeZone in Util.GetCalendarApiSupportedTimeZones())
{
comboBox_Basic_TimeZone.Items.Add(timeZone);
}
comboBox_BodyType.SelectedIndex = 1;
comboBox_Recurring_Range_NumberOfConcurrences.Enabled = false;
dateTimePicker_Recurring_Range_EndByDate.Enabled = false;
comboBox_OnlineMeeting_Provider.Items.Add("None");
comboBox_OnlineMeeting_Provider.SelectedIndex = 0;
// Get allowedOnlineMeetingProviders
try
{
var allowedOnlineMeetingProviders = await viewerRequestHelper.GetAllowdOnlineMeetingProvidersAsync();
if (allowedOnlineMeetingProviders == null || allowedOnlineMeetingProviders.Count == 0)
{
throw new Exception("Microsoft Graph request was succeeded, but allowedOnlineMeetingProviders property is null or empty.");
}
if (allowedOnlineMeetingProviders.Count == 1 && allowedOnlineMeetingProviders[0] == "unknown")
{
throw new Exception("Microsoft Graph request was succeeded, but allowedOnlineMeetingProviders property contains only 'unknown'");
}
foreach (var provider in allowedOnlineMeetingProviders)
{
if (provider != "unknown")
{
comboBox_OnlineMeeting_Provider.Items.Add(provider);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Could not get allowed online meeting providers." + Environment.NewLine + Environment.NewLine + ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
textBox_Basic_Title.Focus();
}