From 94ebdec1b0d3bd5cf63b5a84d1081c5a80eebf7b Mon Sep 17 00:00:00 2001 From: Kilian Wirl Date: Tue, 9 Dec 2025 19:18:28 +0100 Subject: [PATCH] =?UTF-8?q?FormListe=20LV-Schriftgr=C3=B6=C3=9Fe=20&=20TB-?= =?UTF-8?q?TextChanged,=20UserSettings=20mit=20UserSettingManager,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AA-Forms/FormEinstellung.cs | 65 ++++++++++++------------ AA-Forms/FormExpedit.cs | 5 ++ AA-Forms/FormListe.Designer.cs | 2 +- AA-Forms/FormListe.cs | 13 +---- App.config | 13 ++--- Properties/AssemblyInfo.cs | 10 ++-- Properties/Settings.Designer.cs | 5 +- Properties/Settings.settings | 2 +- SetupVerwaltung/SetupVerwaltung.vdproj | 6 +-- UserSettingsManager.cs | 69 ++++++++++++++++++++++++++ Verwaltung.csproj | 5 ++ 11 files changed, 132 insertions(+), 63 deletions(-) create mode 100644 UserSettingsManager.cs diff --git a/AA-Forms/FormEinstellung.cs b/AA-Forms/FormEinstellung.cs index a18f025..3b3c02e 100644 --- a/AA-Forms/FormEinstellung.cs +++ b/AA-Forms/FormEinstellung.cs @@ -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(); } } diff --git a/AA-Forms/FormExpedit.cs b/AA-Forms/FormExpedit.cs index cf24a79..999192d 100644 --- a/AA-Forms/FormExpedit.cs +++ b/AA-Forms/FormExpedit.cs @@ -672,6 +672,11 @@ namespace Deckungsbeitrag this.dGArtikel.Rows.Clear(); } + /// + /// Einstellungen vor allem Drucker für SWS und Etikett funktioniert nicht weil schreiben auf .config nicht möglich. + /// + /// + /// private void buttonEinstellung_Click(object sender, EventArgs e) { FormEinstellung einstellung = new FormEinstellung(this); diff --git a/AA-Forms/FormListe.Designer.cs b/AA-Forms/FormListe.Designer.cs index bbe703c..5db56bc 100644 --- a/AA-Forms/FormListe.Designer.cs +++ b/AA-Forms/FormListe.Designer.cs @@ -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; diff --git a/AA-Forms/FormListe.cs b/AA-Forms/FormListe.cs index d5b87be..44421b7 100644 --- a/AA-Forms/FormListe.cs +++ b/AA-Forms/FormListe.cs @@ -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(); diff --git a/App.config b/App.config index d26fdb3..638466a 100644 --- a/App.config +++ b/App.config @@ -4,9 +4,6 @@
- -
- @@ -88,6 +85,9 @@ + + 1, 53, 101 + @@ -171,11 +171,4 @@ - - - - 1, 53, 101 - - - \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 06a6c2e..1c3aa35 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 47573fb..94896d7 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -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()] diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 5cadf72..fa75501 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -5,7 +5,7 @@ - + 1, 53, 101 diff --git a/SetupVerwaltung/SetupVerwaltung.vdproj b/SetupVerwaltung/SetupVerwaltung.vdproj index deb4fa1..439f59c 100644 --- a/SetupVerwaltung/SetupVerwaltung.vdproj +++ b/SetupVerwaltung/SetupVerwaltung.vdproj @@ -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:" diff --git a/UserSettingsManager.cs b/UserSettingsManager.cs new file mode 100644 index 0000000..570deeb --- /dev/null +++ b/UserSettingsManager.cs @@ -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(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); + } + } +} + diff --git a/Verwaltung.csproj b/Verwaltung.csproj index 30c82e5..a15d7ab 100644 --- a/Verwaltung.csproj +++ b/Verwaltung.csproj @@ -52,6 +52,9 @@ Deckungsbeitrag.Program + + wirlneu_transparent %281%29.ico + packages\AForge.2.2.5\lib\AForge.dll @@ -364,6 +367,7 @@ UCFach.cs + FormArtikelVW.cs @@ -486,6 +490,7 @@ +