First, please note I am a Java developer, started C# just few weeks back. Here is my question, it is about Visual Studio IDE.
I am using visual studio ide 2008 to create C# projects. I opened a new windows application, added a picture box to the form and now ready to add an image to it. I clicked the small black arrow button in picture box and it opens a dialog where we can put images.
Now, the question comes. In my c# book, they add images using the first option "Local Resource". Anyway, since I have to add number of images, I selected the "Project Resource File" and added all the images to the folder at once. Now I am working smooth without any issue. But, I can see the "Form.resx" file is empty (in my book, they show that file contains all the image files).
I want to know whether what I have done is correct or not. Even though that file is empty, no errors in the program anyway. I don't know whether any issue will occur after the distribution, like missing resources (In Java it normally happens unless otherwise you put all the resources into a new 'Package' inside the project. That's one of reasons I selected the second option when adding the images). Please help!
Your resources will be in a file called Resources.Resx (I think) this can found in your Properties folder in your project file
http://msdn.microsoft.com/en-us/library/7k989cfy(v=vs.80).aspx This link has some information about using Resources
Its better to add the files to the project resource if your going to need them on multiple forms in the project. If they are only going to be required by the current form, you might as well put them in the forms resource file
Related
Still spinning up on Xamarin.Forms and C#.
Did some research and everything is telling me that to create my externalized strings file, I just right click on the directory, click New Item... then click on Resource file. The problem is that my list looks vastly different than the lists I'm seeing in the tutorials and doesn't include a Resource file. Here's my list:
So I'm not sure what to click to get a resource file. There's evidently some special stuff about it because I tried creating an empty file and naming it that and it was confused.
How do I create these i18n resource files in Xamarin?
Thanks.
As suggested by #Deczaloth, I added the C# desktop applications workload and that made the resources file available. Yet another fail from Microsoft.
I have big WinForms project,and now i need to create module,where client can create/update/delete its own localization to a project (dataGrid Name-Value,like resx files).Also we need a default localization.But in WinForms every form has own resx file=( What the best way to realize this feature?Xml file or it could be done by resx files.
In previous version of the project (unfortunately no source code) it was jsut text Key-Value file.
There are diffrent way to approch that topic. On top of my head i have 2 solutions for that problem.
First solution
Since *.resx files are compiled into executable you cannot really modify them, but since you are using them already easiest approach would be to change reference from original build in *.resx file to one you have made and put in your folder hierarchy. That way you could use your build in files as default and search for other languages if they exists replace them.
This might help you Modifying .resx file in c#
Downside of this approach is that resx files are c# classes and could be realy hard to edit outside of Visual Studio editor.
Second solution
If you have time to move all of your default texts to *.xml files you could do that and use similar approach like in *.resx file. Since i found it easier to create and edit xml files this could save your day. Downside of that approach is time required to connect every string to your windows forms app.
I have a very simple use case.
1) I have 4 config files which are needed for the application to start.
When I publish my application these files should be exported by default along with it. How can I do this ? Where should the files be stored so that they are available when the pplication is installed?
The users of this application should be able to edit and access these files.
I have seen the option of saving it using string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
I have tried adding these as resources, but these files need to be editable, hence cannot be in exe.(Reference is this question)
Please comment if you need additional information.
If you're building the installer in Visual Studio, you can add those files as Content and it should be automatically included in the installer when it's built.
You create installers in Visual Studio by adding a Setup Project to the solution.
Link to tutorial on MSDN: http://msdn.microsoft.com/en-us/library/vstudio/19x10e5c(v=vs.100).aspx
I recall it should automatically add all Content items automatically, but I'm a bit rusty. Here's more detail on how to add items to your installer, including desktop shortcuts and such:
http://msdn.microsoft.com/en-us/library/vstudio/z11b431t(v=vs.100).aspx
Good luck!
There are meny ways to do whay you want to do. the main question is why do you want to do it?
if you have a normal program for personal use you can simply link it to the needed file, meaning using the file without actual knowledge that it's there.
if it's for a task then you can zip them together, that way you'll know they are together, without adding them as resource.
for other kind of use, or if you have to add them as resources, just add them like shown here
for more reading on what do you need and how to do it i have here linked vs. Embeded resources
good luck
So anyways, I got a program recently called "SkinBuilder Tool". More specifically "SkinBuilder for Sunisoft Skin Solutions v2".
It can open bitmaps and their own type of "skin" file (file extension is .ssk).
It then "builds" the theme/skin into something that is allegedly applicable to a C# forum, however, when I click build, it just tries to save it as another skin file (.ssk).
So, how do I:
1) Save it to something other than a .SSK that is applicable to my form?
2) Use the .SSK on my form to apply the skin/theme?
When you setup SuniSoft IrisSkin you find an extra control in the control box of visual studio with the name "SkinEngine".
When you use this controls in your application, it affects all forms in this application.
You should choose the .ssk file from the skinfile property of the control, If You used Trial version or Unregistered copy of software then please register first.
I have used a JPG for backgroundImage for an application form.
My question is that do I always need the JPG with the exe program?
So if I give my exe program to another user, the person won't be able to view the backgroundImage if I dont provide the JPG file?
another question is regarding the icons that I use for the program (exe icon and an icon that displays at top of your program).. are these icons stored in the program? or i need to provide the icon file(s)?
sorry i only have a machine and don't have someone to test for me.
cheers,
D
You need to add image as a resource for the Application. If you add it simply as a file link e.g. C:\somelocation as soon as that changes you loose teh image.
If its added as a resource then it is inculded with the build and always present for the Application.
To know more on how to do this look here:
http://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.80%29.aspx
http://www.homeandlearn.co.uk/csharp/csharp_s4p8.html
An easy test would be to put the .exe in a separate folder and try to launch it.
For the JPG it depends how you refer to it in your program, if it is a resource that you added it will be in the executable.
The icon should be in the executable already.
You can add the .jpg file as a resource in your application, which results in it being compiled into the .exe itself, giving you one less file to distribute.
Check out Accessing an image in the projects resources?