vendredi 23 février 2018

C#, Announce class settings to GUI

I am working on a C# project where I have several electrical instruments such as Power supplies and Volt meters.

There are multiple choices for each instrument, for instance we have two different type of power supplies. We only connect to one of each type for every run.

In the design that I have in mind, I would like to have a common interface for each type, for instance

public interface PSU
{
    public void connect();
    public void disconnect();
    ...
}

Next in my GUI I will register all the available PSU units which will show up under a menu item and in that menu item only one of them can be selected for each type.

Next what I would like to do is for the units to announce their settings in a way that the GUI can create a sub menu out of those settings. My goal is to have it like this, so that if I add another PSU for instance, I would only need to register it.

My main questions here are the following:

  • How do I provide the settings in a way that can be turned into menus?
  • How do I connect menu event(s) to these dynamically created submenus? These events should actually update the instrument settings.
  • Is this even a valid and maintainable idea?

Thank you

Aucun commentaire:

Enregistrer un commentaire