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

AppointmentElement Width

4 Answers 112 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 06 Feb 2016, 05:18 AM

How do I get the width of the AppointmentElement in the AppointmentFormatting Event?

e.AppointmentElement.Size returns nothing

e.AppointmentElement.Bounds returns 0,0,0,0

I am trying to place an image at a specific time point within the appointment element.

Is there an easier way to accomplish this?

Thanks,

 

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Feb 2016, 10:49 AM
Hello Ken,

Thank you for writing.

Depending on the current view and whether the exact time rendering is enabled, the AppointmentElement may have different size. When the AppointmentFormatting event is fire for the first time, the visual appointment element is not sized yet. However, at each next firing of the AppointmentFormatting after the form has been loaded, you can get the AppointmentElement.ControlBoundingRectangle or Size property. 

In order to achieve your goal and place an image inside the event element, you can use a custom AppointmentElement and replace the default one in the SchedulerElementProvider. Here is demonstrated a sample approach. Feel free to modify it in a way which suits your requirement best:
public Form1()
{
    InitializeComponent();
 
    this.radScheduler1.ElementProvider = new CustomElementProvider(this.radScheduler1);
    this.radScheduler1.Appointments.Add(new Appointment(DateTime.Now, TimeSpan.FromHours(2),"Business meeting"));
}
 
public class CustomAppointmentElement : AppointmentElement
{
    public CustomAppointmentElement(RadScheduler scheduler, SchedulerView view, IEvent appointment) : base(scheduler, view, appointment)
    {
    }
 
    LightVisualElement lve = new LightVisualElement();
 
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
        lve.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
        this.Children.Add(lve);
    }
 
    public override void Synchronize()
    {
        base.Synchronize();
 
        lve.Text = this.Appointment.Summary; 
        lve.Image = Properties.Resources.calendar;
    }
 
    public override void DrawEventText(Telerik.WinControls.Paint.IGraphics graphics)
    {
        //do no draw the default text and use the one in the LightVisualElement
        //base.DrawEventText(graphics);
    }
}
 
public class CustomElementProvider : SchedulerElementProvider
{
    public CustomElementProvider(RadScheduler scheduler) : base(scheduler)
    {
    }
 
    protected override T CreateElement<T>(SchedulerView view, object context)
    {
        if (typeof(T) == typeof(AppointmentElement))
        {
            return new CustomAppointmentElement(this.Scheduler, view, (IEvent)context)as T;
        }
          
        return base.CreateElement<T>(view, context);
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ken
Top achievements
Rank 1
answered on 08 Feb 2016, 01:47 PM

Thanks for the reply.  I will give the code a try and see if it gets me where I need to go.

What I am really needing in the ability to calculate the correct time position within the appointmentelement so that I can place the image there.

i.e. If Tom is working a 9:00 AM to 6:00 PM shift (appointmentelement) and has a Dr's appointment on that day at 2:00 PM, then I want to place that image on his appointmentelemet at the 2:00 PM mark.

What is the best way to approach this?

 

 

0
Ken
Top achievements
Rank 1
answered on 08 Feb 2016, 02:07 PM

Sorry, forgot to mention that I am using the timeline view.

Attached is a sample of what I am trying to do.

Thanks,

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Feb 2016, 02:31 PM
Hello Ken,

Thank you for writing back. 

It is not recommended to use a single Appointment from 9:00 AM to 6:00 PM to indicate the work time for a person because that way it is not possible to display in a convenient way the other events during the day. RadScheduler offers work time for its DayView to specify a predefined range of hours, which can be specified within the timeline to make it easier for end-users to carry out scheduling. Please refer to the Scheduler >> Day View help article >> Changing the work time section. Thus, you can add an Appointment from 2 PM for the Dr's meeting and use the RadScheduler control by its designed usage.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Scheduler and Reminder
Asked by
Ken
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ken
Top achievements
Rank 1
Share this question
or