From: <ant...@us...> - 2009-03-17 19:01:55
|
Revision: 2727 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2727&view=rev Author: anthrax-leprosy Date: 2009-03-17 19:01:23 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Release 1.0.3.0 Modified Paths: -------------- trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer.xmp trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs Added Paths: ----------- trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer_1.0.3.0.mpi Modified: trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer.xmp =================================================================== --- trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer.xmp 2009-03-17 18:47:54 UTC (rev 2726) +++ trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer.xmp 2009-03-17 19:01:23 UTC (rev 2727) @@ -1,4 +1,4 @@ -<MPinstaler> +<MPinstaler> <ver>1.00.000</ver> <FileList> <File> @@ -8,7 +8,7 @@ <Source>MySleepTimer.dll</Source> <Id>01010</Id> <Option /> - <Guid>c15a31e5-e651-4fb8-a866-a36add95f5f2</Guid> + <Guid>5bcd0785-7f02-4c03-a46e-e9b73f8675d0</Guid> </File> <File> <FileName>MySleepTimer_logo.png</FileName> @@ -17,7 +17,7 @@ <Source>MySleepTimer_logo.png</Source> <Id>02020</Id> <Option>OutputFileName=|DefaultFile=True|</Option> - <Guid>9eb5ae95-a00d-461e-9cc1-45d3cda5b257</Guid> + <Guid>dce7d4f2-44a1-4673-9c70-5c4da5a022bf</Guid> </File> </FileList> <StringList /> @@ -28,11 +28,11 @@ <SetupGroupMappings /> <Option> <BuildFileName>MySleepTimer.mpi</BuildFileName> - <ProiectFileName>MySleepTimer.xmp</ProiectFileName> + <ProiectFileName>D:\!Prasse\MySleepTimer\MpiRelease\MySleepTimer.xmp</ProiectFileName> <ProiectName>MySleepTimer</ProiectName> <Author>Anthrax</Author> <UpdateURL>http://www.team-mediaportal.com</UpdateURL> - <Version>1.0.2.0</Version> + <Version>1.0.3.0</Version> <Description>Anybody around here using MediaPortal as his/her over-the-counter (but highly addictive) sleeping agent? Well, I sure as heck do Added: trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer_1.0.3.0.mpi =================================================================== (Binary files differ) Property changes on: trunk/plugins/MySleepTimer/MpiRelease/MySleepTimer_1.0.3.0.mpi ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-03-17 18:47:54 UTC (rev 2726) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.cs 2009-03-17 19:01:23 UTC (rev 2727) @@ -26,171 +26,248 @@ using System; using System.Collections.Generic; using System.Text; -using System; using System.Windows.Forms; -using MediaPortal.GUI.Library; using MediaPortal.UserInterface.Controls; using MediaPortal.GUI; +using MediaPortal.GUI.Library; using MediaPortal.Util; using MediaPortal.Dialogs; using MediaPortal.Configuration; + 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 System.Timers.Timer timerShutDown; + private System.Timers.Timer timerAction; + private System.Timers.Timer timerNotify; + //MP + private GUIDialogNotify dialogSleepTimerNotify; + + //globals private int sleepTimeCurrent = 0; - private GUIDialogNotify dialogSleepTimerNotify; - private Action.ActionType actionType; - private RestartOptions restartOption; + 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; - private int sleepTimeStep = 10; - private int notifyInterval = 5; - private int notifyBeforeSleep = 3; - private Timer timerNotify; - private Timer timerShutDown; - private System.Timers.Timer timerActionTimeOut; - private bool timedOut = false; - private int notifyCounter = 0; + 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() { - timerNotify = new Timer(); - timerNotify.Tick += new EventHandler(timerNotify_Tick); - timerShutDown = new Timer(); - timerShutDown.Tick += new EventHandler(timerShutDown_Tick); - timerActionTimeOut = new System.Timers.Timer(); - timerActionTimeOut.AutoReset = false; - timerActionTimeOut.Elapsed += new System.Timers.ElapsedEventHandler(timerActionTimeOut_Tick); - using (MediaPortal.Profile.Settings xmlReader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - timerActionTimeOut.Interval = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 1) * 1000; - actionType = (Action.ActionType)xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", (int)(Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); - restartOption = (RestartOptions)xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", (int)RestartOptions.ShutDown); - sleepBehavior = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", "Shutdown"); - shutdownForce = xmlReader.GetValueAsBool("MySleepTimer", "#MySleepTimer.ShutdownForce", false); - sleepTimeMaxium = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Maximum", 120); - sleepTimeStep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.Step", 10); - notifyInterval = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); - notifyBeforeSleep = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", 3); + 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); } - GUIWindowManager.OnNewAction += new OnActionHandler(GUIWindowManager_OnNewAction); + catch (Exception ex) { + //log errors here + } } void GUIWindowManager_OnNewAction(Action action) { - if (action.wID == actionType) { - timerActionTimeOut.Stop(); - if (timerShutDown.Enabled && (timedOut || sleepTimeCurrent >= sleepTimeMaxium)) { - StopTimers(); - sleepTimeCurrent = 0; - ShowNotifyDialog("Sleep Timer stopped!"); + 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); } - else { - SetTimers(sleepTimeCurrent); - timerActionTimeOut.Start(); - } - timedOut = false; - base.OnAction(action); } + catch (Exception ex) { + //log errors here + } } - void timerActionTimeOut_Tick(object sender, EventArgs e) { - timedOut = true; - } - - void timerShutDown_Tick(object sender, EventArgs e) { - StopTimers(); - sleepTimeCurrent = 0; - ShowNotifyDialog("Time's up - Have a good night!"); - 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; + 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) { - if (timerNotify.Interval != notifyInterval * 60000) { - notifyCounter = timerNotify.Interval; - timerNotify.Stop(); - timerNotify.Interval = notifyInterval * 60000; - timerNotify.Start(); + try { + timedOut = true; + //will stop after tick (AutoReset = false) } - else { - notifyCounter += notifyInterval; - ShowNotifyDialog("Minutes remaining: " + ((timerShutDown.Interval / 60000) - notifyCounter)); + catch (Exception ex) { + //log errors here } } - private void StopTimers() { - timerNotify.Stop(); - timerShutDown.Stop(); + 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); + } + } + } + catch (Exception ex) { + //log errors here + } } - private void SetTimers(int when) { - SetTimers(when, null); - } - - private void SetTimers(int when, string message) { - StopTimers(); - notifyCounter = 0; - sleepTimeCurrent += sleepTimeStep; - if (when == 0) { + 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[] { ':' }); - TimeSpan currentRemaining = new TimeSpan(Convert.ToInt16(shortCurrentRemaining[0]), Convert.ToInt16(shortCurrentRemaining[1]), 0); - if ((int)currentRemaining.TotalMinutes != 0) { - when = (int)currentRemaining.TotalMinutes + 1; - message = "Sleep in: " + ((int)currentRemaining.TotalMinutes + 1) + " min (remaining playtime)"; - SetTimers(when, message); - return; - } + totalMinutes = (int.Parse(shortCurrentRemaining[0]) * 60) + int.Parse(shortCurrentRemaining[1]); } - catch { + catch { } + + if ((totalMinutes != 0) && (sleepTimeCurrent == 0)) { + //play and additional press from "stopped" + sleepTimeCurrent = totalMinutes + 1; + setByPlay = true; //set play flag } - SetTimers(sleepTimeCurrent); - return; + 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 + } } - timerShutDown.Interval = when * 60000; + catch (Exception ex) { + //log errors here + } + } + + private void ShowNotifyDialog(int timeOut, string notifyMessage) { try { - timerNotify.Interval = timerShutDown.Interval - (notifyBeforeSleep * 60000); + 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 { - timerNotify.Interval = notifyInterval * 60000; + catch (Exception ex) { + //log errors here } - timerNotify.Start(); - timerShutDown.Start(); - if (message == null) { - ShowNotifyDialog("Sleep in: " + when + " min"); - } - else { - ShowNotifyDialog(message); - } - message = null; - - } - private void ShowNotifyDialog(string notifyMessage) { - dialogSleepTimerNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); - dialogSleepTimerNotify.TimeOut = 2; - dialogSleepTimerNotify.SetImage(GUIGraphicsContext.Skin + @"\Media\MySleepTimer_logo.png"); - dialogSleepTimerNotify.SetHeading("MySleepTimer"); - dialogSleepTimerNotify.SetText(notifyMessage); - dialogSleepTimerNotify.DoModal(GUIWindowManager.ActiveWindow); - } - #region ISetupForm Members // Returns the name of the plugin which is shown in the plugin menu Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2009-03-17 18:47:54 UTC (rev 2726) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2009-03-17 19:01:23 UTC (rev 2727) @@ -1,4 +1,4 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -9,6 +9,26 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MySleepTimer</RootNamespace> <AssemblyName>MySleepTimer</AssemblyName> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>2.0</OldToolsVersion> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>false</DebugSymbols> @@ -18,6 +38,7 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> @@ -26,26 +47,23 @@ <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <ItemGroup> - <Reference Include="Core, Version=0.9.3.890, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Core, Version=1.0.0.29788, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>C:\Programme\Team MediaPortal\MediaPortal\Core.dll</HintPath> </Reference> - <Reference Include="Dialogs, Version=0.9.3.896, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Dialogs, Version=1.0.0.29798, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>C:\Programme\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> </Reference> - <Reference Include="RemotePlugins, Version=0.9.3.900, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> - <HintPath>C:\Programme\Team MediaPortal\MediaPortal\RemotePlugins.dll</HintPath> - </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> - <Reference Include="Utils, Version=2.2.6.879, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Utils, Version=2.2.6.29782, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>C:\Programme\Team MediaPortal\MediaPortal\Utils.dll</HintPath> </Reference> @@ -71,6 +89,23 @@ <EmbeddedResource Include="img\MySleepTimer_disabled.png" /> <EmbeddedResource Include="img\MySleepTimer_enabled.png" /> </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </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. @@ -80,7 +115,7 @@ </Target> --> <PropertyGroup> - <PostBuildEvent>xcopy "$(TargetPath)" "..\..\..\MpiRelease" /Y -xcopy "$(TargetPath)" "C:\Programme\Team MediaPortal\MediaPortal\plugins\Windows" /Y</PostBuildEvent> + <PostBuildEvent>REM xcopy "$(TargetPath)" "..\..\..\MpiRelease" /Y +REM xcopy "$(TargetPath)" "C:\Programme\Team MediaPortal\MediaPortal\plugins\Windows" /Y</PostBuildEvent> </PropertyGroup> </Project> \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-03-17 18:47:54 UTC (rev 2726) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-03-17 19:01:23 UTC (rev 2727) @@ -28,24 +28,27 @@ this.numericUpDownSleepTimeMax = new System.Windows.Forms.NumericUpDown(); this.numericUpDownSleepTimeStep = new System.Windows.Forms.NumericUpDown(); this.numericUpDownNotifyInterval = new System.Windows.Forms.NumericUpDown(); - this.label32 = new System.Windows.Forms.Label(); + 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.label5 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); this.comboBoxShutDownType = new System.Windows.Forms.ComboBox(); this.checkBoxShutDownForce = new System.Windows.Forms.CheckBox(); - this.label4 = new System.Windows.Forms.Label(); + 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.comboBoxSleepBehavior = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); - this.numericUpDownTimeOut = new System.Windows.Forms.NumericUpDown(); + 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.numericUpDownTimeOut)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).BeginInit(); this.SuspendLayout(); // // comboBoxActionType @@ -55,7 +58,7 @@ 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 = 0; + this.comboBoxActionType.TabIndex = 5; // // label1 // @@ -63,7 +66,7 @@ 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 = 1; + this.label1.TabIndex = 0; this.label1.Text = "ActionType to set sleep timer:"; // // numericUpDownSleepTimeMax @@ -75,7 +78,7 @@ 0}); this.numericUpDownSleepTimeMax.Location = new System.Drawing.Point(169, 87); this.numericUpDownSleepTimeMax.Maximum = new decimal(new int[] { - 500, + 1440, 0, 0, 0}); @@ -86,7 +89,7 @@ 0}); this.numericUpDownSleepTimeMax.Name = "numericUpDownSleepTimeMax"; this.numericUpDownSleepTimeMax.Size = new System.Drawing.Size(71, 20); - this.numericUpDownSleepTimeMax.TabIndex = 2; + this.numericUpDownSleepTimeMax.TabIndex = 25; this.numericUpDownSleepTimeMax.Value = new decimal(new int[] { 1, 0, @@ -95,11 +98,6 @@ // // numericUpDownSleepTimeStep // - this.numericUpDownSleepTimeStep.Increment = new decimal(new int[] { - 10, - 0, - 0, - 0}); this.numericUpDownSleepTimeStep.Location = new System.Drawing.Point(169, 113); this.numericUpDownSleepTimeStep.Minimum = new decimal(new int[] { 1, @@ -108,7 +106,7 @@ 0}); this.numericUpDownSleepTimeStep.Name = "numericUpDownSleepTimeStep"; this.numericUpDownSleepTimeStep.Size = new System.Drawing.Size(71, 20); - this.numericUpDownSleepTimeStep.TabIndex = 3; + this.numericUpDownSleepTimeStep.TabIndex = 30; this.numericUpDownSleepTimeStep.Value = new decimal(new int[] { 1, 0, @@ -117,7 +115,7 @@ // // numericUpDownNotifyInterval // - this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(169, 165); + this.numericUpDownNotifyInterval.Location = new System.Drawing.Point(169, 191); this.numericUpDownNotifyInterval.Minimum = new decimal(new int[] { 1, 0, @@ -125,66 +123,67 @@ 0}); this.numericUpDownNotifyInterval.Name = "numericUpDownNotifyInterval"; this.numericUpDownNotifyInterval.Size = new System.Drawing.Size(71, 20); - this.numericUpDownNotifyInterval.TabIndex = 4; + this.numericUpDownNotifyInterval.TabIndex = 45; this.numericUpDownNotifyInterval.Value = new decimal(new int[] { 1, 0, 0, 0}); + this.numericUpDownNotifyInterval.ValueChanged += new System.EventHandler(this.numericUpDownNotifyInterval_ValueChanged); // - // label32 + // label4 // - this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(53, 89); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(105, 13); - this.label32.TabIndex = 5; - this.label32.Text = "Sleep time maximum:"; + 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:"; // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(71, 115); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(87, 13); - this.label3.TabIndex = 6; - this.label3.Text = "Sleep time steps:"; - // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(57, 167); + this.label5.Location = new System.Drawing.Point(71, 115); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(101, 13); - this.label5.TabIndex = 8; - this.label5.Text = "Notification Interval:"; + this.label5.Size = new System.Drawing.Size(87, 13); + this.label5.TabIndex = 0; + this.label5.Text = "Sleep time steps:"; // - // button1 + // label8 // - this.button1.Location = new System.Drawing.Point(290, 188); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(47, 23); - this.button1.TabIndex = 9; - this.button1.Text = "OK"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + 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:"; // - // label2 + // buttonOK // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(77, 63); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 13); - this.label2.TabIndex = 11; - this.label2.Text = "Shutdown type:"; + 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 = 10; + this.comboBoxShutDownType.TabIndex = 15; // // checkBoxShutDownForce // @@ -192,44 +191,35 @@ 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 = 12; + this.checkBoxShutDownForce.TabIndex = 20; this.checkBoxShutDownForce.Text = "force"; this.checkBoxShutDownForce.UseVisualStyleBackColor = true; // - // label4 + // label7 // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(9, 141); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(149, 13); - this.label4.TabIndex = 14; - this.label4.Text = "Start notification prior to sleep:"; + 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, 139); - this.numericUpDownNotifyBeforeSleep.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); + 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 = 13; - this.numericUpDownNotifyBeforeSleep.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); + this.numericUpDownNotifyBeforeSleep.TabIndex = 40; + this.numericUpDownNotifyBeforeSleep.ValueChanged += new System.EventHandler(this.numericUpDownNotifyBeforeSleep_ValueChanged); // - // label6 + // label2 // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(77, 35); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(81, 13); - this.label6.TabIndex = 18; - this.label6.Text = "Sleep behavior:"; + 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 // @@ -243,52 +233,86 @@ 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 = 19; + this.comboBoxSleepBehavior.TabIndex = 10; + this.comboBoxSleepBehavior.SelectedIndexChanged += new System.EventHandler(this.comboBoxSleepBehavior_SelectedIndexChanged); // - // label7 + // label6 // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(74, 193); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(84, 13); - this.label7.TabIndex = 21; - this.label7.Text = "Button TimeOut:"; + 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]:"; // - // numericUpDownTimeOut + // numericUpDownTimeOutB // - this.numericUpDownTimeOut.Location = new System.Drawing.Point(169, 191); - this.numericUpDownTimeOut.Minimum = new decimal(new int[] { + this.numericUpDownTimeOutB.Location = new System.Drawing.Point(169, 139); + this.numericUpDownTimeOutB.Minimum = new decimal(new int[] { 1, 0, 0, 0}); - this.numericUpDownTimeOut.Name = "numericUpDownTimeOut"; - this.numericUpDownTimeOut.Size = new System.Drawing.Size(71, 20); - this.numericUpDownTimeOut.TabIndex = 20; - this.numericUpDownTimeOut.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[] { + 65, + 0, + 0, + 0}); + 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[] { + 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, 222); + 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.numericUpDownTimeOut); - this.Controls.Add(this.comboBoxSleepBehavior); - this.Controls.Add(this.label6); - this.Controls.Add(this.label4); this.Controls.Add(this.numericUpDownNotifyBeforeSleep); this.Controls.Add(this.checkBoxShutDownForce); - this.Controls.Add(this.label2); + this.Controls.Add(this.label3); this.Controls.Add(this.comboBoxShutDownType); - this.Controls.Add(this.button1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.label8); this.Controls.Add(this.label5); - this.Controls.Add(this.label3); - this.Controls.Add(this.label32); + this.Controls.Add(this.label4); this.Controls.Add(this.numericUpDownNotifyInterval); this.Controls.Add(this.numericUpDownSleepTimeStep); this.Controls.Add(this.numericUpDownSleepTimeMax); @@ -301,7 +325,8 @@ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOut)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutB)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -314,18 +339,20 @@ private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeMax; private System.Windows.Forms.NumericUpDown numericUpDownSleepTimeStep; private System.Windows.Forms.NumericUpDown numericUpDownNotifyInterval; - private System.Windows.Forms.Label label32; + 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.Label label5; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox comboBoxShutDownType; private System.Windows.Forms.CheckBox checkBoxShutDownForce; - private System.Windows.Forms.Label label4; + 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.ComboBox comboBoxSleepBehavior; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.NumericUpDown numericUpDownTimeOut; + private System.Windows.Forms.NumericUpDown numericUpDownTimeOutB; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.NumericUpDown numericUpDownTimeOutN; } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-03-17 18:47:54 UTC (rev 2726) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-03-17 19:01:23 UTC (rev 2727) @@ -36,73 +36,211 @@ using MediaPortal.Util; -namespace MySleepTimer { +namespace MySleepTimer +{ public partial class MySleepTimerConfig : MPConfigForm { - public MySleepTimerConfig() { - InitializeComponent(); - Load += new EventHandler(MySleepTimerConfig_Load); + public MySleepTimerConfig() + { + try + { + InitializeComponent(); + Load += new EventHandler(MySleepTimerConfig_Load); + } + catch (Exception ex) + { + //log errors here + } + } + void MySleepTimerConfig_Load(object sender, EventArgs e) + { + try + { + comboBoxActionType.DataSource = GenerateActionList(); + comboBoxActionType.DisplayMember = "ActionName"; + comboBoxActionType.ValueMember = "ActionID"; + comboBoxShutDownType.DataSource = GenerateShutdownList(); + comboBoxShutDownType.DisplayMember = "ShutdownName"; + comboBoxShutDownType.ValueMember = "ShutdownID"; + + using (MediaPortal.Profile.Settings xmlReader = new MediaPortal.Profile.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); + } + + SetUpShutDownTypeControls(); + SetUpNotifyControls(); + } + catch (Exception ex) + { + //log errors here + } } - void MySleepTimerConfig_Load(object sender, EventArgs e) { - comboBoxActionType.DataSource = GenerateActionList(); - comboBoxActionType.DisplayMember = "ActionName"; - comboBoxActionType.ValueMember = "ActionID"; - comboBoxShutDownType.DataSource = GenerateShutdownList(); - comboBoxShutDownType.DisplayMember = "ShutdownName"; - comboBoxShutDownType.ValueMember = "ShutdownID"; + private void comboBoxSleepBehavior_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + SetUpShutDownTypeControls(); + } + catch (Exception ex) + { + //log errors here + } + } - using (MediaPortal.Profile.Settings xmlReader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - comboBoxActionType.SelectedValue = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionType", (int)(Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON)); - comboBoxShutDownType.SelectedValue = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ShutdownType", (int)RestartOptions.ShutDown); - comboBoxSleepBehavior.Text = xmlReader.GetValueAsString("MySleepTimer", "#MySleepTimer.SleepBehavior", "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); - numericUpDownNotifyInterval.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyInterval", 1); - numericUpDownNotifyBeforeSleep.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", 3); - numericUpDownTimeOut.Value = xmlReader.GetValueAsInt("MySleepTimer", "#MySleepTimer.ActionTimeOut", 1); - + private void numericUpDownNotifyBeforeSleep_ValueChanged(object sender, EventArgs e) + { + try + { + SetUpNotifyControls(); } + catch (Exception ex) + { + //log errors here + } } - private ArrayList GenerateActionList() { + private void numericUpDownNotifyInterval_ValueChanged(object sender, EventArgs e) + { + try + { + SetUpNotifyControls(); + } + catch (Exception ex) + { + //log errors here + } + } + + private void button1_Click(object sender, EventArgs e) + { + try + { + // Write configuration settings + using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.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()); + } + this.Close(); + } + catch (Exception ex) + { + //log errors here + } + } + + private ArrayList GenerateActionList() + { ArrayList ret = new ArrayList(); - 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])); + 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 errors here + } return ret; } - private ArrayList GenerateShutdownList() { + private ArrayList GenerateShutdownList() + { ArrayList ret = new ArrayList(); - 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])); + 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 errors here + } return ret; } + private void SetUpShutDownTypeControls() + { + try + { + if (comboBoxSleepBehavior.Text == "Shutdown") + { + label3.Enabled = true; + comboBoxShutDownType.Enabled = true; + checkBoxShutDownForce.Enabled = true; + } + else + { + label3.Enabled = false; + comboBoxShutDownType.Enabled = false; + checkBoxShutDownForce.Enabled = false; + } + } + catch (Exception ex) + { + //log errors here + } + } - private void button1_Click(object sender, EventArgs e) { - // Read configuration settings - using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ActionType", comboBoxActionType.SelectedValue); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ShutdownType", comboBoxShutDownType.SelectedValue); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.SleepBehavior", comboBoxSleepBehavior.Text); - 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.NotifyInterval", numericUpDownNotifyInterval.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.NotifyBeforeSleep", numericUpDownNotifyBeforeSleep.Value.ToString()); - xmlWriter.SetValue("MySleepTimer", "#MySleepTimer.ActionTimeOut", numericUpDownTimeOut.Value.ToString()); + private void SetUpNotifyControls() + { + try + { + if (numericUpDownNotifyBeforeSleep.Value != 0) + { + if (numericUpDownNotifyInterval.Value > numericUpDownNotifyBeforeSleep.Value) + { + numericUpDownNotifyInterval.Value = numericUpDownNotifyBeforeSleep.Value; + } + + label8.Enabled = true; + numericUpDownNotifyInterval.Enabled = true; + label9.Enabled = true; + numericUpDownTimeOutN.Enabled = true; + ... [truncated message content] |