B2017-270 only enable the Steps Section and/or Word Section radio buttons if the format has them defined.

This commit is contained in:
John Jenko 2017-12-13 15:43:17 +00:00
parent 8b177644f7
commit bd167bbb13

View File

@ -59,8 +59,12 @@ namespace VEPROMS
_MyStepTabRibbon.Name = "displayTabRibbon1";
_MyStepTabRibbon.Visible = false;
// if creating a new section, enable the StepSect and WordSect radio buttons
rbStepSect.Enabled = rbWordSect.Enabled = !(ii.HasWordContent || ii.HasStepContent);
// B2017-272 disable/enable the Steps and Word radio buttons based on the section types defined in the format
// and the type of an existing section or if we are creating a new section.
// Move the check of creating a new section into CheckAvailableSectionTypes()
CheckAvaibleSectionTypes();
//// if creating a new section, enable the StepSect and WordSect radio buttons
//rbStepSect.Enabled = rbWordSect.Enabled = !(ii.HasWordContent || ii.HasStepContent);
// if this is an auto table of contents (mydocstyle == null if new section, so must check for that first)
if (ii.IsAutoTOCSection)
@ -78,6 +82,27 @@ namespace VEPROMS
if (ii.HasWordContent) _isStepSection = false;
}
// B2017-272 disable/enable the Steps and Word section radio buttons based on the section types defined in the format
// and the type of an existing section or if we are creating a new section
private void CheckAvaibleSectionTypes()
{
PlantFormat pf = (ppCmbxFormat.SelectedIndex != -1) ? FormatInfoList.SortedFormatInfoList[ppCmbxFormat.SelectedIndex].PlantFormat : (_SectionConfig.MyFormat != null) ? _SectionConfig.MyFormat.PlantFormat : _SectionConfig.MyDefaultFormat.PlantFormat;
ItemInfo ii = ItemInfo.Get(_SectionConfig.MySection.ItemID);
// if creating a new section, enable the StepSect and WordSect radio buttons
bool isNewSection = !(ii.HasWordContent || ii.HasStepContent);
int numStepSects = 0;
int numWordSects = 0;
foreach (DocStyle nds in pf.DocStyles.DocStyleListActive)
{
if (nds.IsStepSection)
numStepSects++;
else
numWordSects++;
}
rbStepSect.Enabled = (numStepSects > 0 && (isNewSection || ii.IsStepSection)); // there are step section types and current section is a step section or creating new section
rbWordSect.Enabled = (numWordSects > 0 && (isNewSection || !ii.IsStepSection)); // there are word section types and current section is a word section or creating new section
}
private void btnSectPropOK_Click(object sender, EventArgs e)
{
sectionConfigBindingSource.EndEdit();
@ -88,7 +113,8 @@ namespace VEPROMS
Settings.Default.ShowDefaultSectionProp = ppCbShwDefSettings.Checked;
Settings.Default.Save();
// save the type based on selection.
_SectionConfig.MySection.MyContent.Type = ((DocStyle)ppCmbxStyleSectionType.SelectedItem).Index + 10000;
if (ppCmbxStyleSectionType.Items.Count > 0) // B2017-270 user click on OK button but format does not have section style for this section type
_SectionConfig.MySection.MyContent.Type = ((DocStyle)ppCmbxStyleSectionType.SelectedItem).Index + 10000;
// save any changes to checkoffs. The bindings were added to the designer, but the 'save' was
// hanging, so they're being done here.
@ -628,7 +654,8 @@ namespace VEPROMS
}
}
ppCmbxStyleSectionType.DataSource = newDocStyles;
ppCmbxStyleSectionType.SelectedIndex = selindx;
if (newDocStyles.Count > 0)
ppCmbxStyleSectionType.SelectedIndex = selindx;
ppCmbxStyleSectionType.Refresh();
ppBtnConvertToDocX.Visible = false;// Set the Convert To DocX button to invisible by default
@ -745,6 +772,9 @@ namespace VEPROMS
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
//if (!didDefault) SetupPpCmbxSectionType();
SetupPpCmbxSectionType();
// B2017-272 disable/enable the Steps and Word radio buttons based on the section types defined in the format
// and the type of an existing section or if we are creating a new section.
CheckAvaibleSectionTypes();
}
// This function is used when the user selects different format for a give section.
@ -752,8 +782,8 @@ namespace VEPROMS
// compatable with the that section. (i.e. if the section is a Word section, the selected format has Word section docstyle)
private bool ValidPlantFormat(PlantFormat pf)
{
bool foundMatch = false;
bool isWordSection = rbWordSect.Checked;
bool foundMatch = false;
bool isWordSection = rbWordSect.Checked;
foreach (DocStyle ds in pf.DocStyles.DocStyleList)
{
if (ds.IsStepSection != isWordSection) foundMatch = true;