c# - Generalized settings UI + settings classes -


For more classes derived from the base class, I use basic user control and derived class for each user (for visibility; on the right side).

Now each of the derived UserControls has a specific setting (red rectangle on the left) settings UI is a separate userrent (it can be moved easily, can put different dialogs if too large Is ...) and the underlying data class that changes it (the example of this class is a member of the main user control)

This allows me to hold different classes (and possibly, Savings), makes settings different, al By setting c-different user controls and manually adding it manually For the first time I did not run into such a problem, so I started thinking about some class + interface, so that I can easily create classes containing data and generate consumer control. My idea is something

  class SettingsItem {string name; TypeEnum type; Double value; // How about bool of different types? Inheritance? }  

The Settings class will be a list of these items. For each type, a single value will be UserControl (checkbox / text box / numeric + description). A foreach loop will be compared to making the end user control (one value under UCs each)

On the one hand I consider this idea a challenging challenge and boring, duplication and time Like the possible relief, I should align the small sections by putting them into big people. On the other hand, I feel like killing a fly with a shotgun

Is there some standard / prepared solution? Is there a better way to do this? Or is this a very complex solution to a minor problem? I would be happy to see any answers, suggestions, comments ...

First of all, take thread At a glance, it can discover interesting things for you.

However, according to your question, you can use the serialization for this purpose, if for some reason you do not want to use settings provided with VS Feature feature, here's how you can convert and unconnect your item in XML:

  class program {static void main (string [] args) {var setting = New SettingsTemplate {Name = "Setting1", type = SettingType.UserSetting, Value = "setting"}; XmlSerializer serializer = New XmlSerializer (TypeType (SettingsItem)); Stringbilder sb = new stringbiller (); (String Vitter SR = New String Vitter (SB)) using serializer Serialize (sr, setting); Var serialized = sb.ToString (); Console.WriteLine (serial); Settings item item; (Var r = serializer.Deserialize (r); console.light line ("name: {0}, type: {1}, value: (SettingsItem) using new string reader (sb.ToString ()) {2} ", item name, item type, item value); Console.ReadKey ();}} [serializable] public class settingsitem {public string name {get; set;} type public setting type {get; Set;} public object values ​​{get} set;}} [flags] public emm settings tap {application setting = 1, user settings = 2, admin = 4, Temporary = 8}  

Once you receive XML, simply select 'D' in the folder or elsewhere.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -