Re: Tips on runtime-customized UI

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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!


.



Relevant Pages

  • Re: OO debate: assuming type of containing object
    ... For example, when a control wants access to a method in a common base class for the page, it's not a bad idea to use an interface, for several reasons: ... You can't use a method from the Page class instead of a method from the base class by mistake, as they are simply not available. ... Creating pages and controls that depend on each other doesn't only prevent reusability, it also makes the code harder to follow. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: OO debate: assuming type of containing object
    ... For example, when a control wants access to a method in a common base class for the page, it's not a bad idea to use an interface, for several reasons: ... You can't use a method from the Page class instead of a method from the base class by mistake, as they are simply not available. ... Creating pages and controls that depend on each other doesn't only prevent reusability, it also makes the code harder to follow. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Q re Bridge Design Pattern - Abstract Classes vs Interfaces
    ... I guess it gives more flexiblity in the future - you can always extend the ... base class with additional features easily (i.e. base implementations). ... With an interface, you would need to update the entire project. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Inheritance problem
    ... Say I am developing a search interface but I don't want the developers down ... I could potentially write all the controls on the ascx as derived controls ... I can manipulate the controls from my base class would make it so much ... mybaseclass inherits from system.web.ui.usercontrol ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Unsafe Names for HTML Form Controls
    ... controls, not just input elements. ... The DOM specification says that a form encompasses behavior of a collection. ... the ECMAScript bindings documents make assertions about the mapping of bracket notation property accessors to collection interface methods. ...
    (comp.lang.javascript)