From: <che...@us...> - 2009-07-15 02:54:44
|
Revision: 3014 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3014&view=rev Author: chef_koch Date: 2009-07-15 02:54:41 +0000 (Wed, 15 Jul 2009) Log Message: ----------- using LoadSettings and SaveSettings using buttons for dialog result for ok and cancel button Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.resx trunk/plugins/MyAlarm/MyAlarm/SetupForm.Designer.cs trunk/plugins/MyAlarm/MyAlarm/SetupForm.cs trunk/plugins/MyAlarm/MyAlarm/SetupForm.resx trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -31,6 +31,7 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FritzBoxConfig)); this.tabControlFritzBoxSettings = new MediaPortal.UserInterface.Controls.MPTabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); + this.labelHelp = new System.Windows.Forms.TextBox(); this.checkBoxExtensiveLogging = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.mpGroupBox1 = new MediaPortal.UserInterface.Controls.MPGroupBox(); this.mpButton1 = new MediaPortal.UserInterface.Controls.MPButton(); @@ -81,10 +82,8 @@ this.labelCallerId = new MediaPortal.UserInterface.Controls.MPLabel(); this.labelCallerName = new MediaPortal.UserInterface.Controls.MPLabel(); this.labelVersion = new MediaPortal.UserInterface.Controls.MPLabel(); - this.buttonSave = new MediaPortal.UserInterface.Controls.MPButton(); - this.buttonCancel = new MediaPortal.UserInterface.Controls.MPButton(); - this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.labelHelp = new System.Windows.Forms.TextBox(); + this.okButton = new MediaPortal.UserInterface.Controls.MPButton(); + this.cancelButton = new MediaPortal.UserInterface.Controls.MPButton(); this.tabControlFritzBoxSettings.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.mpGroupBox1.SuspendLayout(); @@ -129,6 +128,18 @@ this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // + // labelHelp + // + this.labelHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelHelp.Location = new System.Drawing.Point(6, 161); + this.labelHelp.Multiline = true; + this.labelHelp.Name = "labelHelp"; + this.labelHelp.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.labelHelp.Size = new System.Drawing.Size(561, 190); + this.labelHelp.TabIndex = 7; + // // checkBoxExtensiveLogging // this.checkBoxExtensiveLogging.AutoSize = true; @@ -733,54 +744,46 @@ this.labelVersion.TabIndex = 17; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // buttonSave + // okButton // - this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.Location = new System.Drawing.Point(436, 402); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(75, 25); - this.buttonSave.TabIndex = 15; - this.buttonSave.Text = "Save"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.Location = new System.Drawing.Point(436, 402); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 25); + this.okButton.TabIndex = 15; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); // - // buttonCancel + // cancelButton // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.Location = new System.Drawing.Point(517, 402); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 25); - this.buttonCancel.TabIndex = 16; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + 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(517, 402); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 25); + this.cancelButton.TabIndex = 16; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // - // labelHelp - // - this.labelHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.labelHelp.Location = new System.Drawing.Point(6, 161); - this.labelHelp.Multiline = true; - this.labelHelp.Name = "labelHelp"; - this.labelHelp.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.labelHelp.Size = new System.Drawing.Size(561, 190); - this.labelHelp.TabIndex = 7; - // // FritzBoxConfig // + 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(602, 439); this.Controls.Add(this.tabControlFritzBoxSettings); this.Controls.Add(this.labelVersion); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FritzBoxConfig"; + this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "FRITZ!Box configuration"; this.tabControlFritzBoxSettings.ResumeLayout(false); @@ -849,9 +852,8 @@ private MediaPortal.UserInterface.Controls.MPLabel labelCallerId; private MediaPortal.UserInterface.Controls.MPLabel labelCallerName; private MediaPortal.UserInterface.Controls.MPLabel labelVersion; - private MediaPortal.UserInterface.Controls.MPButton buttonSave; - private MediaPortal.UserInterface.Controls.MPButton buttonCancel; - private System.Windows.Forms.OpenFileDialog openFileDialog; + private MediaPortal.UserInterface.Controls.MPButton okButton; + private MediaPortal.UserInterface.Controls.MPButton cancelButton; private MediaPortal.UserInterface.Controls.MPNumericUpDown numericUpDownMaxNotifies; private MediaPortal.UserInterface.Controls.MPLabel lblMaxNotifies; private System.Windows.Forms.NumericUpDown numericUpDownPort; Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -34,10 +34,11 @@ public FritzBoxConfig() { InitializeComponent(); - LoadSettings(); } + #region Settings + private void LoadSettings() { labelVersion.Text = "v" + FritzBox.VERSION; @@ -125,8 +126,11 @@ Settings.Save(); } + #endregion - private void buttonSave_Click(object sender, EventArgs e) + #region Windows Forms events + + private void okButton_Click(object sender, EventArgs e) { SaveSettings(); FritzBoxClient.StopClient(); @@ -134,13 +138,14 @@ Close(); } - private void buttonCancel_Click(object sender, EventArgs e) + private void cancelButton_Click(object sender, EventArgs e) { FritzBoxClient.StopClient(); FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); Close(); } + private void checkBoxCloseOnTimout_CheckedChanged(object sender, EventArgs e) { numericUpDownTimeout.Enabled = checkBoxCloseOnTimout.Checked; @@ -164,7 +169,7 @@ checkBoxSaveUnknownCaller.Enabled = checkBoxUsePhonebook.Checked; } - + private void buttonMSNsAdd_Click(object sender, EventArgs e) { if (isMSNvalid(comboBoxMSNs.Text) == true) @@ -182,25 +187,6 @@ } - private bool isMSNvalid(string msn) - { - string msg = ""; - - if (msn.Length == 0) - msg += "No MSN specified. Some numbers/characters are needed.\n"; - if (msn.Contains(";")) - msg += "A ';' ist not allowed.\n"; - - if (msg == "") - return true; - else - { - MessageBox.Show(msg); - return false; - } - } - - private void buttonCallerChange_Click(object sender, EventArgs e) { if (!CheckCallerId()) return; @@ -239,39 +225,6 @@ } } - private bool CheckCallerId() - { - if (textBoxCallerId.Text.Length == 0) - { - textBoxCallerId.Focus(); - MessageBox.Show("CallerID is empty. Please type in the correct CallerID."); - return false; - } - - if (dataGridView.Rows[dataGridView.NewRowIndex].Selected) - for (int i = 0; i < dataGridView.Rows.Count - 1; i++) - if (textBoxCallerId.Text == dataGridView.Rows[i].Cells[0].Value.ToString()) - { - textBoxCallerId.Focus(); - MessageBox.Show("CallerID already exists in phonebook. Please check and change the id."); - return false; - } - - return true; - } - - private bool CheckCallerName() - { - if (textBoxCallerName.Text.Length == 0) - { - textBoxCallerName.Focus(); - MessageBox.Show("Name is empty. Please type the name to display for this CallerID."); - return false; - } - - return true; - } - private void buttonCallerRemove_Click(object sender, EventArgs e) { if ((!dataGridView.Rows[dataGridView.NewRowIndex].Selected) && (dataGridView.SelectedRows.Count > 0)) @@ -305,6 +258,7 @@ private void mpImportFBMonitor_Click(object sender, EventArgs e) { + OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { int count = PhoneBook.ImportFritzBoxMonitor(openFileDialog.FileName); @@ -314,32 +268,6 @@ } } - private void RefreshDataGridView() - { - dataGridView.Rows.Clear(); - - for (int i = 0; i < PhoneBook.Contacts.Count; i++) - { - dataGridView.Rows.Add(PhoneBook.Contacts[i].ID, PhoneBook.Contacts[i].Name, PhoneBook.Contacts[i].Show); - } - } - - private void SaveDataGridView() - { - PhoneBook.Contacts.Clear(); - - for (int i = 0; i < dataGridView.RowCount - 1; i++) - { - Caller caller = new Caller(); - - caller.ID = dataGridView.Rows[i].Cells[0].Value.ToString(); - caller.Name = dataGridView.Rows[i].Cells[1].Value.ToString(); - caller.Show = bool.Parse(dataGridView.Rows[i].Cells[2].Value.ToString()); - - PhoneBook.Contacts.Add(caller); - } - } - private void dataGridView_Sorted(object sender, EventArgs e) { SaveDataGridView(); @@ -361,20 +289,7 @@ } } - private void OnLogAction(FritzBoxClient.LogLevel logLevel, string logMessage) - { - if (labelHelp.InvokeRequired) - { - SetTextCallback d = new SetTextCallback(OnLogAction); - Invoke(d, new object[] {logLevel, logMessage}); - } - else - { - labelHelp.Text += logMessage + Environment.NewLine; - } - } - private void mpButton1_Click(object sender, EventArgs e) { FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); @@ -388,7 +303,7 @@ // set current used text FritzBoxClient.Address = textBoxAddress.Text; - FritzBoxClient.Port = (int) numericUpDownPort.Value; + FritzBoxClient.Port = (int)numericUpDownPort.Value; // port test if (!FritzBoxClient.TestConnection()) @@ -397,5 +312,97 @@ // start client FritzBoxClient.StartClient(); } + + #endregion + + private bool isMSNvalid(string msn) + { + string msg = ""; + + if (msn.Length == 0) + msg += "No MSN specified. Some numbers/characters are needed.\n"; + if (msn.Contains(";")) + msg += "A ';' ist not allowed.\n"; + + if (msg == "") + return true; + else + { + MessageBox.Show(msg); + return false; + } + } + + private bool CheckCallerId() + { + if (textBoxCallerId.Text.Length == 0) + { + textBoxCallerId.Focus(); + MessageBox.Show("CallerID is empty. Please type in the correct CallerID."); + return false; + } + + if (dataGridView.Rows[dataGridView.NewRowIndex].Selected) + for (int i = 0; i < dataGridView.Rows.Count - 1; i++) + if (textBoxCallerId.Text == dataGridView.Rows[i].Cells[0].Value.ToString()) + { + textBoxCallerId.Focus(); + MessageBox.Show("CallerID already exists in phonebook. Please check and change the id."); + return false; + } + + return true; + } + + private bool CheckCallerName() + { + if (textBoxCallerName.Text.Length == 0) + { + textBoxCallerName.Focus(); + MessageBox.Show("Name is empty. Please type the name to display for this CallerID."); + return false; + } + + return true; + } + + private void RefreshDataGridView() + { + dataGridView.Rows.Clear(); + + for (int i = 0; i < PhoneBook.Contacts.Count; i++) + { + dataGridView.Rows.Add(PhoneBook.Contacts[i].ID, PhoneBook.Contacts[i].Name, PhoneBook.Contacts[i].Show); + } + } + + private void SaveDataGridView() + { + PhoneBook.Contacts.Clear(); + + for (int i = 0; i < dataGridView.RowCount - 1; i++) + { + Caller caller = new Caller(); + + caller.ID = dataGridView.Rows[i].Cells[0].Value.ToString(); + caller.Name = dataGridView.Rows[i].Cells[1].Value.ToString(); + caller.Show = bool.Parse(dataGridView.Rows[i].Cells[2].Value.ToString()); + + PhoneBook.Contacts.Add(caller); + } + } + + private void OnLogAction(FritzBoxClient.LogLevel logLevel, string logMessage) + { + if (labelHelp.InvokeRequired) + { + SetTextCallback d = new SetTextCallback(OnLogAction); + Invoke(d, new object[] {logLevel, logMessage}); + } + else + { + labelHelp.Text += logMessage + Environment.NewLine; + } + } } } \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.resx =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.resx 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.resx 2009-07-15 02:54:41 UTC (rev 3014) @@ -126,9 +126,6 @@ <metadata name="colShow.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> - <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>17, 17</value> - </metadata> <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> Modified: trunk/plugins/MyAlarm/MyAlarm/SetupForm.Designer.cs =================================================================== --- trunk/plugins/MyAlarm/MyAlarm/SetupForm.Designer.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/MyAlarm/MyAlarm/SetupForm.Designer.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -404,7 +404,7 @@ this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(432, 271); + this.tabPage2.Size = new System.Drawing.Size(432, 268); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "tabPage2"; this.tabPage2.UseVisualStyleBackColor = true; @@ -698,6 +698,7 @@ this.Controls.Add(this.okButton); this.Controls.Add(this.tabControl1); this.Name = "SetupForm"; + this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Alarm - Setup"; ((System.ComponentModel.ISupportInitialize)(this.RepeatCount)).EndInit(); Modified: trunk/plugins/MyAlarm/MyAlarm/SetupForm.cs =================================================================== --- trunk/plugins/MyAlarm/MyAlarm/SetupForm.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/MyAlarm/MyAlarm/SetupForm.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -36,6 +36,8 @@ LoadSettings(); } + #region Settings + /// <summary> /// Loads my alarm settings from the profile xml. /// </summary> @@ -59,8 +61,6 @@ //alarmBindingSource.DataSource = Settings.Alarms; } - public Alarm CurrentAlarm { get; set; } - /// <summary> /// Saves my alarm settings to the profile xml. /// </summary> @@ -68,9 +68,9 @@ { Settings.AlarmSoundPath = soundsFolderTextBox.Text; - Settings.AlarmTimeout = (int) NUDAlarmTimeout.Value; - Settings.RepeatSeconds = (int) RepeatSeconds.Value; - Settings.RepeatCount = (int) RepeatCount.Value; + Settings.AlarmTimeout = (int)NUDAlarmTimeout.Value; + Settings.RepeatSeconds = (int)RepeatSeconds.Value; + Settings.RepeatCount = (int)RepeatCount.Value; Settings.SetVolume = chkEnableDefaultVol.Checked; Settings.VolumeLevel = ConvertPercentageToRealVolume(NUDAlarmVol.Value); @@ -78,41 +78,10 @@ Settings.Save(); } - /// <summary> - /// Converts the real volume value into a volume percentage - /// </summary> - /// <param name="realVolume">real volume value</param> - /// <returns></returns> - private static int ConvertRealVolumeToPercentage(decimal realVolume) - { - decimal tmpVolume; - VolumeHandler volumeHandler = new VolumeHandler(); - tmpVolume = realVolume; - tmpVolume = tmpVolume / (volumeHandler.Maximum - volumeHandler.Minimum); - tmpVolume = tmpVolume * 100; - return (int) Math.Round(tmpVolume, 0); - } + #endregion - /// <summary> - /// Converts the volume percentage into a real volume value - /// </summary> - /// <param name="percentVolume">volume percentage value, e.g. 50</param> - /// <returns></returns> - private static int ConvertPercentageToRealVolume(decimal percentVolume) - { - VolumeHandler volumeHandler = new VolumeHandler(); + #region Windows Forms events - decimal tmpVolume; - tmpVolume = percentVolume; - tmpVolume = tmpVolume / 100; - tmpVolume = tmpVolume * (volumeHandler.Maximum - volumeHandler.Minimum); - tmpVolume = tmpVolume + volumeHandler.Minimum; - - return (int) Math.Round(tmpVolume, 0); - } - - #region WindowsForms events - private void okButton_Click(object sender, EventArgs e) { SaveSettings(); @@ -124,6 +93,7 @@ Close(); } + private void browseSoundFolderButton_Click(object sender, EventArgs e) { FolderBrowserDialog fd = new FolderBrowserDialog(); @@ -173,5 +143,40 @@ } #endregion + + public Alarm CurrentAlarm { get; set; } + + /// <summary> + /// Converts the real volume value into a volume percentage + /// </summary> + /// <param name="realVolume">real volume value</param> + /// <returns></returns> + private static int ConvertRealVolumeToPercentage(decimal realVolume) + { + decimal tmpVolume; + VolumeHandler volumeHandler = new VolumeHandler(); + tmpVolume = realVolume; + tmpVolume = tmpVolume / (volumeHandler.Maximum - volumeHandler.Minimum); + tmpVolume = tmpVolume * 100; + return (int) Math.Round(tmpVolume, 0); + } + + /// <summary> + /// Converts the volume percentage into a real volume value + /// </summary> + /// <param name="percentVolume">volume percentage value, e.g. 50</param> + /// <returns></returns> + private static int ConvertPercentageToRealVolume(decimal percentVolume) + { + VolumeHandler volumeHandler = new VolumeHandler(); + + decimal tmpVolume; + tmpVolume = percentVolume; + tmpVolume = tmpVolume / 100; + tmpVolume = tmpVolume * (volumeHandler.Maximum - volumeHandler.Minimum); + tmpVolume = tmpVolume + volumeHandler.Minimum; + + return (int) Math.Round(tmpVolume, 0); + } } } \ No newline at end of file Modified: trunk/plugins/MyAlarm/MyAlarm/SetupForm.resx =================================================================== --- trunk/plugins/MyAlarm/MyAlarm/SetupForm.resx 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/MyAlarm/MyAlarm/SetupForm.resx 2009-07-15 02:54:41 UTC (rev 3014) @@ -120,9 +120,6 @@ <metadata name="alarmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> - <metadata name="alarmBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>17, 17</value> - </metadata> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>43</value> </metadata> Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.Designer.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -50,8 +50,8 @@ 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(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNotifyInterval)).BeginInit(); @@ -349,38 +349,38 @@ this.groupBoxTimer.TabStop = false; this.groupBoxTimer.Text = "Timer && notify settings"; // - // buttonClose + // cancelButton // - 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); + 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(263, 341); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 58; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // - // buttonSave + // okButton // - 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); + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.Location = new System.Drawing.Point(182, 341); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 59; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); // // MySleepTimerConfig // - this.AcceptButton = this.buttonSave; + this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.buttonClose; + this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(350, 372); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.buttonClose); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); this.Controls.Add(this.groupBoxTimer); this.Controls.Add(this.groupBox1); this.Controls.Add(this.comboBoxSleepBehavior); @@ -390,6 +390,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "MySleepTimerConfig"; this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "MySleepTimer - Configuration"; ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeMax)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSleepTimeStep)).EndInit(); @@ -430,7 +431,7 @@ 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; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button okButton; } } \ No newline at end of file Modified: trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs =================================================================== --- trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-07-15 01:31:10 UTC (rev 3013) +++ trunk/plugins/MySleepTimer/MySleepTimer/MySleepTimerConfig.cs 2009-07-15 02:54:41 UTC (rev 3014) @@ -22,28 +22,23 @@ using System; using System.Collections.Generic; +using System.Windows.Forms; using MediaPortal.GUI.Library; -using MediaPortal.UserInterface.Controls; using MediaPortal.Util; namespace MySleepTimer { - public partial class MySleepTimerConfig : MPConfigForm + public partial class MySleepTimerConfig : Form { public MySleepTimerConfig() { - try - { - InitializeComponent(); - Load += new EventHandler(MySleepTimerConfig_Load); - } - catch (Exception ex) - { - Log.Error(ex); - } + InitializeComponent(); + LoadSettings(); } - private void MySleepTimerConfig_Load(object sender, EventArgs e) + #region Settings + + private void LoadSettings() { try { @@ -78,6 +73,40 @@ } } + private void SaveSettings() + { + Settings.ActionType = (Action.ActionType)comboBoxActionType.SelectedValue; + Settings.SleepBehavior = comboBoxSleepBehavior.Text; + + 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(); + } + + #endregion + + #region Windows Forms events + + private void okButton_Click(object sender, EventArgs e) + { + SaveSettings(); + Close(); + } + + private void cancelButton_Click(object sender, EventArgs e) + { + Close(); + } + + private void comboBoxSleepBehavior_SelectedIndexChanged(object sender, EventArgs e) { SetUpShutDownTypeControls(); @@ -98,31 +127,8 @@ SetUpNotifyControls(); } - private void buttonSave_Click(object sender, EventArgs e) - { - Settings.ActionType = (Action.ActionType) comboBoxActionType.SelectedValue; - Settings.SleepBehavior = comboBoxSleepBehavior.Text; + #endregion - 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>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |