How to manage resources in XIDE

This forum is meant for examples of X# code.

Post Reply
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to manage resources in XIDE

Post by wriedmann »

Hello,

since I had some difficulties to understand how to add resources in XIDE to use them in my X# program, I wrote a small test program. But there is also other people that has the same understanding problems.
Therefore I would like to post it here.
1) "Add existing" - "Add resource files"
You can retrieve it with:

Code: Select all

oAssembly := Assembly.GetExecutingAssembly()
oBitmap	:= Bitmap{ oAssembly:GetManifestResourceStream( "blue.png" ) }

2) "Create new" - "New resource file"

Code: Select all

oResourceManager := System.Resources.ResourceManager{ "bitmap", oAssembly }
oObject := oResourceManager:GetObject( "red.png" )
if oObject is Bitmap
  oBitmap := ( Bitmap ) oResourceManager:GetObject( "red.png" )
endif
You can find the complete working code including samples how to list the resources as XIDE export file here:

ResourcesSample.zip

Hope to help someone.

Wolfgang
Last edited by ConradB on Mon Jul 10, 2017 4:15 am, edited 1 time in total.
Reason: Typo
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

How to manage resources in XIDE

Post by FFF »

Wolfgang,
cool, and thx for the embedded link to MS doc.
One question: in the article he mentions
"...use of an alternate resource name after the comma of the file name to be embedded. The alternate resource name allows you to provide arbitrarily period-nested names for resources, regardless of the name of the file. It's the alternate name that makes it into the assembly..."
If i'd like to do so, how/where could i add the alternate name in Xide?

TIA
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to manage resources in XIDE

Post by wriedmann »

Hi Karl,

I'll do some tests, maybe speak with Chris, and let you know in the next days.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

How to manage resources in XIDE

Post by FFF »

No hurry, asked only of curiosity ;)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to manage resources in XIDE

Post by Chris »

Hi Karl,

Hmm, that's not support at the moment, but I can add an option in the resource file item for specifying the namespace. If you needed to do that now, you would have to specify the resource via a direct /resource compiler option (in the general options editbox of the app properties). The syntax of the compiler switch in x# is exactly the same as in c#.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to manage resources in XIDE

Post by wriedmann »

Hi Chris,

thank you very much! So I don't need to investigate more at this time. (it's not that I have too much time <g>)

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply