Geeks With Blogs
RebelGeekz' Blog Overclocked brain at work!

What if we could create CSS styles in C#?
Skinning would be soooo easy.
Think of the ZenGarden but in winForms.

public style Overdue
{
    fontname  = tahoma;
    fontsize  = 10px;
    forecolor = white;
    backcolor = red;
}

then, when applying the style to any object, if the object has the properties then it applies the value to the property, if not it just ignores it.

if (dueDate < today) textAmount.style = Overdue;

what do you think?

Posted on Sunday, January 18, 2004 11:15 AM | Back to top


Comments on this post: Coding with style

# re: Coding with style
Requesting Gravatar...
Nice idea, but I'd prefer to use the standard CSS format for doing it. This way, you don't have to learn something new and you can reuse your skillz. Then again...

Style cssOverdue = Style.Load("styles.css", ".overdue");

Or, even...

StyleCollection colStyles = Style.Load("styles.css");
Left by Michael Flanakin on Jan 18, 2004 5:45 PM

# re: Coding with style
Requesting Gravatar...
Good point Mike,

But as soon as the style is imported, it has to be interpreted by the language and at the end by the CLR.

So, even if the style is external (like a css file) or internally defined, the language has to have the functionality to understand it and use it.

That's why the 'style' keyword is needed.

The same would apply to VB.NET:

Style Overdue
FontName = Tahoma
FontSize = 10px
ForeColor = White
BackColor = Red
End Style

and all .NET languages as well

Would it be implemented in Orcas?
Left by RebelGeekz on Jan 18, 2004 7:30 PM

# re: Coding with style
Requesting Gravatar...
Unfortunately, XAML seems to be heading the other direction: toward HTML 3.0-like mixing of markup declaration and style.

You could implement this right now in C#/VB by using a Visitor-like pattern: come up with the style, then use the form "myStyle.applyTo(myControl)". As a separate object, styles could then be cloned from one another, inherited (populated up the chain through mybase construction), delegated, etc.--even more powerful than CSS.
Left by Richard Tallent on Feb 10, 2004 12:01 PM

Your comment:
 (will show your gravatar)
 


Copyright © RebelGeekz | Powered by: GeeksWithBlogs.net | Join free