Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Enlight past appointments like Google Calendar (Read 2359 times)
fractal07
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Enlight past appointments like Google Calendar
Dec 5th, 2017 at 8:24am
Print Post  
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
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Enlight past appointments like Google Calendar
Reply #1 - Dec 5th, 2017 at 12:42pm
Print Post  
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
Select All
var defaultBrush = calendar.ItemSettings.Style.Brush as MindFusion.Drawing.SolidBrush;
item.Style.Brush = new MindFusion.Drawing.SolidBrush(Color.FromArgb(100, defaultBrush.Color)); 


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

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


Regards,
Meppy
  
Back to top
 
IP Logged
 
fractal07
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Re: Enlight past appointments like Google Calendar
Reply #2 - Dec 5th, 2017 at 1:16pm
Print Post  
Thank you for your quick reply!
If I do this in the Draw event, it will not overload the method?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Enlight past appointments like Google Calendar
Reply #3 - Dec 6th, 2017 at 11:16am
Print Post  
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
  
Back to top
 
IP Logged
 
fractal07
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Re: Enlight past appointments like Google Calendar
Reply #4 - Mar 9th, 2018 at 10:23am
Print Post  
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  Wink ) ?! However the _ItemModified is perfectly raised...
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 2466
Joined: Oct 19th, 2005
Re: Enlight past appointments like Google Calendar
Reply #5 - Mar 12th, 2018 at 8:40am
Print Post  
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
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint