Skip to content

Commit

Permalink
Support default value for checkboxes parameters
Browse files Browse the repository at this point in the history
Checkboxes now taken into account to check if INFO must be saved
  • Loading branch information
vletroye committed Dec 13, 2017
1 parent 9be493a commit a7bacb5
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 86 deletions.
Binary file modified MyOwnDSMShortcuts/.vs/Mods/v14/.suo
Binary file not shown.
112 changes: 56 additions & 56 deletions MyOwnDSMShortcuts/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 57 additions & 26 deletions MyOwnDSMShortcuts/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ private void FillInfoScreen(string path)
{
if (info != null)
{
string subkey;
var unused = new List<string>(info.Keys);
foreach (var control in groupBoxPackage.Controls)
{
Expand All @@ -525,12 +526,15 @@ private void FillInfoScreen(string path)
textBox.Text = "";
foreach (var key in keys)
{
var subkey = key.Substring(3);
if (info.Keys.Contains(subkey))
if (key.StartsWith("PKG"))
{
if (string.IsNullOrEmpty(textBox.Text))
textBox.Text = info[subkey];
unused.Remove(subkey);
subkey = key.Substring(3);
if (info.Keys.Contains(subkey))
{
if (string.IsNullOrEmpty(textBox.Text))
textBox.Text = info[subkey];
unused.Remove(subkey);
}
}
}
}
Expand All @@ -541,14 +545,20 @@ private void FillInfoScreen(string path)
var keys = checkBox.Tag.ToString().Split(';');
foreach (var key in keys)
{
var val = key.Substring(3);
if (info.Keys.Contains(val))
subkey = key.Substring(3);
if (key.StartsWith("PKG"))
{
if (info.Keys.Contains(subkey))
{
unused.Remove(subkey);
tick = (info[subkey] == "yes");
}
}
if (key.StartsWith("DEF"))
{
unused.Remove(val);
tick = info[val] == "yes";
tick = (subkey == "yes");
}
}

checkBox.Checked = tick;
}
}
Expand All @@ -568,9 +578,7 @@ private void FillInfoScreen(string path)
unused.Remove("dsmuidir");
unused.Remove("checksum");
unused.Remove("adminport");//Not yet supported but ignored
//unused.Remove("arch");
unused.Remove("reloadui");//Not yet supported but ignored
unused.Remove("startable");//Not yet supported but ignored

unused.Remove("thirdparty");//Not yet supported but ignored
unused.Remove("startstop_restart_services");//Not yet supported but ignored
Expand Down Expand Up @@ -684,11 +692,14 @@ private void SavePackageInfo(string path)
var keys = textBox.Tag.ToString().Split(';');
foreach (var key in keys)
{
var keyId = key.Substring(3);
if (info.Keys.Contains(keyId))
info[keyId] = textBox.Text.Trim();
else
info.Add(keyId, textBox.Text.Trim());
if (key.StartsWith("PKG"))
{
var keyId = key.Substring(3);
if (info.Keys.Contains(keyId))
info[keyId] = textBox.Text.Trim();
else
info.Add(keyId, textBox.Text.Trim());
}
}
}
var checkBox = control as CheckBox;
Expand All @@ -697,12 +708,15 @@ private void SavePackageInfo(string path)
var keys = checkBox.Tag.ToString().Split(';');
foreach (var key in keys)
{
var keyId = key.Substring(3);
var value = checkBox.Checked ? "yes" : "no";
if (info.Keys.Contains(keyId))
info[keyId] = value;
else
info.Add(keyId, value);
if (key.StartsWith("PKG"))
{
var keyId = key.Substring(3);
var value = checkBox.Checked ? "yes" : "no";
if (info.Keys.Contains(keyId))
info[keyId] = value;
else
info.Add(keyId, value);
}
}
}
}
Expand All @@ -717,7 +731,10 @@ private void SavePackageInfo(string path)
{
foreach (var element in info)
{
outputFile.WriteLine("{0}=\"{1}\"", element.Key, element.Value);
if (!string.IsNullOrEmpty(element.Value))
{
outputFile.WriteLine("{0}=\"{1}\"", element.Key, element.Value);
}
}
}

Expand Down Expand Up @@ -2340,7 +2357,7 @@ private void textBoxDsmAppName_Validating(object sender, CancelEventArgs e)
{
if (!CheckEmpty(textBoxDsmAppName, ref e))
{
var name = textBoxDsmAppName.Text.Replace(".", "_").Replace("__","_");
var name = textBoxDsmAppName.Text.Replace(".", "_").Replace("__", "_");
var cleaned = Helper.CleanUpText(textBoxDsmAppName.Text);
if (name != cleaned)
{
Expand Down Expand Up @@ -2640,12 +2657,26 @@ private bool CheckChanges()
if (textBox != null && textBox.Tag != null && textBox.Tag.ToString().StartsWith("PKG"))
{
var keys = textBox.Tag.ToString().Split(';');
var key = keys[0].Substring(3);
var key = keys[0].Substring(3);

if (info.ContainsKey(key))
{
dirty = textBox.Text != info[key];

if (dirty)
break;
}
}
var checkBox = control as CheckBox;
if (checkBox != null && checkBox.Tag != null && checkBox.Tag.ToString().StartsWith("PKG"))
{
var keys = checkBox.Tag.ToString().Split(';');
var key = keys[0].Substring(3);

if (info.ContainsKey(key))
{
dirty = checkBox.Checked != (info[key] == "yes");

if (dirty)
break;
}
Expand Down
8 changes: 4 additions & 4 deletions MyOwnDSMShortcuts/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,16 @@ All: this app can be selected for all users.</value>
<data name="checkBoxLegacy.ToolTip" xml:space="preserve">
<value>When you select this option, urls will be opened in a DSM window instead of being opened in a new tab. However, this only works if you have disabled DSM's security option 'Improve security with HTTP Content Security Policy (CSP) header'</value>
</data>
<data name="checkBoxSupportCenter.ToolTip" xml:space="preserve">
<value>Check this option to let Package Center displays a link to make the end user launch Synology Support Center Application when your package is installed.
The report_url link won’t show in Package Center. </value>
</data>
<metadata name="openFileDialog4Mods.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>297, 17</value>
</metadata>
<metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>468, 17</value>
</metadata>
<data name="checkBoxSupportCenter.ToolTip" xml:space="preserve">
<value>Check this option to let Package Center displays a link to make the end user launch Synology Support Center Application when your package is installed.
The report_url link won’t show in Package Center. </value>
</data>
<metadata name="menuStripMainBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand Down
Binary file modified MyOwnDSMShortcuts/bin/Debug/Mods.exe
Binary file not shown.
Binary file modified MyOwnDSMShortcuts/bin/Debug/Mods.pdb
Binary file not shown.
Binary file modified MyOwnDSMShortcuts/bin/Release.zip
Binary file not shown.
Binary file modified MyOwnDSMShortcuts/obj/Debug/Mods.csproj.GenerateResource.Cache
Binary file not shown.
Binary file modified MyOwnDSMShortcuts/obj/Debug/Mods.exe
Binary file not shown.
Binary file modified MyOwnDSMShortcuts/obj/Debug/Mods.pdb
Binary file not shown.

0 comments on commit a7bacb5

Please sign in to comment.