diff --git a/src/UniversalValveToolbox/Model/VIewModel/FormAddonViewModel.cs b/src/UniversalValveToolbox/Model/VIewModel/FormAddonViewModel.cs
index 3d83562..0a0fab9 100644
--- a/src/UniversalValveToolbox/Model/VIewModel/FormAddonViewModel.cs
+++ b/src/UniversalValveToolbox/Model/VIewModel/FormAddonViewModel.cs
@@ -57,7 +57,14 @@ namespace UniversalValveToolbox.Model.ViewModel {
}
}
- public AddonDtoModel SelectAddon => addons[selectAddonIndex];
+ public AddonDtoModel SelectAddon {
+ get {
+ if (addons == null || addons.Length == 0)
+ return null;
+
+ return addons[selectAddonIndex];
+ }
+ }
public DictionaryEntry SelectCategory {
get { return categories[selectCategoryIndex]; }
diff --git a/src/UniversalValveToolbox/Properties/translations/VarStrings.Designer.cs b/src/UniversalValveToolbox/Properties/translations/VarStrings.Designer.cs
index 07f3b2b..dbd3363 100644
--- a/src/UniversalValveToolbox/Properties/translations/VarStrings.Designer.cs
+++ b/src/UniversalValveToolbox/Properties/translations/VarStrings.Designer.cs
@@ -61,7 +61,16 @@ namespace UniversalValveToolbox.Properties.translations {
}
///
- /// Looks up a localized string similar to <new project>.
+ /// Looks up a localized string similar to <New Addon>.
+ ///
+ internal static string strNewAddon {
+ get {
+ return ResourceManager.GetString("strNewAddon", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to <New Project>.
///
internal static string strNewProject {
get {
diff --git a/src/UniversalValveToolbox/Properties/translations/VarStrings.resx b/src/UniversalValveToolbox/Properties/translations/VarStrings.resx
index 46a5b9d..c7a6433 100644
--- a/src/UniversalValveToolbox/Properties/translations/VarStrings.resx
+++ b/src/UniversalValveToolbox/Properties/translations/VarStrings.resx
@@ -117,7 +117,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ <New Addon>
+
- <new project>
+ <New Project>
\ No newline at end of file
diff --git a/src/UniversalValveToolbox/Properties/translations/VarStrings.ru.resx b/src/UniversalValveToolbox/Properties/translations/VarStrings.ru.resx
index 972559d..7e479a7 100644
--- a/src/UniversalValveToolbox/Properties/translations/VarStrings.ru.resx
+++ b/src/UniversalValveToolbox/Properties/translations/VarStrings.ru.resx
@@ -117,7 +117,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ <Новое Дополнение>
+
- <новый проект>
+ <Новый Проект>
\ No newline at end of file
diff --git a/src/UniversalValveToolbox/UI/FormAddons.cs b/src/UniversalValveToolbox/UI/FormAddons.cs
index e3b185c..31c30af 100644
--- a/src/UniversalValveToolbox/UI/FormAddons.cs
+++ b/src/UniversalValveToolbox/UI/FormAddons.cs
@@ -75,11 +75,18 @@ namespace UniversalValveToolbox {
engineCheckedListBox.Items.Clear();
engineCheckedListBox.Items.AddRange(model.Engines);
- for (var i = 0; i < model.Engines.Length; i++) {
- var engine = model.Engines[i];
+ if (model.SelectAddon != null) {
+ for (var i = 0; i < model.Engines.Length; i++) {
+ var engine = model.Engines[i];
- if (model.SelectAddon.Engines.Contains(engine.Appid)) {
- engineCheckedListBox.SetItemChecked(i, true);
+ if (model.SelectAddon.Engines.Contains(engine.Appid)) {
+ engineCheckedListBox.SetItemChecked(i, true);
+ }
+ }
+ }
+ else {
+ for (var i = 0; i < model.Engines.Length; i++) {
+ engineCheckedListBox.SetItemChecked(i, false);
}
}
@@ -87,9 +94,15 @@ namespace UniversalValveToolbox {
}
private void UpdateAddonsComboBox() {
- comboBox_Addon.Items.Clear();
- comboBox_Addon.Items.AddRange(model.Addons);
- comboBox_Addon.SelectedIndex = 0;
+ if (model.Addons.Length == 0) {
+ New();
+ }
+ else {
+ comboBox_Addon.Items.Clear();
+ comboBox_Addon.Items.AddRange(model.Addons);
+
+ comboBox_Addon.SelectedIndex = 0;
+ }
}
private void UpdateAddonCategoryComboBox() {
@@ -136,8 +149,7 @@ namespace UniversalValveToolbox {
}
private void New() {
- var newAddon = new AddonDtoModel();
- newAddon.Name = "";
+ var newAddon = CreateNewEmptyAddon();
var newAddonList = new List(model.Addons);
newAddonList.Insert(0, newAddon);
@@ -147,6 +159,13 @@ namespace UniversalValveToolbox {
UpdateAddonsComboBox();
}
+ private AddonDtoModel CreateNewEmptyAddon() {
+ var newAddon = new AddonDtoModel();
+ newAddon.Name = Properties.translations.VarStrings.strNewAddon;
+
+ return newAddon;
+ }
+
private void Save() {
JsonFileUtil.SaveValues(DataProvider.AddonsPath, "json", model.Addons.ToList());
}