- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing. We have released our Java Swing Pack.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Add interactive picture inside an item header
Read 76 times

fractal07   Offline
YaBB Newbies
*
Posts: 21
Gender: male
France
I Love MindFusion!


   
     
 
Add interactive picture inside an item header
Aug 22nd, 2017 at 5: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?

 
 

 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Add interactive picture inside an item header
Reply #1 - Aug 22nd, 2017 at 9:28pm
 
Hi,

Try setting Image or ImageIndex in Item.Style.

Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

fractal07   Offline
YaBB Newbies
*
Posts: 21
Gender: male
France
I Love MindFusion!


   
     
 
Re: Add interactive picture inside an item header
Reply #2 - Aug 25th, 2017 at 3: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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1769
Gender: male
MindFusion support


   
     
 
Re: Add interactive picture inside an item header
Reply #3 - Aug 28th, 2017 at 7:21am
 
Hi,

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

Regards,
Meppy
 
 
 
IP Logged    
 
     

fractal07   Offline
YaBB Newbies
*
Posts: 21
Gender: male
France
I Love MindFusion!


   
     
 
Re: Add interactive picture inside an item header
Reply #4 - Aug 28th, 2017 at 2: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;
 

 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1769
Gender: male
MindFusion support


   
     
 
Re: Add interactive picture inside an item header
Reply #5 - Aug 29th, 2017 at 8: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);
}; 


Regards,
Meppy
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print