From: <che...@us...> - 2009-06-21 14:12:57
|
Revision: 2953 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2953&view=rev Author: chef_koch Date: 2009-06-21 13:48:56 +0000 (Sun, 21 Jun 2009) Log Message: ----------- using *type instead of *id for selectedValue of comboboxes Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-21 13:30:13 UTC (rev 2952) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-21 13:48:56 UTC (rev 2953) @@ -34,8 +34,8 @@ [PluginIcons("MySleepTimer.img.MySleepTimer_enabled.png", "MySleepTimer.img.MySleepTimer_disabled.png")] public class MySleepTimer : IPlugin, ISetupForm { - private const int SHUTDOWN_CYCLE_MS = 60*1000; - private const int SHUTDOWN_ANNOUNCE_MS = 3*1000; + private const int SHUTDOWN_CYCLE_MS = 60 * 1000; + private const int SHUTDOWN_ANNOUNCE_MS = 3 * 1000; //timers private Timer _timerShutDown; @@ -154,7 +154,8 @@ break; } } - else if ((_sleepTimeCurrent <= Settings.NotifyBeforeSleep) && ((Settings.NotifyBeforeSleep - _sleepTimeCurrent) % Settings.NotifyInterval == 0)) + else if ((_sleepTimeCurrent <= Settings.NotifyBeforeSleep) && + ((Settings.NotifyBeforeSleep - _sleepTimeCurrent) % Settings.NotifyInterval == 0)) //notify { _timerAction.Stop(); @@ -182,7 +183,7 @@ //TO DO - add additional test here - to detect if some video play is realy in progress string[] shortCurrentRemaining = GUIPropertyManager.GetProperty("#shortcurrentremaining").Split(new char[] {':'}); - totalMinutes = (int.Parse(shortCurrentRemaining[0])*60) + int.Parse(shortCurrentRemaining[1]); + totalMinutes = (int.Parse(shortCurrentRemaining[0]) * 60) + int.Parse(shortCurrentRemaining[1]); } catch { Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-21 13:30:13 UTC (rev 2952) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-21 13:48:56 UTC (rev 2953) @@ -21,10 +21,8 @@ #endregion using System; -using System.Collections; -using MediaPortal.Configuration; +using System.Collections.Generic; using MediaPortal.GUI.Library; -using MediaPortal.Profile; using MediaPortal.UserInterface.Controls; using MediaPortal.Util; @@ -51,10 +49,10 @@ { comboBoxActionType.DataSource = GenerateActionList(); comboBoxActionType.DisplayMember = "ActionName"; - comboBoxActionType.ValueMember = "ActionID"; + comboBoxActionType.ValueMember = "ActionType"; comboBoxShutDownType.DataSource = GenerateShutdownList(); comboBoxShutDownType.DisplayMember = "ShutdownName"; - comboBoxShutDownType.ValueMember = "ShutdownID"; + comboBoxShutDownType.ValueMember = "ShutdownType"; Settings.Load(); comboBoxActionType.SelectedValue = Settings.ActionType; @@ -67,7 +65,7 @@ numericUpDownNotifyBeforeSleep.Value = Settings.NotifyBeforeSleep; numericUpDownNotifyInterval.Value = Settings.NotifyInterval; numericUpDownTimeOutN.Value = Settings.NotifyTimeOutMs; - + SetUpShutDownTypeControls(); SetUpNotifyControls(); } @@ -117,16 +115,16 @@ { try { - Settings.ActionType =(Action.ActionType) comboBoxActionType.SelectedValue; + Settings.ActionType = (Action.ActionType) comboBoxActionType.SelectedValue; Settings.SleepBehavior = comboBoxSleepBehavior.Text; - Settings.ShutdownType = (RestartOptions)comboBoxShutDownType.SelectedValue; + Settings.ShutdownType = (RestartOptions) comboBoxShutDownType.SelectedValue; Settings.ShutdownForce = checkBoxShutDownForce.Checked; - Settings.SleepTimeMaxium = (int)numericUpDownSleepTimeMax.Value; - Settings.SleepTimeStep = (int)numericUpDownSleepTimeStep.Value; - Settings.ActionTimeOutMs = (int)numericUpDownTimeOutB.Value; - Settings.NotifyBeforeSleep = (int)numericUpDownNotifyBeforeSleep.Value; - Settings.NotifyInterval = (int)numericUpDownNotifyInterval.Value; - Settings.NotifyTimeOutMs = (int)numericUpDownTimeOutN.Value; + Settings.SleepTimeMaxium = (int) numericUpDownSleepTimeMax.Value; + Settings.SleepTimeStep = (int) numericUpDownSleepTimeStep.Value; + Settings.ActionTimeOutMs = (int) numericUpDownTimeOutB.Value; + Settings.NotifyBeforeSleep = (int) numericUpDownNotifyBeforeSleep.Value; + Settings.NotifyInterval = (int) numericUpDownNotifyInterval.Value; + Settings.NotifyTimeOutMs = (int) numericUpDownTimeOutN.Value; Settings.Save(); Close(); @@ -137,43 +135,23 @@ } } - private ArrayList GenerateActionList() + private static List<ActionEntry> GenerateActionList() { - ArrayList ret = new ArrayList(); - try - { - string[] names = Enum.GetNames(typeof (Action.ActionType)); - int[] values = (int[]) Enum.GetValues(typeof (Action.ActionType)); - for (int i = 0; i < names.Length; i++) - { - ret.Add(new ActionEntry(names[i], values[i])); - //MessageBox.Show(String.Format("{0} : {1}",names[i],values[i])); - } - } - catch (Exception ex) - { - Log.Error(ex); - } + var ret = new List<ActionEntry>(); + + foreach (var variable in Enum.GetValues(typeof (Action.ActionType))) + ret.Add(new ActionEntry((Action.ActionType) variable)); + return ret; } - private ArrayList GenerateShutdownList() + private static List<ShutdownEntry> GenerateShutdownList() { - ArrayList ret = new ArrayList(); - try - { - string[] names = Enum.GetNames(typeof (RestartOptions)); - int[] values = (int[]) Enum.GetValues(typeof (RestartOptions)); - for (int i = 0; i < names.Length; i++) - { - ret.Add(new ShutdownEntry(names[i], values[i])); - //MessageBox.Show(String.Format("{0} : {1}",names[i],values[i])); - } - } - catch (Exception ex) - { - Log.Error(ex); - } + var ret = new List<ShutdownEntry>(); + + foreach (var variable in Enum.GetValues(typeof (RestartOptions))) + ret.Add(new ShutdownEntry((RestartOptions) variable)); + return ret; } @@ -235,45 +213,41 @@ internal class ActionEntry { - private readonly string _actionName; - private readonly int _actionID; + public Action.ActionType ActionType { get; private set; } public string ActionName { - get { return _actionName; } + get { return ActionType.ToString(); } } public int ActionID { - get { return _actionID; } + get { return (int) ActionType; } } - public ActionEntry(string name, int id) + public ActionEntry(Action.ActionType actionType) { - _actionName = name; - _actionID = id; + ActionType = actionType; } } internal class ShutdownEntry { - private readonly string _shutdownName; - private readonly int _shutdownID; + public RestartOptions ShutDownType { get; private set; } public string ShutdownName { - get { return _shutdownName; } + get { return ShutDownType.ToString(); } } public int ShutdownID { - get { return _shutdownID; } + get { return (int) ShutDownType; } } - public ShutdownEntry(string name, int id) + public ShutdownEntry(RestartOptions restartOptions) { - _shutdownName = name; - _shutdownID = id; + ShutDownType = restartOptions; } } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2009-06-21 13:30:13 UTC (rev 2952) +++ trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2009-06-21 13:48:56 UTC (rev 2953) @@ -1,14 +1,31 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This Program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU Make; see the file COPYING. If not, write to +// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +// http://www.gnu.org/copyleft/gpl.html + +#endregion + +using System.Reflection; using MediaPortal.Configuration; using MediaPortal.GUI.Library; using MediaPortal.Util; using Log=MediaPortal.ServiceImplementations.Log; -using System.Reflection; - namespace MySleepTimer { internal static class Settings @@ -55,11 +72,11 @@ ActionType = (Action.ActionType) xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ActionType", - (int)(Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); + (int) (Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); SleepBehavior = xmlReader.GetValueAsString(PLUGIN_NAME, "#MySleepTimer.SleepBehavior", "Shutdown"); ShutdownType = (RestartOptions) - xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int)RestartOptions.ShutDown); + xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int) RestartOptions.ShutDown); ShutdownForce = xmlReader.GetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", false); SleepTimeMaxium = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Maximum", 120); SleepTimeStep = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Step", 10); @@ -69,7 +86,7 @@ NotifyTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.NotifyTimeOut", 3) * 1000; } - //WriteToLog(); + WriteToLog(); } public static void Save() @@ -80,9 +97,9 @@ MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionType", ActionType); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionType", (int) ActionType); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.SleepBehavior", SleepBehavior); - xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", ShutdownType); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int) ShutdownType); xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", ShutdownForce); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.Maximum", SleepTimeMaxium); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.Step", SleepTimeStep); @@ -96,7 +113,7 @@ public static void WriteToLog() { // get all properties - PropertyInfo[] propertyInfos = typeof(Settings).GetProperties(); + PropertyInfo[] propertyInfos = typeof (Settings).GetProperties(); // write property names and values foreach (PropertyInfo propertyInfo in propertyInfos) { @@ -104,4 +121,4 @@ } } } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |