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. |