Man kann jetzt die einstellungen speichern
This commit is contained in:
26
SanSystem/Einstellungen/ObjecteListSetting.cs
Normal file
26
SanSystem/Einstellungen/ObjecteListSetting.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SanSystem.Einstellungen
|
||||
{
|
||||
class ObjecteListSetting : Settings
|
||||
{
|
||||
public ObjecteListSetting() : base("ObjecteList") { }
|
||||
|
||||
public override void InitDevValues()
|
||||
{
|
||||
// Hausnummer
|
||||
// Von punkt
|
||||
// Bis punkt
|
||||
// Haltungslänge
|
||||
|
||||
configuration.Add("Hausnummer", 40);
|
||||
configuration.Add("VonPunkt", 100);
|
||||
configuration.Add("BisPunkt", 100);
|
||||
configuration.Add("Haltungslaenge", 40);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
SanSystem/Einstellungen/Settings.cs
Normal file
49
SanSystem/Einstellungen/Settings.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SanSystem.Einstellungen
|
||||
{
|
||||
abstract class Settings : IDisposable
|
||||
{
|
||||
public Dictionary<string, int> configuration = new Dictionary<string, int>();
|
||||
|
||||
const string pfad = "Settings";
|
||||
|
||||
string modPath = "";
|
||||
public Settings(string module)
|
||||
{
|
||||
string modname = string.Format("{0}.set", module);
|
||||
|
||||
modPath = Path.Combine(pfad, modname);
|
||||
if (!Directory.Exists(pfad)) Directory.CreateDirectory(pfad);
|
||||
if(!File.Exists(modPath))
|
||||
{
|
||||
InitDevValues();
|
||||
SaveSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
string input = File.ReadAllText(modPath);
|
||||
configuration = (Dictionary<string, int>)JsonConvert.DeserializeObject(input, typeof(Dictionary<string, int>));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void InitDevValues();
|
||||
|
||||
public virtual void SaveSettings()
|
||||
{
|
||||
string ser = JsonConvert.SerializeObject(configuration);
|
||||
File.WriteAllText(modPath, ser);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using SanShared;
|
||||
using Microsoft.Win32;
|
||||
using SanShared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -12,9 +13,24 @@ namespace SanSystem
|
||||
{
|
||||
public static readonly Global instance = new Global();
|
||||
|
||||
const string userroot = "HKEY_CURRENT_USER\\Software";
|
||||
const string firmkey = "Cosysda";
|
||||
const string subkey = "SanManager";
|
||||
const string speicherpfad_to_projekts = "projekte";
|
||||
string projektpfad = "18-850";
|
||||
|
||||
string projektpfad = "18-850";
|
||||
|
||||
public string ProjektNummer
|
||||
{
|
||||
get
|
||||
{
|
||||
return projektpfad;
|
||||
}
|
||||
set
|
||||
{
|
||||
projektpfad = value;
|
||||
}
|
||||
}
|
||||
public string Projektpfad
|
||||
{
|
||||
get
|
||||
@@ -34,12 +50,24 @@ namespace SanSystem
|
||||
|
||||
void LadeRegistry()
|
||||
{
|
||||
string userroot = "HKEY_CURRENT_USER\\Software";
|
||||
string firmkey = "Cosysda";
|
||||
string subkey = "SanManager";
|
||||
|
||||
string keyName = userroot + "\\" + firmkey + "\\" + subkey;
|
||||
|
||||
string lastProjektNummer = "";
|
||||
|
||||
try
|
||||
{
|
||||
lastProjektNummer = Registry.GetValue(keyName, "LastProjekt", "").ToString();
|
||||
ProjektNummer = lastProjektNummer;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
void SpeicherInRegistry()
|
||||
{
|
||||
string keyName = userroot + "\\" + firmkey + "\\" + subkey;
|
||||
Registry.SetValue(keyName, "LastProjekt", ProjektNummer);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,5 +76,15 @@ namespace SanSystem
|
||||
{
|
||||
language = Language.Language.GetLanguage(Language.BUILTINLANGUAGES.GERMAN);
|
||||
}
|
||||
|
||||
public Global()
|
||||
{
|
||||
LadeRegistry();
|
||||
}
|
||||
|
||||
~Global()
|
||||
{
|
||||
SpeicherInRegistry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Syncfusion.Chart.Base, Version=16.1460.0.37, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\3rdPackage\Syncfusion.Chart.Base.dll</HintPath>
|
||||
@@ -65,6 +68,8 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Einstellungen\ObjecteListSetting.cs" />
|
||||
<Compile Include="Einstellungen\Settings.cs" />
|
||||
<Compile Include="frmObjektEdit.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -22,9 +22,10 @@ namespace SanSystem
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
//Global.Instance.
|
||||
|
||||
if (!Directory.Exists(Global.Instance.Projektpfad)) Directory.CreateDirectory(Global.Instance.Projektpfad);
|
||||
Datenbank.Instance.LoadProjekt("18-850", Global.Instance.Projektpfad);// Path.Combine(Global.Instance.Projektpfad,"18-850.xaml"));
|
||||
Datenbank.Instance.LoadProjekt(Global.Instance.ProjektNummer, Global.Instance.Projektpfad);// Path.Combine(Global.Instance.Projektpfad,"18-850.xaml"));
|
||||
|
||||
|
||||
//Datenbank.Instance.CreateProjekt("");
|
||||
|
||||
2
SanSystem/frmObjekteList.Designer.cs
generated
2
SanSystem/frmObjekteList.Designer.cs
generated
@@ -55,6 +55,7 @@
|
||||
// dGObjekte
|
||||
//
|
||||
this.dGObjekte.AllowUserToOrderColumns = true;
|
||||
this.dGObjekte.AllowUserToResizeRows = false;
|
||||
this.dGObjekte.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dGObjekte.Location = new System.Drawing.Point(10, 77);
|
||||
this.dGObjekte.Margin = new System.Windows.Forms.Padding(2);
|
||||
@@ -243,6 +244,7 @@
|
||||
this.Name = "frmObjekteList";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "frmObjekteList";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmObjekteList_FormClosing);
|
||||
this.Load += new System.EventHandler(this.frmObjekteList_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dGObjekte)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.strasseBindingSource)).EndInit();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Database;
|
||||
using KlassenBIB;
|
||||
using SanSystem.Einstellungen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -17,6 +18,7 @@ namespace SanSystem
|
||||
{
|
||||
|
||||
private List<Inspektionsobjekt> inspektionsobjekte;
|
||||
ObjecteListSetting objecteListSetting = new ObjecteListSetting();
|
||||
|
||||
private void loadObjekte(string streetname)
|
||||
{
|
||||
@@ -192,6 +194,11 @@ namespace SanSystem
|
||||
dGObjekte.Columns["Objektbezeichnung"].Visible = false;
|
||||
dGObjekte.Columns["Haltunggemessen"].Visible = false;
|
||||
dGObjekte.Columns["Bemerkung"].Visible = false;
|
||||
|
||||
dGObjekte.Columns["Hausnummer"].Width = objecteListSetting.configuration["Hausnummer"];
|
||||
dGObjekte.Columns["VonPunkt"].Width = objecteListSetting.configuration["VonPunkt"];
|
||||
dGObjekte.Columns["BisPunkt"].Width = objecteListSetting.configuration["BisPunkt"];
|
||||
dGObjekte.Columns["Haltungslaenge"].Width = objecteListSetting.configuration["Haltungslaenge"];
|
||||
//dGObjekte.Columns["Sanierung"].Visible = false;
|
||||
}
|
||||
|
||||
@@ -199,5 +206,14 @@ namespace SanSystem
|
||||
{
|
||||
CheckEntries();
|
||||
}
|
||||
|
||||
private void frmObjekteList_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
objecteListSetting.configuration["Hausnummer"] = dGObjekte.Columns["Hausnummer"].Width;
|
||||
objecteListSetting.configuration["VonPunkt"] = dGObjekte.Columns["VonPunkt"].Width;
|
||||
objecteListSetting.configuration["BisPunkt"] = dGObjekte.Columns["BisPunkt"].Width;
|
||||
objecteListSetting.configuration["Haltungslaenge"] = dGObjekte.Columns["Haltungslaenge"].Width;
|
||||
objecteListSetting.SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<packages>
|
||||
<package id="FluentFTP" version="19.2.2" targetFramework="net461" />
|
||||
<package id="Ionic.Zip" version="1.9.1.8" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user