From: <pop...@us...> - 2015-01-28 20:02:45
|
Revision: 4927 http://sourceforge.net/p/mp-plugins/code/4927 Author: popy2007 Date: 2015-01-28 20:02:42 +0000 (Wed, 28 Jan 2015) Log Message: ----------- * Fixed compatibility with MP 1.4+ (livetv issue) * AQdded AutoActivate feature Modified Paths: -------------- trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.Designer.cs trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.cs trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/Settings.cs trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Window/MySleepTimer.cs Added Paths: ----------- trunk/plugins/MySleepTimer/MySleepTimer/Language/ trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj trunk/plugins/MySleepTimer/MySleepTimer/Properties/ trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs trunk/plugins/MySleepTimer/MySleepTimer.sln Added: trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/Language/de.xml 2015-01-28 20:02:42 UTC (rev 4927) @@ -0,0 +1,13 @@ +<?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="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 Added: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimer.csproj 2015-01-28 20:02:42 UTC (rev 4927) @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.21022</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{03856C9E-0926-41DB-A13A-AE3D08285428}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>MySleepTimer</RootNamespace> + <AssemblyName>MySleepTimer</AssemblyName> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>3.5</OldToolsVersion> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <IsWebBootstrapper>false</IsWebBootstrapper> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <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> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>false</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <UseVSHostingProcess>true</UseVSHostingProcess> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <UseVSHostingProcess>false</UseVSHostingProcess> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup> + <StartupObject> + </StartupObject> + </PropertyGroup> + <ItemGroup> + <Reference Include="Common.Utils"> + <HintPath>Resources\dll\Common.Utils.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Core"> + <HintPath>Resources\dll\Core.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Dialogs"> + <HintPath>Resources\dll\Dialogs.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Stateless, Version=2.3.1.1, Culture=neutral, PublicKeyToken=93038f0927583c9a, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>Resources\dll\Stateless.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Web" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + <Reference Include="Utils"> + <HintPath>Resources\dll\Utils.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="WindowPlugins"> + <HintPath>Resources\dll\WindowPlugins.dll</HintPath> + <Private>False</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Plugin\Configuration\MySleepTimerConfig.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Plugin\Configuration\MySleepTimerConfig.Designer.cs"> + <DependentUpon>MySleepTimerConfig.cs</DependentUpon> + </Compile> + <Compile Include="Plugin\Configuration\Settings.cs" /> + <Compile Include="Plugin\Window\MySleepTimer.cs" /> + <Compile Include="Plugin\Window\MySleepTimerOld.cs" /> + <Compile Include="Plugin\Window\Translation.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Plugin\Configuration\MySleepTimerConfig.resx"> + <DependentUpon>MySleepTimerConfig.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <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> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <Content Include="Extension\Forum\MySleepTimer_01.png" /> + <Content Include="Extension\Forum\MySleepTimer_02.png" /> + <Content Include="Extension\Forum\MySleepTimer_03.png" /> + <Content Include="Extension\Forum\MySleepTimer_04.png" /> + <Content Include="Extension\Forum\MySleepTimer_logo.png" /> + <Content Include="Extension\Installer\update.xml" /> + <Content Include="Language\de.xml"> + <SubType>Designer</SubType> + </Content> + <EmbeddedResource Include="Resources\img\MySleepTimer_disabled.png" /> + <EmbeddedResource Include="Resources\img\MySleepTimer_enabled.png" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Resources\dll\" /> + <Folder Include="Skin\Media\" /> + </ItemGroup> + <ItemGroup> + <None Include="Extension\Installer\MySleepTimer.mpe1" /> + <None Include="Extension\Installer\MySleepTimer.xmp2" /> + </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. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <PostBuildEvent>REM xcopy "$(TargetPath)" "..\..\..\MpiRelease" /Y +xcopy "$(TargetPath)" "C:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows" /Y</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.Designer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.Designer.cs 2015-01-12 06:59:42 UTC (rev 4926) +++ trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.Designer.cs 2015-01-28 20:02:42 UTC (rev 4927) @@ -43,12 +43,16 @@ this.groupBoxTimer = new System.Windows.Forms.GroupBox(); this.cancelButton = new System.Windows.Forms.Button(); this.okButton = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.dateTimePicker_AutoActivate = new System.Windows.Forms.DateTimePicker(); + this.checkBoxAutoActivate = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyBeforeSleep)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeOutN)).BeginInit(); this.groupBox1.SuspendLayout(); this.groupBoxTimer.SuspendLayout(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // comboBoxActionType @@ -285,7 +289,7 @@ // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(260, 303); + this.cancelButton.Location = new System.Drawing.Point(260, 351); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); this.cancelButton.TabIndex = 58; @@ -296,7 +300,7 @@ // okButton // this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.Location = new System.Drawing.Point(179, 303); + this.okButton.Location = new System.Drawing.Point(179, 351); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(75, 23); this.okButton.TabIndex = 59; @@ -304,13 +308,48 @@ this.okButton.UseVisualStyleBackColor = true; this.okButton.Click += new System.EventHandler(this.okButton_Click); // + // groupBox2 + // + this.groupBox2.Controls.Add(this.dateTimePicker_AutoActivate); + this.groupBox2.Controls.Add(this.checkBoxAutoActivate); + this.groupBox2.Location = new System.Drawing.Point(12, 289); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(323, 46); + this.groupBox2.TabIndex = 61; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Auto Activation"; + // + // dateTimePicker_AutoActivate + // + this.dateTimePicker_AutoActivate.CustomFormat = "HH:mm"; + this.dateTimePicker_AutoActivate.Enabled = false; + this.dateTimePicker_AutoActivate.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dateTimePicker_AutoActivate.Location = new System.Drawing.Point(210, 14); + this.dateTimePicker_AutoActivate.Name = "dateTimePicker_AutoActivate"; + this.dateTimePicker_AutoActivate.ShowUpDown = true; + this.dateTimePicker_AutoActivate.Size = new System.Drawing.Size(71, 20); + this.dateTimePicker_AutoActivate.TabIndex = 62; + this.dateTimePicker_AutoActivate.Value = new System.DateTime(2015, 1, 26, 0, 0, 0, 0); + // + // checkBoxAutoActivate + // + this.checkBoxAutoActivate.AutoSize = true; + this.checkBoxAutoActivate.Location = new System.Drawing.Point(9, 19); + this.checkBoxAutoActivate.Name = "checkBoxAutoActivate"; + this.checkBoxAutoActivate.Size = new System.Drawing.Size(161, 17); + this.checkBoxAutoActivate.TabIndex = 61; + this.checkBoxAutoActivate.Text = "Auto Activate Sleep Timer at"; + this.checkBoxAutoActivate.UseVisualStyleBackColor = true; + this.checkBoxAutoActivate.CheckedChanged += new System.EventHandler(this.checkBoxAutoActivate_CheckedChanged); + // // MySleepTimerConfig // this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(347, 334); + this.ClientSize = new System.Drawing.Size(347, 382); + this.Controls.Add(this.groupBox2); this.Controls.Add(this.okButton); this.Controls.Add(this.cancelButton); this.Controls.Add(this.groupBoxTimer); @@ -334,6 +373,8 @@ this.groupBox1.PerformLayout(); this.groupBoxTimer.ResumeLayout(false); this.groupBoxTimer.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -361,5 +402,8 @@ private System.Windows.Forms.GroupBox groupBoxTimer; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button okButton; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.DateTimePicker dateTimePicker_AutoActivate; + private System.Windows.Forms.CheckBox checkBoxAutoActivate; } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.cs 2015-01-12 06:59:42 UTC (rev 4926) +++ trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/MySleepTimerConfig.cs 2015-01-28 20:02:42 UTC (rev 4927) @@ -1,6 +1,6 @@ -#region Copyright (C) 2005-2010 Team MediaPortal +#region Copyright (C) 2005-2015 Team MediaPortal -// Copyright (C) 2005-2010 Team MediaPortal +// Copyright (C) 2005-2015 Team MediaPortal // http://www.team-mediaportal.com // // MediaPortal is free software: you can redistribute it and/or modify @@ -60,6 +60,10 @@ numericUpDownNotifyBeforeSleep.Value = Settings.NotifyBeforeSleep; numericUpDownTimeOutN.Value = Settings.NotifyTimeOutMs; + checkBoxAutoActivate.Checked = Settings.AutoActivate; + dateTimePicker_AutoActivate.Value = Settings.AutoActivateTime; + + SetUpShutDownTypeControls(); SetUpNotifyControls(); } catch (Exception ex) { @@ -79,6 +83,10 @@ Settings.SleepTimeStep = (int)numericUpDownSleepTimeStep.Value; Settings.NotifyBeforeSleep = (int)numericUpDownNotifyBeforeSleep.Value; Settings.NotifyTimeOutMs = (int)numericUpDownTimeOutN.Value; + + Settings.AutoActivate = checkBoxAutoActivate.Checked; + Settings.AutoActivateTime = dateTimePicker_AutoActivate.Value; + Settings.Save(); } @@ -163,6 +171,19 @@ Log.Error(ex); } } + + private void checkBoxAutoActivate_CheckedChanged(object sender, EventArgs e) + { + if (checkBoxAutoActivate.Checked) + { + dateTimePicker_AutoActivate.Enabled = true; + } + else + { + dateTimePicker_AutoActivate.Enabled = false; + } + } + } internal class ActionEntry : IComparable<ActionEntry> { Modified: trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/Settings.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/Settings.cs 2015-01-12 06:59:42 UTC (rev 4926) +++ trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Configuration/Settings.cs 2015-01-28 20:02:42 UTC (rev 4927) @@ -45,6 +45,9 @@ public static int NotifyBeforeSleep { get; set; } //(0..n) public static int NotifyTimeOutMs { get; set; } //(1..65 * 1000) + public static bool AutoActivate { get; set; } + public static System.DateTime AutoActivateTime { get; set; } + static Settings() { ActionType = Action.ActionType.ACTION_REMOTE_YELLOW_BUTTON; SleepBehavior = "Shutdown"; @@ -56,7 +59,10 @@ SleepTimeMaxium = 120; SleepTimeStep = 10; NotifyBeforeSleep = 3; - NotifyTimeOutMs = 3 * 1000; + NotifyTimeOutMs = 3; + + AutoActivate = false; + AutoActivateTime = System.DateTime.Now; } #endregion @@ -99,7 +105,13 @@ SleepTimeMaxium = xmlReader.GetValueAsInt(PLUGIN_NAME, "Maximum", 120); SleepTimeStep = xmlReader.GetValueAsInt(PLUGIN_NAME, "Step", 10); NotifyBeforeSleep = xmlReader.GetValueAsInt(PLUGIN_NAME, "NotifyBeforeSleep", 3); - NotifyTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "NotifyTimeOut", 3) * 1000; + NotifyTimeOutMs = xmlReader.GetValueAsInt(PLUGIN_NAME, "NotifyTimeOut", 3); + + AutoActivate = + xmlReader.GetValueAsBool(PLUGIN_NAME, "AutoActivate", false); + + AutoActivateTime = System.DateTime.ParseExact(xmlReader.GetValueAsString(PLUGIN_NAME, "AutoActivateTime", "00:00:00"), "HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture); + } WriteToLog(); @@ -126,6 +138,9 @@ xmlWriter.SetValue(PLUGIN_NAME, "Step", SleepTimeStep); xmlWriter.SetValue(PLUGIN_NAME, "NotifyBeforeSleep", NotifyBeforeSleep); xmlWriter.SetValue(PLUGIN_NAME, "NotifyTimeOut", NotifyTimeOutMs); + + xmlWriter.SetValueAsBool(PLUGIN_NAME, "AutoActivate", AutoActivate); + xmlWriter.SetValue(PLUGIN_NAME, "AutoActivateTime", AutoActivateTime.ToString("HH:mm:ss")); } } Modified: trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Window/MySleepTimer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Window/MySleepTimer.cs 2015-01-12 06:59:42 UTC (rev 4926) +++ trunk/plugins/MySleepTimer/MySleepTimer/Plugin/Window/MySleepTimer.cs 2015-01-28 20:02:42 UTC (rev 4927) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using Timer = System.Timers.Timer; using System.Windows.Forms; using MediaPortal.Configuration; @@ -144,11 +145,13 @@ private Timer NotificationTimer { get; set; } private string ShutDownType { get; set; } private LinkedList<String> ShutDownIterator { get; set; } + private System.Threading.Timer AutoActivateTimer; public MySleepTimer() { Settings.Load(); SetupStateMachine(); - + + ShutDownType = Settings.SleepBehavior == "Shutdown" ? Settings.ShutdownType.ToString() : Settings.SleepBehavior; ShutDownIterator = new LinkedList<String>(); foreach (string option in Enum.GetNames(typeof(RestartOptions))) { @@ -161,8 +164,74 @@ ShutDownIterator.AddLast("Exit MediaPortal"); ShutDownIterator.AddLast("Show Basic Home"); GUIWindowManager.OnNewAction += GUIWindowManager_OnNewAction; + + if (Settings.AutoActivate) + { + //Auto Activate Feature enabled -> start timer for auto activate + Log.Info("MySleepTimer: AutoActivate enabled, trigger at " + Settings.AutoActivateTime.Hour.ToString("D2") + ":" + Settings.AutoActivateTime.Minute.ToString("D2") + ":" + Settings.AutoActivateTime.Second.ToString("D2")); + SetAutoActivateTimerValue(); + } + else + { + Log.Info("MySleepTimer: AutoActivate disabled"); + } + } + + + private void SetAutoActivateTimerValue() + { + // trigger the event at the given hour and minute + TimeSpan span; + DateTime requiredTime = DateTime.Today.AddHours(Settings.AutoActivateTime.Hour).AddMinutes(Settings.AutoActivateTime.Minute); + if (DateTime.Now > requiredTime) + { + requiredTime = requiredTime.AddDays(1); + } + + // initialize timer only, do not specify the start time or the interval + AutoActivateTimer = new System.Threading.Timer(new TimerCallback(AutoActivateTimerCallback)); + // first parameter is the start time and the second parameter is the interval + // Timeout.Infinite means do not repeat the interval, only start the timer + AutoActivateTimer.Change((int)(requiredTime - DateTime.Now).TotalMilliseconds, Timeout.Infinite); + + //Debug + span = requiredTime.Subtract(DateTime.Now); + Log.Info("MySleepTimer: SetAutoActivateTimerValue, remaining time to next auto activate: " + span.Hours.ToString("D2") + ":" + span.Minutes.ToString("D2") + ":" + span.Seconds.ToString("D2")); + } + + private void AutoActivateTimerCallback(object e) + { + // start SleepTimer + if (ShutDownTimer.Enabled) + { + Log.Info("MySleepTimer: AutoActivateTimerCallback, shutdown timer already running -> skip activate!"); + } + else + { + //Fire Trigger event + GUIGraphicsContext.form.Invoke(new MethodInvoker(AutoActivateShutdownTimer)); + } + + // call the set timer method to reset its next call time (ex. next day) + SetAutoActivateTimerValue(); + } + + + private void AutoActivateShutdownTimer() + { + if (_mySleepTimer.CanFire(Trigger.ButtonSet)) + { + _mySleepTimer.Fire(Trigger.ButtonSet); + Log.Info("MySleepTimer: AutoActivateShutdownTimer: Shutdown Timer set to " + Settings.SleepTimeStep.ToString() + " minutes!"); + } + else + { + Log.Warn("MySleepTimer: AutoActivateShutdownTimer: could not fire Trigger.ButtonSet!!!"); + } + } + void TimerShutDown_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (_mySleepTimer.CanFire(Trigger.SleepTimerElapsed)) { _mySleepTimer.Fire(Trigger.SleepTimerElapsed); @@ -280,7 +349,10 @@ void SleepTimerOnEntry() { double currentRemaining = GetRemainingPlaytime(); - if (currentRemaining <= 0) { + //pOpY 26.01.2015 - currentRemaining must be > Settings.SleepTimeStep that it will be accepted. + // TODO: GetRemainingPlaytime() should also return the correct remaining time if livetv is running. Then the following check could be "<= 0" + if (currentRemaining <= Settings.SleepTimeStep * 60 * 1000) + { currentRemaining = Settings.SleepTimeStep * 60 * 1000; } Shutdown = DateTime.Now.AddMilliseconds(currentRemaining); @@ -368,7 +440,6 @@ private void ShowNotifyDialog(int timeOutMs, string notifyMessage) { try { - timeOutMs /= 1000; //to seconds GUIDialogNotify _dialogSleepTimerNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); _dialogSleepTimerNotify.TimeOut = timeOutMs; _dialogSleepTimerNotify.SetImage(GUIGraphicsContext.Skin + @"\Media\MySleepTimer_enabled.png"); Added: trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer/Properties/AssemblyInfo.cs 2015-01-28 20:02:42 UTC (rev 4927) @@ -0,0 +1,61 @@ +#region Copyright (C) 2005-2010 Team MediaPortal + +// Copyright (C) 2005-2010 Team MediaPortal +// http://www.team-mediaportal.com +// +// 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 of the License, or +// (at your option) any later version. +// +// 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 MediaPortal. If not, see <http://www.gnu.org/licenses/>. + +#endregion + +using System.Reflection; +using System.Runtime.InteropServices; + +using MediaPortal.Common.Utils; + +// 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. + +[assembly: CompatibleVersion("1.1.7.0")] +[assembly: AssemblyTitle("MySleepTimer")] +[assembly: AssemblyDescription("MediaPortal Plugin - Sleep Timer")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Anthrax")] +[assembly: AssemblyProduct("MySleepTimer")] +[assembly: AssemblyCopyright("Copyright \xA9 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("216cf21b-9128-47a1-bd0f-33baa87b887f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("2.0.3.0")] +[assembly: AssemblyFileVersion("2.0.3.0")] \ No newline at end of file Added: trunk/plugins/MySleepTimer/MySleepTimer.sln =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer.sln (rev 0) +++ trunk/plugins/MySleepTimer/MySleepTimer.sln 2015-01-28 20:02:42 UTC (rev 4927) @@ -0,0 +1,33 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 11 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySleepTimer", "MySleepTimer\MySleepTimer.csproj", "{03856C9E-0926-41DB-A13A-AE3D08285428}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03856C9E-0926-41DB-A13A-AE3D08285428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Debug|x86.ActiveCfg = Debug|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Release|Any CPU.Build.0 = Release|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {03856C9E-0926-41DB-A13A-AE3D08285428}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + VisualSVNWorkingCopyRoot = . + EndGlobalSection +EndGlobal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |