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 2
Plugin Development
Plugin: Shutdown Manager (or call it whatever you want ;) ) - A blog to develop a MP2 plugin
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="chefkoch" data-source="post: 942565" data-attributes="member: 10438"><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000"><strong><span style="font-size: 15px">Settings and Configuration Management in MediaPortal 2</span></strong></span></span></span></p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">Please also read wiki for more information about <a href="http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/Core_Services/Settings" target="_blank"><span style="color: #063b5e">settings</span></a>, <a href="http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/User_Services/Configuration" target="_blank"><span style="color: #063b5e">configuration </span></a>and <a href="http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/User_Services/Configuration#Configuration_vs_Settings" target="_blank"><span style="color: #063b5e">their difference</span></a>.</span></span></span></p><p> </p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">Loading/Saving settings from/to xml files is done by the SettingsManager.</span></span></span></p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">A plugin only needs to provide it's own class and all's properties are then automatically (de-)serialized from/to the xml files. The plugin itself does not need to care about any Serialization or file handling stuff.</span></span></span></p><p> </p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">The <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L46-L66" target="_blank"><span style="color: #063b5e">ShutdownSettings</span></a> contains <strong><span style="color: #ff0000">three public properties</span></strong>:</span></span></span></p><p></p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">For each setting</span></span></span></p><ul> <li data-xf-list-type="ul"><span style="font-family: 'Tahoma'">the </span><span style="color: #008000"><strong>scope, whether it is a MP2 global or a 'per-user'</strong></span><span style="font-family: 'Tahoma'"> setting and</span></li> <li data-xf-list-type="ul"><span style="font-family: 'Tahoma'">a </span><strong><span style="color: #0000ff">default value</span></strong><span style="font-family: 'Tahoma'"> will be defined.</span></li> </ul><p><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L66-L67" target="_blank">Loading the settings</a>is simply done by:</p><p></p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">After settings are loaded, all it's properties can be accessed as usual.</span></span></span></p><p> </p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000"><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L156-L161" target="_blank"><span style="color: #063b5e">Saving </span>the settings</a> is similar to loading them:</span></span></span></p><p></p><p> </p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">Up to this point it is already possible to load/save various settings from/to xml files, <strong>without</strong> writing any line of code regarding paths, file names, or xml file handling.</span></span></span></p><p> </p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">Even if the settings management is already working, nothing has been changed from the user point of view. To change settings the configuration management is needed. Like explained in the first post, the user should be able to configure the order and visibility of the shutdown items.</span></span></span></p><p><span style="font-size: 13px"><span style="font-family: 'Tahoma'"><span style="color: #000000">To achieve this a <strong>CustomConfigSetting</strong> is needed. For using other settings, like YesNo (Boolean), paths, Single- or MutlipleSelections please take a look at the <a href="http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/Plugins/Configuration#Exposing_configurable_settings" target="_blank"><span style="color: #063b5e">wiki </span></a>and other existing plugins.</span></span></span></p><p>[spoiler]Example: Videoplayer\DefaultGeometry: <a href="https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/plugin.xml#L133-L148" target="_blank"><span style="color: #063b5e">registration of ConfigSetting in plugin.xml</span></a> with reference to DefaultGeometry class, definition of <a href="https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/Configuration/Players/DefaultGeometry.cs" target="_blank"><span style="color: #063b5e">DefaultGeometry class</span></a> as SingleSelectionSetting, <a href="https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/PlayerSettings.cs" target="_blank"><span style="color: #063b5e">DefaultGeometry in PlayerSettings</span></a>[/spoiler]</p><p>Compared i.e. to the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/Configuration/Players/DefaultGeometry.cs#L33-L62" target="_blank">DefaultGeometry setting</a>, which is only a SingleSelection out of a list and already has the overloads Load() and Save(), is our <span style="font-family: 'Consolas'"><span style="color: #2b91af">CustomConfigSetting </span></span><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/Configuration/General/ShutdownDialogSetting.cs" target="_blank">ShutdownDialogSetting </a>empty.</p><p></p><p> </p><p>Within the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml" target="_blank">plugin.xml</a></p><ul> <li data-xf-list-type="ul">the workflow model <span style="color: #ff00ff"><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L28-L30" target="_blank"><span style="color: #ff00ff">ShutdownConfigurationModel </span></a></span>is being registered</li> </ul><p></p><ul> <li data-xf-list-type="ul">the workflow state <span style="color: #ff6600"><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L46-L51" target="_blank"><span style="color: #ff6600">dialogShutdownConfiguration </span></a></span>is defined as a DialogState and references to the <span style="color: #ff00ff">ShutdownConfigurationModel</span></li> </ul><p></p><ul> <li data-xf-list-type="ul">a setting <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L83-L90" target="_blank">ShutdownDialogSetting</a> is being registered as <span style="font-family: 'Consolas'"><span style="color: #2b91af">CustomConfigSetting </span></span>with reference to the <span style="color: #ff6600">dialogShutdownConfiguration</span> workflow state</li> </ul><p></p><p> </p><p><strong><span style="font-size: 15px"><span style="font-family: 'Tahoma'">Creating the GUI for the CustomConfigSetting</span></span></strong></p><p>At next a new class <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Helper%20Classes/ShutdownItem.cs#L42-L43" target="_blank">ShutdownItem</a> with it's properties Action (type: ShutdownAction) and Enabled (type: bool) has been implemented.</p><p>The <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L52-L66" target="_blank">ShutdownSettings</a> class got the property ShutdownItemsList (type: List<ShutdownItems>)</p><p>Now it is already possible to save and load the order and the visibility of the shutdown items.</p><p> </p><p>Let's make it available to GUI through the new <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs" target="_blank">ShutdownConfigurationModel.</a></p><p>It <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L64-L68" target="_blank">loads </a>and <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L154-L162" target="_blank">saves </a>the list of shutdown items and provides <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L140-L187" target="_blank">public properties and methods for usage within the GUI</a>.</p><p>Within skin skin files it is possible to trigger:</p><ul> <li data-xf-list-type="ul"><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L154-L162" target="_blank">save settings</a>,</li> <li data-xf-list-type="ul"><a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L164-L173" target="_blank">move an item up</a></li> <li data-xf-list-type="ul">and <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L175-L185" target="_blank">move an item down</a></li> </ul><p>Additionally an <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L142-L145" target="_blank">ItemList of available shutdown actions</a> is provided. Each item of that ItemList has <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L123-L130" target="_blank">AddtionalProperties</a>. The currently the important one here is: <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L126" target="_blank">IsChecked</a>(in code the constant KEY_IS_CHECKED is being used, see previous post for infos about the constans and their usage)</p><p>Let's design the screen files (skin file) for the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml" target="_blank">dialogShutdownConfiguration</a>:</p><ul> <li data-xf-list-type="ul">As a base (empty dialog with close button) we use again <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L5" target="_blank">master_dialog_bare.xaml</a> and provide the required <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L11" target="_blank">header text</a> for the ...bare.xaml</li> <li data-xf-list-type="ul">The <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L14-L15" target="_blank">ShutdownConfigurationModel </a>is referenced from this screen file.</li> <li data-xf-list-type="ul">And last but not least the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L18-L71" target="_blank">content area</a>. To achieve the layout I am looking for, I used a <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L19" target="_blank">StackPanel</a> and a <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L38" target="_blank">Grid </a>for positioning.</li> <li data-xf-list-type="ul">In the end the dialog contains 3 visible controls:<ul> <li data-xf-list-type="ul">The <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L21-L35" target="_blank">ListView</a> of all available ShutdownItems (incl. visibility & controls to re-order)</li> <li data-xf-list-type="ul">An <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L47-L60" target="_blank">OK button</a> to save settings and close the dialog.</li> <li data-xf-list-type="ul">A <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L62-L68" target="_blank">Cancel button</a> to close the dialog without saving.</li> </ul></li> </ul><p>The Layout could be improved and slimmed down in future. If I'll do that I'll make a separated post and link to it from here.</p><ul> <li data-xf-list-type="ul">As you can see the previously mentioned methods <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L55" target="_blank">SaveSettings</a>, <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L27-L29" target="_blank">MoveUp </a>and <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L31-L33" target="_blank">MoveDown </a>are being reused within this screen files.</li> <li data-xf-list-type="ul">The ListView is has the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L24" target="_blank">ShutdownItems as ItemsSource</a> and is using the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L23" target="_blank">ShutdownConfigurationListViewStyle</a>, which is defined in <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L60-L71" target="_blank">ShutdownStyles.xaml</a>.</li> <li data-xf-list-type="ul">The ShutdownConfigurationListViewStyle is using <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L69-L70" target="_blank">ShutdownConfigurationItemContainerStyle </a>to define the controls which are being displayed for each item of the ItemList.</li> <li data-xf-list-type="ul">The ShutdownConfigurationItemContainerStyle contains<ul> <li data-xf-list-type="ul">a <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L23-L27" target="_blank">checkbox</a> to enable or disable a shutdown action,</li> <li data-xf-list-type="ul">a <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L29-L40" target="_blank">button </a>to move the item one position up in the list and</li> <li data-xf-list-type="ul">a <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L42-L53" target="_blank">button </a>to move the item one position down in the list</li> </ul></li> </ul><p>What we've got here:</p><p>[ATTACH=full]118419[/ATTACH]</p><p> </p><p>As you can see you can freely define any screen like you want it to in MP2. You even could build the list horizontal instead of vertical and move everything from left to right etc, without any changes to plugin code itself, because the required properties and methods are already populated.</p><p> </p><p>Screens of the other dialogs:</p><p>[ATTACH]118420[/ATTACH] [ATTACH]118421[/ATTACH]</p><p> </p><p>The other properties of the <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L46-L50" target="_blank">ShutdownSettings </a>are not populated to the user, but managed by the ShutdownTimerModel: <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownTimerModel.cs#L81-L88" target="_blank">Load</a>, <a href="https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownTimerModel.cs#L111-L114" target="_blank">Save</a></p><p> </p><p>Next task should be the collection of infos about the remaining playtime of the current media and the current active playlist, their conditional visibility in dialogShutdownTimer and some reworks, cleanups & imrovements in code and skin files.</p></blockquote><p></p>
[QUOTE="chefkoch, post: 942565, member: 10438"] [SIZE=13px][FONT=Tahoma][COLOR=#000000][B][SIZE=4]Settings and Configuration Management in MediaPortal 2[/SIZE][/B][/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]Please also read wiki for more information about [URL='http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/Core_Services/Settings'][COLOR=#063b5e]settings[/COLOR][/URL], [URL='http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/User_Services/Configuration'][COLOR=#063b5e]configuration [/COLOR][/URL]and [URL='http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/User_Services/Configuration#Configuration_vs_Settings'][COLOR=#063b5e]their difference[/COLOR][/URL].[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]Loading/Saving settings from/to xml files is done by the SettingsManager.[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]A plugin only needs to provide it's own class and all's properties are then automatically (de-)serialized from/to the xml files. The plugin itself does not need to care about any Serialization or file handling stuff.[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]The [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L46-L66'][COLOR=#063b5e]ShutdownSettings[/COLOR][/URL] contains [B][COLOR=#ff0000]three public properties[/COLOR][/B]:[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000][/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]For each setting[/COLOR][/FONT][/SIZE] [LIST] [*][FONT=Tahoma]the [/FONT][COLOR=#008000][B]scope, whether it is a MP2 global or a 'per-user'[/B][/COLOR][FONT=Tahoma] setting and[/FONT] [*][FONT=Tahoma]a [/FONT][B][COLOR=#0000ff]default value[/COLOR][/B][FONT=Tahoma] will be defined.[/FONT] [/LIST] [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L66-L67']Loading the settings[/URL]is simply done by: [FONT=Tahoma][/FONT] [SIZE=13px][FONT=Tahoma][COLOR=#000000]After settings are loaded, all it's properties can be accessed as usual.[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L156-L161'][COLOR=#063b5e]Saving [/COLOR]the settings[/URL] is similar to loading them:[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000][/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]Up to this point it is already possible to load/save various settings from/to xml files, [B]without[/B] writing any line of code regarding paths, file names, or xml file handling.[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]Even if the settings management is already working, nothing has been changed from the user point of view. To change settings the configuration management is needed. Like explained in the first post, the user should be able to configure the order and visibility of the shutdown items.[/COLOR][/FONT][/SIZE] [SIZE=13px][FONT=Tahoma][COLOR=#000000]To achieve this a [B]CustomConfigSetting[/B] is needed. For using other settings, like YesNo (Boolean), paths, Single- or MutlipleSelections please take a look at the [URL='http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/Contribute/Development/4_Modules/Plugins/Configuration#Exposing_configurable_settings'][COLOR=#063b5e]wiki [/COLOR][/URL]and other existing plugins.[/COLOR][/FONT][/SIZE] [spoiler]Example: Videoplayer\DefaultGeometry: [URL='https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/plugin.xml#L133-L148'][COLOR=#063b5e]registration of ConfigSetting in plugin.xml[/COLOR][/URL] with reference to DefaultGeometry class, definition of [URL='https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/Configuration/Players/DefaultGeometry.cs'][COLOR=#063b5e]DefaultGeometry class[/COLOR][/URL] as SingleSelectionSetting, [URL='https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/PlayerSettings.cs'][COLOR=#063b5e]DefaultGeometry in PlayerSettings[/COLOR][/URL][/spoiler] Compared i.e. to the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/9790cd19b4cc851e80e1df517fd8f49aaf40ee80/MediaPortal/Source/UI/SkinEngine/Settings/Configuration/Players/DefaultGeometry.cs#L33-L62']DefaultGeometry setting[/URL], which is only a SingleSelection out of a list and already has the overloads Load() and Save(), is our [FONT=Consolas][COLOR=#2b91af]CustomConfigSetting [/COLOR][/FONT][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/Configuration/General/ShutdownDialogSetting.cs']ShutdownDialogSetting [/URL]empty. Within the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml']plugin.xml[/URL] [LIST] [*]the workflow model [COLOR=#ff00ff][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L28-L30'][COLOR=#ff00ff]ShutdownConfigurationModel [/COLOR][/URL][/COLOR]is being registered [/LIST] [LIST] [*]the workflow state [COLOR=#ff6600][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L46-L51'][COLOR=#ff6600]dialogShutdownConfiguration [/COLOR][/URL][/COLOR]is defined as a DialogState and references to the [COLOR=#ff00ff]ShutdownConfigurationModel[/COLOR] [/LIST] [LIST] [*]a setting [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/plugin.xml#L83-L90']ShutdownDialogSetting[/URL] is being registered as [FONT=Consolas][COLOR=#2b91af]CustomConfigSetting [/COLOR][/FONT]with reference to the [COLOR=#ff6600]dialogShutdownConfiguration[/COLOR] workflow state [/LIST] [B][SIZE=4][FONT=Tahoma]Creating the GUI for the CustomConfigSetting[/FONT][/SIZE][/B] At next a new class [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Helper%20Classes/ShutdownItem.cs#L42-L43']ShutdownItem[/URL] with it's properties Action (type: ShutdownAction) and Enabled (type: bool) has been implemented. The [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L52-L66']ShutdownSettings[/URL] class got the property ShutdownItemsList (type: List<ShutdownItems>) Now it is already possible to save and load the order and the visibility of the shutdown items. Let's make it available to GUI through the new [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs']ShutdownConfigurationModel.[/URL] It [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L64-L68']loads [/URL]and [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L154-L162']saves [/URL]the list of shutdown items and provides [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L140-L187']public properties and methods for usage within the GUI[/URL]. Within skin skin files it is possible to trigger: [LIST] [*][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L154-L162']save settings[/URL], [*][URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L164-L173']move an item up[/URL] [*]and [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L175-L185']move an item down[/URL] [/LIST] Additionally an [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L142-L145']ItemList of available shutdown actions[/URL] is provided. Each item of that ItemList has [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L123-L130']AddtionalProperties[/URL]. The currently the important one here is: [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownConfigurationModel.cs#L126']IsChecked[/URL](in code the constant KEY_IS_CHECKED is being used, see previous post for infos about the constans and their usage) Let's design the screen files (skin file) for the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml']dialogShutdownConfiguration[/URL]: [LIST] [*]As a base (empty dialog with close button) we use again [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L5']master_dialog_bare.xaml[/URL] and provide the required [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L11']header text[/URL] for the ...bare.xaml [*]The [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L14-L15']ShutdownConfigurationModel [/URL]is referenced from this screen file. [*]And last but not least the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L18-L71']content area[/URL]. To achieve the layout I am looking for, I used a [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L19']StackPanel[/URL] and a [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L38']Grid [/URL]for positioning. [*]In the end the dialog contains 3 visible controls: [LIST] [*]The [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L21-L35']ListView[/URL] of all available ShutdownItems (incl. visibility & controls to re-order) [*]An [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L47-L60']OK button[/URL] to save settings and close the dialog. [*]A [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L62-L68']Cancel button[/URL] to close the dialog without saving. [/LIST] [/LIST] The Layout could be improved and slimmed down in future. If I'll do that I'll make a separated post and link to it from here. [LIST] [*]As you can see the previously mentioned methods [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L55']SaveSettings[/URL], [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L27-L29']MoveUp [/URL]and [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L31-L33']MoveDown [/URL]are being reused within this screen files. [*]The ListView is has the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L24']ShutdownItems as ItemsSource[/URL] and is using the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/screens/dialogShutdownConfiguration.xaml#L23']ShutdownConfigurationListViewStyle[/URL], which is defined in [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L60-L71']ShutdownStyles.xaml[/URL]. [*]The ShutdownConfigurationListViewStyle is using [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L69-L70']ShutdownConfigurationItemContainerStyle [/URL]to define the controls which are being displayed for each item of the ItemList. [*]The ShutdownConfigurationItemContainerStyle contains [LIST] [*]a [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L23-L27']checkbox[/URL] to enable or disable a shutdown action, [*]a [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L29-L40']button [/URL]to move the item one position up in the list and [*]a [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Skin/default/themes/default/styles/ShutdownStyles.xaml#L42-L53']button [/URL]to move the item one position down in the list [/LIST] [/LIST] What we've got here: [ATTACH=full]118419[/ATTACH] As you can see you can freely define any screen like you want it to in MP2. You even could build the list horizontal instead of vertical and move everything from left to right etc, without any changes to plugin code itself, because the required properties and methods are already populated. Screens of the other dialogs: [ATTACH]118420[/ATTACH] [ATTACH]118421[/ATTACH] The other properties of the [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Settings/ShutdownSettings.cs#L46-L50']ShutdownSettings [/URL]are not populated to the user, but managed by the ShutdownTimerModel: [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownTimerModel.cs#L81-L88']Load[/URL], [URL='https://github.com/MediaPortal/MediaPortal-2/blob/219d8327cbdeaef9f5adff69d1b0c49bedd957fe/MediaPortal/Incubator/ShutdownManager/Models/ShutdownTimerModel.cs#L111-L114']Save[/URL] Next task should be the collection of infos about the remaining playtime of the current media and the current active playlist, their conditional visibility in dialogShutdownTimer and some reworks, cleanups & imrovements in code and skin files. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Plugin: Shutdown Manager (or call it whatever you want ;) ) - A blog to develop a MP2 plugin
Contact us
RSS
Top
Bottom