Fixed a bug that allowed the user to change a section’s format to a format that did not support that document style
This commit is contained in:
parent
5de80d59d1
commit
e0bac39b9b
@ -259,7 +259,7 @@ namespace VEPROMS
|
|||||||
ppCmbxFormat.DisplayMember = "FullName";
|
ppCmbxFormat.DisplayMember = "FullName";
|
||||||
ppCmbxFormat.ValueMember = "FullName";
|
ppCmbxFormat.ValueMember = "FullName";
|
||||||
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
|
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
|
||||||
|
ppCmbxFormat.SelectedIndex = -1;
|
||||||
// Get the saved settings for this user
|
// Get the saved settings for this user
|
||||||
//
|
//
|
||||||
// Get setting telling us whether to display the default values on this property page
|
// Get setting telling us whether to display the default values on this property page
|
||||||
@ -408,7 +408,9 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Initializing = false;
|
_Initializing = false;
|
||||||
|
//_InitialIndex = ppCmbxFormat.SelectedIndex;
|
||||||
}
|
}
|
||||||
|
int _InitialIndex = -2;
|
||||||
|
|
||||||
private void ppCmbxLibDocFill()
|
private void ppCmbxLibDocFill()
|
||||||
{
|
{
|
||||||
@ -464,7 +466,6 @@ namespace VEPROMS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Format tab
|
#region Format tab
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the Format button used on the button interface design
|
/// This is the Format button used on the button interface design
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -473,7 +474,7 @@ namespace VEPROMS
|
|||||||
private void btnFormat_Click(object sender, EventArgs e)
|
private void btnFormat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ProcessButtonClick(tiFormat, btnFormat);
|
ProcessButtonClick(tiFormat, btnFormat);
|
||||||
|
if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section is set to the default format)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupPpCmbxSectionType()
|
private void SetupPpCmbxSectionType()
|
||||||
@ -603,23 +604,83 @@ namespace VEPROMS
|
|||||||
|
|
||||||
private void ppBtnDefaultFmt_Click(object sender, EventArgs e)
|
private void ppBtnDefaultFmt_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting
|
bool foundMatch = false;
|
||||||
|
bool isWordSection = rbWordSect.Checked;
|
||||||
|
FormatInfo dfi = _SectionConfig.MyDefaultFormat;
|
||||||
|
// check to see if the default format has a similar document style
|
||||||
|
// if it does not, then do not allow the selection of the default format
|
||||||
|
foreach (DocStyle ds in dfi.PlantFormat.DocStyles.DocStyleList)
|
||||||
|
{
|
||||||
|
if (ds.IsStepSection != isWordSection) foundMatch = true;
|
||||||
|
}
|
||||||
|
if (foundMatch)
|
||||||
|
{
|
||||||
|
_Initializing = true;
|
||||||
|
ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting
|
||||||
|
_Initializing = false;
|
||||||
|
SetupPpCmbxSectionType();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string suffix = "format ";
|
||||||
|
if (_DefaultFormatName.ToUpper().Contains("FORMAT")) suffix = "";
|
||||||
|
MessageBox.Show(string.Format("{0}\n\n{1}does not support {2} section type", _DefaultFormatName, suffix, isWordSection ? "MS Word" : "Step"), "Incompatible Format", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e)
|
private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_Initializing) return;
|
if (_Initializing)
|
||||||
|
{
|
||||||
|
// determine if the default button and the default description text should visable
|
||||||
|
ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1);
|
||||||
|
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section format is not the default section)
|
||||||
|
PlantFormat pf = FormatInfoList.SortedFormatInfoList[ppCmbxFormat.SelectedIndex].PlantFormat;
|
||||||
|
// If the selected format does not have a docstyle compatable with the section
|
||||||
|
// then reset the format selection back to what it was
|
||||||
|
if (!ValidPlantFormat(pf))
|
||||||
|
{
|
||||||
|
_Initializing = true;
|
||||||
|
ppCmbxFormat.SelectedIndex = _InitialIndex; // reset the format selection to what it was
|
||||||
|
ppBtnCancel.Focus(); // this will force the property page to refresh
|
||||||
|
_Initializing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool didDefault = false;
|
bool didDefault = false;
|
||||||
if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue))
|
if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue))
|
||||||
{
|
{
|
||||||
ppBtnDefaultFmt.Focus();
|
ppBtnDefaultFmt.Focus();
|
||||||
ppBtnDefaultFmt.PerformClick();
|
ppBtnDefaultFmt.PerformClick();
|
||||||
didDefault = true;
|
didDefault = true;
|
||||||
}
|
}
|
||||||
ppBtnDefaultFmt.Visible = (ppCmbxFormat.SelectedValue != null);
|
// determine if the default button and the default description text should visable
|
||||||
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
|
ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1);
|
||||||
if (!didDefault)SetupPpCmbxSectionType();
|
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
|
||||||
}
|
//if (!didDefault) SetupPpCmbxSectionType();
|
||||||
|
SetupPpCmbxSectionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is used when the user selects different format for a give section.
|
||||||
|
// It will verify that the newly selected format contains a document style (docstyle)
|
||||||
|
// 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;
|
||||||
|
foreach (DocStyle ds in pf.DocStyles.DocStyleList)
|
||||||
|
{
|
||||||
|
if (ds.IsStepSection != isWordSection) foundMatch = true;
|
||||||
|
}
|
||||||
|
if (foundMatch)
|
||||||
|
return true; // valid format
|
||||||
|
string suffix = "format ";
|
||||||
|
if (ppCmbxFormat.SelectedValue.ToString().ToUpper().Contains("FORMAT")) suffix = "";
|
||||||
|
MessageBox.Show(string.Format("{0}\n\n{1}does not support {2} section type", ppCmbxFormat.SelectedValue, suffix, isWordSection ? "MS Word" : "Step"), "Incompatible Format", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void ppCmbxStyleSectionType_SelectedValueChanged(object sender, EventArgs e)
|
private void ppCmbxStyleSectionType_SelectedValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user