This is a migrated thread and some comments may be shown as answers.

Don't show military time in left side of scheduler

15 Answers 118 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 12 Jan 2015, 02:33 PM
Hello, 

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

Sort by
0
David
Top achievements
Rank 1
answered on 14 Jan 2015, 02:55 PM
Anyone have any ideas on this?  Anyone there from Telerik that can help with this issue?  In the WPF scheduler control it shows the correct time along the left hand side, but not the Winforms control.

Thanks,

David
0
Accepted
Hristo
Telerik team
answered on 15 Jan 2015, 11:42 AM
Hello 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.

 
0
Art
Top achievements
Rank 1
answered on 17 Feb 2015, 09:01 PM
Can you do that for SchedulerWeeklyCalendarPrintStyle, in VB  code?
0
Hristo
Telerik team
answered on 18 Feb 2015, 12:52 PM
Hi Art,

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.

 
0
Art
Top achievements
Rank 1
answered on 18 Feb 2015, 06:40 PM
Excellent, that worked great. Now, two more things.

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
0
Art
Top achievements
Rank 1
answered on 18 Feb 2015, 10:43 PM
Forget the header date, I figured that out. I would still like to add notes.

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.
0
Hristo
Telerik team
answered on 23 Feb 2015, 03:35 PM
Hello Art,

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.

 
0
Art
Top achievements
Rank 1
answered on 23 Feb 2015, 11:36 PM
We are really close now, thanks to your great example app.  now I need to add margins and headers. Something like this

               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.
0
Hristo
Telerik team
answered on 26 Feb 2015, 02:58 PM
Hello Art,

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.

 
0
Art
Top achievements
Rank 1
answered on 27 Feb 2015, 03:53 PM
Great, however I did not get the new project file or PDF. Can you post them here because our mail server blocks them in emails. Thanks.
0
Ivan Todorov
Telerik team
answered on 27 Feb 2015, 05:30 PM
Hi Art,

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.

 
0
Art
Top achievements
Rank 1
answered on 02 Mar 2015, 11:49 PM
Thanks for that, I appreciate you guys helping me with this project, my users are going to love it. I have one final question. Is there a way to make the appointment block size on the printout proportional to the actual appointment start and end times? They seem to be in 1 hour increments.
0
Hristo
Telerik team
answered on 05 Mar 2015, 02:26 PM
Hello Art,

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.

 
0
Art
Top achievements
Rank 1
answered on 05 Mar 2015, 04:27 PM
Thanks for the code snippet. It won't work because the text gets smashed, and it still doesn't place them correctly. It would take a heroic algorithm to make that solution work. One which I shouldn't have to worry about. If an appointment starts at 2:55, your software prints it a 2:00, and if it ends at 3:10 it prints until 4:00. So a 15 minute appointment prints as being 2 hours long. Makes the thing pretty useless. I don't expect "exact" time rendering, but I've not seen another scheduler that isn't within 10 or 15  minutes.

Is there any plans for doing something about this?
0
Hristo
Telerik team
answered on 10 Mar 2015, 03:06 PM
Hello,

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.

 
Tags
Scheduler and Reminder
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Hristo
Telerik team
Art
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or