From: <lk...@us...> - 2008-02-07 08:27:39
|
Revision: 1341 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1341&view=rev Author: lkuech Date: 2008-02-07 00:27:37 -0800 (Thu, 07 Feb 2008) Log Message: ----------- ViewModeSwitcher: Implemented a Import/Export function for the complete settings Modified Paths: -------------- trunk/plugins/ViewModeSwitcher/Settings.cs trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.Designer.cs trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.cs trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.resx Modified: trunk/plugins/ViewModeSwitcher/Settings.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/Settings.cs 2008-02-05 09:42:35 UTC (rev 1340) +++ trunk/plugins/ViewModeSwitcher/Settings.cs 2008-02-07 08:27:37 UTC (rev 1341) @@ -110,14 +110,25 @@ return ret; } + public bool LoadSettings() + { + return LoadSettings(string.Empty); + } + /// <summary> /// load settings from MediaPortal configuration /// </summary> /// <returns></returns> - public bool LoadSettings() + public bool LoadSettings(string ImportFileName) { - using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "MediaPortal.xml"); + if (ImportFileName != string.Empty) { + tmpConfigFileName = ImportFileName; + } + + using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(tmpConfigFileName)) + { bool tmpReturn = false; ViewModeRules.Clear(); int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0); @@ -185,8 +196,19 @@ public void SaveSettings() { - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + SaveSettings(string.Empty); + } + + public void SaveSettings(string ExportFileName) + { + string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "MediaPortal.xml"); + if (ExportFileName != string.Empty) { + tmpConfigFileName = ExportFileName; + } + + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(tmpConfigFileName)) + { xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, verboseLog); xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, ShowSwitchMsg); xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmRescanRulesAfterChannelChange, RescanRulesAfterChannelChange); @@ -243,6 +265,8 @@ xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmVOffsetZoom, VerticalOffSetZoom.ToString()); xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmVOffset14_9, VerticalOffSet14_9.ToString()); xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmVOffsetWide14_9, VerticalOffSetWide14_9.ToString()); + + if (ExportFileName != string.Empty) MediaPortal.Profile.Settings.SaveCache(); } } Modified: trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.Designer.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.Designer.cs 2008-02-05 09:42:35 UTC (rev 1340) +++ trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.Designer.cs 2008-02-07 08:27:37 UTC (rev 1341) @@ -50,6 +50,7 @@ { this.bOK = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.cbRescanRulesAfterChannelChange = new System.Windows.Forms.CheckBox(); this.cmbViewMode = new System.Windows.Forms.ComboBox(); this.cbUseFallbackRule = new System.Windows.Forms.CheckBox(); this.label1 = new System.Windows.Forms.Label(); @@ -112,7 +113,10 @@ this.label16 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label(); - this.cbRescanRulesAfterChannelChange = new System.Windows.Forms.CheckBox(); + this.bImport = new System.Windows.Forms.Button(); + this.bExport = new System.Windows.Forms.Button(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dg_RuleSets)).BeginInit(); this.groupBox2.SuspendLayout(); @@ -150,6 +154,16 @@ this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; // + // cbRescanRulesAfterChannelChange + // + this.cbRescanRulesAfterChannelChange.AutoSize = true; + this.cbRescanRulesAfterChannelChange.Location = new System.Drawing.Point(6, 243); + this.cbRescanRulesAfterChannelChange.Name = "cbRescanRulesAfterChannelChange"; + this.cbRescanRulesAfterChannelChange.Size = new System.Drawing.Size(192, 17); + this.cbRescanRulesAfterChannelChange.TabIndex = 10; + this.cbRescanRulesAfterChannelChange.Text = "Rescan rules after channel change"; + this.cbRescanRulesAfterChannelChange.UseVisualStyleBackColor = true; + // // cmbViewMode // this.cmbViewMode.Enabled = false; @@ -776,21 +790,37 @@ this.label19.TabIndex = 34; this.label19.Text = "!"; // - // cbRescanRulesAfterChannelChange + // bImport // - this.cbRescanRulesAfterChannelChange.AutoSize = true; - this.cbRescanRulesAfterChannelChange.Location = new System.Drawing.Point(6, 243); - this.cbRescanRulesAfterChannelChange.Name = "cbRescanRulesAfterChannelChange"; - this.cbRescanRulesAfterChannelChange.Size = new System.Drawing.Size(192, 17); - this.cbRescanRulesAfterChannelChange.TabIndex = 10; - this.cbRescanRulesAfterChannelChange.Text = "Rescan rules after channel change"; - this.cbRescanRulesAfterChannelChange.UseVisualStyleBackColor = true; + this.bImport.Location = new System.Drawing.Point(543, 461); + this.bImport.Name = "bImport"; + this.bImport.Size = new System.Drawing.Size(88, 23); + this.bImport.TabIndex = 35; + this.bImport.Text = "Import Settings"; + this.bImport.UseVisualStyleBackColor = true; + this.bImport.Click += new System.EventHandler(this.bImport_Click); // + // bExport + // + this.bExport.Location = new System.Drawing.Point(444, 461); + this.bExport.Name = "bExport"; + this.bExport.Size = new System.Drawing.Size(93, 23); + this.bExport.TabIndex = 36; + this.bExport.Text = "Export Settings"; + this.bExport.UseVisualStyleBackColor = true; + this.bExport.Click += new System.EventHandler(this.bExport_Click); + // + // openFileDialog + // + this.openFileDialog.FileName = "openFileDialog1"; + // // ViewModeSwitcherConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(794, 496); + this.Controls.Add(this.bExport); + this.Controls.Add(this.bImport); this.Controls.Add(this.groupBox2); this.Controls.Add(this.label17); this.Controls.Add(this.label16); @@ -883,5 +913,9 @@ private System.Windows.Forms.CheckBox cbUseFallbackRule; private System.Windows.Forms.ComboBox cmbViewMode; private System.Windows.Forms.CheckBox cbRescanRulesAfterChannelChange; + private System.Windows.Forms.Button bImport; + private System.Windows.Forms.Button bExport; + private System.Windows.Forms.OpenFileDialog openFileDialog; + private System.Windows.Forms.SaveFileDialog saveFileDialog; } } \ No newline at end of file Modified: trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.cs 2008-02-05 09:42:35 UTC (rev 1340) +++ trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.cs 2008-02-07 08:27:37 UTC (rev 1341) @@ -41,10 +41,8 @@ LoadSettings(); } - public void LoadSettings() + public void RefreshFormComponents() { - currentSettings.LoadSettings(); - this.cbVerboseLog.Checked = currentSettings.verboseLog; this.cbShowSwitchMsg.Checked = currentSettings.ShowSwitchMsg; this.cbRescanRulesAfterChannelChange.Checked = currentSettings.RescanRulesAfterChannelChange; @@ -76,9 +74,14 @@ cbLBOverScan.Checked = currentSettings.LBOverScanEnabled; txtLBOverScan.Text = currentSettings.LBOberScan.ToString(); - } + public void LoadSettings() + { + currentSettings.LoadSettings(); + RefreshFormComponents(); + } + public void SaveSettings() { currentSettings.verboseLog = cbVerboseLog.Checked; @@ -110,7 +113,6 @@ currentSettings.LBOberScan = Convert.ToInt16(txtLBOverScan.Text); currentSettings.SaveSettings(); - } /// <summary> @@ -246,6 +248,36 @@ cmbViewMode.Enabled = cbUseFallbackRule.Checked; } + private void bExport_Click(object sender, EventArgs e) + { + saveFileDialog.AddExtension = true; + //saveFileDialog.DefaultExt = "VmsSettings"; + saveFileDialog.Filter = "ViewModeSwitcher config (*.VmsSettings)|*.VmsSettings|All files (*.*)|*.*"; + saveFileDialog.FilterIndex = 0; + saveFileDialog.InitialDirectory = Config.GetSubFolder(Config.Dir.Plugins, "Process"); + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + SaveSettings(); // make sure all settings are stored before + currentSettings.SaveSettings(saveFileDialog.FileName); + } + } + private void bImport_Click(object sender, EventArgs e) + { + openFileDialog.AddExtension = true; + openFileDialog.Filter = "ViewModeSwitcher config (*.VmsSettings)|*.VmsSettings|All files (*.*)|*.*"; + openFileDialog.FilterIndex = 0; + openFileDialog.InitialDirectory = Config.GetSubFolder(Config.Dir.Plugins, "Process"); + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (!currentSettings.LoadSettings(openFileDialog.FileName)) + { + MessageBox.Show("Import Error!"); + } + else RefreshFormComponents(); // refresh the form + } + } + + } } \ No newline at end of file Modified: trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.resx =================================================================== --- trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.resx 2008-02-05 09:42:35 UTC (rev 1340) +++ trunk/plugins/ViewModeSwitcher/ViewModeSwitcherConfig.resx 2008-02-07 08:27:37 UTC (rev 1341) @@ -156,4 +156,49 @@ <metadata name="ColEnableLBDetect.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> + <metadata name="ColEnabled.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColRuleName.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColARFrom.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColARTo.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColMinWidth.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColMaxWidth.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColMinHeight.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColMaxHeight.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColChangeAR.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColViewMode.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColChangeOS.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColOverscan.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="ColEnableLBDetect.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> + <metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>157, 17</value> + </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |