protected void DayPilotMonth1_EventMove(object sender, EventMoveEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; //dr["column"] = e.NewResource; table.AcceptChanges(); } else // moved from outside { dr = table.NewRow(); dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["id"] = e.Id; dr["name"] = e.Text; //dr["column"] = e.NewResource; table.Rows.Add(dr); table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataBind(); DayPilotMonth1.Update("Event moved."); }
protected void ButtonExport_Click(object sender, EventArgs e) { DayPilotMonth1.LoadStylesDefaultTheme(); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("Content-Disposition", "attachment;filename=print.png"); DayPilotMonth1.Export(ImageFormat.Png).WriteTo(Response.OutputStream); Response.End(); }
protected void DayPilotMonth1_EventDelete(object sender, EventDeleteEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { table.Rows.Remove(dr); table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Event deleted."); }
protected void DayPilotMonth1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e) { #region Simulation of database update DataRow dr = table.NewRow(); dr["start"] = e.Start; dr["end"] = e.End; dr["id"] = Guid.NewGuid().ToString(); dr["name"] = "New event"; table.Rows.Add(dr); table.AcceptChanges(); #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, null); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); }
protected void DayPilotMonth1_EventResize(object sender, EventResizeEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotMonth1.DataBind(); DayPilotMonth1.Update("Event resized"); }
protected void DayPilotCalendar1_EventMenuClick(object sender, EventMenuClickEventArgs e) { if (e.Command == "Delete") { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { table.Rows.Remove(dr); table.AcceptChanges(); } #endregion DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); } }
protected void DayPilotMonth1_Command(object sender, DayPilot.Web.Ui.Events.CommandEventArgs e) { switch (e.Command) { case "navigate": DayPilotMonth1.StartDate = (DateTime)e.Data["day"]; DayPilotMonth1.DataSource = GetData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "refresh": DayPilotMonth1.DataSource = GetData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; } }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "navigate": DayPilotMonth1.StartDate = (DateTime)e.Data["start"]; DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(CallBackUpdateType.Full); break; case "filter": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(CallBackUpdateType.EventsOnly); break; } }
protected void DayPilotMonth1_EventResize(object sender, EventResizeEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Event resized"); }
protected void DayPilotCalendar1_EventMenuClick(object sender, EventMenuClickEventArgs e) { if (e.Command == "Delete") { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (dr != null) { table.Rows.Remove(dr); table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); } }
protected void DayPilotMonth1_EventMove(object sender, EventMoveEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); // recurrent event but no exception if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["name"] = master["name"]; dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); table.Rows.Add(dr); table.AcceptChanges(); DayPilotMonth1.UpdateWithMessage("Recurrent event exception added."); } // recurrent exception or regular event else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); DayPilotMonth1.UpdateWithMessage("Event moved."); } else { DayPilotMonth1.UpdateWithMessage("No update."); } #endregion DayPilotMonth1.UpdateWithMessage("Update. Start: " + DayPilotMonth1.VisibleStart + " end: " + DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "navigate": DayPilotMonth1.StartDate = (DateTime)e.Data["start"]; DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "filter": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "refresh": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Refreshed."); break; case "delete": #region Simulation of database update string id = (string)e.Data["id"]; DataRow dr = table.Rows.Find(id); if (dr != null) { table.Rows.Remove(dr); table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; } }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "next": DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(1); break; case "previous": DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(-1); break; case "today": DayPilotMonth1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); break; } DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, null); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(CallBackUpdateType.Full); }
protected void DayPilotMonth1_EventResize(object sender, EventResizeEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); /* * if (dr != null) * { * dr["start"] = e.NewStart; * dr["end"] = e.NewEnd; * table.AcceptChanges(); * } */ if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["name"] = master["name"]; table.Rows.Add(dr); table.AcceptChanges(); } else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Event resized"); }
protected void ButtonExportHeader_Click(object sender, EventArgs e) { DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.LoadStylesDefaultTheme(); Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("content-disposition", "attachment;filename=print.png"); int width = 1000; int height = 1000; Bitmap bmp = new Bitmap(width, height); Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; Image cal = DayPilotMonth1.ExportBitmap(); g.DrawImage(cal, 0, 50); string title = String.Format("{0:MMMM yyyy}", DayPilotMonth1.StartDate); Font font = new Font("Tahoma", 16, GraphicsUnit.Point); Brush brush = new SolidBrush(Color.Black); g.DrawString(title, font, brush, 0, 0); // PNG requires random access to the output stream using (MemoryStream mem = new MemoryStream()) { bmp.Save(mem, ImageFormat.Png); mem.WriteTo(Response.OutputStream); } Response.End(); }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "navigate": // display previous and following week as well DateTime start = (DateTime)e.Data["start"]; DateTime previous = start.AddDays(-7); DayPilotMonth1.StartDate = previous; DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(CallBackUpdateType.Full); break; case "filter": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(CallBackUpdateType.EventsOnly); break; } }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "previous": DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(-1); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "next": DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(1); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "navigate": DayPilotMonth1.StartDate = (DateTime)e.Data["start"]; DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "filter": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "refresh": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Refreshed."); break; } }
protected void DayPilotMonth1_Command(object sender, CommandEventArgs e) { switch (e.Command) { case "navigate": DayPilotMonth1.StartDate = (DateTime)e.Data["start"]; DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "filter": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); break; case "refresh": DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Refreshed."); break; case "selected": if (DayPilotMonth1.SelectedEvents.Count > 0) { EventInfo ei = DayPilotMonth1.SelectedEvents[0]; DayPilotMonth1.SelectedEvents.RemoveAt(0); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Event removed from selection: " + ei.Text); } break; } }
protected void Button1_Click(object sender, EventArgs e) { DayPilotMonth1.StartDate = MonthPicker1.StartDate; DayPilotMonth1.DataBind(); }
protected void DayPilotMonth1_Refresh(object sender, RefreshEventArgs e) { DayPilotMonth1.StartDate = e.StartDate; DayPilotMonth1.DataBind(); DayPilotMonth1.Update(); }