Problems with adding icons (XIDE)

This forum is meant for questions and discussions about the X# language and tools
User avatar
Chris
Posts: 5764
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Problems with adding icons (XIDE)

Post by Chris »

Hi Zeljko,

OK, thanks, I understand the problem better now.

Under <Designer.resources>, the green items are bitmaps stored in the resource (System.Drawing.Bitmap objects) and the blue ones are icons (System.Drawing.Icon). The green items which have an extension .ico like bricks.ico are also bitmaps, they are just loaded from an icon (.ico) file, but converted to an image, before stored in the resource file.

This happens because some windows properties like BackgroundImage, button Image etc require a System.Drawing.Image/Bitmap object, but others like Form:Icon require an Icon object. So, when you click on an Image property in the designer, like for a button image, XIDE shows you only the resources that are saved as bitmaps. When you click on an Icon property like the Icon of a form, it will only let you choose from the icons.

Also as I said before, each application and library has its own set of available bitmaps and icons, you can not use a bitmap stored in a resource of app A in a form from app B. This happens because each app and library (exe and dll) has it's own set of resource files, stored inside the exe/dll.

So importing a form form another app/library that contains bitmaps and icons can indeed be problematic, that was a scenario that I hadn't tested. How exactly did you import the form from the other app to another one? Did you move or copy the whole file directly in the Project window of XIDE? Or did you first export the file to .ximef and then imported it in the other app? Or did you do it in a different way? I need to know exactly what you did, so I can follow the same steps here so I can reproduce and fix the problem.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
vzeljko
Posts: 45
Joined: Wed Sep 28, 2016 8:02 pm

Re: Problems with adding icons (XIDE)

Post by vzeljko »

Hi Chris,
I want to share same windows in all applications inside project. Different application have same windows as product search window or company search window and others. So, for me is important to make changes to those windows once and then put in other applications. I did it using project explorer -> Add Existing/Add files as in picture a submit.

Zeljko
Attachments
add.jpg
User avatar
Chris
Posts: 5764
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Problems with adding icons (XIDE)

Post by Chris »

Hi Zeljko,

OK, sharing files which use resources among different applications is a scenario that I hadn't thought about to support it.

There's a trick you can use to make it work, if you have say an application A with the original form and you want to use it also in application B, then first close the file with the form from the editor, then create a new file with a new form in application B (the name is not important, use something like "dummyForm", add a few buttons or different controls in it, and then on each button select the Image property and use Add From File to select one by one the images that are used in the form.

This dummy form you will not really use at all, no need to ever create it in your app, it's just a trick to insert the bitmaps also in the resource file of the app B. Now if you open the form in the designer, you should see the images correctly. And the app should run fine.

Please give this a try and let me know if it works ok now.

I will give it some thought how to support this sharing of forms with images better in XIDE, so it will not be necessary to use this trick in the future.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
vzeljko
Posts: 45
Joined: Wed Sep 28, 2016 8:02 pm

Re: Problems with adding icons (XIDE)

Post by vzeljko »

Hi Chris,
I found easier solution. Import window, remove all icons (usually 5-6), compile, open window and add icon file from 'Select image window'. Previously remove 'blue icons' from resource in project explorer.

Zeljko
User avatar
Chris
Posts: 5764
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Problems with adding icons (XIDE)

Post by Chris »

Hi Zeljko,

That's great! I also found the underlying problem, it has to do with the icons converted to images, those are saved correctly in the resource when you set them directly through an image property, but not when XIDE needs to generate the resource file from scratch. If this bug didn't exist, after adding the form from the other app and saving it, the images should be automatically added to the resource file of the new app.

There's also a command that recreates the resource file from scratch (by reading all forms in the app and seeing what images are used), it's available through Application-Advanced->Recreate Designers Resource File, but it has the same problem as it shares the same code. I will fix this for the next version, thanks for reporting!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply