FormListe LV-Schriftgröße & TB-TextChanged, UserSettings mit UserSettingManager,
This commit is contained in:
parent
f6fd5d2623
commit
94ebdec1b0
@ -15,6 +15,7 @@ namespace Deckungsbeitrag
|
||||
{
|
||||
public partial class FormEinstellung : Form
|
||||
{
|
||||
private readonly UserSettingsManager _settings = new UserSettingsManager();
|
||||
string varkosten = ConfigurationManager.AppSettings["Variabel"];
|
||||
string fixlohnkosten = ConfigurationManager.AppSettings["FixLohn"];
|
||||
string fixmietkosten = ConfigurationManager.AppSettings["FixMiete"];
|
||||
@ -47,10 +48,23 @@ namespace Deckungsbeitrag
|
||||
|
||||
private void FormEinstellung_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Standard Drucker und Kopieanzahl einstellen.
|
||||
foreach (string printer in PrinterSettings.InstalledPrinters)
|
||||
{
|
||||
this.comboBoxEtikettDrucker.Items.Add(printer);
|
||||
this.comboBoxSWSDrucker.Items.Add(printer);
|
||||
}
|
||||
|
||||
_settings.Load();
|
||||
this.comboBoxEtikettDrucker.SelectedText = _settings.DruckerEtikett;
|
||||
this.comboBoxSWSDrucker.SelectedText = _settings.DruckerSWS;
|
||||
this.numericUpDownSWSKopien.Value = _settings.CopiesSWS;
|
||||
|
||||
Load_Settings();
|
||||
}
|
||||
private void Load_Settings()
|
||||
{
|
||||
//TODO: Settings hier ändern auf UserSettingsManager Klasse.
|
||||
this.checkBoxMaxWert.Checked = Settings.Default.MaxChecked;
|
||||
this.checkBoxMinWert.Checked = Settings.Default.MinChecked;
|
||||
this.numUpDownAnzahl.Value = Settings.Default.ZAnzahl;
|
||||
@ -70,47 +84,36 @@ namespace Deckungsbeitrag
|
||||
}
|
||||
}
|
||||
|
||||
// Standart Drucker und Kopieanzahl einstellen.
|
||||
foreach (string printer in PrinterSettings.InstalledPrinters)
|
||||
{
|
||||
this.comboBoxEtikettDrucker.Items.Add(printer);
|
||||
this.comboBoxSWSDrucker.Items.Add(printer);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Settings.Default.Etikett_Drucker)) this.comboBoxEtikettDrucker.SelectedIndex = -1;
|
||||
else this.comboBoxEtikettDrucker.SelectedText = Settings.Default.Etikett_Drucker;
|
||||
if (string.IsNullOrWhiteSpace(Settings.Default.SWS_Drucker)) this.comboBoxSWSDrucker.SelectedIndex = -1;
|
||||
else this.comboBoxSWSDrucker.SelectedItem = Settings.Default.SWS_Drucker;
|
||||
|
||||
this.comboBoxSWSDrucker.DropDownStyle = this.comboBoxEtikettDrucker.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
this.numericUpDownSWSKopien.Value = Settings.Default.SWS_Copies;
|
||||
}
|
||||
private void Save_Settings()
|
||||
{
|
||||
if (MessageBox.Show("Möchtest du die Einstellungen speichern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
||||
else
|
||||
{
|
||||
if (changed)
|
||||
{
|
||||
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
|
||||
config.AppSettings.Settings.Remove("SortimentPfad");
|
||||
config.AppSettings.Settings.Add("SortimentPfad", this.textBoxSortiment.Text);
|
||||
config.AppSettings.Settings.Remove("BildPfad");
|
||||
config.AppSettings.Settings.Add("BildPfad", this.textBoxRatingbild.Text);
|
||||
//TODO: Hier Settings speichern mit UserSettingsManager Klasse.
|
||||
//if (changed)
|
||||
//{
|
||||
// Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
|
||||
// config.AppSettings.Settings.Remove("SortimentPfad");
|
||||
// config.AppSettings.Settings.Add("SortimentPfad", this.textBoxSortiment.Text);
|
||||
// config.AppSettings.Settings.Remove("BildPfad");
|
||||
// config.AppSettings.Settings.Add("BildPfad", this.textBoxRatingbild.Text);
|
||||
|
||||
config.Save();
|
||||
}
|
||||
if (this.checkBoxMaxWert.Checked) Settings.Default.MaxChecked = this.checkBoxMaxWert.Checked;
|
||||
if (this.checkBoxMinWert.Checked) Settings.Default.MinChecked = this.checkBoxMinWert.Checked;
|
||||
if (this.numUpDownMinWert.Enabled) Settings.Default.RatMin = (double)this.numUpDownMinWert.Value;
|
||||
if (this.numUpDownMaxWert.Enabled) Settings.Default.RatMax = (double)this.numUpDownMaxWert.Value;
|
||||
if (this.comboBoxEtikettDrucker.SelectedItem != null) Settings.Default.Etikett_Drucker = this.comboBoxEtikettDrucker.SelectedItem.ToString();
|
||||
if (this.comboBoxSWSDrucker.SelectedItem != null) { Settings.Default.SWS_Drucker = this.comboBoxSWSDrucker.SelectedItem.ToString(); Settings.Default.SWS_Copies = (int)this.numericUpDownSWSKopien.Value; }
|
||||
// config.Save();
|
||||
//}
|
||||
//if (this.checkBoxMaxWert.Checked) Settings.Default.MaxChecked = this.checkBoxMaxWert.Checked;
|
||||
//if (this.checkBoxMinWert.Checked) Settings.Default.MinChecked = this.checkBoxMinWert.Checked;
|
||||
//if (this.numUpDownMinWert.Enabled) Settings.Default.RatMin = (double)this.numUpDownMinWert.Value;
|
||||
//if (this.numUpDownMaxWert.Enabled) Settings.Default.RatMax = (double)this.numUpDownMaxWert.Value;
|
||||
|
||||
if (this.comboBoxEtikettDrucker.SelectedItem != null) _settings.DruckerEtikett = this.comboBoxEtikettDrucker.SelectedItem.ToString();
|
||||
if (this.comboBoxSWSDrucker.SelectedItem != null) { _settings.DruckerSWS = this.comboBoxSWSDrucker.SelectedItem.ToString(); _settings.CopiesSWS = this.numericUpDownSWSKopien.Value; }
|
||||
|
||||
|
||||
Settings.Default.ZAnzahl = (int)this.numUpDownAnzahl.Value;
|
||||
//Settings.Default.ZAnzahl = (int)this.numUpDownAnzahl.Value;
|
||||
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.Save();
|
||||
_settings.Save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -672,6 +672,11 @@ namespace Deckungsbeitrag
|
||||
this.dGArtikel.Rows.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Einstellungen vor allem Drucker für SWS und Etikett funktioniert nicht weil schreiben auf .config nicht möglich.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonEinstellung_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormEinstellung einstellung = new FormEinstellung(this);
|
||||
|
||||
2
AA-Forms/FormListe.Designer.cs
generated
2
AA-Forms/FormListe.Designer.cs
generated
@ -52,7 +52,7 @@ namespace Deckungsbeitrag
|
||||
this.columnHeader2,
|
||||
this.columnHeader3,
|
||||
this.columnHeader4});
|
||||
this.listViewKunde.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listViewKunde.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listViewKunde.FullRowSelect = true;
|
||||
this.listViewKunde.GridLines = true;
|
||||
this.listViewKunde.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
|
||||
@ -196,15 +196,6 @@ namespace Deckungsbeitrag
|
||||
|
||||
//GetKeyboard();
|
||||
}
|
||||
|
||||
private void GetKeyboard()
|
||||
{
|
||||
// Pfad zur Touch-Tastatur
|
||||
keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
|
||||
// Bildschirmtastatur starten
|
||||
Process.Start(keyboardPath);
|
||||
}
|
||||
private void textBoxKunde_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// TextChanged tritt nur ein wenn x Sekunden keine Eingabe erfolgt. Logik befindet sich in Timer_Tick
|
||||
@ -215,8 +206,8 @@ namespace Deckungsbeitrag
|
||||
{
|
||||
timer.Stop(); // Timer stoppen
|
||||
|
||||
// Wenn kein Fragezeichen am Anfang und die Textlänge ist größer 3 wird Kundenliste erstellt.
|
||||
if (!textBoxKunde.Text.StartsWith("?") && textBoxKunde.TextLength > 3)
|
||||
// Wenn kein Fragezeichen am Anfang wird Kundenliste erstellt.
|
||||
if (!textBoxKunde.Text.StartsWith("?"))
|
||||
{
|
||||
Kundenliste = Kunde.GetTmpList(this.textBoxKunde.Text);
|
||||
listViewKunde_Load();
|
||||
|
||||
13
App.config
13
App.config
@ -4,9 +4,6 @@
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="Deckungsbeitrag.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="Deckungsbeitrag.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="ConnectionString" value="user id=postgres;password=Ki985941Wi;host=10.10.10.1;port=5432;database=Test_Wirl;Timeout=5" />
|
||||
@ -88,6 +85,9 @@
|
||||
<setting name="OLVState" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="Wirlblau" serializeAs="String">
|
||||
<value>1, 53, 101</value>
|
||||
</setting>
|
||||
<setting name="ColPos" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
@ -171,11 +171,4 @@
|
||||
<connectionStrings>
|
||||
<add name="DefaultConnection" connectionString="Data Source = |SQL/CE|" />
|
||||
</connectionStrings>
|
||||
<applicationSettings>
|
||||
<Deckungsbeitrag.Properties.Settings>
|
||||
<setting name="Wirlblau" serializeAs="String">
|
||||
<value>1, 53, 101</value>
|
||||
</setting>
|
||||
</Deckungsbeitrag.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("Deckungsbeitrag")]
|
||||
[assembly: AssemblyTitle("Wirl-Verwaltung")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Deckungsbeitrag")]
|
||||
[assembly: AssemblyCompany("Kilian Wirl GmbH")]
|
||||
[assembly: AssemblyProduct("Verwaltung")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.1.3")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.3")]
|
||||
[assembly: AssemblyVersion("1.0.1.9")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.9")]
|
||||
|
||||
5
Properties/Settings.Designer.cs
generated
5
Properties/Settings.Designer.cs
generated
@ -35,13 +35,16 @@ namespace Deckungsbeitrag.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("1, 53, 101")]
|
||||
public global::System.Drawing.Color Wirlblau {
|
||||
get {
|
||||
return ((global::System.Drawing.Color)(this["Wirlblau"]));
|
||||
}
|
||||
set {
|
||||
this["Wirlblau"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<Setting Name="OLVState" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="Wirlblau" Type="System.Drawing.Color" Scope="Application">
|
||||
<Setting Name="Wirlblau" Type="System.Drawing.Color" Scope="User">
|
||||
<Value Profile="(Default)">1, 53, 101</Value>
|
||||
</Setting>
|
||||
<Setting Name="ColPos" Type="System.Drawing.Color" Scope="User">
|
||||
|
||||
@ -1621,15 +1621,15 @@
|
||||
{
|
||||
"Name" = "8:Microsoft Visual Studio"
|
||||
"ProductName" = "8:SetupVerwaltung"
|
||||
"ProductCode" = "8:{9E8C033A-6762-4108-957E-1D834D568DC0}"
|
||||
"PackageCode" = "8:{B5ED7236-241E-4943-A031-B70E366CC2D5}"
|
||||
"ProductCode" = "8:{6D0E142B-44EA-43EA-9CA0-F4A2BFBC22AF}"
|
||||
"PackageCode" = "8:{4252B4CA-B810-4CA9-9A37-AF7373000FBA}"
|
||||
"UpgradeCode" = "8:{2DC7CE56-8D1C-42EB-B326-2E887EBB7F5A}"
|
||||
"AspNetVersion" = "8:"
|
||||
"RestartWWWService" = "11:FALSE"
|
||||
"RemovePreviousVersions" = "11:FALSE"
|
||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||
"InstallAllUsers" = "11:FALSE"
|
||||
"ProductVersion" = "8:1.0.9"
|
||||
"ProductVersion" = "8:1.0.15"
|
||||
"Manufacturer" = "8:Kilian Wirl GmbH"
|
||||
"ARPHELPTELEPHONE" = "8:"
|
||||
"ARPHELPLINK" = "8:"
|
||||
|
||||
69
UserSettingsManager.cs
Normal file
69
UserSettingsManager.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
public class UserSettingsManager
|
||||
{
|
||||
public string DruckerSWS { get; set; } = "";
|
||||
public string DruckerEtikett { get; set; } = "";
|
||||
public decimal CopiesSWS { get; set; } = 0;
|
||||
|
||||
//TODO: UserSetting Properties eintragen und in EinstellungsScreen abrufen.
|
||||
|
||||
private readonly string _configPath;
|
||||
|
||||
public UserSettingsManager()
|
||||
{
|
||||
_configPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"Kilian Wirl GmbH", "Verwaltung", "settings.json");
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_configPath))
|
||||
{
|
||||
string json = File.ReadAllText(_configPath);
|
||||
var loadedSettings = JsonSerializer.Deserialize<UserSettingsManager>(json);
|
||||
if (loadedSettings != null)
|
||||
{
|
||||
DruckerSWS = loadedSettings.DruckerSWS;
|
||||
DruckerEtikett = loadedSettings.DruckerEtikett;
|
||||
CopiesSWS = loadedSettings.CopiesSWS;
|
||||
// Weitere Properties hier zuweisen
|
||||
//TODO: Weitere Properties von oben hier zuweisen
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* Alte Datei kaputt → Defaults */ }
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_configPath));
|
||||
string json = JsonSerializer.Serialize(this, new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
});
|
||||
File.WriteAllText(_configPath, json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Fallback: LocalAppData
|
||||
string fallbackPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"Kilian Wirl GmbH", "Verwaltung", "settings.json");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fallbackPath));
|
||||
string json = JsonSerializer.Serialize(this, new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
});
|
||||
File.WriteAllText(fallbackPath, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,9 @@
|
||||
<PropertyGroup>
|
||||
<StartupObject>Deckungsbeitrag.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>wirlneu_transparent %281%29.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL">
|
||||
<HintPath>packages\AForge.2.2.5\lib\AForge.dll</HintPath>
|
||||
@ -364,6 +367,7 @@
|
||||
<Compile Include="UCFach.Designer.cs">
|
||||
<DependentUpon>UCFach.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserSettingsManager.cs" />
|
||||
<EmbeddedResource Include="AA-Forms\FormArtikelVW.resx">
|
||||
<DependentUpon>FormArtikelVW.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -486,6 +490,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ILLink\ILLink.Descriptors.LibraryBuild.xml" />
|
||||
<Content Include="wirlneu_transparent %281%29.ico" />
|
||||
<None Include="Resources\Close_WhiteNoHalo_16x.png" />
|
||||
<None Include="Resources\Monaco_Settings_16x.png" />
|
||||
<Content Include="Resources\QR.png" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user