The Resource Editor Control


If you are building your own resource-management utilities, you might be interested in the Resource Editor control. The Resource Editor used by Visual Studio is not available as a control that you can add to your own applications, so I had to write one; it is included in the downloadable source code for this book.

To use the ResourceEditorControl, simply add it to a form. It has a ResourceSet property, which is the ResourceSet that the control manages. The ResourceSet is never saved by the ResourceEditorControl; this is your domain. Instead, you are notified whenever a change is made using the Resource-SetChanging event. You can hook into this event like this:

 resourceEditorControl.ResourceSetChanging +=     new ResourceSetChangingEventHandler(     resourceEditorControlResourceSetChanging); 


The resourceEditorControlResourceSetChanging method is:

 private void resourceEditorControlResourceSetChanging(     object sender, ResourceSetChangeEventArgs eventArgs) {     resourceGovernor.WriteResourceSet(eventArgs.ResourceSet); } 


This method assumes that there is a private field called resourceGovernor, which is an IResourceGovernor and simply saves the ResourceSet. The ResourceSetChangeEventArgs class is:

 public class ResourceSetChangeEventArgs : EventArgs {     public ResourceSetChangeEventArgs(         ResourceSet resourceSet, ResourceSetAction action,         string resourceKey, object resourceValue ,         string resourceComment,         string oldResourceKey, object oldResourceValue ,         string oldResourceComment);     public ResourceSetAction Action { get; set; }     public string OldResourceKey { get; set; }     public string OldResourceComment { get; set; }     public object OldResourceValue { get; set; }     public string ResourceKey { get; set; }     public string ResourceComment { get; set; }     public ResourceSet ResourceSet { get; set; }     public object ResourceValue { get; set; } } 


The Action property is a ResourceSetAction enumeration and can be Add, Change, or Delete. The EventArgs provides sufficient information for you to identify the change that the user made and respond to it appropriately.

You can modify the functionality of the ResourceEditorControl using three Boolean properties: ReadOnly enables you to disable any opportunity to modify the ResourceSet, AllowComments enables you to specify whether to allow the user to enter comments, and Usefilerefs enables you to specify whether files should be referenced or embedded.




.NET Internationalization(c) The Developer's Guide to Building Global Windows and Web Applications
.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
ISBN: 0321341384
EAN: 2147483647
Year: 2006
Pages: 213

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net