This commit is contained in:
2008-10-03 11:32:56 +00:00
parent 9ee8986e50
commit 722e41b25e
9 changed files with 1312 additions and 1376 deletions

View File

@@ -16,6 +16,7 @@ namespace VEPROMS
private string _DefaultFormatName = null;
private bool _Initializing;
private SectionConfig _SectionConfig;
private Document _DocumentToDelete = null;
public frmSectionProperties(SectionConfig sectionConfig)
{
@@ -47,17 +48,25 @@ namespace VEPROMS
private void btnSectPropOK_Click(object sender, EventArgs e)
{
sectionConfigBindingSource.EndEdit();
// Save Default settings for User
//
// Save whether we should display the default values on this property page
Settings.Default.ShowDefaultSectionProp = ppCbShwDefSettings.Checked;
Settings.Default.Save();
DialogResult = DialogResult.OK;
_SectionConfig.MySection.Save().Dispose();
// if there was a document to delete, do it.
if (_DocumentToDelete != null)
{
Document.Delete(_DocumentToDelete.DocID);
_DocumentToDelete = null;
}
this.Close();
}
private void btnSectPropCancel_Click(object sender, EventArgs e)
{
_DocumentToDelete = null;
sectionConfigBindingSource.CancelEdit();
DialogResult = DialogResult.Cancel;
this.Close();
@@ -87,7 +96,7 @@ namespace VEPROMS
_Initializing = true;
sectionConfigBindingSource.DataSource = _SectionConfig;
//formatInfoListBindingSource.DataSource = FormatInfoList.Get();
ppCmbxFormat.DataSource = null;
ppCmbxFormat.DisplayMember = "FullName";
ppCmbxFormat.ValueMember = "FullName";
@@ -122,9 +131,39 @@ namespace VEPROMS
ppCmbxNumColumns.ValueMember = "EValue";
ppCmbxNumColumns.SelectedIndex = -1;
_Initializing = false;
if (!cbIsStepSection.Enabled) ppCmbxLibDocFill();
_Initializing = false;
}
private void ppCmbxLibDocFill()
{
_Initializing = true;
bool isLib = _SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "";
if (isLib)
{
ppBtnCvrtToLibDoc.Text = "Convert this Section To A Non-Library Document";
lblLibraryDocument.Text = "Library Document";
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Non-Library Document", "", "This button will convert the current section from a library document to a non-library document",
null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76)));
}
else
{
ppBtnCvrtToLibDoc.Text = "Convert this to a Library Document";
lblLibraryDocument.Text = "Select Library Document to Link";
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" +
"o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76)));
}
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
for (int i = 0; i < LibDocList.Count; i++)
{
ppCmbxLibDoc.Items.Add(LibDocList[i].DocumentTitle);
// see if this lib doc should be the selected index?
if (isLib && (LibDocList[i].DocID == _SectionConfig.MySection.MyContent.MyEntry.MyDocument.DocID)) ppCmbxLibDoc.SelectedIndex = i;
}
_Initializing = false;
}
#region General tab
/// <summary>
@@ -208,6 +247,31 @@ namespace VEPROMS
ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting
}
private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e)
{
if (_Initializing) return;
if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue))
{
ppBtnDefaultFmt.Focus();
ppBtnDefaultFmt.PerformClick();
}
ppBtnDefaultFmt.Visible = (ppCmbxFormat.SelectedValue != null);
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
SetupPpCmbxSectionType();
}
private void ppCmbxStyleSectionType_SelectedValueChanged(object sender, EventArgs e)
{
if (_Initializing) return;
if (ppCmbxStyleSectionType.SelectedValue != null)
_SectionConfig.SectionType = (int)(ppCmbxStyleSectionType.SelectedValue);
}
private void cbIsStepSection_CheckedChanged(object sender, EventArgs e)
{
if (_Initializing) return;
SetupPpCmbxSectionType();
}
#endregion
#region Library Document tab
@@ -221,7 +285,76 @@ namespace VEPROMS
{
ProcessButtonClick(tiLibDoc, btnLibDocs);
}
private void ppBtnCvrtToLibDoc_Click(object sender, EventArgs e)
{
// If current section is library document, user selected to convert to non-library document. If
// this is the case, data from lib doc must be copied to new document and the section must point
// to id.
if (ppBtnCvrtToLibDoc.Text.IndexOf("Non") > 0) // convert to a 'non' library.
{
ItemInfo ii = ItemInfo.Get(_SectionConfig.MySection.ItemID);
DocumentInfo doclibinfo = ii.MyContent.MyEntry.MyDocument;
// if just one usage (this one), then just convert this to a non-library document. If there are more
// than one usage, make a copy so that the rest of the usages still point to the library document.
if (doclibinfo.DocumentEntryCount == 1)
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = null;
else
{
// make new document with 'no' libtitle - use libtitle for the doc title. Then link this
// to the item...
Document doc = Document.MakeDocument(null, doclibinfo.DocContent, null, null);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc;
}
ppCmbxLibDoc.Items.Clear();
ppCmbxLibDoc.WatermarkEnabled = true;
ppBtnCvrtToLibDoc.Text = "Convert this to a Library Document";
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" +
"o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76)));
}
// If current section is not a library document, the user selected the button to convert it to a
// library document, to do this, just put 'text' into the 'LibTitle' property (that's what flags
// it to be a library document.
else
{
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = _SectionConfig.MySection.MyContent.Text;
// TODO: Kbr/Rhm - CSLA was not saving document (libtitle change) on higher level save. Delete following
// line after this is fixed.
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.Save();
// ppCmbxLibDocFill();
ppCmbxLibDoc.Enabled = false;
}
}
private void ppCmbxLibDoc_SelectedIndexChanged(object sender, EventArgs e)
{
if (_Initializing) return;
// see if this was NOT a library document. If it is not a library document, ask the user if
// it should be linked, thus losing the original text/data.
if (!(_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != ""))
{
if (ppCmbxLibDoc.SelectedIndex > -1)
{
if (MessageBox.Show("Linking to this library document will cause loss of data. Do you want to continue?", "Link", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_DocumentToDelete = _SectionConfig.MySection.MyContent.MyEntry.MyDocument;
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
}
else
{
ppCmbxLibDoc.SelectedIndex = -1;
}
}
}
else
{
// it already is a library document, just change usages...
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
}
}
#endregion
#region View Settings tab
@@ -289,32 +422,7 @@ namespace VEPROMS
defaultSettingsVisiblity();
}
#endregion
private void ppCmbxStyleSectionType_SelectedValueChanged(object sender, EventArgs e)
{
if (_Initializing) return;
if (ppCmbxStyleSectionType.SelectedValue != null)
_SectionConfig.SectionType = (int)(ppCmbxStyleSectionType.SelectedValue);
}
private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e)
{
if (_Initializing) return;
if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue))
{
ppBtnDefaultFmt.Focus();
ppBtnDefaultFmt.PerformClick();
}
ppBtnDefaultFmt.Visible = (ppCmbxFormat.SelectedValue != null);
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
SetupPpCmbxSectionType();
}
private void cbIsStepSection_CheckedChanged(object sender, EventArgs e)
{
if (_Initializing) return;
SetupPpCmbxSectionType();
}
}
}