Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After reading your comments, what about this:</p> <pre><code>class StyleProperty&lt;T&gt; { T _Value; public StyleProperty(T inheritedValue) { _Value = inheritedValue; } public T Value { get { return this._Value; } set { this._Value = value; } } } </code></pre> <p>Your first problem is how should the inherited value flow into the concrete instance? The only way i can think of would be the constructor. If the user doesn't like this value he can simply change it (to maybe the same value).</p> <p>If you would use for inheritance some kind of global variable (but that wouldn't be inheritance, that would be a default value) you could also think about using a boolean flag which will be checked in the getter to find out if the backing store or the default should be used and it will set always to the opposite of its initial state within the setter.</p> <pre><code>class StyleProperty&lt;T&gt; { T _Value; bool _UseBackingStore; public T Value { get { return _UseBackingStore ? this._Value : INHERIT; } set { this._Value = value; _UseBackingStore = true; } } } </code></pre> <h3>Update</h3> <p>To get a skin support into your application i think you need to take a different approach. All forms and gui controls you are using should implement some kind of interface (e.g. <code>ISkin</code>). Also your application should have some kind of <code>SkinSelector</code>. This one holds all informations about coloring, fonts, etc and it also gets a reference to the MainForm. Within the constructor it recursively runs through the Controls property of the form and checks if there are any controls implementing your interface (simply using <code>as ISkin</code> and check for <code>null</code>). If it is skinnable, simply set the colors, fonts, etc. of the control as defined within you <code>SkinSelector</code>. Sounds quite easy but the problem is, that you have to derive all gui controls and add your interface to them. So this is not such a complicated thing, but maybe a lot of work. Maybe you can test if Generics can help you out by using a <code>SkinWrapper&lt;T&gt; where T : Control</code> and an extension function like <code>ISkin ToSkinnableControl(this Control control)</code>). But this will only work if you need to change a few common properties, that are the same for all controls. If you need more skin control e.g. for the DataGridView or a ComboBox i think derivement is the only way to help you out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload