Configuring custom controls in the development environment

H

Haumersen

Thanks for taking time to read this question.

A little background:

I have implement a custom control called InTextLabel that inherits
Windows.Forms.Label. The InTextLabel is a control that will display
international text. The international text that is displayed comes
from a SQL database. The InTextLabel contains a property called
TranslationId which is passed to a singleton manager when the
InTextLabel asks for its text to display. An event is fired when an
operator changes languages and the InTextLabel queries a singleton
manager for its text.

This all was working great, then I decided to take it another step
further:

I needed to allow different applications to have controls with
duplicate TranslationIds but have different text associated with
them. In order to accomplish this I added an ApplicationId attribute
to my database table. Again everything was working good when I
hardcoded the application id in my singleton manager. To be effective
though, I need to have this application id be entered by a developer
in the development environment to avoid custom building the singleton
manager specifically for each application. Both the controls and the
singleton manager reside in their own dll.

Currently my solution is to have the developer enter an application id
and translation id in each control, which works but will be prone to
human error while entering an application id.

I have already tried adding a component to my singleton manager dll
that I could modify a property on called applicationid but it seems
like the development environment is instantiating a singleton manager
before the component is available in the editor. The development
environment is actually instantiating my InTextLabel control which
call the instance method of the singleton manager, therefore creating
a singleton manager and the property I change seems to be ignored.

I thought about a resource string but I need to know the namespace of
the application in my singleton manager at development time so that
wont work. I thought about using reflection for the application name
as the application id but the application name during development time
is not the compiled application's name.

Does anyone have any thoughts to help me avoid having a developer
enter the same application id ( just a unique id ) for every control
in the application?

Thanks for your help.
 
M

Mayur H Chauhan

Haumersen,
This is what I have understood from your problem.
1. You pass Application ID as well as TranslationId to the Singleton Manager
which in returns gives text for that text box and for that application.

What you want
1. You want to stop developer sending same Application ID.
Soln : Use name space of the class / form where your InTextLabel control
resides. All the application can be define with their own namespace. For
e.g. Me.GetType.AssemblyQualifiedName

We have implemented in same way for our application where we are showing
different string for different modules and application. ResourceManager acts
as an wrapper. All UI needs to request to ResourceManager for the display
string by passing StringID as the NameSpaceID of the current form.
ResourceManager in returns checks for the NameSpaceManagerID and the
StringID passed and reads information from the database.
Also there is possible that we need to share same string between 2
application. In that case we pass just string ID. Internally ResourceManager
uses its own namespaceID and finds the string from the database.


While going thought your implementation description....
1. InTextcontrol should ignore all the events till the control is not loaded
completely. You can say all the controls are loaded only when its container
is loaded. In this way you will avoid unnecessary events getting raised
while loading the UI.

I hope I have answered your doubts.

Mayur
 
H

Haumersen

Mayur,

Thanks for the reply.

I looked at you solution. I tried using
Me.GetType.AssemblyQualifiedName but I get the qualified name of my
dll, not the application that is using the controls from the dll.

It would be ideal if there was a project property that my dll could
access at design time.

Does anything like a "project property" exist in VS2005 that an custom
control, in a dll, could access?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top