diff --git a/tabler/Classes/Settings.cs b/tabler/Classes/Settings.cs index 271e82b..8fdd261 100644 --- a/tabler/Classes/Settings.cs +++ b/tabler/Classes/Settings.cs @@ -8,11 +8,13 @@ namespace tabler.Classes { public class Settings { public IndentationSettings IndentationSettings { get; set; } public int TabSize { get; set; } + public bool RemoveEmptyNodes { get; set; } public Settings() { // defaults IndentationSettings = IndentationSettings.Spaces; TabSize = 4; + RemoveEmptyNodes = true; } } diff --git a/tabler/Helper/ConfigHelper.cs b/tabler/Helper/ConfigHelper.cs index 30b3458..2efdb00 100644 --- a/tabler/Helper/ConfigHelper.cs +++ b/tabler/Helper/ConfigHelper.cs @@ -13,6 +13,7 @@ public class ConfigHelper { private const string LASTPATHTODATAFILES_NAME = "LastPathToDataFiles"; private const string INDENTATION_NAME = "Indentation"; private const string TABSIZE_NAME = "TabSize"; + private const string EMPTYNODES_NAME = "RemoveEmptyNodes"; private readonly FileInfo _fiConfig = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"config\config.xml")); private XDocument _xDocConfig; @@ -36,8 +37,9 @@ private XDocument CreateOrLoadConfig(bool forceCreation) { var path = new XElement(LASTPATHTODATAFILES_NAME); var indent = new XElement(INDENTATION_NAME, 0); var tabsize = new XElement(TABSIZE_NAME, 4); + var removeEmptyNodes = new XElement(EMPTYNODES_NAME, true); - var lstElements = new List { path, indent, tabsize }; + var lstElements = new List { path, indent, tabsize, removeEmptyNodes }; _xDocConfig = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), @@ -135,6 +137,11 @@ public Settings GetSettings() { loadedSettings.TabSize = int.Parse(tabSizeElement.Value); } + var removeEmptyNodes = _xDocConfig.Descendants().FirstOrDefault(d => d.Name == EMPTYNODES_NAME); + if (removeEmptyNodes != null) { + loadedSettings.RemoveEmptyNodes = bool.Parse(removeEmptyNodes.Value); + } + return loadedSettings; } @@ -168,6 +175,13 @@ public bool SaveSettings(Settings settingsToSave) { CreateOrLoadConfig(true); } + var removeEmptyNodes = _xDocConfig.Descendants().FirstOrDefault(d => d.Name == EMPTYNODES_NAME); + if (removeEmptyNodes != null) { + removeEmptyNodes.Value = settingsToSave.RemoveEmptyNodes.ToString(); + } else { + CreateOrLoadConfig(true); + } + SaveConfigXml(); return true; } diff --git a/tabler/Helper/GridUiHelper.cs b/tabler/Helper/GridUiHelper.cs index ffc4dcc..ad13f11 100644 --- a/tabler/Helper/GridUiHelper.cs +++ b/tabler/Helper/GridUiHelper.cs @@ -147,7 +147,7 @@ private DataGridView CreateGridViewAndFillWithData(TranslationComponents tc, str row.Cells[index].Style.BackColor = Color.FromKnownColor(COLOR_BASELANGUAGE); } - if (!translationsWithKey.Value.ContainsKey(header)) { + if (!translationsWithKey.Value.ContainsKey(header) || String.IsNullOrWhiteSpace(translationsWithKey.Value[header])) { row.Cells[index].Style.BackColor = Color.FromKnownColor(COLOR_EMPTYCELL); AddMissingTranslationToStatistics(tc.Statistics, header, currentModule); } else { diff --git a/tabler/Helper/XmlHelper.cs b/tabler/Helper/XmlHelper.cs index 53d9409..67d9260 100644 --- a/tabler/Helper/XmlHelper.cs +++ b/tabler/Helper/XmlHelper.cs @@ -157,9 +157,14 @@ public void UpdateXmlFiles(List filesByNameInDirectory, List d.IsEmpty || String.IsNullOrWhiteSpace(d.Value)).Remove(); + } + } + using (var writer = XmlWriter.Create(currentFileInfo.FullName, xmlSettings)) { xdoc.Save(writer); } diff --git a/tabler/SettingsForm.Designer.cs b/tabler/SettingsForm.Designer.cs index 94ecd59..39af039 100644 --- a/tabler/SettingsForm.Designer.cs +++ b/tabler/SettingsForm.Designer.cs @@ -30,7 +30,10 @@ private void InitializeComponent() { this.rbIndentSpaces = new System.Windows.Forms.RadioButton(); this.tbIndentation = new System.Windows.Forms.TextBox(); this.rbIndentTabs = new System.Windows.Forms.RadioButton(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.cbRemoveEmptyNodes = new System.Windows.Forms.CheckBox(); this.grpBIndentation.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // btnCancel @@ -76,10 +79,26 @@ private void InitializeComponent() { this.rbIndentTabs.UseVisualStyleBackColor = true; this.rbIndentTabs.CheckedChanged += new System.EventHandler(this.rbIndentTabs_CheckedChanged); // + // groupBox1 + // + resources.ApplyResources(this.groupBox1, "groupBox1"); + this.groupBox1.Controls.Add(this.cbRemoveEmptyNodes); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.TabStop = false; + // + // cbRemoveEmptyNodes + // + resources.ApplyResources(this.cbRemoveEmptyNodes, "cbRemoveEmptyNodes"); + this.cbRemoveEmptyNodes.Checked = true; + this.cbRemoveEmptyNodes.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbRemoveEmptyNodes.Name = "cbRemoveEmptyNodes"; + this.cbRemoveEmptyNodes.UseVisualStyleBackColor = true; + // // SettingsForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.groupBox1); this.Controls.Add(this.grpBIndentation); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnSaveSettings); @@ -87,6 +106,8 @@ private void InitializeComponent() { this.Load += new System.EventHandler(this.Settings_Load); this.grpBIndentation.ResumeLayout(false); this.grpBIndentation.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.ResumeLayout(false); } @@ -99,5 +120,7 @@ private void InitializeComponent() { private System.Windows.Forms.RadioButton rbIndentSpaces; private System.Windows.Forms.TextBox tbIndentation; private System.Windows.Forms.RadioButton rbIndentTabs; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.CheckBox cbRemoveEmptyNodes; } } \ No newline at end of file diff --git a/tabler/SettingsForm.cs b/tabler/SettingsForm.cs index e8eebe3..202643b 100644 --- a/tabler/SettingsForm.cs +++ b/tabler/SettingsForm.cs @@ -56,6 +56,8 @@ private void btnSaveSettings_Click(object sender, System.EventArgs e) { } } + newSettings.RemoveEmptyNodes = cbRemoveEmptyNodes.Checked; + configHelper.SaveSettings(newSettings); Close(); } diff --git a/tabler/SettingsForm.de.resx b/tabler/SettingsForm.de.resx index 0764233..c172c37 100644 --- a/tabler/SettingsForm.de.resx +++ b/tabler/SettingsForm.de.resx @@ -119,7 +119,7 @@ - 114, 116 + 114, 142 Abbrechen @@ -127,6 +127,12 @@ Speichern + + 177, 72 + + + Einrückung + 83, 17 @@ -145,14 +151,20 @@ Tabulatoren - - 177, 72 + + 177, 46 - - Einrückung + + Leere Nodes + + + 160, 17 + + + Leere XML-Nodes entfernen - 201, 151 + 201, 179 diff --git a/tabler/SettingsForm.resx b/tabler/SettingsForm.resx index 27d283d..6c731cb 100644 --- a/tabler/SettingsForm.resx +++ b/tabler/SettingsForm.resx @@ -117,163 +117,166 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + grpBIndentation - - Settings - - - 6, 13 + + 132, 17 - - 75, 23 + + $this - - - True + + Spaces - - $this + + 73, 41 - - 10 + + btnCancel + + + 7, 20 1 - + + 0 - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 75, 23 + + SettingsForm - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 12, 142 - - btnSaveSettings + + 7 - + + Save + + True - - 7 + + 12 - - 2 + + 6, 19 - - grpBIndentation + + groupBox1 - - $this + + 6, 13 + + + 12, 12 + + + True + + + cbRemoveEmptyNodes + + + 0 + + + tbIndentation + + + Indentation 6 - - 179, 151 + + 13 - - 93, 116 + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Spaces + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - rbIndentSpaces + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 61, 17 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 29, 20 + + grpBIndentation + + + groupBox1 10 - - 12, 116 - - - 12, 12 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - tbIndentation + + 2 - - Tabs + + 29, 20 - + 1 - - grpBIndentation + + Remove Empty Nodes - - SettingsForm + + rbIndentSpaces - - btnCancel + + 11 - - Indentation + + $this - - Save + + 12, 90 - - 4 + + 93, 142 - - $this + + Tabs - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 156, 46 - - grpBIndentation + + 75, 23 - - Cancel + + 4 - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Indentation 6, 42 - - rbIndentTabs - - - 12 - - - 11 - - - 156, 72 - - + 2 - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 73, 41 + + 75, 23 @@ -5037,19 +5040,67 @@ /////////////////////////////////////////////////////////////////////////////w== - - 6, 19 - 49, 17 - + + 156, 72 + + + $this + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0 + + + Settings + + + 61, 17 + + + grpBIndentation + + + 3 + + + True + + + rbIndentTabs + + + btnSaveSettings + + + Cancel + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 179, 179 + + 0 + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + grpBIndentation + + + 10 + True - - de + + True \ No newline at end of file diff --git a/tabler/SettingsForm.ru.resx b/tabler/SettingsForm.ru.resx index 76b90c7..cda68cf 100644 --- a/tabler/SettingsForm.ru.resx +++ b/tabler/SettingsForm.ru.resx @@ -1,5 +1,64 @@ + @@ -60,7 +119,7 @@ - 114, 116 + 114, 142 Отменить @@ -68,8 +127,14 @@ Сохранить + + 177, 72 + + + Отступ + - 83, 17 + 71, 17 Пробелы @@ -81,19 +146,19 @@ 31, 20 - 82, 17 + 79, 17 Табуляция - - 177, 72 + + 177, 46 - - Отступ + + Empty Nodes - 201, 151 + 201, 177