Skip to content

Commit c0b999e

Browse files
committed
Display message box to set all default values to the current entered value if all default values are currently the same.
1 parent 448295f commit c0b999e

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

EDSEditorGUI/DeviceODView.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,22 +534,29 @@ private void ObjectSave()
534534

535535
// Default value
536536
bool setDefaultValueToAll = false;
537-
if (od.parent != null && od.Subindex > 0 && od.defaultvalue == "" && textBox_defaultValue.Text != "")
537+
bool identicalDefaultValues = true;
538+
string oldDefaultValue = "";
539+
if (od.parent != null && od.Subindex > 1)
538540
{
539-
DialogResult confirm = MessageBox.Show("Do you want to set the Default value to all unset default values in subobjects?", "Set to all?", MessageBoxButtons.YesNo);
540-
if (confirm == DialogResult.Yes)
541+
542+
for (int i = 2; i < od.parent.Nosubindexes; i++)
541543
{
542-
setDefaultValueToAll = true;
544+
identicalDefaultValues &= (od.parent.subobjects[(ushort)i].defaultvalue == od.parent.subobjects[(ushort)(i - 1)].defaultvalue);
545+
}
546+
547+
if (identicalDefaultValues) {
548+
DialogResult confirm = MessageBox.Show("Do you want to set all identical default values in subobjects to this default value?", "Set to all?", MessageBoxButtons.YesNo);
549+
if (confirm == DialogResult.Yes)
550+
{
551+
setDefaultValueToAll = true;
552+
}
543553
}
544554
}
545555
if (setDefaultValueToAll)
546556
{
547557
for (ushort i = 1; i < od.parent.Nosubindexes; i++)
548558
{
549-
if (od.parent.subobjects[i].defaultvalue == "")
550-
{
551559
od.parent.subobjects[i].defaultvalue = textBox_defaultValue.Text;
552-
}
553560
}
554561
}
555562
else

0 commit comments

Comments
 (0)