This might be an easy thing to do but I've searched and haven't found a solution as to how to do this yet. Right now with the scheduler it shows military/24 hour time on the left hand side bar and I'd like it to show 12 hour time, such as 12pm instead of 1300. How can this be set?
Kind regards,
David
15 Answers, 1 is accepted
Thanks,
David
Thank you for writing.
You could disable the 24 hour ruler by creating your own instance of RulerFormatStrings class and set it as FormatStrings property of the ruler. Please see my code snippet below and this article for additional information:
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
RulerPrimitive ruler = (
this
.radScheduler1.SchedulerElement.ViewElement
as
SchedulerDayViewElement).DataAreaElement.Ruler;
ruler.FormatStrings =
new
RulerFormatStrings(
"hh"
,
"mm: tt"
,
null
,
null
);
ruler.RulerWidth = 60;
}
}
You could also subscribe to RulerTextFormatting event and in the handler perform additional formatting and styling of the text which is going to be rendered in the ruler.
I am also sending you a screenshot showing how the scheduler looks on my side.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you for writing.
Although there is no property allowing us to specify a date format, there is a way to accomplish this task and show AM and PM in the printed document. You would need to subscribe your SchedulerWeeklyCalendarPrintStyle instance to the CellElementFormatting event and in the handler change the date format of the cell elements in the ruler. Please see my code snippet below:
Public
Class
Form1
Sub
New
()
InitializeComponent()
Dim
weeklyCalendarStyle
As
New
SchedulerWeeklyCalendarPrintStyle()
weeklyCalendarStyle.AppointmentFont =
New
System.Drawing.Font(
"Segoe UI"
, 12, FontStyle.Regular)
weeklyCalendarStyle.HeadingAreaHeight = 120
weeklyCalendarStyle.HoursColumnWidth = 60
Me
.RadScheduler1.PrintStyle = weeklyCalendarStyle
AddHandler
weeklyCalendarStyle.CellElementFormatting,
AddressOf
weeklyCalendarStyle_CellElementFormatting
End
Sub
Private
Sub
weeklyCalendarStyle_CellElementFormatting(sender
As
Object
, e
As
PrintSchedulerCellEventArgs)
Dim
cell
As
SchedulerPrintCellElement = TryCast(e.CellElement, SchedulerPrintCellElement)
If
cell IsNot
Nothing
AndAlso
cell.DateFormat =
"hh:mm"
Then
cell.DateFormat =
"hh:mm tt"
End
If
End
Sub
End
Class
Additional information on the print styles in the RadScheduler element you can find here. I am also sending you a screenshot of the result on my end using the code in the snippet above.
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
How can I make the days column say "Monday Feb. 16", instead of "16 Feb"?
Can I add notes (text) to the notes area?
Thanks for your help, I'm getting there.
Later
Art
Also, I'm having a problem creating the bitmap and the PDF.
Private Sub CreateBMP(OutFileName As String, AthleteID As Long, AthleteName As String)
Try
Dim x As Integer = 1200
Dim y As Integer = 1500
Dim weeklyCalendarStyle As New SchedulerWeeklyCalendarPrintStyle()
With weeklyCalendarStyle
If Me.chkWeekends.Checked Then
.FirstDayOfWeek = DayOfWeek.Sunday
.ExcludeNonWorkingDays = False
Else
.FirstDayOfWeek = DayOfWeek.Monday
.ExcludeNonWorkingDays = True
End If
.DateStartRange = dpWeek.Value.Date
.DateEndRange = dpWeek.Value.Date
.TimeStartRange = TimeSpan.FromHours(7)
.TimeEndRange = TimeSpan.FromHours(22)
.AppointmentFont = New Font("Segoe UI Light", 8, FontStyle.Regular)
.DateHeadingFont = New Font("Segoe UI Light", 12, FontStyle.Regular)
.PageHeadingFont = New Font("Segoe UI Light", 16, FontStyle.Regular)
.DrawPageTitle = False
.DrawPageTitleCalendar = False
.ShowLinedNotesArea = False
.ShowNotesArea = Me.chkPrintNotes.Checked
.ShowTimezone = False
.GroupType = SchedulerPrintGroupType.Date
.HoursColumnWidth = 55
End With
Me.RadScheduler1.PrintStyle = weeklyCalendarStyle
AddHandler weeklyCalendarStyle.CellElementFormatting, AddressOf weeklyCalendarStyle_CellElementFormatting
With RadPrintDocument1
.LeftHeader = AthleteName
.RightHeader = "Week of " & dpWeek.Value.Date.AddDays(-dpWeek.Value.DayOfWeek)
.Landscape = False
.HeaderFont = New Font("Microsoft Sans Serif", 20, FontStyle.Bold)
.HeaderHeight = 50
.Margins.Bottom = 50
.Margins.Top = 50
.Margins.Left = 50
.Margins.Right = 50
End With
'RadScheduler1.PrintPreview(RadPrintDocument1)
DirectCast(RadScheduler1, IPrintable).BeginPrint(RadPrintDocument1, New PrintEventArgs())
'this is needed in order to set the printStyle source
Dim bmp As New Bitmap(x, y)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim pages As Integer = RadScheduler1.PrintStyle.GetNumberOfPages(New Rectangle(0, 0, x, y), g)
g.Dispose()
bmp.Dispose()
For i As Integer = 0 To pages - 1
bmp = New Bitmap(x, y)
g = Graphics.FromImage(bmp)
g.FillRectangle(Brushes.White, New Rectangle(0, 0, x, y))
RadScheduler1.PrintStyle.DrawPage(g, New Rectangle(0, 0, x, y), i + 1)
g.Dispose()
bmp.Save(OutFileName)
bmp.Dispose()
Next
End Sub
Private Sub weeklyCalendarStyle_CellElementFormatting(sender As Object, e As PrintSchedulerCellEventArgs)
Dim cell As SchedulerPrintCellElement = TryCast(e.CellElement, SchedulerPrintCellElement)
If cell IsNot Nothing Then
If cell.DateFormat = "hh:mm" Then
cell.DateFormat = "h:mm tt"
cell.Font = New Font("Segoe UI Light", 12, FontStyle.Bold)
ElseIf cell.DateFormat = "dd MMM" Then
cell.DateFormat = "ddd M/d"
cell.TextAlignment = ContentAlignment.MiddleCenter
End If
End If
End Sub
It works fine up to, and including, 'RadScheduler1.PrintPreview(RadPrintDocument1). The preview looks great but the bitmap does not include the header or any other RadPrintDocument1 properties. Then it gets worse when going to a PDF.
I have created a sample project in which I am generating the pdf file out of a bitmap image which is styled via a SchedulerWeeklyPrintStyle object. Then using our PDF Processing framework, I converted the image to a pdf document.
The purpose of the notes area is to leave an empty space on the page so that one could write down some information once the document is printed. You could subscribe to the PrintElementFormatting event and change the header text of the NotesAreaPrintElement which you receive as an argument. Please my code sample below:
Public
Class
Form1
Private
weeklyCalendarStyle
As
New
SchedulerWeeklyCalendarPrintStyle
Sub
New
()
InitializeComponent()
Dim
weeklyCalendarStyle
As
SchedulerWeeklyCalendarPrintStyle =
New
SchedulerWeeklyCalendarPrintStyle()
AddHandler
weeklyCalendarStyle.PrintElementFormatting,
AddressOf
weeklyCalendarStyle_PrintElementFormatting
End
Sub
Private
Sub
weeklyCalendarStyle_PrintElementFormatting(sender
As
Object
, e
As
PrintElementEventArgs)
Dim
notesArea
As
NotesAreaPrintElement = TryCast(e.PrintElement, NotesAreaPrintElement)
If
notesArea IsNot
Nothing
Then
notesArea.Text =
"YourText!"
End
If
End
Sub
End
Class
In order to write inside the notes area you should create a CustomSchedulerWeeklyCalendarPrintStyle, I have included a sample implementation in my project, which I am sending you attached.
I hope this information helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
With printDoc
.LeftHeader = "My LeftHeader text"
.RightHeader = "My Right Header text"
'.MiddleHeader = "Term Credits: "
.Landscape = True
.HeaderFont = New Font("Microsoft Sans Serif", 20, FontStyle.Bold)
.HeaderHeight = 25
.Margins.Bottom = 50
.Margins.Top = 50
.Margins.Left = 50
.Margins.Right = 50
End With
I tried adding to your CreateBitmap procedure, but can't get it to work. Any ideas? Thanks again for your help so far.
Thank you for writing back.
I modified my project so that it meets your requirement. Have in mind that we do not have this type of functionality out of the box but thanks to the PdfProcessing framework we managed to accomplish this task.
Besides my project I am also sending you a screenshot of the pdf file after the export.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
It appears there is some sort of problem with attaching files to this thread. I have uploaded to google drive the files that my colleague Hristo originally sent you. Here are the links you can download the files from:
https://drive.google.com/file/d/0B-caNWTYkUs8VWV0S292RXBQaWM/view?usp=sharing
https://drive.google.com/file/d/0B-caNWTYkUs8WjBXM3hTUndFc3c/view?usp=sharing
Hope this helps.
Regards,
Ivan Todorov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you for writing back.
I am glad that the sample project could help you develop your application.
As we discussed in this thread, currently we do not support exact time rendering of the appointments while they are being printed. However you could change the block size of the appointment by subscribing to the AppointmentPrintElementFormatting event and in the handler change the value of the ScaleTransform property so that it affects the Height. Depending which appointment is being formatted you could set different height.
Please see my code snippet below:
Private
Sub
RadScheduler1_AppointmentPrintElementFormatting(sender
As
Object
, e
As
PrintAppointmentEventArgs)
e.AppointmentElement.ScaleTransform =
New
SizeF(1, 0.75F)
End
Sub
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Is there any plans for doing something about this?
Thank you for writing back.
Indeed this type of functionality is currently missing in our suite. I am posting again our feedback item so that more people can see it and vote for it.
I would алсо like to draw your attention to the AppointmentPrintElementPaint event, you can subscribe for it and perform custom painting of the appointments which are being printed.
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.