In a Silverlight 4 app, our user base needs to define for us what content they want on buttons, labels, various screen text, etc. I understand the methods of resource files, but what i'm wondering is when wanting to give that kind of control to the users to define the text in the resource file, what is the best way to let them do that in a way that they can view their changes to the XAML pages? Do they need to have Blend installed?
I vaguely remember when doing a WinForms app, at one point I handed off to the users the actual winform, and they used some sort of visual designer to edit button text, labels, etc., and those changes were then saved to the resource file.
Our app is MVVM, so each item in the XAML would bind to a property in its view model, and that property would then load the entry from the resource file.
If there is a way to let the user update the contents of the resx file while visually reviewing their changes please let me know.
Thanks very much in advance for any assistance.
What I have done in the past is to have a dedicated assembly for Resources (resx) files. By default, they are "embedded" into the assembly. The trick is to change the property on the resx file to NOT be embedded (False). This way, the files are separate resx xml files that must go with the assembly (and live in the same /bin directory of the running application). This is what you see in some /bin directories with the /en-US/ and other resources. In the past, I have created a simply GUI for users to be able to edit these resx files that gets written back to disk. I am not familiar with Silverlight's inner workings for this type of permissions needed, but I would guess at worse case the edited resx files just get uploaded to a server where a new copy is downloaded on next app restart or alike.
Now, when I said "in the past", that was back in 2003 days. Recently I had to do this manually using the ResXResourceReader because of an existing assembly I could not modify.
Some example code (writing it from memory, completely untested):
using (var reader = new ResXResourceReader("[path-to-bin]/MyResources.resx"))
{
var value = reader["My_key_in_the_resx_file"].ToString;
}
Do note that by going this route, you do have access to other types of resources such as binary and files embedded int he resx files.
Lastly, watch your encoding formats. Some over-seas editors use UTF16. So going with a common Unicode converter may be needed.
Also note there is a ResXResourceWriter class, should you want to roll your own writers for updating the resx files through code.
Related
I would like to know if there is any way to add a local file as resource using VB code. Its an image file . Normally I go to Project -> Project1 Properties -> Resources -> Add Resource -> Add Existing File -> and select my executable. I would like to do the above using Visual Basic code. Does anybody have any idea?
Last time I added a resource into my VB program I did the same as you have mentioned above, recently I went to do the same thing and found I had to search for the location and most replays to this question told you what to do but did not show the steps nor the screen which was kinda confusing. I hope the following helps.
Visual Studio 2017:
Right click in the solution explorer window on the VB project name name (Not where is says Solution 'Solution name' (1 project) the line just under that one. Select properties and you will see the project options screen open in front of you mine defaulted to the application tab shown on the left in the screen shot below.
Select the resources option on the left hand side of the screen, you now have options to add resource files to your executable, you can select the following types (Strings, images, icons, audio, files, other) . Note I read there is a size limit for individual files but it is possible to have multiple small files added.
Add your file. In the solution explorer a resources tab will now be visible with your file listed, in my example I added two sound files bite.wav and moan.wav (sorry not an image file). These sound files were compiled into my executable and I executed the sounds in the program with the following:
My.Computer.Audio.Play(My.Resources.Moan, AudioPlayMode.Background) 'Play audio file in background do not halt program
Your resource should now be able to be seen if you enter 'My.Resources.'
Enterprise Architect offers a handy feature to generate UML artifacts (or glossary entries) from external sources that can be imported into the project as RTF files.
These RTF can be attached to an existing project as a "linked document" or "UML document artifact" (using the << document >> stereotype for an "artifact" model entity).
This is described here on page 36:
http://www.sparxsystems.com/downloads/whitepapers/Requirements_Management_in_Enterprise_Architect.pdf
Is the same possible with a file that is formatted as PDF? For example using an add-in?
I tried to drag-and-drop it or import PDFs the same way as an RTF but this failed.
Rationale: Most customer input comes in PDF format.
.doc or .docx may also be of some help.
I know it could all be copy-pasted into an RTF but that is quite error-prone.
Thanks in advance
The only external artifacts that can be stored and edited inside EA are RTFs. You can also store, but not edit, bitmaps (under Settings - Images).
There is a third-party Add-In for MS Word and Excel documents called EADocx. This integrates EA and Word/Excel, but AFAIK the documents are never stored in the EA model.
If you just want to refer to files stored in the file system, there are two ways of going about it.
The Common toolbox allows you to create hyperlinks, which can refer to (among other things) external files. Double-clicking the hyperlink will cause EA to open the file, in its built-in editor or hypertext browser if it can, otherwise with the associated Windows program.
You can also add File properties to just about any element, eg classes, requirements or use cases. Open the element properties, select the Related - Files tab and add the file path.
Disadvantage with the hyperlink is that it is a diagram object, and as such is only visible in the diagram where it was created (does not appear in the project browser).
A File property, on the other hand, cannot be opened with a simple double-click; you have to go to the Related - Files tab and Launch the file from there. Also, the element does not indicate visually that it has a File property. However, creating an Add-In which launches a file on double-click is a simple job.
I am building an AIR app which will be kind of like Dropbox. It will allow users to sync their files between various OSs. What I would like to know is that how can i change the default file system's file icons (add an overlay for eg) for states like - Synced and Syncing, the way Dropbox does it ??
On Windows i found out that Dropbox edits the registry files to insert the overlay icons..not yet sure how they do it in MAC OS X though.
I saw some threads here asking similar questions about AIR, but none referencing how to change file's icons. Hoping to get a solution for this from the various experts .. Please suggest any ideas if you know how it can be accomplished. Much thanks.
A simple yet effective solution would be to use icons that are only internal to your application : just embed in your application files some transparent pictures representing the various states of your files (with only the small part telling in which state it is, with the rest totally transparent), that you will add at runtime above the displayed icons.
Since you can get the actual icon of your files, just draw them into a BitmapData (if needed) & add an overlay with theses custom images, using the one related to your file's state in your application.
And one step further could be to store in your AIR application folder any resulting icons for future use (check what types of files you already have, and if your new file type isn't in thoses, export the various icons with your custom overlays to PNG files directly on the user device, for re-loading them the next time the application is opened).
Each new Windows 8 C# Metro project contains StandardStyles.xaml file with lot of styles and templates for various controls. Mostly I use only like 10% of them and I define lot of my own styles.
Hot to easily and safely find and/or remove all unused styles? As far as I know parsing long XAML files increases the startup time of my Windows 8 app and that's something I'd like to avoid. Or do you think I should not care about those 1800 lines of code?
The comment in the header gives you a pretty good idea:
This file contains XAML styles that simplify application development.
These are not merely convenient, but are required by most Visual Studio project and item templates.
Removing, renaming, or otherwise modifying the content of these files may result in a project that
does not build, or that will not build once additional pages are added. If variations on these
styles are desired it is recommended that you copy the content under a new name and modify your
private copy.
If you modify the file then add another view later on, you might be stuck with a view that is not working and you will have to then figure out which styles you need to re-add.
The overhead of this file is small and I would not worry about how it affects your startup time as almost every other XAML app will have the same overhead.
We are developing a CF application and are making use of the default localization/resource handling in the framework (that is, when editing a form in the designer properties like Text have their value stored in the .resx files and the resource manager and framework loads it for us again in the selected locale using satelite assemblies and a call to ApplyResources in the .Designer file)
We have a few custom controls and one of these includes a string property called EditTitle. We would like this value to be stored in the resx file when editing the designer to get the same localization support as the Text property but we can't find anywhere to specify this. We do have an .xmta file for other designtime attributes but we can't find any element in there that would trigger this behavior.
Are there any way to specify this behavior for the particular property. Is it possible to do this for our own properties or is Visual Studio hardwired to only work with a known set of properties and we should be looking for other solutions (like editing the resx file by hand and hoping that the ApplyResources-call picks up and applies the EditTitle property)?
Well, discovered the solution (was pretty self-evident, actually). You can add the following attribute via the DesignTimeAttributes.xmta file:
<Property Name="EditTitle">
<Localizable>true</Localizable>
</Property>
This Localizable attribute will make sure that the value entered in the designer ends up in the .resx file