The MindFusion Forums
Scheduling and Gantt Components >> Windows Forms >> Enlight past appointments like Google Calendar
https://mindfusion.eu/Forum/YaBB.pl?num=1512462242

Message started by fractal07 on Dec 5th, 2017 at 8:24am

Title: Enlight past appointments like Google Calendar
Post by fractal07 on Dec 5th, 2017 at 8:24am
Hello,
Using Winforms > Scheduler > Timetable display, is there an easy way to change opacity or enlight/darken past events to increase the visilibity of futures appointments?
Kind regards

Title: Re: Enlight past appointments like Google Calendar
Post by Meppy on Dec 5th, 2017 at 12:42pm
Hi,

You can set collect the past items and manually set their background brush to a brighter, darker or a semi-transparent version of the default brush. For example, to change the background of an item to a more transparent one, use the following code:


Code (]var defaultBrush = calendar.ItemSettings.Style.Brush as MindFusion.Drawing.SolidBrush;
item.Style.Brush = new MindFusion.Drawing.SolidBrush(Color.FromArgb(100, defaultBrush.Color));[/code):


To collect the past items, you can use one of the Schedule.GetAllItems overload, or you can do it manually, like this:

[code]foreach (var item in calendar.Schedule.Items.Where(i => i.EndTime < DateTime.Now))
{
    // Set the item's background
}

Regards,
Meppy

Title: Re: Enlight past appointments like Google Calendar
Post by fractal07 on Dec 5th, 2017 at 1:16pm
Thank you for your quick reply!
If I do this in the Draw event, it will not overload the method?

Title: Re: Enlight past appointments like Google Calendar
Post by Meppy on Dec 6th, 2017 at 11:16am
Hi,

The Draw method is not the best place for this because it is invoked very often whereas you need to set the item backgrounds rarely, possibly even once when the items are created. Move this code to an ItemCreated or ItemModified event handler.

Regards,
Meppy

Title: Re: Enlight past appointments like Google Calendar
Post by fractal07 on Mar 9th, 2018 at 10:23am
Sorry for the delay... Thank you for your answer, job's done! Except one tiny thing: surprisingly, the _ItemCreated event is never raised (yes, obviously the event handler is correctly set  ;) ) ?! However the _ItemModified is perfectly raised...

Title: Re: Enlight past appointments like Google Calendar
Post by Slavcho on Mar 12th, 2018 at 8:40am
Hi,

ItemCreated should be raised for appointments created interactively the built-in way, by selecting a time range and typing. It's probably not raised if you add items from code, e.g. in response to click or drag/drop events.

Regards,
Slavcho
Mindfusion

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.