|
Nevermind worked it out (im abit slow on a monday!) thanks
|
|
|
|
|
Following is a set of appointment - these actually are real times for a day. They present overlaps and that is not good. I have been unable to figure out where the problem is.
// For testing, set appointment for tomorrow
int thisYear = m_Date.Year;
int thisMonth = m_Date.Month;
int thisDay = m_Date.Day;
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 14, 0, 0);
m_Appointment.Title = "My test 1";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 8, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 14, 0, 0);
m_Appointment.Title = "My test 2";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 13, 50, 0);
m_Appointment.Title = "My test 3";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 12, 34, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 13, 30, 0);
m_Appointment.Title = "My test 4";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 13, 45, 0);
m_Appointment.Title = "My test 5";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 13, 45, 0);
m_Appointment.Title = "My test 5a";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 55, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 8, 30, 0);
m_Appointment.Title = "My test 6";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 7, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 9, 30, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 13, 30, 0);
m_Appointment.Title = "My test 7";
m_Appointments.Add(m_Appointment);
m_Appointment = new Appointment();
m_Appointment.StartDate = new DateTime(thisYear, thisMonth, thisDay, 9, 00, 0);
m_Appointment.EndDate = new DateTime(thisYear, thisMonth, thisDay, 14, 45, 0);
m_Appointment.Title = "My test 8";
m_Appointments.Add(m_Appointment);
//I hope someone can ascertain which routine in DrawAppointments is in error.
David
|
|
|
|
|
The key to understanding this behavior is to study the conflict count, group properties, and halfhourlayouts. Also realize that dayview is designed for 1/2 hour increments and thus the layouts are optimized for half hour rectangles.
You will need to do some work on HalfHourLayouts.
Sorry for little detail, but it's not really an "error", just the way the code is written.
|
|
|
|
|
I use yor control in my project and it work very well, but i have a little problem.
I have myApponintment inherit by Appontment, when i change the end hour by drag top margin of apponitment, i want to change end hour on my dbtable.
How can do it, I don't find an event for this action.
Thank you for yor help and sorry for my english
Francesca Nardi
|
|
|
|
|
You need to create a custom appointment class and override the OnEndDateChanged() method to receive notifications.
class MyAppointment : Appointment
{
protected override void OnEndDateChanged()
{
// db update
}
}
You may use other protected methods to update db.
|
|
|
|
|
Thank you
I have find a problem in your control.
If I select un appointment and after change day, the selected appointment remain visible in the current day.
I adjust this problem set editbox.visible = false.
Also I ask you if you add a property ReadOnly to appointment for not change edit mode if you click on appointment; I manage the appointment information from a custom form and this is not very likeable.
Thank you
Francesca Nardi
|
|
|
|
|
I need to create appointments of 15 or 22 minutes for instance. As well grid`s appearance should stay changeless. I mean what should I do to change the interval of selection from the "halfhour" to one minute. So I`d be able to select area of 16 minutes and set new appointment.
Help me please! Thanks
In code we trust
|
|
|
|
|
If I understand correctly that what you're trying to do is make the control work in one minute instead of half hour intervals, this is not possible with the current code.
|
|
|
|
|
Will it be possible one day ?
Maybe not one minute interval, but 15 ?
|
|
|
|
|
Why not implement the functionality yourself?
|
|
|
|
|
How to save my appointments on my DB and when form load restore my saved appoinmrnt i dont like uso Recordset or other resource , i used direct code
ex:
try
{
conn.Open();
rdr = cmd.ExecuteReader();
if (rdr.HasRows == true)
{
while (rdr.Read())
{
Calend.Name = rdr["CN"].ToString();
Calend.Hour = rdr["Hour"].ToString();
Calend.Date = rdr["Date"].toString();
Calend.Backgrou = rdr["Color"].toString();
}
// The Problem
m_App = new Appointment();
--> m_App.StartDate = ???? MyStart date Saved --> m_App.EndDate = My EndDAte Saved
m_App.BorderColor = MyCOlor Sabved ---> m_App.Title = "Name " +Name " + "Hour "+Hour+ etc..etc..
m_Appointments.Add(m_App);
dayView1.Invalidate();
}
conn.Close();
}
Help me...
|
|
|
|
|
Last week I made some promises about bringing an updated version of the control to the public. Even though it took me longer than I thought, and I was not able to implement everything that I wanted, there are still many changes, and progress has been made towards making this an ultimate bug-free control.
Ladies and gentlemen, without further ado I give you - Calendar DayView Control - Updated, available at http://gimlei.my-place.us
|
|
|
|
|
looks like you did all day events very good thanx for feedback.
i'll try to merge changes to codeplex when i have free time.
|
|
|
|
|
Thanks Ertan. I've sent you an e-mail, so if you want, we can discuss which of the changes should be merged and then give me write access so that I can do some of it a little later.
|
|
|
|
|
Great job Gimlei, i like your fixes a lot.
|
|
|
|
|
Thanks very much Andy. I hoped that my changed would come handy for many people. If you will be developing the control for your needs further and are able to spot/fix any bugs, or implement some of the features in the to-do list (or maybe some others!) and share it with us, that would be amazing.
|
|
|
|
|
Hi, i am in need of any update to this control exists. Unfortunately gimlei, your link is dead, so please could you post a working one or send me an email
vidas.vasiliauskas(eta)etalink.lt
I would be very happy and thankful to you.
Vidas Vasiliauskas
|
|
|
|
|
Hi all,
(Finally) I have created a project site on www.codeplex.com/calendar . To contribute the project please register to site and mail me (ertant@rdgnet.org) your user name for developer access rights.
Anonymous users still have access the project source but you have to register for changing the source.
|
|
|
|
|
Hi Batzo,
Thanks for the reply. Sorry that I wasn't clear on the point.
Below is a small section that I got stuck with an error pointing to the 'List groups = new List();' I followed everything you said, I don't know what is missing on my end.
============
AppointmentList appointments = (AppointmentList)cachedAppointments[time.Day];
if (appointments != null)
{
List groups = new List();
foreach (Appointment app in appointments)
{
if (!groups.Contains(app.Group))
groups.Add(app.Group);
app.refresh();
}
============
Thanks,
S.
|
|
|
|
|
Hi
I think error cause is another thing.
Please check another point. It may be that error cause is datasource that is is not found.
I will send email with attachment (sample project) later.
But, just now I can not send because It prohibits to send email from here.
I am sorry for I can not send sample project. I will send email later from another location.
|
|
|
|
|
I am having some trouble, you posted the code sample and I just replaced the entire thing. But then errors come up so I compared the one you posted to mine and there were chunks of code missing from yours.
I don't really get why but here is what I discovered was missing at the end...
internal int m_ConflictCount;
and other places that I can not pin point cause it would take too long. Is there away you can provide us all with your source of Appointment.cs and DayView.cs and maybe your modded code in Form1 cause I was also confused on where to put things.
It would be good if you could upload these files as a ZIP to Windows Live SkyDrive or something so we can see how you did it because I am getting many build errors.
Thanks,
Michael
P.S. If you would like it better, you can just send me the source or whatever through e-mail.
My email is TheFatPoliceMan[AT]gmail[DOTCOM]
|
|
|
|
|
how can i save all the Appointments in xml file(, for day | manth)?
sory4my english
oCcSkïng
|
|
|
|
|
Hello oCcSkïng.
You should use dataset. So, you can do it.
At the first, you should bind your Appointment with any dataset.
If you could data binding, you can save appointment into xml or any database table.
If you need sample code, I will give you.
-- modified at 2:08 Thursday 1st March, 2007
|
|
|
|
|
Hello batzo,
Yes, I would like to see the sample code. I have lots of problem saving it and display it on the control.
Thank you very much if you don't mind to show me some sample code.
S.
|
|
|
|
|
Hello,
Sorry for replying too late. At first, add new property named scheduleRow and new function named refresh into the Appoinment class and change the get/set methods little. Sample is here:
public class Appointment
{
private DataRow scheduleRow=null; //New property
public Appointment()
{
initialize();
}
public Appointment(DataRow dr)
{
scheduleRow = dr;
refresh();
}
private void initialize()
{
Color = Color.White;
BorderColor = Color.Blue;
Title = "New Appointment";
}
//new function
public void refresh()
{
if (scheduleRow == null)
return;
System.Drawing.ColorConverter colorConverter = new ColorConverter();
color = (Color)colorConverter.ConvertFromString(scheduleRow["Color"].ToString());
borderColor = (Color)colorConverter.ConvertFromString(scheduleRow["BorderColor"].ToString());
title = scheduleRow["Title"].ToString();
startDate = (DateTime)scheduleRow["StartDate"];
endDate = (DateTime)scheduleRow["EndDate"];
locked = System.Convert.ToBoolean(scheduleRow["Locked"].ToString());
}
private string group;
public string Group
{
get { return group; }
set { group = value; }
}
private DateTime startDate;
public DateTime StartDate
{
get
{
return startDate;
}
set
{
startDate = value;
OnStartDateChanged();
}
}
protected virtual void OnStartDateChanged()
{
if (scheduleRow != null)
{
scheduleRow["StartDate"] = StartDate;
}
}
private DateTime endDate;
public DateTime EndDate
{
get
{
return endDate;
}
set
{
endDate = value;
OnEndDateChanged();
}
}
protected virtual void OnEndDateChanged()
{
//System.Diagnostics.Debug.WriteLine("OnEndDateChanged: "+this.EndDate.ToString("yyyy-MM-dd HH:mm:ss"));
if (scheduleRow != null)
{
scheduleRow["EndDate"] = EndDate;
}
}
private bool locked = false;
[System.ComponentModel.DefaultValue(false)]
public bool Locked
{
get { return locked; }
set
{
locked = value;
OnLockedChanged();
}
}
protected virtual void OnLockedChanged()
{
if (scheduleRow != null)
{
scheduleRow["Locked"] = Locked.ToString();
}
}
private Color color = Color.White;
public Color Color
{
get
{
return color;
}
set
{
color = value;
OnColorChanged();
}
}
private void OnColorChanged()
{
if (scheduleRow != null)
{
System.Drawing.ColorConverter colorConverter = new ColorConverter();
scheduleRow["Color"] = colorConverter.ConvertToString(Color);
}
}
private Color textColor = Color.Black;
public Color TextColor
{
get { return textColor; }
set { textColor = value; }
}
private Color borderColor = Color.Blue;
public Color BorderColor
{
get
{
return borderColor;
}
set
{
borderColor = value;
OnBorderColorChanged();
}
}
private void OnBorderColorChanged()
{
if (scheduleRow != null)
{
System.Drawing.ColorConverter colorConverter = new ColorConverter();
scheduleRow["BorderColor"] = colorConverter.ConvertToString(BorderColor);
}
}
private string title = "";
[System.ComponentModel.DefaultValue("")]
public string Title
{
get
{
return title;
}
set
{
title = value;
OnTitleChanged();
}
}
protected virtual void OnTitleChanged()
{
//System.Diagnostics.Debug.WriteLine("OnTitleChanged: " + this.Title);
if (scheduleRow != null)
{
scheduleRow["Title"] = Title;
}
}
internal int conflictCount;
internal bool allDayEvent;
}
Then, you should change DayView Class as following code. (In DrawDay() function, call refresh() function of Appointment class)
private void DrawDay(PaintEventArgs e, Rectangle rect, DateTime time)
{
//renderer.DrawDayBackground(e.Graphics, rect);
Rectangle workingHoursRectangle = GetHourRangeRectangle(workStart, workEnd, rect);
if (workingHoursRectangle.Y < this.HeaderHeight)
workingHoursRectangle.Y = this.HeaderHeight;
if (!((time.DayOfWeek == DayOfWeek.Saturday) || (time.DayOfWeek == DayOfWeek.Sunday))) //weekends off -> no working hours
renderer.DrawHourRange(e.Graphics, workingHoursRectangle, false, false);
if ((selection == SelectionType.DateRange) && (time.Day == selectionStart.Day))
{
Rectangle selectionRectangle = GetHourRangeRectangle(selectionStart, selectionEnd, rect);
renderer.DrawHourRange(e.Graphics, selectionRectangle, false, true);
}
e.Graphics.SetClip(rect);
for (int hour = 0; hour < 24 * 2; hour++)
{
int y = rect.Top + (hour * halfHourHeight) - scrollbar.Value;
using (Pen pen = new Pen(((hour % 2) == 0 ? renderer.HourSeperatorColor : renderer.HalfHourSeperatorColor)))
e.Graphics.DrawLine(pen, rect.Left, y, rect.Right, y);
if (y > rect.Bottom)
break;
}
renderer.DrawDayGripper(e.Graphics, rect, appointmentGripWidth);
e.Graphics.ResetClip();
/* BEGIN */
AppointmentList appointments = (AppointmentList)cachedAppointments[time.Day];
if (appointments != null)
{
List<string> groups = new List<string>();
foreach (Appointment app in appointments)
{
if (!groups.Contains(app.Group))
groups.Add(app.Group);
app.refresh();
}
Rectangle rect2 = rect;
rect2.Width = rect2.Width / groups.Count;
groups.Sort();
foreach (string group in groups)
{
DrawAppointments(e, rect2, time, group);
rect2.X += rect2.Width;
}
}
/* END */
}
Next, Add new property into the container of DayView control. For example: Form1 class.
partial class Form1
{
private System.Data.DataSet scheduleDataSet;
......
.....
}
Now, you should get data from Database or xml file. I wrote some functions you need.
private void CreateTable()
{
this.scheduleDataSet = new System.Data.DataSet();
System.Data.DataTable scheduleDataTable = new System.Data.DataTable();
System.Data.DataColumn TitleColumn = new System.Data.DataColumn();
System.Data.DataColumn StartDateColumn = new System.Data.DataColumn();
System.Data.DataColumn EndDateColumn = new System.Data.DataColumn();
System.Data.DataColumn BorderColorColumn = new System.Data.DataColumn();
System.Data.DataColumn ColorColumn = new System.Data.DataColumn();
System.Data.DataColumn LockedColumn = new System.Data.DataColumn();
//
// scheduleDataSet
//
this.scheduleDataSet.DataSetName = "scheduleDataSet";
this.scheduleDataSet.Tables.AddRange(new System.Data.DataTable[] {
scheduleDataTable});
//
// scheduleDataTable
//
scheduleDataTable.Columns.AddRange(new System.Data.DataColumn[] {
TitleColumn,
StartDateColumn,
EndDateColumn,
BorderColorColumn,
ColorColumn,
LockedColumn});
scheduleDataTable.TableName = "schedule";
//
// TitleColumn
//
TitleColumn.ColumnName = "Title";
//
// StartDateColumn
//
StartDateColumn.ColumnName = "StartDate";
StartDateColumn.DataType = typeof(System.DateTime);
//
// EndDateColumn
//
EndDateColumn.ColumnName = "EndDate";
EndDateColumn.DataType = typeof(System.DateTime);
//
// BorderColorColumn
//
BorderColorColumn.ColumnName = "BorderColor";
//
// ColorColumn
//
ColorColumn.ColumnName = "Color";
//
// LockedColumn
//
LockedColumn.ColumnName = "Locked";
}
private void createData()
{
CreateTable();
System.Data.DataRow dr = scheduleDataSet.Tables["schedule"].NewRow();
DateTime dateTime = DateTime.Now;
dr["Title"] = "Appointment1 (Purevsuren)";
dr["StartDate"] = dateTime;
dr["EndDate"] = dateTime.AddMinutes(15);
dr["Color"] = "White";
dr["BorderColor"] = "Blue";
dr["Locked"] = "false";
scheduleDataSet.Tables["schedule"].Rows.Add(dr);
dr = scheduleDataSet.Tables["schedule"].NewRow();
dateTime = dateTime.AddMinutes(30);
dr["Title"] = "Appointment2 (Zorigt)";
dr["StartDate"] = dateTime;
dr["EndDate"] = dateTime.AddMinutes(30);
dr["Color"] = "White";
dr["BorderColor"] = "Blue";
dr["Locked"] = "false";
scheduleDataSet.Tables["schedule"].Rows.Add(dr);
dr = scheduleDataSet.Tables["schedule"].NewRow();
dateTime = dateTime.AddHours(3);
dr["Title"] = "Appointment3 (Batzorigt)";
dr["StartDate"] = dateTime;
dr["EndDate"] = dateTime.AddHours(1);
dr["Color"] = "Red";
dr["BorderColor"] = "Blue";
dr["Locked"] = "true";
scheduleDataSet.Tables["schedule"].Rows.Add(dr);
dr = scheduleDataSet.Tables["schedule"].NewRow();
dateTime = dateTime.AddHours(3);
dr["Title"] = "Flying to Mongolia";
dr["StartDate"] = dateTime;
dr["EndDate"] = dateTime.AddHours(1);
dr["Color"] = "Red";
dr["BorderColor"] = "Blue";
dr["Locked"] = "true";
scheduleDataSet.Tables["schedule"].Rows.Add(dr);
writeToXml("schedule.xml");
}
private void readFromXml(String fileName)
{
//add your own code here
scheduleDataSet.ReadXml(fileName);
}
private void writeToXml(String fileName)
{
//add your own code here
scheduleDataSet.WriteXml(fileName);
}
In constructor function I added some code to display data that read from xml file.
PS: I inserted the DataGridView1 and Save button into the form.
private void initDayView()
{
m_Appointments = new List<appointment>();
for (int i = 0; i < scheduleDataSet.Tables["schedule"].Rows.Count; i++)
{
Appointment app = new Appointment(scheduleDataSet.Tables["schedule"].Rows[i]);
m_Appointments.Add(app);
}
}
public Form1()
{
InitializeComponent();
//if there is no xml file, create xml file
createData(); //else comment out this line
//read from xml file
//readFromXml("schedule.xml"); //if there is xml file
this.dataGridView1.DataSource = scheduleDataSet;
this.dataGridView1.DataMember = "schedule";
initDayView();
dayView1.StartDate = DateTime.Now;
dayView1.NewAppointment += new NewAppointmentEventHandler(dayView1_NewAppointment);
dayView1.SelectionChanged += new EventHandler(dayView1_SelectionChanged);
dayView1.ResolveAppointments += new Calendar.ResolveAppointmentsEventHandler(this.dayView1_ResolveAppointments);
dayView1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dayView1_MouseMove);
comboBox1.SelectedIndex = 1;
}
To save data into xml file on click of Save button:
private void btnSave_Click(object sender, EventArgs e)
{
scheduleDataSet.WriteXml("schedule.xml");
}
If you wish to update DayView control on changing of datagrid, you should add CellEndEdit event.
So, you can use following code:
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
dayView1.Invalidate();
}
Good Luck!
-- modified at 4:58 Monday 5th March, 2007
|
|
|
|
|