home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Using reflection for GUIControlFactory
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="NoMoDo" data-source="post: 3645" data-attributes="member: 10381"><p><strong>Reflection in MP</strong></p><p></p><p>@suicidal - Thanks to you, I've come up with an interesting enhancement to the GUIWindow class, that uses Reflection to make plugin development and skin development easier (see below). I agree with you 100% - a similar change to the ControlFactory class is sorely needed - the class itself and especially the foot-long Create method could really use a big change to improve maintainability.</p><p></p><p><strong><span style="font-size: 18px">A Reflective GUIWindow (or: There's more than one way to skin a cat)</span></strong></p><p></p><p><strong>Purpose:</strong> To make skinning in MP easie for both programmers and skin </p><p>designers.</p><p>The idea is to have developers declare the controls on their GUIWindows as field members (as in Windows Forms), which will then be initialized automatically when the window is loaded. This is achieved through the use Reflection and Attributes.</p><p></p><p>Advantages:</p><ul> <li data-xf-list-type="ul"><strong>1.</strong> Automatic generation of the XML skin template, which you could then <br /> immediatly put to use with the forthcoming <a href="http://nolanparty.com/mediaportal.sourceforge.net/phpBB2/viewtopic.php?t=1735" target="_blank">Skin Editor</a> or a regular XML editor.</li> </ul> <ul> <li data-xf-list-type="ul"><strong>2.</strong>Eliminates the use of <br /> [code]enum Controls { ... }[/code]<br /> which clutters up the code considerably, and the cumbersome repeated calls to GUIWindow.GetControls(...). Instead, using my method, controls<br /> on the window are fields of the window's class, making for a much better, more intuitive, and easier design process. (The exact type of each GUIControl is defined inside the class).</li> </ul> <ul> <li data-xf-list-type="ul"><strong>3.</strong>The "description"and "label" tags of every control are hardcoded into<br /> the GUIWindow descendant class, rather than being tucked away<br /> in the skin's XML data.</li> </ul><p></p><p><strong>ToDo:</strong> Add chapter to the "How to create plugins tutorial" once changes are agreed upon and in CVS. Also: decide on a coding convention for controls (perhaps c_refreshButton, or frodo's m_pRefreshButton).</p><p></p><p>I've uploaded my patch to SourceForge. </p><p>The three files that should be added to guilib in order to make this work are SkinnableWindowAttribute, ControlAttribute, and the changed GUIWindow. Also included in the patch file are an example mock-up window class "My Lyrics" to demonstrate the usefulness of my changes, and a demonstration application project that takes an assembly such as the GUILyrics assembly (or any assembly that has a GUIWindow marked with the new attributes) and generates a XML skin template.</p></blockquote><p></p>
[QUOTE="NoMoDo, post: 3645, member: 10381"] [b]Reflection in MP[/b] @suicidal - Thanks to you, I've come up with an interesting enhancement to the GUIWindow class, that uses Reflection to make plugin development and skin development easier (see below). I agree with you 100% - a similar change to the ControlFactory class is sorely needed - the class itself and especially the foot-long Create method could really use a big change to improve maintainability. [b][size=5]A Reflective GUIWindow (or: There's more than one way to skin a cat)[/size][/b] [b]Purpose:[/b] To make skinning in MP easie for both programmers and skin designers. The idea is to have developers declare the controls on their GUIWindows as field members (as in Windows Forms), which will then be initialized automatically when the window is loaded. This is achieved through the use Reflection and Attributes. Advantages: [list][b]1.[/b] Automatic generation of the XML skin template, which you could then immediatly put to use with the forthcoming [url=http://nolanparty.com/mediaportal.sourceforge.net/phpBB2/viewtopic.php?t=1735]Skin Editor[/url] or a regular XML editor.[/list] [list][b]2.[/b]Eliminates the use of [code]enum Controls { ... }[/code] which clutters up the code considerably, and the cumbersome repeated calls to GUIWindow.GetControls(...). Instead, using my method, controls on the window are fields of the window's class, making for a much better, more intuitive, and easier design process. (The exact type of each GUIControl is defined inside the class).[/list] [list][b]3.[/b]The "description"and "label" tags of every control are hardcoded into the GUIWindow descendant class, rather than being tucked away in the skin's XML data.[/list] [b]ToDo:[/b] Add chapter to the "How to create plugins tutorial" once changes are agreed upon and in CVS. Also: decide on a coding convention for controls (perhaps c_refreshButton, or frodo's m_pRefreshButton). I've uploaded my patch to SourceForge. The three files that should be added to guilib in order to make this work are SkinnableWindowAttribute, ControlAttribute, and the changed GUIWindow. Also included in the patch file are an example mock-up window class "My Lyrics" to demonstrate the usefulness of my changes, and a demonstration application project that takes an assembly such as the GUILyrics assembly (or any assembly that has a GUIWindow marked with the new attributes) and generates a XML skin template. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Using reflection for GUIControlFactory
Contact us
RSS
Top
Bottom