Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Add interactive picture inside an item header (Read 2664 times)
fractal07
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Add interactive picture inside an item header
Aug 22nd, 2017 at 4:20pm
Print Post  
Hello,
I'm still working on a WinForms scheduler and I need to add an interactive icon in the header of items. By "ineractive" I mean a tri-state icon to display the state of the item (cf. picture below), user can click on it to toggle states.
I didn't find any Item.HeaderImage or something I could use with Click events... Please, could you help me on this way?

  

ItemHeaderImage.jpg ( 50 KB | 70 Downloads )
ItemHeaderImage.jpg
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 2466
Joined: Oct 19th, 2005
Re: Add interactive picture inside an item header
Reply #1 - Aug 22nd, 2017 at 8:28pm
Print Post  
Hi,

Try setting Image or ImageIndex in Item.Style.

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


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Re: Add interactive picture inside an item header
Reply #2 - Aug 25th, 2017 at 2:58pm
Print Post  
Hello,
Thank you for your quick answer, Item.Style.Image works fine (except Item.Style.ImageAlignment doesn't align... I will have a look)

What about the second part of my question, looking for a way to raise an event when user clicks on this image to udpate it?
Kind regards
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add interactive picture inside an item header
Reply #3 - Aug 28th, 2017 at 6:21am
Print Post  
Hi,

You need to handle the Calendar.ItemClick event and manually calculate whether the mouse pointer is over the image.

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


I Love MindFusion!

Posts: 28
Location: France
Joined: Mar 13th, 2017
Re: Add interactive picture inside an item header
Reply #4 - Aug 28th, 2017 at 1:39pm
Print Post  
Thank you Meppy.
Could you give more informations about the Item.Style.ImageAlignment, it does not work if I use the code below, image is still in the left hand upper corner of my item... Do I need to write more code than this one?
Code
Select All
appointment.Style.Image = Image.FromFile($"{Application.StartupPath}\\img\\icon_TrafficLight_000.png");
appointment.Style.ImageAlignment = ImageAlignment.Right | ImageAlignment.Top;
 

  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add interactive picture inside an item header
Reply #5 - Aug 29th, 2017 at 7:31am
Print Post  
Hi,

The image alignment is ignored for timetable items. They are always aligned to the left, before the header text of the item, along with the system icons, such as recurrence, reminder and recurrence exception. You can work around this by custom drawing the icon exactly where you need it. This way it will also be easier to determine the bounding rectangle of the item when you hit-test for it.

Code
Select All
var image = Image.FromFile(@"C:\Users\Meppy\Artwork\icon_netcf.gif");
calendar1.CustomDraw = CustomDrawElements.TimetableItem;
calendar1.Draw += (s, e) =>
{
	e.Graphics.DrawImage(image, e.Bounds.Right - image.Width - 4, e.Bounds.Top + 4);
}; 


Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint