From 22cc39124c83b724028d34055d5de0d7ea98ba9f Mon Sep 17 00:00:00 2001 From: Multithread Date: Sat, 20 Jun 2015 18:21:17 +0200 Subject: [PATCH] =?UTF-8?q?Version=202.0=20Mit=20=C3=A4nderbarem=20Einstel?= =?UTF-8?q?lungen=20Download=20Pfad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataWorker/CalculatorSettingsFile.cs | 29 ++++- .../DataWorker/PSUCalculatorSettings.cs | 34 ++--- PSU_Calculator/Dateizugriffe/StorageMapper.cs | 4 +- PSU_Calculator/Forms/InputFeld.Designer.cs | 76 +++++++++++ PSU_Calculator/Forms/InputFeld.cs | 64 ++++++++++ PSU_Calculator/Forms/InputFeld.resx | 120 ++++++++++++++++++ PSU_Calculator/Forms/MainForm.Designer.cs | 22 +++- PSU_Calculator/Forms/MainForm.cs | 31 ++++- PSU_Calculator/PSU_Calculator.csproj | 18 +-- .../Properties/Einstellungen.Designer.cs | 50 -------- .../Properties/Einstellungen.settings | 12 -- PSU_Calculator/Updater.cs | 104 +++++++-------- 12 files changed, 416 insertions(+), 148 deletions(-) create mode 100644 PSU_Calculator/Forms/InputFeld.Designer.cs create mode 100644 PSU_Calculator/Forms/InputFeld.cs create mode 100644 PSU_Calculator/Forms/InputFeld.resx delete mode 100644 PSU_Calculator/Properties/Einstellungen.Designer.cs delete mode 100644 PSU_Calculator/Properties/Einstellungen.settings diff --git a/PSU_Calculator/DataWorker/CalculatorSettingsFile.cs b/PSU_Calculator/DataWorker/CalculatorSettingsFile.cs index b459dd7..b7a45a9 100644 --- a/PSU_Calculator/DataWorker/CalculatorSettingsFile.cs +++ b/PSU_Calculator/DataWorker/CalculatorSettingsFile.cs @@ -35,11 +35,23 @@ private CalculatorSettingsFile() private Updater updater; private bool hasChanged = false; + public bool HasChanged + { + get + { + return hasChanged; + } + set + { + hasChanged = value; + } + } + public void Load() { if (!FileExists(PSUCalculatorSettings.Einstellungen)) { - return; + new Updater().RunUpdateSyncroniced(); } settings = StorageMapper.GetXML(PSUCalculatorSettings.GetFilePath(PSUCalculatorSettings.Einstellungen)); @@ -55,13 +67,20 @@ public void Load() versionFileDict.Add(name, ver); } } + if (settings.getElementByName(PSUCalculatorSettings.Einstellungen)!=null) + { + if (!string.IsNullOrWhiteSpace(settings.getElementByName(PSUCalculatorSettings.Einstellungen).Text)) + { + AddDownloadableFile(PSUCalculatorSettings.Einstellungen, settings.getElementByName(PSUCalculatorSettings.Einstellungen).Text.Trim()); + } + } updater.FileVersions = versionFileDict; updater.FilesToUpdate = updateFileDict; } /// - /// gibt einen Boolschen wert asu dem Settings Element zurück. + /// gibt einen Boolschen wert aus dem Settings Element zurück. /// /// /// @@ -107,7 +126,10 @@ public void SaveSettings() public double GetVersionForFile(string filename) { double outvalue; - if (versionFileDict.TryGetValue(filename, out outvalue)) + string value= settings.getElementByPfadOnCreate(PSUCalculatorSettings.Version). + getElementByPfadOnCreate(filename). + getAttribut(PSUCalculatorSettings.Version); + if (Double.TryParse(value, out outvalue)) { return outvalue; } @@ -147,6 +169,7 @@ public void AddDownloadableFile(string filename, string url) updateFileDict.Remove(filename); } updateFileDict.Add(filename, url); + hasChanged = true; } public bool IsValid() diff --git a/PSU_Calculator/DataWorker/PSUCalculatorSettings.cs b/PSU_Calculator/DataWorker/PSUCalculatorSettings.cs index 78c802d..52f2e3c 100644 --- a/PSU_Calculator/DataWorker/PSUCalculatorSettings.cs +++ b/PSU_Calculator/DataWorker/PSUCalculatorSettings.cs @@ -140,13 +140,12 @@ private void Load() version = Settings.getElementByName("Version"); //ElementDict abfüllen. ElementDict.Add(GPU, version.getElementByName(GPU)); + ElementDict.Add("AskSaveLocal", Settings.getElementByPfadOnCreate("AskSaveLocal")); ElementDict.Add(CPU, version.getElementByName(CPU)); ElementDict.Add(PowerSupply, version.getElementByName(PowerSupply)); ElementDict.Add(SearchEngineString, Settings.getElementByName(SearchEngineString)); - //if (Settings.getElementByName(BoolValues) != null) - //{ - // ElementDict.Add(BoolValues, Settings.getElementByName(BoolValues)); - //} + + SetSearchEngine(Settings.getElementByName(SearchEngineString).Text); } @@ -234,6 +233,10 @@ public void SetSearchEngine(string engine) if (oldEngine != null && !oldEngine.Equals(SearchEngine)) { hasChanged = true; + } + if (string.IsNullOrEmpty(oldEngine) || oldEngine.Equals(SearchEngine)) + { + CalculatorSettingsFile.Get().HasChanged = false; } } @@ -265,17 +268,18 @@ public bool ShowPriceComparer get; set; } - //public bool ShowPriceComparer - //{ - // get - // { - // return GetBoolValue("ShowPriceComparer"); - // } - // set - // { - // SetBoolValue("ShowPriceComparer", value); - // } - //} + + public bool AskSaveLocal + { + get + { + return CalculatorSettingsFile.Get().GetBoolValue("AskSaveLocal"); + } + set + { + CalculatorSettingsFile.Get().SetBoolValue("AskSaveLocal", value); + } + } public bool ConnectorsHaveToFit { diff --git a/PSU_Calculator/Dateizugriffe/StorageMapper.cs b/PSU_Calculator/Dateizugriffe/StorageMapper.cs index 0fe28bf..b1dcc57 100644 --- a/PSU_Calculator/Dateizugriffe/StorageMapper.cs +++ b/PSU_Calculator/Dateizugriffe/StorageMapper.cs @@ -15,7 +15,7 @@ public class StorageMapper public static bool SetLocalData(string _version, List _gpu, List _cpu, List _nt) { //erstesmal? - if (!Properties.Einstellungen.Default.AskSaveLocal) + if (!PSUCalculatorSettings.Get().AskSaveLocal) { if (!StorageMapper.Existiert(PSUCalculatorSettings.Get().DirectoryPath)) { @@ -32,7 +32,7 @@ public static bool SetLocalData(string _version, List _gpu, List + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.cmdShowTest = new System.Windows.Forms.Button(); + this.tbxInput = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // cmdShowTest + // + this.cmdShowTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.cmdShowTest.Location = new System.Drawing.Point(12, 48); + this.cmdShowTest.Name = "cmdShowTest"; + this.cmdShowTest.Size = new System.Drawing.Size(138, 25); + this.cmdShowTest.TabIndex = 1; + this.cmdShowTest.Text = "Übernehmen"; + this.cmdShowTest.UseVisualStyleBackColor = true; + this.cmdShowTest.Click += new System.EventHandler(this.Finished); + // + // tbxInput + // + this.tbxInput.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.tbxInput.Location = new System.Drawing.Point(12, 9); + this.tbxInput.Multiline = true; + this.tbxInput.Name = "tbxInput"; + this.tbxInput.Size = new System.Drawing.Size(285, 33); + this.tbxInput.TabIndex = 2; + // + // InputFeld + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(309, 85); + this.Controls.Add(this.tbxInput); + this.Controls.Add(this.cmdShowTest); + this.Name = "InputFeld"; + this.Text = "TestberichteAuswahl"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button cmdShowTest; + private System.Windows.Forms.TextBox tbxInput; + } +} \ No newline at end of file diff --git a/PSU_Calculator/Forms/InputFeld.cs b/PSU_Calculator/Forms/InputFeld.cs new file mode 100644 index 0000000..b4a8fc7 --- /dev/null +++ b/PSU_Calculator/Forms/InputFeld.cs @@ -0,0 +1,64 @@ +using PSU_Calculator.Komponenten; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace PSU_Calculator +{ + /// + /// Einfaches Input Feld, mit übernehmen Button und Regex Prüfung. + /// + public partial class InputFeld : Form + { + PowerSupply PSU; + private Regex myRegex; + public InputFeld(string inTitle, Regex inRegex) + { + InitializeComponent(); + Name = inTitle; + myRegex = inRegex; + FormClosing += InputFeld_FormClosing; + } + + void InputFeld_FormClosing(object sender, FormClosingEventArgs e) + { + if (string.IsNullOrWhiteSpace(tbxInput.Text)) + { + this.DialogResult = DialogResult.Cancel; + } + if (myRegex !=null) + { + if (!myRegex.IsMatch(tbxInput.Text)) + { + this.DialogResult = DialogResult.Cancel; + } + } + } + + public string GetText + { + get + { + return tbxInput.Text; + } + set + { + tbxInput.Text = value; + } + } + + private void Finished(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + this.Close(); + } + + + } +} diff --git a/PSU_Calculator/Forms/InputFeld.resx b/PSU_Calculator/Forms/InputFeld.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PSU_Calculator/Forms/InputFeld.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PSU_Calculator/Forms/MainForm.Designer.cs b/PSU_Calculator/Forms/MainForm.Designer.cs index f9a960f..dde6467 100644 --- a/PSU_Calculator/Forms/MainForm.Designer.cs +++ b/PSU_Calculator/Forms/MainForm.Designer.cs @@ -91,6 +91,7 @@ private void InitializeComponent() this.cbxOverclocking = new System.Windows.Forms.ComboBox(); this.cbxCPU2 = new System.Windows.Forms.ComboBox(); this.lblCPU2 = new System.Windows.Forms.Label(); + this.downloadpfadÄndernToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.PnlContent.SuspendLayout(); this.gbxNetzteile.SuspendLayout(); @@ -111,7 +112,7 @@ private void InitializeComponent() this.einstellungenToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(307, 24); + this.menuStrip1.Size = new System.Drawing.Size(399, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -181,7 +182,8 @@ private void InitializeComponent() // this.optionenToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.themeToolStripMenuItem, - this.datenSpeicherortToolStripMenuItem}); + this.datenSpeicherortToolStripMenuItem, + this.downloadpfadÄndernToolStripMenuItem}); this.optionenToolStripMenuItem.Name = "optionenToolStripMenuItem"; this.optionenToolStripMenuItem.Size = new System.Drawing.Size(49, 20); this.optionenToolStripMenuItem.Text = "Extras"; @@ -189,7 +191,7 @@ private void InitializeComponent() // themeToolStripMenuItem // this.themeToolStripMenuItem.Name = "themeToolStripMenuItem"; - this.themeToolStripMenuItem.Size = new System.Drawing.Size(169, 22); + this.themeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); this.themeToolStripMenuItem.Text = "Aktualisiere Preise"; this.themeToolStripMenuItem.Visible = false; this.themeToolStripMenuItem.Click += new System.EventHandler(this.themeToolStripMenuItem_Click); @@ -200,7 +202,7 @@ private void InitializeComponent() this.lokalerOrdnerToolStripMenuItem, this.appDataToolStripMenuItem}); this.datenSpeicherortToolStripMenuItem.Name = "datenSpeicherortToolStripMenuItem"; - this.datenSpeicherortToolStripMenuItem.Size = new System.Drawing.Size(169, 22); + this.datenSpeicherortToolStripMenuItem.Size = new System.Drawing.Size(192, 22); this.datenSpeicherortToolStripMenuItem.Text = "Daten Speicherort"; // // lokalerOrdnerToolStripMenuItem @@ -231,7 +233,7 @@ private void InitializeComponent() this.spracheToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.deutschToolStripMenuItem}); this.spracheToolStripMenuItem.Name = "spracheToolStripMenuItem"; - this.spracheToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.spracheToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.spracheToolStripMenuItem.Text = "Sprache"; // // deutschToolStripMenuItem @@ -244,7 +246,7 @@ private void InitializeComponent() // suchmaschineToolStripMenuItem // this.suchmaschineToolStripMenuItem.Name = "suchmaschineToolStripMenuItem"; - this.suchmaschineToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.suchmaschineToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.suchmaschineToolStripMenuItem.Text = "Suchmaschine"; // // PnlHeader @@ -798,6 +800,13 @@ private void InitializeComponent() this.lblCPU2.Text = "CPU 2:"; this.lblCPU2.Visible = false; // + // downloadpfadÄndernToolStripMenuItem + // + this.downloadpfadÄndernToolStripMenuItem.Name = "downloadpfadÄndernToolStripMenuItem"; + this.downloadpfadÄndernToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.downloadpfadÄndernToolStripMenuItem.Text = "Downloadpfad ändern"; + this.downloadpfadÄndernToolStripMenuItem.Click += new System.EventHandler(this.downloadpfadÄndernToolStripMenuItem_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -899,6 +908,7 @@ void cbxCpu_TextChanged(object sender, System.EventArgs e) private System.Windows.Forms.ToolStripMenuItem lokalerOrdnerToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem appDataToolStripMenuItem; private System.Windows.Forms.Panel pnlRow2; + private System.Windows.Forms.ToolStripMenuItem downloadpfadÄndernToolStripMenuItem; } } diff --git a/PSU_Calculator/Forms/MainForm.cs b/PSU_Calculator/Forms/MainForm.cs index bea94b6..9649ddb 100644 --- a/PSU_Calculator/Forms/MainForm.cs +++ b/PSU_Calculator/Forms/MainForm.cs @@ -62,7 +62,9 @@ public Form1() setUpdateVerbrauchEvent(); cbxConectors.Checked = PSUCalculatorSettings.Get().ConnectorsHaveToFit; - new Updater().RunUpdateAsync(); + var updater = new Updater() { InvokeControl = this }; + updater.UpdateFinishedEvent += updater_UpdateFinishedEvent; + updater.RunUpdateAsync(); berechneVerbrauch(this, null); AddPriceComparorsToToolStrip(); @@ -74,6 +76,14 @@ public Form1() addGPU(); } + void updater_UpdateFinishedEvent(Updater sender) + { + if (sender.HasChanged) + { + MessageBox.Show("Es konnte eine neuere Version der Dateien heruntergeladen werden.\nStarten Sie das Programm neu damit die änderungen übernommen werden."); + } + } + void ActiveComponentChangedEvent(object sender) { berechneVerbrauch(sender, null); @@ -678,5 +688,24 @@ private void appDataToolStripMenuItem_Click(object sender, EventArgs e) { PSUCalculatorSettings.Get().ChangeDataPathToAppdata(); } + + private void downloadpfadÄndernToolStripMenuItem_Click(object sender, EventArgs e) + { + var newPath = new InputFeld("Downloadpfad Einstellungen", new System.Text.RegularExpressions.Regex("")); + var settings = CalculatorSettingsFile.Get(); + newPath.GetText = settings.Settings.getElementByPfadOnCreate(PSUCalculatorSettings.Einstellungen).Text; + + if (newPath.ShowDialog() == DialogResult.OK) + { + settings.AddDownloadableFile(PSUCalculatorSettings.Einstellungen, newPath.GetText); + settings.Settings.getElementByPfadOnCreate(PSUCalculatorSettings.Einstellungen).Text = newPath.GetText; + foreach (var ele in settings.Settings.getElementByPfadOnCreate(PSUCalculatorSettings.Version).getAllEntries()) + { + ele.addAttribut(PSUCalculatorSettings.Version, "0"); + } + settings.SaveSettings(); + MessageBox.Show("Bitte Starten Sie das Programm neu, um die Dateien vom neuen Downloadpfad herunterzuladen."); + } + } } } diff --git a/PSU_Calculator/PSU_Calculator.csproj b/PSU_Calculator/PSU_Calculator.csproj index 0cd6769..26dcf0a 100644 --- a/PSU_Calculator/PSU_Calculator.csproj +++ b/PSU_Calculator/PSU_Calculator.csproj @@ -115,6 +115,12 @@ FirstUsageInfoBox.cs + + Form + + + InputFeld.cs + @@ -124,11 +130,6 @@ TestberichteAuswahl.cs - - True - True - Einstellungen.settings - Form @@ -161,6 +162,9 @@ MainForm.cs Designer + + InputFeld.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -174,10 +178,6 @@ TestberichteAuswahl.cs - - SettingsSingleFileGenerator - Einstellungen.Designer.cs - diff --git a/PSU_Calculator/Properties/Einstellungen.Designer.cs b/PSU_Calculator/Properties/Einstellungen.Designer.cs deleted file mode 100644 index c7a05e9..0000000 --- a/PSU_Calculator/Properties/Einstellungen.Designer.cs +++ /dev/null @@ -1,50 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.18444 -// -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. -// -//------------------------------------------------------------------------------ - -namespace PSU_Calculator.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] - internal sealed partial class Einstellungen : global::System.Configuration.ApplicationSettingsBase { - - private static Einstellungen defaultInstance = ((Einstellungen)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Einstellungen()))); - - public static Einstellungen Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("1.3")] - public string Version { - get { - return ((string)(this["Version"])); - } - set { - this["Version"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool AskSaveLocal { - get { - return ((bool)(this["AskSaveLocal"])); - } - set { - this["AskSaveLocal"] = value; - } - } - } -} diff --git a/PSU_Calculator/Properties/Einstellungen.settings b/PSU_Calculator/Properties/Einstellungen.settings deleted file mode 100644 index 244022d..0000000 --- a/PSU_Calculator/Properties/Einstellungen.settings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - 1.3 - - - False - - - \ No newline at end of file diff --git a/PSU_Calculator/Updater.cs b/PSU_Calculator/Updater.cs index 9fb1373..b808cd5 100644 --- a/PSU_Calculator/Updater.cs +++ b/PSU_Calculator/Updater.cs @@ -7,12 +7,14 @@ using System.Net; using System.Text; using System.Threading; +using System.Windows.Forms; +using System.Xml; namespace PSU_Calculator { public class Updater { - private static string Einstellungen = "https://raw.githubusercontent.com/Multithread/PSU_Calculator/master/Einstellungen.data"; + private static string Einstellungen = "https://raw.githubusercontent.com/Multithread/PSU_Calculator/master/Einstellungen.xml"; Thread downloader; public delegate void UpdateFinishedDelegate(Updater sender); @@ -33,6 +35,9 @@ public Dictionary FileVersions set { versionFileDict = value; } } + public Control InvokeControl { get; set; } + private finishedDelegateHandler finishedDelegate; + public bool IsUpdating { get; @@ -42,6 +47,7 @@ public bool IsUpdating public Updater() { IsUpdating = false; + finishedDelegate = new finishedDelegateHandler(callFinishedEvent); } public void RunUpdateAsync() @@ -64,80 +70,78 @@ public void RunUpdateSyncroniced() /// private void run() { + HasChanged = false; string data = DownloadFromSource(GetSettingsDownloadPath()); - ComponentStringSplitter css = new ComponentStringSplitter(data, true); - foreach (string key in updateFileDict.Keys) + XmlDocument doc = new XmlDocument(); + try + { + doc.LoadXml(data); + } + catch (XmlException) + { + return; + //throw new Exception("XML ist Korupted"); + } + Element tmpSettings = new Element(doc.FirstChild); + Element versionen = tmpSettings.getElementByName(PSUCalculatorSettings.Version); + foreach (Element ele in tmpSettings.getAlleElementeByName("File")) { - //EInstellungen Key Ignorieren, den haben wir bereits + string key = ele.getAttribut("Name"); + //Einstellungen Key Ignorieren, den haben wir bereits if (PSUCalculatorSettings.Einstellungen.Equals(key)) { continue; } - //Version auslesen - double version; - versionFileDict.TryGetValue(key, out version); - if (CalculatorSettingsFile.Get().GetVersionForFile(key) < css.GetValueForKeyAsDouble(key)) + double version = 1; + if (!Double.TryParse(versionen.getElementByPfadOnCreate(key).getAttribut(PSUCalculatorSettings.Version), out version)) + { + version = 1; + } + + //Herunterladen wenn die ServerVersion neuer ist. + if (CalculatorSettingsFile.Get().GetVersionForFile(key) < version) { //Herunterladen der Daten. - string url; - updateFileDict.TryGetValue(key, out url); + string url = ele.Text.Trim(); IsUpdating = true; data = DownloadFromSource(url); if (!string.IsNullOrEmpty(data)) { string path = PSUCalculatorSettings.GetFilePath(key); StorageMapper.WriteToFilesystem(path, data); - CalculatorSettingsFile.Get().SetVersionForFile(key, css.GetValueForKeyAsDouble(key)); - LoaderModul.getInstance().ReloadPowerSupplys(); + CalculatorSettingsFile.Get().SetVersionForFile(key, version); + HasChanged = HasChanged || CalculatorSettingsFile.Get().HasChanged; + CalculatorSettingsFile.Get().SaveSettings(); } IsUpdating = false; } } - //if (PSUCalculatorSettings.Get().PSUVersion < css.GetValueForKeyAsDouble(PSUCalculatorSettings.PowerSupply)) - //{ - // IsUpdating = true; - // data = DownloadFromSource(PSUlist); - // if (!string.IsNullOrEmpty(data)) - // { - // string path = PSUCalculatorSettings.GetFilePath(PSUCalculatorSettings.PowerSupply); - // StorageMapper.WriteToFilesystem(path, data); - // PSUCalculatorSettings.Get().PSUVersion = css.GetValueForKeyAsDouble(PSUCalculatorSettings.PowerSupply); - // LoaderModul.getInstance().ReloadPowerSupplys(); - // } - // IsUpdating = false; - //} - //if (PSUCalculatorSettings.Get().CPUVersion < css.GetValueForKeyAsDouble(PSUCalculatorSettings.CPU)) - //{ - // IsUpdating = true; - // data = DownloadFromSource(CPUList); - // if (!string.IsNullOrEmpty(data)) - // { - // string path = PSUCalculatorSettings.GetFilePath(PSUCalculatorSettings.CPU); - // StorageMapper.WriteToFilesystem(path, data); - // PSUCalculatorSettings.Get().CPUVersion = css.GetValueForKeyAsDouble(PSUCalculatorSettings.CPU); - // } - // IsUpdating = false; - //} - //if (PSUCalculatorSettings.Get().GPUVersion < css.GetValueForKeyAsDouble(PSUCalculatorSettings.GPU)) - //{ - // IsUpdating = true; - // data = DownloadFromSource(GPUList); - // if (!string.IsNullOrEmpty(data)) - // { - // string path = PSUCalculatorSettings.GetFilePath(PSUCalculatorSettings.GPU); - // StorageMapper.WriteToFilesystem(path, data); - // PSUCalculatorSettings.Get().GPUVersion = css.GetValueForKeyAsDouble(PSUCalculatorSettings.GPU); - // } - // IsUpdating = false; - //} - CalculatorSettingsFile.Get().SaveSettings(); + callFinishedEvent(); + } + + private delegate void finishedDelegateHandler(); + /// + /// Invoken des Events, je anchdem mit contro.Invoke + /// + public void callFinishedEvent() + { if (UpdateFinishedEvent != null) { + if (InvokeControl != null) + { + if (InvokeControl.InvokeRequired) + { + InvokeControl.Invoke(finishedDelegate); + return; + } + } UpdateFinishedEvent(this); } } + public bool HasChanged { get; set; } + public string GetSettingsDownloadPath() { string tmpPath;