From: <che...@us...> - 2009-06-14 13:07:50
|
Revision: 2921 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2921&view=rev Author: chef_koch Date: 2009-06-14 13:07:48 +0000 (Sun, 14 Jun 2009) Log Message: ----------- resharped the project Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-14 12:59:41 UTC (rev 2920) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-14 13:07:48 UTC (rev 2921) @@ -1,339 +1,383 @@ -#region Copyright (C) 2005-2008 Team MediaPortal +#region Copyright (C) 2005-2009 Team MediaPortal -/* - * Copyright (C) 2005-2008 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 - * - */ +// 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; -using System.Collections.Generic; -using System.Text; +using System.Timers; using System.Windows.Forms; -using MediaPortal.UserInterface.Controls; -using MediaPortal.GUI; +using MediaPortal.Configuration; +using MediaPortal.Dialogs; using MediaPortal.GUI.Library; +using MediaPortal.Profile; using MediaPortal.Util; -using MediaPortal.Dialogs; -using MediaPortal.Configuration; +using Timer=System.Timers.Timer; +namespace MySleepTimer +{ + [PluginIcons("MySleepTimer.img.MySleepTimer_enabled.png", "MySleepTimer.img.MySleepTimer_disabled.png")] + public class MySleepTimer : GUIWindow, ISetupForm + { + private const int SHUTDOWN_CYCLE_MS = 60*1000; + private const int SHUTDOWN_ANNOUNCE_MS = 3*1000; -namespace MySleepTimer { - [PluginIcons("MySleepTimer.img.MySleepTimer_enabled.png", "MySleepTimer.img.MySleepTimer_disabled.png")] - public class MySleepTimer : GUIWindow, ISetupForm { - const int SHUTDOWN_CYCLE_MS = 60 * 1000; - const int SHUTDOWN_ANNOUNCE_MS = 3 * 1000; + //timers + private readonly Timer timerShutDown; + private readonly Timer timerAction; + private readonly Timer timerNotify; + //MP + private GUIDialogNotify dialogSleepTimerNotify; - //timers - private System.Timers.Timer timerShutDown; - private System.Timers.Timer timerAction; - private System.Timers.Timer timerNotify; - //MP - private GUIDialogNotify dialogSleepTimerNotify; + //globals + private int sleepTimeCurrent = 0; + private bool timedOut = true; + private bool setByPlay = false; + private bool shutdowning = false; + //settings + private readonly Action.ActionType actionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; + private readonly string sleepBehavior = "Shutdown"; + private readonly RestartOptions restartOption = RestartOptions.ShutDown; + private readonly bool shutdownForce = false; + private readonly int sleepTimeMaxium = 120; //(1..n) + private readonly int sleepTimeStep = 10; //(1..n) + private readonly int actionTimeOutMs = 2*1000; //(1..n * 1000) + private readonly int notifyBeforeSleep = 3; //(0..n) + private readonly int notifyInterval = 1; //(1..notifyBeforeSleep) + private readonly int notifyTimeOutMs = 3*1000; //(1..65 * 1000) - //globals - private int sleepTimeCurrent = 0; - private bool timedOut = true; - private bool setByPlay = false; - private bool shutdowning = false; - //settings - private Action.ActionType actionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; - private string sleepBehavior = "Shutdown"; - private RestartOptions restartOption = RestartOptions.ShutDown; - private bool shutdownForce = false; - private int sleepTimeMaxium = 120; //(1..n) - private int sleepTimeStep = 10; //(1..n) - private int actionTimeOutMs = 2 * 1000; //(1..n * 1000) - private int notifyBeforeSleep = 3; //(0..n) - private int notifyInterval = 1; //(1..notifyBeforeSleep) - private int notifyTimeOutMs = 3 * 1000; //(1..65 * 1000) - - public MySleepTimer() { - try { - timerShutDown = new System.Timers.Timer(); - timerAction = new System.Timers.Timer(); - timerNotify = new System.Timers.Timer(); - //read settings from config - using (MediaPortal.Profile.Settings xmlReader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - actionType = (Action.ActionType)xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", (int)(Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); - sleepBehavior = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", "Shutdown"); - restartOption = (RestartOptions)xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", (int)RestartOptions.ShutDown); - shutdownForce = xmlReader.GetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", false); - sleepTimeMaxium = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Maximum", 120); - sleepTimeStep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Step", 10); - actionTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 2) * 1000; - notifyBeforeSleep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", 3); - notifyInterval = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); - notifyTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyTimeOut", 3) * 1000; - } - //inits - timerShutDown.Interval = SHUTDOWN_CYCLE_MS; - timerShutDown.Elapsed += new System.Timers.ElapsedEventHandler(timerShutDown_Tick); - timerAction.Interval = actionTimeOutMs; - timerAction.AutoReset = false; - timerAction.Elapsed += new System.Timers.ElapsedEventHandler(timerAction_Tick); - timerNotify.Interval = notifyTimeOutMs; - timerNotify.AutoReset = false; - timerNotify.Elapsed += new System.Timers.ElapsedEventHandler(timerNotify_Tick); - GUIWindowManager.OnNewAction += new OnActionHandler(GUIWindowManager_OnNewAction); - } - catch (Exception ex) { - //log errors here - } + public MySleepTimer() + { + try + { + timerShutDown = new Timer(); + timerAction = new Timer(); + timerNotify = new Timer(); + //read settings from config + using (Settings xmlReader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + actionType = + (Action.ActionType) + xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", + (int) (Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); + sleepBehavior = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", "Shutdown"); + restartOption = + (RestartOptions) + xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", (int) RestartOptions.ShutDown); + shutdownForce = xmlReader.GetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", false); + sleepTimeMaxium = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Maximum", 120); + sleepTimeStep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Step", 10); + actionTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 2)*1000; + notifyBeforeSleep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", 3); + notifyInterval = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); + notifyTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyTimeOut", 3)*1000; } + //inits + timerShutDown.Interval = SHUTDOWN_CYCLE_MS; + timerShutDown.Elapsed += new ElapsedEventHandler(timerShutDown_Tick); + timerAction.Interval = actionTimeOutMs; + timerAction.AutoReset = false; + timerAction.Elapsed += new ElapsedEventHandler(timerAction_Tick); + timerNotify.Interval = notifyTimeOutMs; + timerNotify.AutoReset = false; + timerNotify.Elapsed += new ElapsedEventHandler(timerNotify_Tick); + GUIWindowManager.OnNewAction += new OnActionHandler(GUIWindowManager_OnNewAction); + } + catch (Exception ex) + { + //log errors here + } + } - void GUIWindowManager_OnNewAction(Action action) { - try { - if ((action.wID == actionType) && (!shutdowning)) //action and no shutdown in progress - { - timerAction.Stop(); - timerNotify.Stop(); - if (timedOut && timerShutDown.Enabled) //1st press - { - timedOut = false; - //action - timerAction.Start(); - ShowNotifyDialog(actionTimeOutMs, string.Format("Time left: {0} min", sleepTimeCurrent)); - } - else //additional presses - { - timerShutDown.Stop(); - SetTime(); - if (sleepTimeCurrent > 0) - timerShutDown.Start(); - if ((sleepTimeCurrent > 0) && (sleepTimeCurrent <= notifyBeforeSleep) && ((notifyBeforeSleep - sleepTimeCurrent) % notifyInterval == 0)) //notify - { - timerNotify.Start(); - ShowNotifyDialog(notifyTimeOutMs, null); - } - else //action - { - timerAction.Start(); - ShowNotifyDialog(actionTimeOutMs, null); - } - } - base.OnAction(action); - } + private void GUIWindowManager_OnNewAction(Action action) + { + try + { + if ((action.wID == actionType) && (!shutdowning)) //action and no shutdown in progress + { + timerAction.Stop(); + timerNotify.Stop(); + if (timedOut && timerShutDown.Enabled) //1st press + { + timedOut = false; + //action + timerAction.Start(); + ShowNotifyDialog(actionTimeOutMs, string.Format("Time left: {0} min", sleepTimeCurrent)); + } + else //additional presses + { + timerShutDown.Stop(); + SetTime(); + if (sleepTimeCurrent > 0) + timerShutDown.Start(); + if ((sleepTimeCurrent > 0) && (sleepTimeCurrent <= notifyBeforeSleep) && + ((notifyBeforeSleep - sleepTimeCurrent)%notifyInterval == 0)) //notify + { + timerNotify.Start(); + ShowNotifyDialog(notifyTimeOutMs, null); } - catch (Exception ex) { - //log errors here + else //action + { + timerAction.Start(); + ShowNotifyDialog(actionTimeOutMs, null); } + } + base.OnAction(action); } + } + catch (Exception ex) + { + //log errors here + } + } - void timerAction_Tick(object sender, EventArgs e) { - try { - timedOut = true; - setByPlay = false; //reset play flag - //will stop after tick (AutoReset = false) - } - catch (Exception ex) { - //log errors here - } - } + private void timerAction_Tick(object sender, EventArgs e) + { + try + { + timedOut = true; + setByPlay = false; //reset play flag + //will stop after tick (AutoReset = false) + } + catch (Exception ex) + { + //log errors here + } + } - void timerNotify_Tick(object sender, EventArgs e) { - try { - timedOut = true; - //will stop after tick (AutoReset = false) - } - catch (Exception ex) { - //log errors here - } - } + private void timerNotify_Tick(object sender, EventArgs e) + { + try + { + timedOut = true; + //will stop after tick (AutoReset = false) + } + catch (Exception ex) + { + //log errors here + } + } - void timerShutDown_Tick(object sender, EventArgs e) { - try { - if (sleepTimeCurrent > 0) { - sleepTimeCurrent -= 1; - if (sleepTimeCurrent == 0) //shutdown - { - shutdowning = true; //to block action - timerShutDown.Stop(); - timerAction.Stop(); - timerNotify.Stop(); - ShowNotifyDialog(SHUTDOWN_ANNOUNCE_MS, "Time's up - Have a good night !"); - //reset globals - sleepTimeCurrent = 0; - timedOut = true; - setByPlay = false; - shutdowning = false; - switch (sleepBehavior) { - case "Shutdown": - WindowsController.ExitWindows(restartOption, shutdownForce, null); - break; - case "Exit MediaPortal": - Application.Exit(); - break; - case "Show Basic Home": - GUIWindowManager.ActivateWindow((int)Window.WINDOW_HOME, true); - break; - default: - WindowsController.ExitWindows(restartOption, shutdownForce, null); - break; - } - } - else if ((sleepTimeCurrent <= notifyBeforeSleep) && ((notifyBeforeSleep - sleepTimeCurrent) % notifyInterval == 0)) //notify - { - timerAction.Stop(); - timerNotify.Stop(); - timedOut = false; //simulate 1st press - with reset by notify timer - timerNotify.Start(); - ShowNotifyDialog(notifyTimeOutMs, null); - } - } + private void timerShutDown_Tick(object sender, EventArgs e) + { + try + { + if (sleepTimeCurrent > 0) + { + sleepTimeCurrent -= 1; + if (sleepTimeCurrent == 0) //shutdown + { + shutdowning = true; //to block action + timerShutDown.Stop(); + timerAction.Stop(); + timerNotify.Stop(); + ShowNotifyDialog(SHUTDOWN_ANNOUNCE_MS, "Time's up - Have a good night !"); + //reset globals + sleepTimeCurrent = 0; + timedOut = true; + setByPlay = false; + shutdowning = false; + switch (sleepBehavior) + { + case "Shutdown": + WindowsController.ExitWindows(restartOption, shutdownForce, null); + break; + case "Exit MediaPortal": + Application.Exit(); + break; + case "Show Basic Home": + GUIWindowManager.ActivateWindow((int) Window.WINDOW_HOME, true); + break; + default: + WindowsController.ExitWindows(restartOption, shutdownForce, null); + break; } - catch (Exception ex) { - //log errors here - } + } + else if ((sleepTimeCurrent <= notifyBeforeSleep) && ((notifyBeforeSleep - sleepTimeCurrent)%notifyInterval == 0)) + //notify + { + timerAction.Stop(); + timerNotify.Stop(); + timedOut = false; //simulate 1st press - with reset by notify timer + timerNotify.Start(); + ShowNotifyDialog(notifyTimeOutMs, null); + } } + } + catch (Exception ex) + { + //log errors here + } + } - private void SetTime() { - try { - //get remaining playtime (if any) - int totalMinutes = 0; - try { - //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]); - } - catch { } - - if ((totalMinutes != 0) && (sleepTimeCurrent == 0)) { - //play and additional press from "stopped" - sleepTimeCurrent = totalMinutes + 1; - setByPlay = true; //set play flag - } - else { - //other additional presses - if ((totalMinutes != 0) && (setByPlay)) { - //play and 2nd additional press - sleepTimeCurrent = 0; //prepare for standard increment - } - setByPlay = false; //reset play flag - //standard increment - sleepTimeCurrent += sleepTimeStep; - sleepTimeCurrent = (sleepTimeCurrent / sleepTimeStep) * sleepTimeStep; //normalize - if (sleepTimeCurrent > sleepTimeMaxium) - sleepTimeCurrent = 0; //overflowed; let timer be stopped - } - } - catch (Exception ex) { - //log errors here - } + private void SetTime() + { + try + { + //get remaining playtime (if any) + int totalMinutes = 0; + try + { + //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]); } - - private void ShowNotifyDialog(int timeOut, string notifyMessage) { - try { - timeOut /= 1000; //to seconds - //construct message if empty - if (notifyMessage == null) { - if (sleepTimeCurrent > 0) //running - { - if (setByPlay) //play - notifyMessage = string.Format("Sleep in: {0} min (remaining playtime)", sleepTimeCurrent); - else //standard - notifyMessage = string.Format("Sleep in: {0} min", sleepTimeCurrent); - } - else //stopped - notifyMessage = "Sleep Timer stopped !"; - } - - //show - dialogSleepTimerNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); - dialogSleepTimerNotify.TimeOut = timeOut; - dialogSleepTimerNotify.SetImage(GUIGraphicsContext.Skin + @"\Media\MySleepTimer_logo.png"); - dialogSleepTimerNotify.SetHeading("MySleepTimer"); - dialogSleepTimerNotify.SetText(notifyMessage); - dialogSleepTimerNotify.DoModal(GUIWindowManager.ActiveWindow); - } - catch (Exception ex) { - //log errors here - } + catch + { } - #region ISetupForm Members - - // Returns the name of the plugin which is shown in the plugin menu - public string PluginName() { - return "MySleepTimer"; + if ((totalMinutes != 0) && (sleepTimeCurrent == 0)) + { + //play and additional press from "stopped" + sleepTimeCurrent = totalMinutes + 1; + setByPlay = true; //set play flag } - - // Returns the description of the plugin is shown in the plugin menu - public string Description() { - return "Want MediaPortal to be your sleeping agent of choice? Well, here you go! (but be warned - might be highly addictive!)"; + else + { + //other additional presses + if ((totalMinutes != 0) && (setByPlay)) + { + //play and 2nd additional press + sleepTimeCurrent = 0; //prepare for standard increment + } + setByPlay = false; //reset play flag + //standard increment + sleepTimeCurrent += sleepTimeStep; + sleepTimeCurrent = (sleepTimeCurrent/sleepTimeStep)*sleepTimeStep; //normalize + if (sleepTimeCurrent > sleepTimeMaxium) + sleepTimeCurrent = 0; //overflowed; let timer be stopped } + } + catch (Exception ex) + { + //log errors here + } + } - // Returns the author of the plugin which is shown in the plugin menu - public string Author() { - return "Anthrax"; + private void ShowNotifyDialog(int timeOut, string notifyMessage) + { + try + { + timeOut /= 1000; //to seconds + //construct message if empty + if (notifyMessage == null) + { + if (sleepTimeCurrent > 0) //running + { + if (setByPlay) //play + notifyMessage = string.Format("Sleep in: {0} min (remaining playtime)", sleepTimeCurrent); + else //standard + notifyMessage = string.Format("Sleep in: {0} min", sleepTimeCurrent); + } + else //stopped + notifyMessage = "Sleep Timer stopped !"; } - // show the setup dialog - public void ShowPlugin() { - new MySleepTimerConfig().ShowDialog(); - } + //show + dialogSleepTimerNotify = (GUIDialogNotify) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_NOTIFY); + dialogSleepTimerNotify.TimeOut = timeOut; + dialogSleepTimerNotify.SetImage(GUIGraphicsContext.Skin + @"\Media\MySleepTimer_logo.png"); + dialogSleepTimerNotify.SetHeading("MySleepTimer"); + dialogSleepTimerNotify.SetText(notifyMessage); + dialogSleepTimerNotify.DoModal(GUIWindowManager.ActiveWindow); + } + catch (Exception ex) + { + //log errors here + } + } - // Indicates whether plugin can be enabled/disabled - public bool CanEnable() { - return true; - } + #region ISetupForm Members - // Get Windows-ID - public int GetWindowId() { - // WindowID of windowplugin belonging to this setup - // enter your own unique code - return 9876; - } + // Returns the name of the plugin which is shown in the plugin menu + public string PluginName() + { + return "MySleepTimer"; + } - // Indicates if plugin is enabled by default; - public bool DefaultEnabled() { - return true; - } + // Returns the description of the plugin is shown in the plugin menu + public string Description() + { + return + "Want MediaPortal to be your sleeping agent of choice? Well, here you go! (but be warned - might be highly addictive!)"; + } - // indicates if a plugin has it's own setup screen - public bool HasSetup() { - return true; - } + // Returns the author of the plugin which is shown in the plugin menu + public string Author() + { + return "Anthrax"; + } - /// <summary> - /// If the plugin should have it's own button on the main menu of Mediaportal then it - /// should return true to this method, otherwise if it should not be on home - /// it should return false - /// </summary> - /// <param name="strButtonText">text the button should have</param> - /// <param name="strButtonImage">image for the button, or empty for default</param> - /// <param name="strButtonImageFocus">image for the button, or empty for default</param> - /// <param name="strPictureImage">subpicture for the button or empty for none</param> - /// <returns>true : plugin needs it's own button on home - /// false : plugin does not need it's own button on home</returns> + // show the setup dialog + public void ShowPlugin() + { + new MySleepTimerConfig().ShowDialog(); + } - public bool GetHome(out string strButtonText, out string strButtonImage, - out string strButtonImageFocus, out string strPictureImage) { - strButtonText = PluginName(); - strButtonImage = String.Empty; - strButtonImageFocus = String.Empty; - strPictureImage = String.Empty; - return false; - } + // Indicates whether plugin can be enabled/disabled + public bool CanEnable() + { + return true; + } + // Get Windows-ID + public int GetWindowId() + { + // WindowID of windowplugin belonging to this setup + // enter your own unique code + return 9876; + } - #endregion + // Indicates if plugin is enabled by default; + public bool DefaultEnabled() + { + return true; } + + // indicates if a plugin has it's own setup screen + public bool HasSetup() + { + return true; + } + + /// <summary> + /// If the plugin should have it's own button on the main menu of Mediaportal then it + /// should return true to this method, otherwise if it should not be on home + /// it should return false + /// </summary> + /// <param name="strButtonText">text the button should have</param> + /// <param name="strButtonImage">image for the button, or empty for default</param> + /// <param name="strButtonImageFocus">image for the button, or empty for default</param> + /// <param name="strPictureImage">subpicture for the button or empty for none</param> + /// <returns>true : plugin needs it's own button on home + /// false : plugin does not need it's own button on home</returns> + public bool GetHome(out string strButtonText, out string strButtonImage, + out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = PluginName(); + strButtonImage = String.Empty; + strButtonImageFocus = String.Empty; + strPictureImage = String.Empty; + return false; + } + + #endregion + } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-06-14 12:59:41 UTC (rev 2920) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-06-14 13:07:48 UTC (rev 2921) @@ -1,358 +1,363 @@ -namespace MySleepTimer { - partial class MySleepTimerConfig { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; +namespace MySleepTimer +{ + partial class MySleepTimerConfig + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() { - this.comboBoxActionType = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.numericUpDownSleepTimeMax = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownSleepTimeStep = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownNotifyInterval = new System.Windows.Forms.NumericUpDown(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.label3 = new System.Windows.Forms.Label(); - this.comboBoxShutDownType = new System.Windows.Forms.ComboBox(); - this.checkBoxShutDownForce = new System.Windows.Forms.CheckBox(); - this.label7 = new System.Windows.Forms.Label(); - this.numericUpDownNotifyBeforeSleep = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.comboBoxSleepBehavior = new System.Windows.Forms.ComboBox(); - this.label6 = new System.Windows.Forms.Label(); - this.numericUpDownTimeOutB = new System.Windows.Forms.NumericUpDown(); - this.label9 = new System.Windows.Forms.Label(); - this.numericUpDownTimeOutN = new System.Windows.Forms.NumericUpDown(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).BeginInit(); - this.SuspendLayout(); - // - // comboBoxActionType - // - this.comboBoxActionType.DropDownWidth = 250; - this.comboBoxActionType.FormattingEnabled = true; - this.comboBoxActionType.Location = new System.Drawing.Point(169, 6); - this.comboBoxActionType.Name = "comboBoxActionType"; - this.comboBoxActionType.Size = new System.Drawing.Size(168, 21); - this.comboBoxActionType.TabIndex = 5; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(146, 13); - this.label1.TabIndex = 0; - this.label1.Text = "ActionType to set sleep timer:"; - // - // numericUpDownSleepTimeMax - // - this.numericUpDownSleepTimeMax.Increment = new decimal(new int[] { + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.comboBoxActionType = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.numericUpDownSleepTimeMax = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSleepTimeStep = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownNotifyInterval = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBoxShutDownType = new System.Windows.Forms.ComboBox(); + this.checkBoxShutDownForce = new System.Windows.Forms.CheckBox(); + this.label7 = new System.Windows.Forms.Label(); + this.numericUpDownNotifyBeforeSleep = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.comboBoxSleepBehavior = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.numericUpDownTimeOutB = new System.Windows.Forms.NumericUpDown(); + this.label9 = new System.Windows.Forms.Label(); + this.numericUpDownTimeOutN = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).BeginInit(); + this.SuspendLayout(); + // + // comboBoxActionType + // + this.comboBoxActionType.DropDownWidth = 250; + this.comboBoxActionType.FormattingEnabled = true; + this.comboBoxActionType.Location = new System.Drawing.Point(169, 6); + this.comboBoxActionType.Name = "comboBoxActionType"; + this.comboBoxActionType.Size = new System.Drawing.Size(168, 21); + this.comboBoxActionType.TabIndex = 5; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(146, 13); + this.label1.TabIndex = 0; + this.label1.Text = "ActionType to set sleep timer:"; + // + // numericUpDownSleepTimeMax + // + this.numericUpDownSleepTimeMax.Increment = new decimal(new int[] { 10, 0, 0, 0}); - this.numericUpDownSleepTimeMax.Location = new System.Drawing.Point(169, 87); - this.numericUpDownSleepTimeMax.Maximum = new decimal(new int[] { + this.numericUpDownSleepTimeMax.Location = new System.Drawing.Point(169, 87); + this.numericUpDownSleepTimeMax.Maximum = new decimal(new int[] { 1440, 0, 0, 0}); - this.numericUpDownSleepTimeMax.Minimum = new decimal(new int[] { + this.numericUpDownSleepTimeMax.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownSleepTimeMax.Name = "numericUpDownSleepTimeMax"; - this.numericUpDownSleepTimeMax.Size = new System.Drawing.Size(71, 20); - this.numericUpDownSleepTimeMax.TabIndex = 25; - this.numericUpDownSleepTimeMax.Value = new decimal(new int[] { + this.numericUpDownSleepTimeMax.Name = "numericUpDownSleepTimeMax"; + this.numericUpDownSleepTimeMax.Size = new System.Drawing.Size(71, 20); + this.numericUpDownSleepTimeMax.TabIndex = 25; + this.numericUpDownSleepTimeMax.Value = new decimal(new int[] { 1, 0, 0, 0}); - // - // numericUpDownSleepTimeStep - // - this.numericUpDownSleepTimeStep.Location = new System.Drawing.Point(169, 113); - this.numericUpDownSleepTimeStep.Minimum = new decimal(new int[] { + // + // numericUpDownSleepTimeStep + // + this.numericUpDownSleepTimeStep.Location = new System.Drawing.Point(169, 113); + this.numericUpDownSleepTimeStep.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownSleepTimeStep.Name = "numericUpDownSleepTimeStep"; - this.numericUpDownSleepTimeStep.Size = new System.Drawing.Size(71, 20); - this.numericUpDownSleepTimeStep.TabIndex = 30; - this.numericUpDownSleepTimeStep.Value = new decimal(new int[] { + this.numericUpDownSleepTimeStep.Name = "numericUpDownSleepTimeStep"; + this.numericUpDownSleepTimeStep.Size = new System.Drawing.Size(71, 20); + this.numericUpDownSleepTimeStep.TabIndex = 30; + this.numericUpDownSleepTimeStep.Value = new decimal(new int[] { 1, 0, 0, 0}); - // - // numericUpDownNotifyInterval - // - this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(169, 191); - this.numericUpDownNotifyInterval.Minimum = new decimal(new int[] { + // + // numericUpDownNotifyInterval + // + this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(169, 191); + this.numericUpDownNotifyInterval.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownNotifyInterval.Name = "numericUpDownNotifyInterval"; - this.numericUpDownNotifyInterval.Size = new System.Drawing.Size(71, 20); - this.numericUpDownNotifyInterval.TabIndex = 45; - this.numericUpDownNotifyInterval.Value = new decimal(new int[] { + this.numericUpDownNotifyInterval.Name = "numericUpDownNotifyInterval"; + this.numericUpDownNotifyInterval.Size = new System.Drawing.Size(71, 20); + this.numericUpDownNotifyInterval.TabIndex = 45; + this.numericUpDownNotifyInterval.Value = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownNotifyInterval.ValueChanged += new System.EventHandler(this.numericUpDownNotifyInterval_ValueChanged); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(53, 89); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 13); - this.label4.TabIndex = 0; - this.label4.Text = "Sleep time maximum:"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(71, 115); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(87, 13); - this.label5.TabIndex = 0; - this.label5.Text = "Sleep time steps:"; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(57, 193); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(101, 13); - this.label8.TabIndex = 0; - this.label8.Text = "Notification Interval:"; - // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(290, 214); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(47, 23); - this.buttonOK.TabIndex = 55; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.button1_Click); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(77, 63); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(81, 13); - this.label3.TabIndex = 0; - this.label3.Text = "Shutdown type:"; - // - // comboBoxShutDownType - // - this.comboBoxShutDownType.FormattingEnabled = true; - this.comboBoxShutDownType.Location = new System.Drawing.Point(169, 60); - this.comboBoxShutDownType.Name = "comboBoxShutDownType"; - this.comboBoxShutDownType.Size = new System.Drawing.Size(115, 21); - this.comboBoxShutDownType.TabIndex = 15; - // - // checkBoxShutDownForce - // - this.checkBoxShutDownForce.AutoSize = true; - this.checkBoxShutDownForce.Location = new System.Drawing.Point(290, 62); - this.checkBoxShutDownForce.Name = "checkBoxShutDownForce"; - this.checkBoxShutDownForce.Size = new System.Drawing.Size(50, 17); - this.checkBoxShutDownForce.TabIndex = 20; - this.checkBoxShutDownForce.Text = "force"; - this.checkBoxShutDownForce.UseVisualStyleBackColor = true; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(9, 167); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(149, 13); - this.label7.TabIndex = 0; - this.label7.Text = "Start notification prior to sleep:"; - // - // numericUpDownNotifyBeforeSleep - // - this.numericUpDownNotifyBeforeSleep.Location = new System.Drawing.Point(169, 165); - this.numericUpDownNotifyBeforeSleep.Name = "numericUpDownNotifyBeforeSleep"; - this.numericUpDownNotifyBeforeSleep.Size = new System.Drawing.Size(71, 20); - this.numericUpDownNotifyBeforeSleep.TabIndex = 40; - this.numericUpDownNotifyBeforeSleep.ValueChanged += new System.EventHandler(this.numericUpDownNotifyBeforeSleep_ValueChanged); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(77, 35); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 13); - this.label2.TabIndex = 0; - this.label2.Text = "Sleep behavior:"; - // - // comboBoxSleepBehavior - // - this.comboBoxSleepBehavior.AccessibleRole = System.Windows.Forms.AccessibleRole.None; - this.comboBoxSleepBehavior.DropDownWidth = 250; - this.comboBoxSleepBehavior.FormattingEnabled = true; - this.comboBoxSleepBehavior.Items.AddRange(new object[] { + this.numericUpDownNotifyInterval.ValueChanged += new System.EventHandler(this.numericUpDownNotifyInterval_ValueChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(53, 89); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(105, 13); + this.label4.TabIndex = 0; + this.label4.Text = "Sleep time maximum:"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(71, 115); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(87, 13); + this.label5.TabIndex = 0; + this.label5.Text = "Sleep time steps:"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(57, 193); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(101, 13); + this.label8.TabIndex = 0; + this.label8.Text = "Notification Interval:"; + // + // buttonOK + // + this.buttonOK.Location = new System.Drawing.Point(290, 214); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(47, 23); + this.buttonOK.TabIndex = 55; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.button1_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(77, 63); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(81, 13); + this.label3.TabIndex = 0; + this.label3.Text = "Shutdown type:"; + // + // comboBoxShutDownType + // + this.comboBoxShutDownType.FormattingEnabled = true; + this.comboBoxShutDownType.Location = new System.Drawing.Point(169, 60); + this.comboBoxShutDownType.Name = "comboBoxShutDownType"; + this.comboBoxShutDownType.Size = new System.Drawing.Size(115, 21); + this.comboBoxShutDownType.TabIndex = 15; + // + // checkBoxShutDownForce + // + this.checkBoxShutDownForce.AutoSize = true; + this.checkBoxShutDownForce.Location = new System.Drawing.Point(290, 62); + this.checkBoxShutDownForce.Name = "checkBoxShutDownForce"; + this.checkBoxShutDownForce.Size = new System.Drawing.Size(50, 17); + this.checkBoxShutDownForce.TabIndex = 20; + this.checkBoxShutDownForce.Text = "force"; + this.checkBoxShutDownForce.UseVisualStyleBackColor = true; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(9, 167); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(149, 13); + this.label7.TabIndex = 0; + this.label7.Text = "Start notification prior to sleep:"; + // + // numericUpDownNotifyBeforeSleep + // + this.numericUpDownNotifyBeforeSleep.Location = new System.Drawing.Point(169, 165); + this.numericUpDownNotifyBeforeSleep.Name = "numericUpDownNotifyBeforeSleep"; + this.numericUpDownNotifyBeforeSleep.Size = new System.Drawing.Size(71, 20); + this.numericUpDownNotifyBeforeSleep.TabIndex = 40; + this.numericUpDownNotifyBeforeSleep.ValueChanged += new System.EventHandler(this.numericUpDownNotifyBeforeSleep_ValueChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(77, 35); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(81, 13); + this.label2.TabIndex = 0; + this.label2.Text = "Sleep behavior:"; + // + // comboBoxSleepBehavior + // + this.comboBoxSleepBehavior.AccessibleRole = System.Windows.Forms.AccessibleRole.None; + this.comboBoxSleepBehavior.DropDownWidth = 250; + this.comboBoxSleepBehavior.FormattingEnabled = true; + this.comboBoxSleepBehavior.Items.AddRange(new object[] { "Shutdown", "Exit MediaPortal", "Show Basic Home"}); - this.comboBoxSleepBehavior.Location = new System.Drawing.Point(169, 33); - this.comboBoxSleepBehavior.Name = "comboBoxSleepBehavior"; - this.comboBoxSleepBehavior.Size = new System.Drawing.Size(168, 21); - this.comboBoxSleepBehavior.TabIndex = 10; - this.comboBoxSleepBehavior.SelectedIndexChanged += new System.EventHandler(this.comboBoxSleepBehavior_SelectedIndexChanged); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(60, 141); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(98, 13); - this.label6.TabIndex = 0; - this.label6.Text = "Button TimeOut [s]:"; - // - // numericUpDownTimeOutB - // - this.numericUpDownTimeOutB.Location = new System.Drawing.Point(169, 139); - this.numericUpDownTimeOutB.Minimum = new decimal(new int[] { + this.comboBoxSleepBehavior.Location = new System.Drawing.Point(169, 33); + this.comboBoxSleepBehavior.Name = "comboBoxSleepBehavior"; + this.comboBoxSleepBehavior.Size = new System.Drawing.Size(168, 21); + this.comboBoxSleepBehavior.TabIndex = 10; + this.comboBoxSleepBehavior.SelectedIndexChanged += new System.EventHandler(this.comboBoxSleepBehavior_SelectedIndexChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(60, 141); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(98, 13); + this.label6.TabIndex = 0; + this.label6.Text = "Button TimeOut [s]:"; + // + // numericUpDownTimeOutB + // + this.numericUpDownTimeOutB.Location = new System.Drawing.Point(169, 139); + this.numericUpDownTimeOutB.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownTimeOutB.Name = "numericUpDownTimeOutB"; - this.numericUpDownTimeOutB.Size = new System.Drawing.Size(71, 20); - this.numericUpDownTimeOutB.TabIndex = 35; - this.numericUpDownTimeOutB.Value = new decimal(new int[] { + this.numericUpDownTimeOutB.Name = "numericUpDownTimeOutB"; + this.numericUpDownTimeOutB.Size = new System.Drawing.Size(71, 20); + this.numericUpDownTimeOutB.TabIndex = 35; + this.numericUpDownTimeOutB.Value = new decimal(new int[] { 1, 0, 0, 0}); - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(38, 219); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(120, 13); - this.label9.TabIndex = 0; - this.label9.Text = "Notification TimeOut [s]:"; - // - // numericUpDownTimeOutN - // - this.numericUpDownTimeOutN.Location = new System.Drawing.Point(169, 217); - this.numericUpDownTimeOutN.Maximum = new decimal(new int[] { + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(38, 219); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(120, 13); + this.label9.TabIndex = 0; + this.label9.Text = "Notification TimeOut [s]:"; + // + // numericUpDownTimeOutN + // + this.numericUpDownTimeOutN.Location = new System.Drawing.Point(169, 217); + this.numericUpDownTimeOutN.Maximum = new decimal(new int[] { 65, 0, 0, 0}); - this.numericUpDownTimeOutN.Minimum = new decimal(new int[] { + this.numericUpDownTimeOutN.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownTimeOutN.Name = "numericUpDownTimeOutN"; - this.numericUpDownTimeOutN.Size = new System.Drawing.Size(71, 20); - this.numericUpDownTimeOutN.TabIndex = 50; - this.numericUpDownTimeOutN.Value = new decimal(new int[] { + this.numericUpDownTimeOutN.Name = "numericUpDownTimeOutN"; + this.numericUpDownTimeOutN.Size = new System.Drawing.Size(71, 20); + this.numericUpDownTimeOutN.TabIndex = 50; + this.numericUpDownTimeOutN.Value = new decimal(new int[] { 1, 0, 0, 0}); - // - // MySleepTimerConfig - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(348, 243); - this.Controls.Add(this.label9); - this.Controls.Add(this.numericUpDownTimeOutN); - this.Controls.Add(this.label6); - this.Controls.Add(this.numericUpDownTimeOutB); - this.Controls.Add(this.comboBoxSleepBehavior); - this.Controls.Add(this.label2); - this.Controls.Add(this.label7); - this.Controls.Add(this.numericUpDownNotifyBeforeSleep); - this.Controls.Add(this.checkBoxShutDownForce); - this.Controls.Add(this.label3); - this.Controls.Add(this.comboBoxShutDownType); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.label8); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.numericUpDownNotifyInterval); - this.Controls.Add(this.numericUpDownSleepTimeStep); - this.Controls.Add(this.numericUpDownSleepTimeMax); - this.Controls.Add(this.label1); - this.Controls.Add(this.comboBoxActionType); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "MySleepTimerConfig"; - this.Text = "MySleepTimer - Configuration"; - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + // + // MySleepTimerConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(348, 243); + this.Controls.Add(this.label9); + this.Controls.Add(this.numericUpDownTimeOutN); + this.Controls.Add(this.label6); + this.Controls.Add(this.numericUpDownTimeOutB); + this.Controls.Add(this.comboBoxSleepBehavior); + this.Controls.Add(this.label2); + this.Controls.Add(this.label7); + this.Controls.Add(this.numericUpDownNotifyBeforeSleep); + this.Controls.Add(this.checkBoxShutDownForce); + this.Controls.Add(this.label3); + this.Controls.Add(this.comboBoxShutDownType); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.label8); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.numericUpDownNotifyInterval); + this.Controls.Add(this.numericUpDownSleepTimeStep); + this.Controls.Add(this.numericUpDownSleepTimeMax); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxActionType); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "MySleepTimerConfig"; + this.Text = "MySleepTimer - Configuration"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); - } + } - #endregion + #endregion - private System.Windows.Forms.ComboBox comboBoxActionType; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeMax; - private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeStep; - private System.Windows.Forms.NumericUpDown numericUpDownNotifyInterval; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.ComboBox comboBoxShutDownType; - private System.Windows.Forms.CheckBox checkBoxShutDownForce; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.NumericUpDown numericUpDownNotifyBeforeSleep; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.ComboBox comboBoxSleepBehavior; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.NumericUpDown numericUpDownTimeOutB; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.NumericUpDown numericUpDownTimeOutN; - } + private System.Windows.Forms.ComboBox comboBoxActionType; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeMax; + private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeStep; + private System.Windows.Forms.NumericUpDown numericUpDownNotifyInterval; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label8; + private System.Windows.F... [truncated message content] |
From: <che...@us...> - 2009-06-21 12:57:54
|
Revision: 2951 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2951&view=rev Author: chef_koch Date: 2009-06-21 12:31:09 +0000 (Sun, 21 Jun 2009) Log Message: ----------- refactored settings inot it's own class Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs Added Paths: ----------- trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-20 02:41:16 UTC (rev 2950) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-06-21 12:31:09 UTC (rev 2951) @@ -26,7 +26,6 @@ using MediaPortal.Configuration; using MediaPortal.Dialogs; using MediaPortal.GUI.Library; -using MediaPortal.Profile; using MediaPortal.Util; using Timer=System.Timers.Timer; @@ -50,53 +49,12 @@ private bool _timedOut = true; private bool _setByPlay = false; private bool _shutdowning = false; - //settings - private readonly Action.ActionType _actionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; - private readonly string _sleepBehavior = "Shutdown"; - private readonly RestartOptions _restartOption = RestartOptions.ShutDown; - private readonly bool _shutdownForce = false; - private readonly int _sleepTimeMaxium = 120; //(1..n) - private readonly int _sleepTimeStep = 10; //(1..n) - private readonly int _actionTimeOutMs = 2*1000; //(1..n * 1000) - private readonly int _notifyBeforeSleep = 3; //(0..n) - private readonly int _notifyInterval = 1; //(1.._notifyBeforeSleep) - private readonly int _notifyTimeOutMs = 3*1000; //(1..65 * 1000) - public MySleepTimer() - { - try - { - //read settings from config - using (Settings xmlReader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - { - _actionType = - (Action.ActionType) - xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", - (int) (Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); - _sleepBehavior = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", "Shutdown"); - _restartOption = - (RestartOptions) - xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", (int) RestartOptions.ShutDown); - _shutdownForce = xmlReader.GetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", false); - _sleepTimeMaxium = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Maximum", 120); - _sleepTimeStep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Step", 10); - _actionTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 2)*1000; - _notifyBeforeSleep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", 3); - _notifyInterval = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); - _notifyTimeOutMs = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyTimeOut", 3)*1000; - } - } - catch (Exception ex) - { - Log.Error(ex); - } - } - private void GUIWindowManager_OnNewAction(Action action) { try { - if ((action.wID == _actionType) && (!_shutdowning)) //action and no shutdown in progress + if ((action.wID == Settings.ActionType) && (!_shutdowning)) //action and no shutdown in progress { _timerAction.Stop(); _timerNotify.Stop(); @@ -105,7 +63,7 @@ _timedOut = false; //action _timerAction.Start(); - ShowNotifyDialog(_actionTimeOutMs, string.Format("Time left: {0} min", _sleepTimeCurrent)); + ShowNotifyDialog(Settings.ActionTimeOutMs, string.Format("Time left: {0} min", _sleepTimeCurrent)); } else //additional presses { @@ -113,16 +71,16 @@ SetTime(); if (_sleepTimeCurrent > 0) _timerShutDown.Start(); - if ((_sleepTimeCurrent > 0) && (_sleepTimeCurrent <= _notifyBeforeSleep) && - ((_notifyBeforeSleep - _sleepTimeCurrent)%_notifyInterval == 0)) //notify + if ((_sleepTimeCurrent > 0) && (_sleepTimeCurrent <= Settings.NotifyBeforeSleep) && + ((Settings.NotifyBeforeSleep - _sleepTimeCurrent) % Settings.NotifyInterval == 0)) //notify { _timerNotify.Start(); - ShowNotifyDialog(_notifyTimeOutMs, null); + ShowNotifyDialog(Settings.NotifyTimeOutMs, null); } else //action { _timerAction.Start(); - ShowNotifyDialog(_actionTimeOutMs, null); + ShowNotifyDialog(Settings.NotifyTimeOutMs, null); } } //base.OnAction(action); @@ -180,10 +138,10 @@ _timedOut = true; _setByPlay = false; _shutdowning = false; - switch (_sleepBehavior) + switch (Settings.SleepBehavior) { case "Shutdown": - WindowsController.ExitWindows(_restartOption, _shutdownForce, null); + WindowsController.ExitWindows(Settings.ShutdownType, Settings.ShutdownForce, null); break; case "Exit MediaPortal": Application.Exit(); @@ -192,18 +150,18 @@ GUIWindowManager.ActivateWindow((int) GUIWindow.Window.WINDOW_HOME, true); break; default: - WindowsController.ExitWindows(_restartOption, _shutdownForce, null); + WindowsController.ExitWindows(Settings.ShutdownType, Settings.ShutdownForce, null); break; } } - else if ((_sleepTimeCurrent <= _notifyBeforeSleep) && ((_notifyBeforeSleep - _sleepTimeCurrent)%_notifyInterval == 0)) + else if ((_sleepTimeCurrent <= Settings.NotifyBeforeSleep) && ((Settings.NotifyBeforeSleep - _sleepTimeCurrent) % Settings.NotifyInterval == 0)) //notify { _timerAction.Stop(); _timerNotify.Stop(); _timedOut = false; //simulate 1st press - with reset by notify timer _timerNotify.Start(); - ShowNotifyDialog(_notifyTimeOutMs, null); + ShowNotifyDialog(Settings.NotifyTimeOutMs, null); } } } @@ -246,9 +204,9 @@ } _setByPlay = false; //reset play flag //standard increment - _sleepTimeCurrent += _sleepTimeStep; - _sleepTimeCurrent = (_sleepTimeCurrent/_sleepTimeStep)*_sleepTimeStep; //normalize - if (_sleepTimeCurrent > _sleepTimeMaxium) + _sleepTimeCurrent += Settings.SleepTimeStep; + _sleepTimeCurrent = (_sleepTimeCurrent / Settings.SleepTimeStep) * Settings.SleepTimeStep; //normalize + if (_sleepTimeCurrent > Settings.SleepTimeMaxium) _sleepTimeCurrent = 0; //overflowed; let timer be stopped } } @@ -402,6 +360,8 @@ /// </summary> public void Start() { + Settings.Load(); + _timerShutDown = new Timer(); _timerAction = new Timer(); _timerNotify = new Timer(); @@ -409,10 +369,10 @@ //inits _timerShutDown.Interval = SHUTDOWN_CYCLE_MS; _timerShutDown.Elapsed += new ElapsedEventHandler(timerShutDown_Tick); - _timerAction.Interval = _actionTimeOutMs; + _timerAction.Interval = Settings.ActionTimeOutMs; _timerAction.AutoReset = false; _timerAction.Elapsed += new ElapsedEventHandler(timerAction_Tick); - _timerNotify.Interval = _notifyTimeOutMs; + _timerNotify.Interval = Settings.NotifyTimeOutMs; _timerNotify.AutoReset = false; _timerNotify.Elapsed += new ElapsedEventHandler(timerNotify_Tick); Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2009-06-20 02:41:16 UTC (rev 2950) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2009-06-21 12:31:09 UTC (rev 2951) @@ -69,6 +69,7 @@ </Reference> </ItemGroup> <ItemGroup> + <Compile Include="Settings.cs" /> <Compile Include="MySleepTimer.cs"> </Compile> <Compile Include="MySleepTimerConfig.cs"> Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-20 02:41:16 UTC (rev 2950) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-21 12:31:09 UTC (rev 2951) @@ -56,25 +56,18 @@ comboBoxShutDownType.DisplayMember = "ShutdownName"; comboBoxShutDownType.ValueMember = "ShutdownID"; - using (Settings xmlReader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - { - comboBoxActionType.SelectedValue = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", - (int) - (Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); - comboBoxSleepBehavior.Text = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", - "Shutdown"); - comboBoxShutDownType.SelectedValue = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", - (int) RestartOptions.ShutDown); - checkBoxShutDownForce.Checked = xmlReader.GetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", false); - numericUpDownSleepTimeMax.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Maximum", 120); - numericUpDownSleepTimeStep.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Step", 10); - numericUpDownTimeOutB.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 2); - numericUpDownNotifyBeforeSleep.Value = xmlReader.GetValueAsInt("MySleepTimer", - "#MySleepTimer.NotifyBeforeSleep", 3); - numericUpDownNotifyInterval.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); - numericUpDownTimeOutN.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyTimeOut", 3); - } - + Settings.Load(); + comboBoxActionType.SelectedValue = Settings.ActionType; + comboBoxSleepBehavior.Text = Settings.SleepBehavior; + comboBoxShutDownType.SelectedValue = Settings.ShutdownType; + checkBoxShutDownForce.Checked = Settings.ShutdownForce; + numericUpDownSleepTimeMax.Value = Settings.SleepTimeMaxium; + numericUpDownSleepTimeStep.Value = Settings.SleepTimeStep; + numericUpDownTimeOutB.Value = Settings.ActionTimeOutMs; + numericUpDownNotifyBeforeSleep.Value = Settings.NotifyBeforeSleep; + numericUpDownNotifyInterval.Value = Settings.NotifyInterval; + numericUpDownTimeOutN.Value = Settings.NotifyTimeOutMs; + SetUpShutDownTypeControls(); SetUpNotifyControls(); } @@ -124,22 +117,18 @@ { try { - // Write configuration settings - using (Settings xmlWriter = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - { - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ActionType", comboBoxActionType.SelectedValue); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.SleepBehavior", comboBoxSleepBehavior.Text); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ShutdownType", comboBoxShutDownType.SelectedValue); - xmlWriter.SetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", checkBoxShutDownForce.Checked); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.Maximum", numericUpDownSleepTimeMax.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.Step", numericUpDownSleepTimeStep.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ActionTimeOut", numericUpDownTimeOutB.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", - numericUpDownNotifyBeforeSleep.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.NotifyInterval", - numericUpDownNotifyInterval.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.NotifyTimeOut", numericUpDownTimeOutN.Value.ToString()); - } + Settings.ActionType =(Action.ActionType) comboBoxActionType.SelectedValue; + Settings.SleepBehavior = comboBoxSleepBehavior.Text; + 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.Save(); + Close(); } catch (Exception ex) Added: trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2009-06-21 12:31:09 UTC (rev 2951) @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; +using MediaPortal.Util; +using Log=MediaPortal.ServiceImplementations.Log; + +using System.Reflection; + +namespace MySleepTimer +{ + internal static class Settings + { + #region Properties + + private const string PLUGIN_NAME = "MySleepTimer"; + + public static Action.ActionType ActionType { get; set; } + public static string SleepBehavior { get; set; } + public static RestartOptions ShutdownType { get; set; } + public static bool ShutdownForce { get; set; } + public static int SleepTimeMaxium { get; set; } //(1..n) + public static int SleepTimeStep { get; set; } //(1..n) + public static int ActionTimeOutMs { get; set; } //(1..n * 1000) + public static int NotifyBeforeSleep { get; set; } //(0..n) + public static int NotifyInterval { get; set; } //(1..NotifyBeforeSleep) + public static int NotifyTimeOutMs { get; set; } //(1..65 * 1000) + + static Settings() + { + ActionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; + SleepBehavior = "Shutdown"; + ShutdownType = RestartOptions.ShutDown; + ShutdownForce = false; + SleepTimeMaxium = 120; + SleepTimeStep = 10; + ActionTimeOutMs = 2 * 1000; + NotifyBeforeSleep = 3; + NotifyInterval = 1; + NotifyTimeOutMs = 3 * 1000; + } + + #endregion + + public static void Load() + { + Log.Info("{0}: Settings.Load()", PLUGIN_NAME); + + using ( + MediaPortal.Profile.Settings xmlReader = + new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + ActionType = + (Action.ActionType) + xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ActionType", + (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); + ShutdownForce = xmlReader.GetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", false); + SleepTimeMaxium = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Maximum", 120); + SleepTimeStep = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Step", 10); + ActionTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ActionTimeOut", 2) * 1000; + NotifyBeforeSleep = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.NotifyBeforeSleep", 3); + NotifyInterval = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.NotifyInterval", 1); + NotifyTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.NotifyTimeOut", 3) * 1000; + } + + //WriteToLog(); + } + + public static void Save() + { + Log.Info("{0}: Settings.Save()", PLUGIN_NAME); + + using ( + 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.SleepBehavior", SleepBehavior); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", ShutdownType); + xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", ShutdownForce); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.Maximum", SleepTimeMaxium); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.Step", SleepTimeStep); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionTimeOut", ActionTimeOutMs); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.NotifyBeforeSleep", NotifyBeforeSleep); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.NotifyInterval", NotifyInterval); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.NotifyTimeOut", NotifyTimeOutMs); + } + } + + public static void WriteToLog() + { + // get all properties + PropertyInfo[] propertyInfos = typeof(Settings).GetProperties(); + // write property names and values + foreach (PropertyInfo propertyInfo in propertyInfos) + { + Log.Info("{0}: {1} = {2}", PLUGIN_NAME, propertyInfo.Name, propertyInfo.GetValue(null, null).ToString()); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <che...@us...> - 2009-06-21 18:51:18
|
Revision: 2956 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2956&view=rev Author: chef_koch Date: 2009-06-21 18:51:16 +0000 (Sun, 21 Jun 2009) Log Message: ----------- added option to use shutdown PowerScheduler Client plugins' settings refactored config form ActionEntry list and ShutdownEntry list are sorted make usage of AcceptButton and OKButton Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-06-21 18:46:19 UTC (rev 2955) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-06-21 18:51:16 UTC (rev 2956) @@ -36,7 +36,6 @@ this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.comboBoxShutDownType = new System.Windows.Forms.ComboBox(); this.checkBoxShutDownForce = new System.Windows.Forms.CheckBox(); @@ -48,12 +47,19 @@ this.numericUpDownTimeOutB = new System.Windows.Forms.NumericUpDown(); this.label9 = new System.Windows.Forms.Label(); this.numericUpDownTimeOutN = new System.Windows.Forms.NumericUpDown(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.checkBoxUsePSSettings = new System.Windows.Forms.CheckBox(); + this.groupBoxTimer = new System.Windows.Forms.GroupBox(); + this.buttonClose = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).BeginInit(); + this.groupBox1.SuspendLayout(); + this.groupBoxTimer.SuspendLayout(); this.SuspendLayout(); // // comboBoxActionType @@ -82,7 +88,7 @@ 0, 0, 0}); - this.numericUpDownSleepTimeMax.Location = new System.Drawing.Point(169, 87); + this.numericUpDownSleepTimeMax.Location = new System.Drawing.Point(210, 19); this.numericUpDownSleepTimeMax.Maximum = new decimal(new int[] { 1440, 0, @@ -104,7 +110,7 @@ // // numericUpDownSleepTimeStep // - this.numericUpDownSleepTimeStep.Location = new System.Drawing.Point(169, 113); + this.numericUpDownSleepTimeStep.Location = new System.Drawing.Point(210, 45); this.numericUpDownSleepTimeStep.Minimum = new decimal(new int[] { 1, 0, @@ -121,7 +127,7 @@ // // numericUpDownNotifyInterval // - this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(169, 191); + this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(210, 123); this.numericUpDownNotifyInterval.Minimum = new decimal(new int[] { 1, 0, @@ -140,7 +146,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(53, 89); + this.label4.Location = new System.Drawing.Point(94, 21); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(105, 13); this.label4.TabIndex = 0; @@ -149,7 +155,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(71, 115); + this.label5.Location = new System.Drawing.Point(112, 47); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(87, 13); this.label5.TabIndex = 0; @@ -158,26 +164,16 @@ // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(57, 193); + this.label8.Location = new System.Drawing.Point(98, 125); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(101, 13); this.label8.TabIndex = 0; this.label8.Text = "Notification Interval:"; // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(290, 214); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(47, 23); - this.buttonOK.TabIndex = 55; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.button1_Click); - // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(77, 63); + this.label3.Location = new System.Drawing.Point(6, 45); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(81, 13); this.label3.TabIndex = 0; @@ -185,17 +181,20 @@ // // comboBoxShutDownType // + this.comboBoxShutDownType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxShutDownType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxShutDownType.FormattingEnabled = true; - this.comboBoxShutDownType.Location = new System.Drawing.Point(169, 60); + this.comboBoxShutDownType.Location = new System.Drawing.Point(93, 42); this.comboBoxShutDownType.Name = "comboBoxShutDownType"; - this.comboBoxShutDownType.Size = new System.Drawing.Size(115, 21); + this.comboBoxShutDownType.Size = new System.Drawing.Size(171, 21); this.comboBoxShutDownType.TabIndex = 15; // // checkBoxShutDownForce // + this.checkBoxShutDownForce.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.checkBoxShutDownForce.AutoSize = true; - this.checkBoxShutDownForce.Location = new System.Drawing.Point(290, 62); + this.checkBoxShutDownForce.Location = new System.Drawing.Point(270, 44); this.checkBoxShutDownForce.Name = "checkBoxShutDownForce"; this.checkBoxShutDownForce.Size = new System.Drawing.Size(50, 17); this.checkBoxShutDownForce.TabIndex = 20; @@ -205,7 +204,7 @@ // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(9, 167); + this.label7.Location = new System.Drawing.Point(50, 99); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(149, 13); this.label7.TabIndex = 0; @@ -213,7 +212,7 @@ // // numericUpDownNotifyBeforeSleep // - this.numericUpDownNotifyBeforeSleep.Location = new System.Drawing.Point(169, 165); + this.numericUpDownNotifyBeforeSleep.Location = new System.Drawing.Point(210, 97); this.numericUpDownNotifyBeforeSleep.Name = "numericUpDownNotifyBeforeSleep"; this.numericUpDownNotifyBeforeSleep.Size = new System.Drawing.Size(71, 20); this.numericUpDownNotifyBeforeSleep.TabIndex = 40; @@ -247,7 +246,7 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(60, 141); + this.label6.Location = new System.Drawing.Point(101, 73); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(98, 13); this.label6.TabIndex = 0; @@ -255,7 +254,7 @@ // // numericUpDownTimeOutB // - this.numericUpDownTimeOutB.Location = new System.Drawing.Point(169, 139); + this.numericUpDownTimeOutB.Location = new System.Drawing.Point(210, 71); this.numericUpDownTimeOutB.Minimum = new decimal(new int[] { 1, 0, @@ -273,7 +272,7 @@ // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(38, 219); + this.label9.Location = new System.Drawing.Point(79, 151); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(120, 13); this.label9.TabIndex = 0; @@ -281,7 +280,7 @@ // // numericUpDownTimeOutN // - this.numericUpDownTimeOutN.Location = new System.Drawing.Point(169, 217); + this.numericUpDownTimeOutN.Location = new System.Drawing.Point(210, 149); this.numericUpDownTimeOutN.Maximum = new decimal(new int[] { 65, 0, @@ -301,33 +300,96 @@ 0, 0}); // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.checkBoxUsePSSettings); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.comboBoxShutDownType); + this.groupBox1.Controls.Add(this.checkBoxShutDownForce); + this.groupBox1.Location = new System.Drawing.Point(12, 73); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(326, 75); + this.groupBox1.TabIndex = 56; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Shutdown options"; + // + // checkBoxUsePSSettings + // + this.checkBoxUsePSSettings.AutoSize = true; + this.checkBoxUsePSSettings.Location = new System.Drawing.Point(9, 19); + this.checkBoxUsePSSettings.Name = "checkBoxUsePSSettings"; + this.checkBoxUsePSSettings.Size = new System.Drawing.Size(234, 17); + this.checkBoxUsePSSettings.TabIndex = 21; + this.checkBoxUsePSSettings.Text = "Use settings of Powerscheduler client plugin"; + this.checkBoxUsePSSettings.UseVisualStyleBackColor = true; + this.checkBoxUsePSSettings.CheckedChanged += new System.EventHandler(this.checkBoxUsePSSettings_CheckedChanged); + // + // groupBoxTimer + // + this.groupBoxTimer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxTimer.Controls.Add(this.label4); + this.groupBoxTimer.Controls.Add(this.numericUpDownSleepTimeMax); + this.groupBoxTimer.Controls.Add(this.label9); + this.groupBoxTimer.Controls.Add(this.numericUpDownSleepTimeStep); + this.groupBoxTimer.Controls.Add(this.numericUpDownTimeOutN); + this.groupBoxTimer.Controls.Add(this.numericUpDownNotifyInterval); + this.groupBoxTimer.Controls.Add(this.label6); + this.groupBoxTimer.Controls.Add(this.label5); + this.groupBoxTimer.Controls.Add(this.numericUpDownTimeOutB); + this.groupBoxTimer.Controls.Add(this.label8); + this.groupBoxTimer.Controls.Add(this.numericUpDownNotifyBeforeSleep); + this.groupBoxTimer.Controls.Add(this.label7); + this.groupBoxTimer.Location = new System.Drawing.Point(12, 154); + this.groupBoxTimer.Name = "groupBoxTimer"; + this.groupBoxTimer.Size = new System.Drawing.Size(326, 181); + this.groupBoxTimer.TabIndex = 57; + this.groupBoxTimer.TabStop = false; + this.groupBoxTimer.Text = "Timer && notify settings"; + // + // buttonClose + // + this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonClose.Location = new System.Drawing.Point(263, 341); + this.buttonClose.Name = "buttonClose"; + this.buttonClose.Size = new System.Drawing.Size(75, 23); + this.buttonClose.TabIndex = 58; + this.buttonClose.Text = "Close"; + this.buttonClose.UseVisualStyleBackColor = true; + this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); + // + // buttonSave + // + this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSave.Location = new System.Drawing.Point(182, 341); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 59; + this.buttonSave.Text = "Save"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // // MySleepTimerConfig // + this.AcceptButton = this.buttonSave; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(348, 243); - this.Controls.Add(this.label9); - this.Controls.Add(this.numericUpDownTimeOutN); - this.Controls.Add(this.label6); - this.Controls.Add(this.numericUpDownTimeOutB); + this.CancelButton = this.buttonClose; + this.ClientSize = new System.Drawing.Size(350, 372); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonClose); + this.Controls.Add(this.groupBoxTimer); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.comboBoxSleepBehavior); this.Controls.Add(this.label2); - this.Controls.Add(this.label7); - this.Controls.Add(this.numericUpDownNotifyBeforeSleep); - this.Controls.Add(this.checkBoxShutDownForce); - this.Controls.Add(this.label3); - this.Controls.Add(this.comboBoxShutDownType); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.label8); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.numericUpDownNotifyInterval); - this.Controls.Add(this.numericUpDownSleepTimeStep); - this.Controls.Add(this.numericUpDownSleepTimeMax); this.Controls.Add(this.label1); this.Controls.Add(this.comboBoxActionType); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "MySleepTimerConfig"; + this.ShowInTaskbar = false; this.Text = "MySleepTimer - Configuration"; ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).EndInit(); @@ -335,6 +397,10 @@ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBoxTimer.ResumeLayout(false); + this.groupBoxTimer.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -350,7 +416,6 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label8; - private System.Windows.Forms.Button buttonOK; private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox comboBoxShutDownType; private System.Windows.Forms.CheckBox checkBoxShutDownForce; @@ -362,5 +427,10 @@ private System.Windows.Forms.NumericUpDown numericUpDownTimeOutB; private System.Windows.Forms.Label label9; private System.Windows.Forms.NumericUpDown numericUpDownTimeOutN; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.CheckBox checkBoxUsePSSettings; + private System.Windows.Forms.GroupBox groupBoxTimer; + private System.Windows.Forms.Button buttonClose; + private System.Windows.Forms.Button buttonSave; } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-21 18:46:19 UTC (rev 2955) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-06-21 18:51:16 UTC (rev 2956) @@ -57,8 +57,11 @@ Settings.Load(); comboBoxActionType.SelectedValue = Settings.ActionType; comboBoxSleepBehavior.Text = Settings.SleepBehavior; + + checkBoxUsePSSettings.Checked = Settings.UsePowerSchedulerSettings; comboBoxShutDownType.SelectedValue = Settings.ShutdownType; checkBoxShutDownForce.Checked = Settings.ShutdownForce; + numericUpDownSleepTimeMax.Value = Settings.SleepTimeMaxium; numericUpDownSleepTimeStep.Value = Settings.SleepTimeStep; numericUpDownTimeOutB.Value = Settings.ActionTimeOutMs; @@ -77,64 +80,49 @@ private void comboBoxSleepBehavior_SelectedIndexChanged(object sender, EventArgs e) { - try - { - SetUpShutDownTypeControls(); - } - catch (Exception ex) - { - Log.Error(ex); - } + SetUpShutDownTypeControls(); } + private void checkBoxUsePSSettings_CheckedChanged(object sender, EventArgs e) + { + SetUpShutDownTypeControls(); + } + private void numericUpDownNotifyBeforeSleep_ValueChanged(object sender, EventArgs e) { - try - { - SetUpNotifyControls(); - } - catch (Exception ex) - { - Log.Error(ex); - } + SetUpNotifyControls(); } private void numericUpDownNotifyInterval_ValueChanged(object sender, EventArgs e) { - try - { - SetUpNotifyControls(); - } - catch (Exception ex) - { - Log.Error(ex); - } + SetUpNotifyControls(); } - private void button1_Click(object sender, EventArgs e) + private void buttonSave_Click(object sender, EventArgs e) { - try - { - Settings.ActionType = (Action.ActionType) comboBoxActionType.SelectedValue; - Settings.SleepBehavior = comboBoxSleepBehavior.Text; - 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.Save(); + Settings.ActionType = (Action.ActionType) comboBoxActionType.SelectedValue; + Settings.SleepBehavior = comboBoxSleepBehavior.Text; - Close(); - } - catch (Exception ex) - { - Log.Error(ex); - } + Settings.UsePowerSchedulerSettings = checkBoxUsePSSettings.Checked; + 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.Save(); + + Close(); } + private void buttonClose_Click(object sender, EventArgs e) + { + Close(); + } + private static List<ActionEntry> GenerateActionList() { var ret = new List<ActionEntry>(); @@ -142,6 +130,8 @@ foreach (var variable in Enum.GetValues(typeof (Action.ActionType))) ret.Add(new ActionEntry((Action.ActionType) variable)); + ret.Sort(); + return ret; } @@ -152,29 +142,26 @@ foreach (var variable in Enum.GetValues(typeof (RestartOptions))) ret.Add(new ShutdownEntry((RestartOptions) variable)); + ret.Sort(); + return ret; } private void SetUpShutDownTypeControls() { - try + groupBox1.Enabled = comboBoxSleepBehavior.Text == "Shutdown"; + + checkBoxUsePSSettings.Enabled = Settings.PowerSchedulerAvailable; + + if (checkBoxUsePSSettings.Enabled && checkBoxUsePSSettings.Checked) { - if (comboBoxSleepBehavior.Text == "Shutdown") - { - label3.Enabled = true; - comboBoxShutDownType.Enabled = true; - checkBoxShutDownForce.Enabled = true; - } - else - { - label3.Enabled = false; - comboBoxShutDownType.Enabled = false; - checkBoxShutDownForce.Enabled = false; - } + comboBoxShutDownType.Enabled = false; + checkBoxShutDownForce.Enabled = false; } - catch (Exception ex) + else { - Log.Error(ex); + comboBoxShutDownType.Enabled = true; + checkBoxShutDownForce.Enabled = true; } } @@ -211,7 +198,7 @@ } } - internal class ActionEntry + internal class ActionEntry : IComparable<ActionEntry> { public Action.ActionType ActionType { get; private set; } @@ -229,9 +216,18 @@ { ActionType = actionType; } + + #region IComparable<ActionEntry> Member + + public int CompareTo(ActionEntry other) + { + return ActionName.CompareTo(other.ActionName); + } + + #endregion } - internal class ShutdownEntry + internal class ShutdownEntry : IComparable<ShutdownEntry> { public RestartOptions ShutDownType { get; private set; } @@ -249,5 +245,14 @@ { ShutDownType = restartOptions; } + + #region IComparable<ShutdownEntry> Member + + public int CompareTo(ShutdownEntry other) + { + return ShutdownName.CompareTo(other.ShutdownName); + } + + #endregion } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2009-06-21 18:46:19 UTC (rev 2955) +++ trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2009-06-21 18:51:16 UTC (rev 2956) @@ -20,6 +20,7 @@ #endregion +using System.IO; using System.Reflection; using MediaPortal.Configuration; using MediaPortal.GUI.Library; @@ -36,8 +37,12 @@ public static Action.ActionType ActionType { get; set; } public static string SleepBehavior { get; set; } + + public static bool PowerSchedulerAvailable { get; private set; } + public static bool UsePowerSchedulerSettings { get; set; } public static RestartOptions ShutdownType { get; set; } public static bool ShutdownForce { get; set; } + public static int SleepTimeMaxium { get; set; } //(1..n) public static int SleepTimeStep { get; set; } //(1..n) public static int ActionTimeOutMs { get; set; } //(1..n * 1000) @@ -49,8 +54,11 @@ { ActionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; SleepBehavior = "Shutdown"; + + UsePowerSchedulerSettings = true; ShutdownType = RestartOptions.ShutDown; ShutdownForce = false; + SleepTimeMaxium = 120; SleepTimeStep = 10; ActionTimeOutMs = 2 * 1000; @@ -69,15 +77,38 @@ MediaPortal.Profile.Settings xmlReader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { + // ahutdown settings + PowerSchedulerAvailable = + (File.Exists(Config.GetSubFolder(Config.Dir.Plugins, "process") + @"\PowerSchedulerClientPlugin.dll")) && + xmlReader.GetValueAsBool("pluginsdlls", "PowerSchedulerClientPlugin.dll", false); + UsePowerSchedulerSettings = + xmlReader.GetValueAsBool(PLUGIN_NAME, "#MySleepTimer.UsePowerSchedulerSettings", true); + + if (PowerSchedulerAvailable && UsePowerSchedulerSettings) + { + int tmp = xmlReader.GetValueAsInt("psclientplugin", "shutdownmode", 1); + if (tmp == 1) + ShutdownType = RestartOptions.Hibernate; + else + ShutdownType = RestartOptions.Suspend; + + ShutdownForce = xmlReader.GetValueAsBool("psclientplugin", "forceshutdown", false); + } + else + { + ShutdownType = + (RestartOptions) + xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int) RestartOptions.ShutDown); + ShutdownForce = xmlReader.GetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", false); + } + + // sleeptimer settings ActionType = (Action.ActionType) xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ActionType", (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); - ShutdownForce = xmlReader.GetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", false); + SleepTimeMaxium = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Maximum", 120); SleepTimeStep = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Step", 10); ActionTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.ActionTimeOut", 2) * 1000; @@ -97,10 +128,18 @@ MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { + // ahutdown settings + xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.UsePowerSchedulerSettings", UsePowerSchedulerSettings); + if (!PowerSchedulerAvailable || !UsePowerSchedulerSettings) + { + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int) ShutdownType); + xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", ShutdownForce); + } + + // sleeptimer settings xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionType", (int) ActionType); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.SleepBehavior", SleepBehavior); - 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); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionTimeOut", ActionTimeOutMs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2010-01-24 21:04:21
|
Revision: 3381 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3381&view=rev Author: chef_koch Date: 2010-01-24 21:04:14 +0000 (Sun, 24 Jan 2010) Log Message: ----------- updated file header Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2010-01-24 19:34:26 UTC (rev 3380) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2010-01-24 21:04:14 UTC (rev 3381) @@ -1,22 +1,20 @@ -#region Copyright (C) 2005-2009 Team MediaPortal +#region Copyright (C) 2005-2010 Team MediaPortal -// Copyright (C) 2005-2009 Team MediaPortal +// Copyright (C) 2005-2010 Team MediaPortal // http://www.team-mediaportal.com // -// This Program is free software; you can redistribute it and/or modify +// MediaPortal 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. +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. // -// This Program is distributed in the hope that it will be useful, +// MediaPortal 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 +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. #endregion @@ -27,7 +25,7 @@ using MediaPortal.Dialogs; using MediaPortal.GUI.Library; using MediaPortal.Util; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; namespace MySleepTimer { @@ -147,7 +145,7 @@ Application.Exit(); break; case "Show Basic Home": - GUIWindowManager.ActivateWindow((int) GUIWindow.Window.WINDOW_HOME, true); + GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_HOME, true); break; default: WindowsController.ExitWindows(Settings.ShutdownType, Settings.ShutdownForce, null); @@ -185,9 +183,7 @@ GUIPropertyManager.GetProperty("#shortcurrentremaining").Split(new char[] {':'}); totalMinutes = (int.Parse(shortCurrentRemaining[0]) * 60) + int.Parse(shortCurrentRemaining[1]); } - catch - { - } + catch {} if ((totalMinutes != 0) && (_sleepTimeCurrent == 0)) { @@ -238,7 +234,7 @@ //show _dialogSleepTimerNotify = - (GUIDialogNotify) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); _dialogSleepTimerNotify.TimeOut = timeOut; _dialogSleepTimerNotify.SetImage(GUIGraphicsContext.Skin + @"\Media\MySleepTimer_logo.png"); _dialogSleepTimerNotify.SetHeading("MySleepTimer"); Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2010-01-24 19:34:26 UTC (rev 3380) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2010-01-24 21:04:14 UTC (rev 3381) @@ -1,22 +1,20 @@ -#region Copyright (C) 2005-2009 Team MediaPortal +#region Copyright (C) 2005-2010 Team MediaPortal -// Copyright (C) 2005-2009 Team MediaPortal +// Copyright (C) 2005-2010 Team MediaPortal // http://www.team-mediaportal.com // -// This Program is free software; you can redistribute it and/or modify +// MediaPortal 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. +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. // -// This Program is distributed in the hope that it will be useful, +// MediaPortal 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 +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. #endregion @@ -134,7 +132,7 @@ var ret = new List<ActionEntry>(); foreach (var variable in Enum.GetValues(typeof (Action.ActionType))) - ret.Add(new ActionEntry((Action.ActionType) variable)); + ret.Add(new ActionEntry((Action.ActionType)variable)); ret.Sort(); @@ -146,7 +144,7 @@ var ret = new List<ShutdownEntry>(); foreach (var variable in Enum.GetValues(typeof (RestartOptions))) - ret.Add(new ShutdownEntry((RestartOptions) variable)); + ret.Add(new ShutdownEntry((RestartOptions)variable)); ret.Sort(); @@ -215,7 +213,7 @@ public int ActionID { - get { return (int) ActionType; } + get { return (int)ActionType; } } public ActionEntry(Action.ActionType actionType) @@ -244,7 +242,7 @@ public int ShutdownID { - get { return (int) ShutDownType; } + get { return (int)ShutDownType; } } public ShutdownEntry(RestartOptions restartOptions) Modified: trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2010-01-24 19:34:26 UTC (rev 3380) +++ trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2010-01-24 21:04:14 UTC (rev 3381) @@ -1,22 +1,20 @@ -#region Copyright (C) 2005-2009 Team MediaPortal +#region Copyright (C) 2005-2010 Team MediaPortal -// Copyright (C) 2005-2009 Team MediaPortal +// Copyright (C) 2005-2010 Team MediaPortal // http://www.team-mediaportal.com // -// This Program is free software; you can redistribute it and/or modify +// MediaPortal 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. +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. // -// This Program is distributed in the hope that it will be useful, +// MediaPortal 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 +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. #endregion Modified: trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2010-01-24 19:34:26 UTC (rev 3380) +++ trunk/plugins/MySleepTimer/MySleepTimer/Settings.cs 2010-01-24 21:04:14 UTC (rev 3381) @@ -1,22 +1,20 @@ -#region Copyright (C) 2005-2009 Team MediaPortal +#region Copyright (C) 2005-2010 Team MediaPortal -// Copyright (C) 2005-2009 Team MediaPortal +// Copyright (C) 2005-2010 Team MediaPortal // http://www.team-mediaportal.com // -// This Program is free software; you can redistribute it and/or modify +// MediaPortal 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. +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. // -// This Program is distributed in the hope that it will be useful, +// MediaPortal 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 +// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>. #endregion @@ -25,7 +23,7 @@ using MediaPortal.Configuration; using MediaPortal.GUI.Library; using MediaPortal.Util; -using Log=MediaPortal.ServiceImplementations.Log; +using Log = MediaPortal.ServiceImplementations.Log; namespace MySleepTimer { @@ -98,7 +96,7 @@ { 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); } @@ -106,7 +104,7 @@ 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"); SleepTimeMaxium = xmlReader.GetValueAsInt(PLUGIN_NAME, "#MySleepTimer.Maximum", 120); @@ -132,12 +130,12 @@ xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.UsePowerSchedulerSettings", UsePowerSchedulerSettings); if (!PowerSchedulerAvailable || !UsePowerSchedulerSettings) { - xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int) ShutdownType); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ShutdownType", (int)ShutdownType); xmlWriter.SetValueAsBool(PLUGIN_NAME, "#MySleepTimer.ShutdownForce", ShutdownForce); } // sleeptimer settings - xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionType", (int) ActionType); + xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.ActionType", (int)ActionType); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.SleepBehavior", SleepBehavior); xmlWriter.SetValue(PLUGIN_NAME, "#MySleepTimer.Maximum", SleepTimeMaxium); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2010-01-24 21:58:35
|
Revision: 3384 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3384&view=rev Author: chef_koch Date: 2010-01-24 21:58:25 +0000 (Sun, 24 Jan 2010) Log Message: ----------- added Translation support Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj Added Paths: ----------- trunk/plugins/MySleepTimer/MySleepTimer/Language/ trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml trunk/plugins/MySleepTimer/MySleepTimer/Translation.cs Added: trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml 2010-01-24 21:58:25 UTC (rev 3384) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- MyAlarm translation file --> +<!-- German (de) --> +<!-- Note: English is the fallback for any strings not found in other languages --> +<strings> + <!-- P --> + <string Field="PluginDescription">Schl\xE4fst auch du beim Fernsehen st\xE4ndig ein? Dann brauchst du dieses Plugin, welches MediaPortal automatisch nach einer bestimmten Zeit ausschaltet.</string> + <!-- S --> + <string Field="SleepingInXMin">Autom. Ausschalten in {0} min.</string> + <string Field="SleepingInXMinPlaytime">Autom. Ausschalten in {0} min. (restl. Wiedergabezeit)</string> + <string Field="SleepTimer">Automatisches Ausschalten</string> + <!-- T --> + <string Field="TimeIsUp">Es ist Schlafenszeit! Gute Nacht.</string> + <string Field="TimerStopped">Sleeptimer ausgeschaltet!</string> +</strings> \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2010-01-24 21:32:46 UTC (rev 3383) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2010-01-24 21:58:25 UTC (rev 3384) @@ -69,6 +69,7 @@ </Reference> </ItemGroup> <ItemGroup> + <Compile Include="Translation.cs" /> <Compile Include="Settings.cs" /> <Compile Include="MySleepTimer.cs"> </Compile> @@ -107,6 +108,9 @@ <Install>false</Install> </BootstrapperPackage> </ItemGroup> + <ItemGroup> + <Content Include="Language\de.xml" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Added: trunk/plugins/MySleepTimer/MySleepTimer/Translation.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Translation.cs (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/Translation.cs 2010-01-24 21:58:25 UTC (rev 3384) @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Xml; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; + +namespace MySleepTimer +{ + public static class Translation + { + #region Private variables + + private static Dictionary<string, string> _translations; + private static readonly string _path = string.Empty; + + #endregion + + #region Constructor + + static Translation() + { + string lang; + + try + { + lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()); + } + catch (Exception) + { + // when running MovingPicturesConfigTester outside of the MediaPortal directory this happens unfortunately + // so we grab the active culture name from the system + lang = CultureInfo.CurrentUICulture.Name; + } + + Log.Info("Using language " + lang); + + _path = Config.GetSubFolder(Config.Dir.Language, "MySleepTimer"); + + if (!System.IO.Directory.Exists(_path)) + System.IO.Directory.CreateDirectory(_path); + + LoadTranslations(lang); + } + + #endregion + + #region Public Properties + + /// <summary> + /// Gets the translated strings collection in the active language + /// </summary> + public static Dictionary<string, string> Strings + { + get + { + if (_translations == null) + { + _translations = new Dictionary<string, string>(); + Type transType = typeof(Translation); + FieldInfo[] fields = transType.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo field in fields) + { + _translations.Add(field.Name, field.GetValue(transType).ToString()); + } + } + return _translations; + } + } + + #endregion + + #region Public Methods + + public static int LoadTranslations(string lang) + { + XmlDocument doc = new XmlDocument(); + Dictionary<string, string> TranslatedStrings = new Dictionary<string, string>(); + string langPath = ""; + try + { + langPath = Path.Combine(_path, lang + ".xml"); + doc.Load(langPath); + } + catch (Exception e) + { + if (lang == "en") + return 0; // otherwise we are in an endless loop! + + if (e.GetType() == typeof(FileNotFoundException)) + Log.Warn("Cannot find translation file {0}. Failing back to English", langPath); + else + { + Log.Error("Error in translation xml file: {0}. Failing back to English", lang); + Log.Error(e); + } + + return LoadTranslations("en"); + } + foreach (XmlNode stringEntry in doc.DocumentElement.ChildNodes) + { + if (stringEntry.NodeType == XmlNodeType.Element) + try + { + TranslatedStrings.Add(stringEntry.Attributes.GetNamedItem("Field").Value, stringEntry.InnerText); + } + catch (Exception ex) + { + Log.Error("Error in Translation Engine"); + Log.Error(ex); + } + } + + Type TransType = typeof(Translation); + FieldInfo[] fieldInfos = TransType.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo fi in fieldInfos) + { + if (TranslatedStrings != null && TranslatedStrings.ContainsKey(fi.Name)) + TransType.InvokeMember(fi.Name, BindingFlags.SetField, null, TransType, new object[] { TranslatedStrings[fi.Name] }); + else + Log.Info("Translation not found for field: {0}. Using hard-coded English default.", fi.Name); + } + return TranslatedStrings.Count; + } + + public static string GetByName(string name) + { + if (!Strings.ContainsKey(name)) + return name; + + return Strings[name]; + } + + public static string GetByName(string name, params object[] args) + { + return String.Format(GetByName(name), args); + } + + /// <summary> + /// Takes an input string and replaces all ${named} variables with the proper translation if available + /// </summary> + /// <param name="input">a string containing ${named} variables that represent the translation keys</param> + /// <returns>translated input string</returns> + public static string ParseString(string input) + { + Regex replacements = new Regex(@"\$\{([^\}]+)\}"); + MatchCollection matches = replacements.Matches(input); + foreach (Match match in matches) + { + input = input.Replace(match.Value, GetByName(match.Groups[1].Value)); + } + return input; + } + + #endregion + + #region Translations / Strings + + // P + public static string PluginDescription = + "Want MediaPortal to be your sleeping agent of choice? Well, here you go! (but be warned - might be highly addictive!)"; + + // S + public static string SleepingInXMin = "Sleep in: {0} min"; + public static string SleepingInXMinPlaytime = "Sleep in: {0} min (remaining playtime)"; + public static string SleepTimer = "Sleeptimer"; + + // T + public static string TimeIsUp = "Time is up - Have a good night!"; + public static string TimerStopped = "Sleep Timer stopped!"; + + #endregion + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2011-04-05 16:03:23
|
Revision: 4166 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4166&view=rev Author: chef_koch Date: 2011-04-05 16:03:17 +0000 (Tue, 05 Apr 2011) Log Message: ----------- MP 1.2 compatibility: added version compatibility attributes Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2011-04-05 15:34:39 UTC (rev 4165) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2011-04-05 16:03:17 UTC (rev 4166) @@ -25,6 +25,7 @@ using MediaPortal.Dialogs; using MediaPortal.GUI.Library; using MediaPortal.Util; +using Action = MediaPortal.GUI.Library.Action; using Timer = System.Timers.Timer; namespace MySleepTimer Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2011-04-05 15:34:39 UTC (rev 4165) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2011-04-05 16:03:17 UTC (rev 4166) @@ -16,8 +16,9 @@ <UpgradeBackupLocation> </UpgradeBackupLocation> <IsWebBootstrapper>false</IsWebBootstrapper> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> - <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile> + </TargetFrameworkProfile> <PublishUrl>publish\</PublishUrl> <Install>true</Install> <InstallFrom>Disk</InstallFrom> @@ -55,12 +56,13 @@ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <ItemGroup> - <Reference Include="Core, Version=1.0.2.0, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> + <Reference Include="Common.Utils"> + <HintPath>..\..\..\..\..\MediaPortal\trunk\Common-MP-TVE3\Common.Utils\bin\Release\Common.Utils.dll</HintPath> + </Reference> + <Reference Include="Core"> <HintPath>..\..\..\..\..\MediaPortal\trunk\mediaportal\Core\bin\Release\Core.dll</HintPath> </Reference> - <Reference Include="Dialogs, Version=1.0.2.0, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> + <Reference Include="Dialogs"> <HintPath>..\..\..\..\..\MediaPortal\trunk\mediaportal\Dialogs\bin\Release\Dialogs.dll</HintPath> </Reference> <Reference Include="System" /> @@ -68,8 +70,7 @@ <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> - <Reference Include="Utils, Version=2.2.7.0, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> + <Reference Include="Utils"> <HintPath>..\..\..\..\..\MediaPortal\trunk\mediaportal\Utils\bin\Release\Utils.dll</HintPath> </Reference> </ItemGroup> Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2011-04-05 15:34:39 UTC (rev 4165) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2011-04-05 16:03:17 UTC (rev 4166) @@ -23,6 +23,7 @@ using System.Windows.Forms; using MediaPortal.GUI.Library; using MediaPortal.Util; +using Action = MediaPortal.GUI.Library.Action; namespace MySleepTimer { Modified: trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2011-04-05 15:34:39 UTC (rev 4165) +++ trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2011-04-05 16:03:17 UTC (rev 4166) @@ -21,6 +21,9 @@ using System.Reflection; using System.Runtime.InteropServices; +using MediaPortal.Common.Utils; +[assembly: CompatibleVersion("1.1.6.0")] + // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <che...@us...> - 2011-04-05 16:23:17
|
Revision: 4167 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4167&view=rev Author: chef_koch Date: 2011-04-05 16:23:11 +0000 (Tue, 05 Apr 2011) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2011-04-05 16:03:17 UTC (rev 4166) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2011-04-05 16:23:11 UTC (rev 4167) @@ -16,9 +16,7 @@ <UpgradeBackupLocation> </UpgradeBackupLocation> <IsWebBootstrapper>false</IsWebBootstrapper> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - <TargetFrameworkProfile> - </TargetFrameworkProfile> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <PublishUrl>publish\</PublishUrl> <Install>true</Install> <InstallFrom>Disk</InstallFrom> Modified: trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2011-04-05 16:03:17 UTC (rev 4166) +++ trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2011-04-05 16:23:11 UTC (rev 4167) @@ -22,7 +22,7 @@ using System.Runtime.InteropServices; using MediaPortal.Common.Utils; -[assembly: CompatibleVersion("1.1.6.0")] +[assembly: CompatibleVersion("1.1.6.27644")] // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |