The MindFusion Forums
Scheduling and Gantt Components >> Windows Forms >> Add interactive picture inside an item header
https://mindfusion.eu/Forum/YaBB.pl?num=1503418840

Message started by fractal07 on Aug 22nd, 2017 at 4:20pm

Title: Add interactive picture inside an item header
Post by fractal07 on Aug 22nd, 2017 at 4:20pm
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 | 233 Downloads )

Title: Re: Add interactive picture inside an item header
Post by Slavcho on Aug 22nd, 2017 at 8:28pm
Hi,

Try setting Image or ImageIndex in Item.Style.

Regards,
Slavcho
Mindfusion

Title: Re: Add interactive picture inside an item header
Post by fractal07 on Aug 25th, 2017 at 2:58pm
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

Title: Re: Add interactive picture inside an item header
Post by Meppy on Aug 28th, 2017 at 6:21am
Hi,

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

Regards,
Meppy

Title: Re: Add interactive picture inside an item header
Post by fractal07 on Aug 28th, 2017 at 1:39pm
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]
appointment.Style.Image = Image.FromFile($"{Application.StartupPath}\\img\\icon_TrafficLight_000.png");
appointment.Style.ImageAlignment = ImageAlignment.Right | ImageAlignment.Top;
[/code]

Title: Re: Add interactive picture inside an item header
Post by Meppy on Aug 29th, 2017 at 7:31am
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]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);
};[/code]
Regards,
Meppy

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