Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
Mit änderbarem Einstellungen Download Pfad
  • Loading branch information
Multithread committed Jun 20, 2015
1 parent 51ba282 commit 22cc391
Show file tree
Hide file tree
Showing 12 changed files with 416 additions and 148 deletions.
29 changes: 26 additions & 3 deletions PSU_Calculator/DataWorker/CalculatorSettingsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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;

}

/// <summary>
/// gibt einen Boolschen wert asu dem Settings Element zurück.
/// gibt einen Boolschen wert aus dem Settings Element zurück.
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -147,6 +169,7 @@ public void AddDownloadableFile(string filename, string url)
updateFileDict.Remove(filename);
}
updateFileDict.Add(filename, url);
hasChanged = true;
}

public bool IsValid()
Expand Down
34 changes: 19 additions & 15 deletions PSU_Calculator/DataWorker/PSUCalculatorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions PSU_Calculator/Dateizugriffe/StorageMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class StorageMapper
public static bool SetLocalData(string _version, List<PcComponent> _gpu, List<PcComponent> _cpu, List<PcComponent> _nt)
{
//erstesmal?
if (!Properties.Einstellungen.Default.AskSaveLocal)
if (!PSUCalculatorSettings.Get().AskSaveLocal)
{
if (!StorageMapper.Existiert(PSUCalculatorSettings.Get().DirectoryPath))
{
Expand All @@ -32,7 +32,7 @@ public static bool SetLocalData(string _version, List<PcComponent> _gpu, List<Pc
{
return false;
}
Properties.Einstellungen.Default.AskSaveLocal = true;
PSUCalculatorSettings.Get().AskSaveLocal = true;
}

}
Expand Down
76 changes: 76 additions & 0 deletions PSU_Calculator/Forms/InputFeld.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions PSU_Calculator/Forms/InputFeld.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Einfaches Input Feld, mit übernehmen Button und Regex Prüfung.
/// </summary>
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();
}


}
}
Loading

0 comments on commit 22cc391

Please sign in to comment.