FormListe LV-Schriftgröße & TB-TextChanged, UserSettings mit UserSettingManager,

This commit is contained in:
Kilian Wirl 2025-12-09 19:18:28 +01:00
parent f6fd5d2623
commit 94ebdec1b0
11 changed files with 132 additions and 63 deletions

View File

@ -15,6 +15,7 @@ namespace Deckungsbeitrag
{ {
public partial class FormEinstellung : Form public partial class FormEinstellung : Form
{ {
private readonly UserSettingsManager _settings = new UserSettingsManager();
string varkosten = ConfigurationManager.AppSettings["Variabel"]; string varkosten = ConfigurationManager.AppSettings["Variabel"];
string fixlohnkosten = ConfigurationManager.AppSettings["FixLohn"]; string fixlohnkosten = ConfigurationManager.AppSettings["FixLohn"];
string fixmietkosten = ConfigurationManager.AppSettings["FixMiete"]; string fixmietkosten = ConfigurationManager.AppSettings["FixMiete"];
@ -47,10 +48,23 @@ namespace Deckungsbeitrag
private void FormEinstellung_Load(object sender, EventArgs e) 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(); Load_Settings();
} }
private void Load_Settings() private void Load_Settings()
{ {
//TODO: Settings hier ändern auf UserSettingsManager Klasse.
this.checkBoxMaxWert.Checked = Settings.Default.MaxChecked; this.checkBoxMaxWert.Checked = Settings.Default.MaxChecked;
this.checkBoxMinWert.Checked = Settings.Default.MinChecked; this.checkBoxMinWert.Checked = Settings.Default.MinChecked;
this.numUpDownAnzahl.Value = Settings.Default.ZAnzahl; 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() private void Save_Settings()
{ {
if (MessageBox.Show("Möchtest du die Einstellungen speichern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; if (MessageBox.Show("Möchtest du die Einstellungen speichern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
else else
{ {
if (changed) //TODO: Hier Settings speichern mit UserSettingsManager Klasse.
{ //if (changed)
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); //{
config.AppSettings.Settings.Remove("SortimentPfad"); // Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings.Add("SortimentPfad", this.textBoxSortiment.Text); // config.AppSettings.Settings.Remove("SortimentPfad");
config.AppSettings.Settings.Remove("BildPfad"); // config.AppSettings.Settings.Add("SortimentPfad", this.textBoxSortiment.Text);
config.AppSettings.Settings.Add("BildPfad", this.textBoxRatingbild.Text); // config.AppSettings.Settings.Remove("BildPfad");
// config.AppSettings.Settings.Add("BildPfad", this.textBoxRatingbild.Text);
config.Save(); // config.Save();
} //}
if (this.checkBoxMaxWert.Checked) Settings.Default.MaxChecked = this.checkBoxMaxWert.Checked; //if (this.checkBoxMaxWert.Checked) Settings.Default.MaxChecked = this.checkBoxMaxWert.Checked;
if (this.checkBoxMinWert.Checked) Settings.Default.MinChecked = this.checkBoxMinWert.Checked; //if (this.checkBoxMinWert.Checked) Settings.Default.MinChecked = this.checkBoxMinWert.Checked;
if (this.numUpDownMinWert.Enabled) Settings.Default.RatMin = (double)this.numUpDownMinWert.Value; //if (this.numUpDownMinWert.Enabled) Settings.Default.RatMin = (double)this.numUpDownMinWert.Value;
if (this.numUpDownMaxWert.Enabled) Settings.Default.RatMax = (double)this.numUpDownMaxWert.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; } 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();
} }
} }

View File

@ -672,6 +672,11 @@ namespace Deckungsbeitrag
this.dGArtikel.Rows.Clear(); 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) private void buttonEinstellung_Click(object sender, EventArgs e)
{ {
FormEinstellung einstellung = new FormEinstellung(this); FormEinstellung einstellung = new FormEinstellung(this);

View File

@ -52,7 +52,7 @@ namespace Deckungsbeitrag
this.columnHeader2, this.columnHeader2,
this.columnHeader3, this.columnHeader3,
this.columnHeader4}); 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.FullRowSelect = true;
this.listViewKunde.GridLines = true; this.listViewKunde.GridLines = true;
this.listViewKunde.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.listViewKunde.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;

View File

@ -196,15 +196,6 @@ namespace Deckungsbeitrag
//GetKeyboard(); //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) private void textBoxKunde_TextChanged(object sender, EventArgs e)
{ {
// TextChanged tritt nur ein wenn x Sekunden keine Eingabe erfolgt. Logik befindet sich in Timer_Tick // 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 timer.Stop(); // Timer stoppen
// Wenn kein Fragezeichen am Anfang und die Textlänge ist größer 3 wird Kundenliste erstellt. // Wenn kein Fragezeichen am Anfang wird Kundenliste erstellt.
if (!textBoxKunde.Text.StartsWith("?") && textBoxKunde.TextLength > 3) if (!textBoxKunde.Text.StartsWith("?"))
{ {
Kundenliste = Kunde.GetTmpList(this.textBoxKunde.Text); Kundenliste = Kunde.GetTmpList(this.textBoxKunde.Text);
listViewKunde_Load(); listViewKunde_Load();

View File

@ -4,9 +4,6 @@
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <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" /> <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>
<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> </configSections>
<appSettings> <appSettings>
<add key="ConnectionString" value="user id=postgres;password=Ki985941Wi;host=10.10.10.1;port=5432;database=Test_Wirl;Timeout=5" /> <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"> <setting name="OLVState" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="Wirlblau" serializeAs="String">
<value>1, 53, 101</value>
</setting>
<setting name="ColPos" serializeAs="String"> <setting name="ColPos" serializeAs="String">
<value /> <value />
</setting> </setting>
@ -171,11 +171,4 @@
<connectionStrings> <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source = |SQL/CE|" /> <add name="DefaultConnection" connectionString="Data Source = |SQL/CE|" />
</connectionStrings> </connectionStrings>
<applicationSettings>
<Deckungsbeitrag.Properties.Settings>
<setting name="Wirlblau" serializeAs="String">
<value>1, 53, 101</value>
</setting>
</Deckungsbeitrag.Properties.Settings>
</applicationSettings>
</configuration> </configuration>

View File

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind. // die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Deckungsbeitrag")] [assembly: AssemblyTitle("Wirl-Verwaltung")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Kilian Wirl GmbH")]
[assembly: AssemblyProduct("Deckungsbeitrag")] [assembly: AssemblyProduct("Verwaltung")]
[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [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, // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben: // indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.3")] [assembly: AssemblyVersion("1.0.1.9")]
[assembly: AssemblyFileVersion("1.0.1.3")] [assembly: AssemblyFileVersion("1.0.1.9")]

View File

@ -35,13 +35,16 @@ namespace Deckungsbeitrag.Properties {
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1, 53, 101")] [global::System.Configuration.DefaultSettingValueAttribute("1, 53, 101")]
public global::System.Drawing.Color Wirlblau { public global::System.Drawing.Color Wirlblau {
get { get {
return ((global::System.Drawing.Color)(this["Wirlblau"])); return ((global::System.Drawing.Color)(this["Wirlblau"]));
} }
set {
this["Wirlblau"] = value;
}
} }
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]

View File

@ -5,7 +5,7 @@
<Setting Name="OLVState" Type="System.String" Scope="User"> <Setting Name="OLVState" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </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> <Value Profile="(Default)">1, 53, 101</Value>
</Setting> </Setting>
<Setting Name="ColPos" Type="System.Drawing.Color" Scope="User"> <Setting Name="ColPos" Type="System.Drawing.Color" Scope="User">

View File

@ -1621,15 +1621,15 @@
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:SetupVerwaltung" "ProductName" = "8:SetupVerwaltung"
"ProductCode" = "8:{9E8C033A-6762-4108-957E-1D834D568DC0}" "ProductCode" = "8:{6D0E142B-44EA-43EA-9CA0-F4A2BFBC22AF}"
"PackageCode" = "8:{B5ED7236-241E-4943-A031-B70E366CC2D5}" "PackageCode" = "8:{4252B4CA-B810-4CA9-9A37-AF7373000FBA}"
"UpgradeCode" = "8:{2DC7CE56-8D1C-42EB-B326-2E887EBB7F5A}" "UpgradeCode" = "8:{2DC7CE56-8D1C-42EB-B326-2E887EBB7F5A}"
"AspNetVersion" = "8:" "AspNetVersion" = "8:"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:FALSE" "RemovePreviousVersions" = "11:FALSE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE" "InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.0.9" "ProductVersion" = "8:1.0.15"
"Manufacturer" = "8:Kilian Wirl GmbH" "Manufacturer" = "8:Kilian Wirl GmbH"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"

69
UserSettingsManager.cs Normal file
View 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);
}
}
}

View File

@ -52,6 +52,9 @@
<PropertyGroup> <PropertyGroup>
<StartupObject>Deckungsbeitrag.Program</StartupObject> <StartupObject>Deckungsbeitrag.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationIcon>wirlneu_transparent %281%29.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL"> <Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL">
<HintPath>packages\AForge.2.2.5\lib\AForge.dll</HintPath> <HintPath>packages\AForge.2.2.5\lib\AForge.dll</HintPath>
@ -364,6 +367,7 @@
<Compile Include="UCFach.Designer.cs"> <Compile Include="UCFach.Designer.cs">
<DependentUpon>UCFach.cs</DependentUpon> <DependentUpon>UCFach.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UserSettingsManager.cs" />
<EmbeddedResource Include="AA-Forms\FormArtikelVW.resx"> <EmbeddedResource Include="AA-Forms\FormArtikelVW.resx">
<DependentUpon>FormArtikelVW.cs</DependentUpon> <DependentUpon>FormArtikelVW.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@ -486,6 +490,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="ILLink\ILLink.Descriptors.LibraryBuild.xml" /> <Content Include="ILLink\ILLink.Descriptors.LibraryBuild.xml" />
<Content Include="wirlneu_transparent %281%29.ico" />
<None Include="Resources\Close_WhiteNoHalo_16x.png" /> <None Include="Resources\Close_WhiteNoHalo_16x.png" />
<None Include="Resources\Monaco_Settings_16x.png" /> <None Include="Resources\Monaco_Settings_16x.png" />
<Content Include="Resources\QR.png" /> <Content Include="Resources\QR.png" />