Wednesday, August 29, 2012 4:08 PM
I have a large DSL product that works very well for my needs (thanks to those brillant MS folks who designed it !!!) and I am about to implement localization on any and all string, image, or icon related properties of any domain element through a simple resource key based approach.
My thought is I would create a read-only string based property per each string, icon path etc, as placeholders for a corresponding resource key that would be selected within a resource edtior tool.
My initial thoughts were to create a custom resource editor as a custom editor which when selected would open into a similar looking editor to that provided by Visual Studio out of the box (OTB) however the only reason I'd attempt to build my own resource editor, is that I am unaware as to how to invoke the OTB resource editor, which is actually my preference.
I use T4 templates to code generate domain elements from my model into .Net classes thus, once I have the abilty to edit the resource keys I will simply embed the edited resource keys for each property into an underlying property for the respective type being code generated within my T4 templates.
I am very familiar on how to include custom editors within a property of my Domain element thus this is what I hope to accomplish;
- Create a custom editor that I will place on all fields in which I want to invoke the OTB Resource Editor on. (I am very familiar as to how to set this part up).
- When the user invokes this custom editor, just prior to invoking the OTB resource editor, the logic will first check if the resource file exists (by a very specific name), and if not, will create it automatically. (need help here)
- After ensuring the resource file exists, the logic would then pass in the resource key (if existing) from a hidden property within the Domain element the user is currently on into the OTB resource editor, along with the name of the resource file. (need help here)
- Once the User completes the editing of the resource and closes the editor it then returns back the resource key that was last selected/created within the OTB resource editor, which is then inturn stored against a hidden/readonly property of the domain element. (need help here)
Are there any examples out there that others have implemented that do something similar to what I describe?
Any assistance would be very much appreciated!
Friday, August 31, 2012 9:25 AM
Friday, August 31, 2012 10:50 AM
Thank you however I was looking for guidance to build an integrated product invoking OTB resource editor within a custom UIEditor from within my DSL tool rather than purchase.
As it turned out it was not too difficult to build from scratch which is what I ended up doing.
I am pleased with end result, as I am now able to launch my custom resource editor and edit any string or image based property directly within the DSL tool, as well am able to edit same RESX file with OTB resource editor outside of DSL tool but still within Visual Studio.
Ironically the only bit I am still struggling with is the creation of the resource file initially. In my current logic, each time a user selects to edit a property within my new Resource UI editor logic, I check for the existence of a very distinct and specific named resource file (NavigationLayoutResources.resx) in a very specific Solution Folder (Resources) within the same VS project as modeling tool.
I am able to automatically create the destination Solution Folder called Resources if it does not already exist as a Project Item via the DTE but when I attempt to add a new Resource file as a VS project item it throws an exception. In order to get the rest of the editor functioning I manually created this named resource file, but now that I have the UIEditor working I have to resolve this last issue and then all is good. I will create a separate forum discussion thread if still unable to resolve. This is the code that I am using in an attempt to add a new resource file into the project (if does not already exist)..
var soln = (Solution2)service.Solution; var csTemplatePath = soln.GetProjectTemplate(@"General\Resources File", "CSharp"); activeProject.ProjectItems.Item("Resources").ProjectItems.AddFromTemplate(csTemplatePath, resourceFileName);
Other than the above issue, here is the end result where I am editing a property called Large Icon on a Domain Element (UIFragment) ...
Friday, August 31, 2012 10:52 AM
Monday, September 03, 2012 6:18 AMModerator
Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.
MSDN Community Support | Feedback to us