Re: Tips on runtime-customized UI
- From: "Andrew Faust" <andrew@xxxxxxxxxxxxxxx>
- Date: Tue, 23 Oct 2007 02:53:14 -0600
Take a look at the code Visual Studio builds for you automatically and places in the .Designer.cs class. Everything it's doing there you can do as well to create dynamic objects on your forms.
1) How do I give each element a common interface so I can send it data
from the main form
Probably create some interface that exposes the methods you want. Maybe something like GetData(). You'll then need to create controls that extend all the controls you want to be able to use on the form and have them implement that interface.
2) How would I best implement a plugin system that would allow us to
send a simple DLL to allow the user to extend the application with
elements that may not have been available at compile-time?
Depends on what your needs are. Do the controls they build merely need to have a common set of methods that your code can call? If so then you can create an Interface that all the plugin controls must implement such as:
interface IDataControl
{
void LoadDataSet(DataSet dataSet);
}
Your users can then create new controls that implement this such as:
public partial class CustomControl1 : ComboBox, IDataControl
{
public CustomControl1()
{
InitializeComponent();
}
public void LoadDataSet(DataSet dataSet)
{
throw new Exception("The method or operation is not implemented.");
}
}
On the other hand. If there are any base operations that each of these controls must do that you want to implement for them then you would need to create a base class that extends from Control that has that common functionality in it. Your users would then extend that class to build their new controls.
I would recommend avoiding the base class for this usage, though. By using the interface route you allow your users to easily leverage existing controls such as combo box, list views, etc. Wheras requiring them to extend from your class burns their base class and would force them to implement their own brand new versions of combo boxes, list views, etc.
--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Dave" <omgroflz@xxxxxxxxx> wrote in message news:1192819884.769255.16950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Oct 19, 2:45 pm, Dave <omgro...@xxxxxxxxx> wrote:Hi,
I should mention two other things:
1) How do I give each element a common interface so I can send it data
from the main form (or rather, a processing loop in a separate thread?
For example, I have a Data object; how do I force each element to take
in the same parameters such that each data processing interval I can
simply iterate over each shown form and pass it the data it needs to
update?
2) How would I best implement a plugin system that would allow us to
send a simple DLL to allow the user to extend the application with
elements that may not have been available at compile-time? Not looking
for specific code necessarily, just a general architectural overview.
Thanks!
.
- References:
- Tips on runtime-customized UI
- From: Dave
- Re: Tips on runtime-customized UI
- From: Dave
- Tips on runtime-customized UI
- Prev by Date: Re: ListView tooltips appearing at top-left corner of screen
- Next by Date: Re: KeyPress Not Firing
- Previous by thread: Re: Tips on runtime-customized UI
- Next by thread: Re: Tips on runtime-customized UI
- Index(es):
Relevant Pages
|