using AxXtremeCalendarControl;
using System;
using System.Diagnostics;
using System.Windows.Forms;
using XtremeCalendarControl;
namespace CodejockTest_
{
public partial class Form1 : Form
{
AxCalendarControl axCalendarControl;
CalendarResource _outlook = new CalendarResource();
public Form1()
{
InitializeComponent();
axCalendarControl = new AxCalendarControl
{
Dock = DockStyle.Fill
};
Controls.Add(axCalendarControl);
}
private void Form1_Load(object sender, EventArgs e)
{
axCalendarControl.ViewType = CalendarViewType.xtpCalendarWorkWeekView;
CalendarResource resource = new CalendarResource();
resource.SetDataProvider2("", true);
if (!resource.DataProvider.Open())
{
if (!resource.DataProvider.Create())
{
}
}
CalendarSchedules schedules = resource.DataProvider.Schedules;
schedules.AddNewSchedule("");
schedules.AddNewSchedule("outlook");
resource.Name = schedules[0].Name;
resource.ScheduleIDs.Add(schedules[0].Id);
CalendarResource res2 = new CalendarResource();
_outlook.SetDataProvider2("", true);
if (!_outlook.DataProvider.Open())
{
if (!_outlook.DataProvider.Create())
{
Debug.Assert(false);
}
}
_outlook.Name = schedules[1].Name;
_outlook.ScheduleIDs.Add(schedules[1].Id);
CalendarResources res3 = new CalendarResources();
res3.Add(resource);
axCalendarControl.SetMultipleResources(res3);
CalendarEvent c0 = axCalendarControl.DataProvider.CreateEvent();
c0.StartTime = DateTime.Now;
c0.EndTime = DateTime.Now.AddMinutes(30);
c0.Subject = "test";
c0.EventVisible = true;
c0.ScheduleID = schedules[0].Id;
axCalendarControl.DataProvider.AddEvent(c0);
var c1 = _outlook.DataProvider.CreateEvent();
c1.StartTime = DateTime.Now.AddHours(-5);
c1.EndTime = DateTime.Now.AddHours(-4);
c1.Subject = "test2";
c1.EventVisible = true;
c1.ScheduleID = schedules[1].Id;
_outlook.DataProvider.AddEvent(c1);
axCalendarControl.Populate();
axCalendarControl.RedrawControl();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripMenuItem1.Checked = !toolStripMenuItem1.Checked;
if (!toolStripMenuItem1.Checked)
{
axCalendarControl.MultipleResources.Remove(1);
axCalendarControl.MultipleResources[0].DataProvider.Schedules.RemoveSchedule(2);
}
else
{
axCalendarControl.MultipleResources.Add(_outlook);
}
axCalendarControl.Populate();
axCalendarControl.RedrawControl();
}
}
}