Putting a Image on a Button Tool

Discussions relating to plugin development, and the Jiwa API.

Putting a Image on a Button Tool

Postby SBarnes » Sun Nov 19, 2017 8:58 am

Hi All,

The following code works for putting an image on a button being added to the toolbar but is there an easier way to get the image?

Code: Select all
         ButtonTool buttonTool = new ButtonTool("ID_Export");
         buttonTool.SharedProps.Caption = "Export";
         buttonTool.Key = "ID_Export";
         buttonTool.InstanceProps.MinimumSizeOnRibbon = Infragistics.Win.UltraWinToolbars.RibbonToolSize.Normal;
         buttonTool.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText;
         JiwaFinancials.Jiwa.JiwaApplication.Image.ImageCollection  imgcol = new JiwaFinancials.Jiwa.JiwaApplication.Image.ImageCollection();
         imgcol.Manager = Manager;
         imgcol.Read();
         JiwaFinancials.Jiwa.JiwaApplication.Image.Image img = imgcol.GetItem("Name", "Creditors.32x32");
         System.IO.MemoryStream imstream = new System.IO.MemoryStream(img.ImageBinary);
         Image bmpImage = new Bitmap(imstream,false);       
         buttonTool.SharedProps.AppearancesSmall.Appearance.Image = bmpImage;
         this.UltraToolbarsManager1.Tools.Add(buttonTool);
         Infragistics.Win.UltraWinToolbars.RibbonGroup rbgroup  = this.UltraToolbarsManager1.Ribbon.Tabs["Main"].Groups["Actions"];
         rbgroup.Tools.AddTool("ID_Export");
         buttonTool.ToolClick += Export_ToolClick;
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Putting a Image on a Button Tool

Postby Mike.Sheen » Fri Dec 08, 2017 10:24 am

SBarnes wrote:Hi All,

The following code works for putting an image on a button being added to the toolbar but is there an easier way to get the image?


Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Image.ImageCollection  imgcol = new JiwaFinancials.Jiwa.JiwaApplication.Image.ImageCollection();
imgcol.Manager = Manager;
imgcol.Read();
JiwaFinancials.Jiwa.JiwaApplication.Image.Image img = imgcol.GetItem("Name", "Creditors.32x32");
System.IO.MemoryStream imstream = new System.IO.MemoryStream(img.ImageBinary);
Image bmpImage = new Bitmap(imstream,false);       
buttonTool.SharedProps.AppearancesSmall.Appearance.Image = bmpImage;


No - that looks like it's the best you can do with the interface we've provided. Perhaps a static method somewhere would be useful to get that down to one line of code.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Putting a Image on a Button Tool

Postby SBarnes » Fri Dec 08, 2017 10:32 am

Would it be possible to enhance the Manager to do it on the Image collection itself to create the Bitmap, at some point that way it could be used anywhere in Jiwa or a plugin ?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 35 guests