Page 1 of 1

Putting a Image on a Button Tool

PostPosted: Sun Nov 19, 2017 8:58 am
by SBarnes
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;

Re: Putting a Image on a Button Tool

PostPosted: Fri Dec 08, 2017 10:24 am
by Mike.Sheen
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.

Re: Putting a Image on a Button Tool

PostPosted: Fri Dec 08, 2017 10:32 am
by SBarnes
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 ?