Enhanced Documents – various improvements

Enhanced Documents – existing docversion properties UI
This commit is contained in:
2016-01-20 16:35:48 +00:00
parent 33850f59c1
commit 77cdf81736
4 changed files with 1353 additions and 629 deletions

View File

@@ -22,6 +22,7 @@ namespace VEPROMS
{
private List<MiniConfig> _Apples;
private List<MiniConfig> _DeletedApples;
private List<EnhancedMiniConfig> _Enhanced;
private bool _Initializing = false;
private DocVersionConfig _DocVersionConfig;
@@ -78,7 +79,7 @@ namespace VEPROMS
}
max++;
System.Xml.XmlNode nn = xd.CreateElement("Slave");
AddSlaveAttribute(nn,"index",max.ToString());
AddSlaveAttribute(nn, "index", max.ToString());
AddSlaveAttribute(nn, "ID", mc.ID);
AddSlaveAttribute(nn, "Name", mc.Name);
AddSlaveAttribute(nn, "Number", mc.Number);
@@ -94,7 +95,7 @@ namespace VEPROMS
sn.AppendChild(nn);
return xd.OuterXml;
}
private void AddSlaveAttribute(System.Xml.XmlNode nn,string name,string value)
private void AddSlaveAttribute(System.Xml.XmlNode nn, string name, string value)
{
System.Xml.XmlAttribute xa = nn.OwnerDocument.CreateAttribute(name);
xa.InnerText = value;
@@ -106,7 +107,7 @@ namespace VEPROMS
{
if (_DeletedApples != null && _DeletedApples.Count > 0)
{
foreach(MiniConfig mc in _DeletedApples)
foreach (MiniConfig mc in _DeletedApples)
_DocVersionConfig.RemoveSlave(mc.Index);
}
foreach (MiniConfig mc in _Apples)
@@ -138,6 +139,27 @@ namespace VEPROMS
}
}
}
if (_Enhanced != null)
{
foreach (EnhancedMiniConfig emc in _Enhanced)
{
if (emc.IsDirty)
{
foreach (DVEnhancedDocument dved in _DocVersionConfig.MyEnhancedDocuments)
{
if (dved.Type == Convert.ToInt32(emc.Type))
{
// pdfxoffset must be int? how to check
dved.Name = emc.Name;
dved.PdfToken = emc.PdfToken;
dved.PdfX = Convert.ToInt32(emc.PdfXOffset);
}
}
}
}
_DocVersionConfig.SaveDVEnhancedDocuments();
}
_DocVersionConfig.Print_UnitNumberForPageList = ppTxbxUnitNum.Text;
docVersionConfigBindingSource.EndEdit();
@@ -296,7 +318,7 @@ namespace VEPROMS
ppCmbxProcSetType.DisplayMember = "Description";
ppCmbxProcSetType.ValueMember = "EValue";
ppCmbxProcSetType.Enabled = false; // maybe enable this if used for version creation
// check active format to see if the unit number text box on the format tab is visible.
if (_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.UnitNumber)
{
@@ -355,35 +377,174 @@ namespace VEPROMS
}
else
{
Button btnPC = new Button();
btnPC.Text = "Add Applicability to Working Draft";
btnPC.Width = 250;
btnPC.Location = new Point(25, 271);
btnPC.Parent = tcpGeneral;
btnPC.Click += new EventHandler(btnPC_Click);
btnApplicability.Visible = false;
tiApplicability.Visible = false;
Button btnPC = new Button();
btnPC.Text = "Add Applicability to Working Draft";
btnPC.Width = 250;
btnPC.Location = new Point(25, 271);
btnPC.Parent = tcpGeneral;
btnPC.Click += new EventHandler(btnPC_Click);
btnApplicability.Visible = false;
tiApplicability.Visible = false;
}
ppTxtBxPDFLoc.TextChanged += new EventHandler(ppTxtBxPDFLoc_TextChanged);
//end add new applicability stuff
lblProcSetRev.Visible = ppRTxtProcSetRev.Visible = _DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.MyStepSectionPrintData.UseXtraRevNumber;
_Initializing = false;
// the phone list button is only visible if the format has the print/phonelist format flag.
btnPhoneList.Visible = _DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList;
}
void btnPC_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "Are you sure you want to add Applicability to this Working Draft?", "Add Applicability", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes)
{
btnApplicability.Visible = true;
tiApplicability.Visible = true;
Button btnPC = (Button)sender;
btnPC.Visible = false;
btnApplicability_Click(sender, e);
}
}
InitEnhanced();
_Initializing = false;
}
private void InitEnhanced()
{
// first determine if enhanced tab should be turned off: KBR HOW?
// get enhanced tab's data if:
// 1) hasEnhancedPO: this is source and format file has the purchase options for enhanced deviation or enhanced background
// 2) isEnhanced: this docversion has a config/enhanced node that defines it as an enhanced document.
bool hasEnhancedPO = true; // for now all can be enhanced
bool isEnhanced = (_DocVersionConfig.MyEnhancedDocuments != null && _DocVersionConfig.MyEnhancedDocuments.Count == 1 && _DocVersionConfig.MyEnhancedDocuments[0].Type == 0);
// isEnhanced is an already existing enhanced document. Only allow the user to change the Pdf settings:
if (isEnhanced)
{
_Enhanced = new List<EnhancedMiniConfig>();
// only display the data from the config setting. And only allow modify of PdfID and PdfXoffset
lbEnhanced.Visible = false;
lblEnhSet.Visible = false;
DocVersionInfo dvi = DocVersionInfo.Get(_DocVersionConfig.MyEnhancedDocuments[0].VersionID);
DVEnhancedDocument dvedUseData = _DocVersionConfig.MyEnhancedDocuments[0];
DocVersionConfig dvc = dvi.MyConfig as DocVersionConfig;
EnhancedMiniConfig ecfg = new EnhancedMiniConfig(0, dvi.VersionID, "?", dvi.SearchDVPath, dvedUseData.Name, dvedUseData.Type.ToString(), dvedUseData.PdfToken, dvedUseData.PdfX.ToString());
cbxEnhVersions.Items.Add(dvi.SearchDVPath);
tbEnhName.Enabled = false;
tbEnhType.Enabled = false;
_Enhanced.Add(ecfg);
bsMiniEnhanced.DataSource = _Enhanced;
cbxEnhVersions.SelectedIndex = 0;
cbxEnhVersions.Enabled = false;
}
// This is a source document that already has settings KBR ? - Can additions can be made
else if (hasEnhancedPO)
{
// first set up existing enhanced linked documents (this is a listbox on left of form)
_Enhanced = new List<EnhancedMiniConfig>();
lbEnhanced.Visible = true;
lblEnhSet.Visible = true;
foreach (DVEnhancedDocument dved in _DocVersionConfig.MyEnhancedDocuments)
{
DocVersionInfo dvi = DocVersionInfo.Get(dved.VersionID);
DocVersionConfig dvc = dvi.MyConfig as DocVersionConfig;
EnhancedMiniConfig ecfg = new EnhancedMiniConfig(0, dvi.VersionID, "?", dvi.SearchDVPath, dved.Name, dved.Type.ToString(), dved.PdfToken, dved.PdfX.ToString());
cbxEnhVersions.Items.Add(dvi.SearchDVPath);
_Enhanced.Add(ecfg);
}
tbEnhName.Enabled = true;
tbEnhType.Enabled = false;
cbxEnhVersions.Enabled = false;
bsEnhanced.DataSource = _Enhanced;
if (cbxEnhVersions.Items.Count>0) cbxEnhVersions.SelectedIndex = 0;
if (lbEnhanced.Items.Count > 0) lbEnhanced.SelectedIndex = 0;
bsMiniEnhanced.DataSource = bsEnhanced.Current as EnhancedMiniConfig;
}
}
//private void InitEnhancedOld()
//{
// // get enhanced tab's data if:
// // 1) hasEnhancedPO: this is source and format file has the purchase options for enhanced deviation or enhanced background
// // 2) isEnhanced: this docversion has a config/enhanced node that defines it as an enhanced document.
// bool hasEnhancedPO = true;
// //if (((_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)
// // || ((_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds)) hasEnhancedPO = true;
// bool isEnhanced = (_DocVersionConfig.MyEnhancedDocuments != null && _DocVersionConfig.MyEnhancedDocuments.Count == 1 && _DocVersionConfig.MyEnhancedDocuments[0].Type == 0);
// if (hasEnhancedPO || isEnhanced)
// {
// // need to filter the list and add only those that are set for the current doc version whose properties
// // we are working with, or that have no setting. (If the docversion has a source that is not this one, don't list)
// DocVersionInfoList dvil = DocVersionInfoList.Get();
// _Enhanced = new List<EnhancedMiniConfig>();
// DVEnhancedDocument dvedUseData = null;
// int indxDataSource = 0;
// for (int ie = 0; ie < dvil.Count; ie++)
// {
// DocVersionInfo dvi = dvil[ie];
// // get config items for filling in the data:
// DocVersionConfig dvc = dvi.MyConfig as DocVersionConfig;
// // need to see if it should be include
// bool includeit = false;
// if (isEnhanced && dvi.VersionID == _DocVersionConfig.MyDocVersion.VersionID)
// {
// dvedUseData = dvc.MyEnhancedDocuments[0];
// includeit = true;
// }
// if (hasEnhancedPO && !isEnhanced)
// {
// // if this docversion has no relationships, include it:
// if (dvc.MyEnhancedDocuments == null || dvc.MyEnhancedDocuments.Count == 0)
// includeit = true;
// else
// {
// //DVEnhancedDocuments dveds = _DocVersionConfig.MyEnhancedDocuments;
// //foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
// //{
// // DVEnhancedDocument dved = dveds[ed.Type];
// // AddLinkToEnhancedDocument(cb, yLocation, ed.ItemID, dved.PdfToken, dved.PdfX);
// //}
// foreach (DVEnhancedDocument ed in dvc.MyEnhancedDocuments) // config for enhanced
// {
// if (ed.VersionID == _DocVersionConfig.MyDocVersion.VersionID)
// {
// // the displayed data is the enhanced config item pointing to this one:
// foreach (DVEnhancedDocument sed in _DocVersionConfig.MyEnhancedDocuments)
// {
// if (sed.VersionID == dvi.VersionID)
// {
// dvedUseData = sed;
// break;
// }
// }
// if (dvedUseData != null)
// {
// includeit = true;
// break;
// }
// }
// }
// }
// }
// if (includeit)
// {
// // get config items for filling in the data:
// EnhancedMiniConfig ecfg = null;
// if (dvedUseData != null)
// ecfg = new EnhancedMiniConfig(indxDataSource, dvi.VersionID, "?", dvi.SearchDVPath, dvedUseData.Name, dvedUseData.Type.ToString(), dvedUseData.PdfToken, dvedUseData.PdfX.ToString());
// else
// ecfg = new EnhancedMiniConfig(indxDataSource, dvi.VersionID, "?", dvi.SearchDVPath, "", "", "", "");
// indxDataSource++;
// _Enhanced.Add(ecfg);
// dvedUseData = null;
// includeit = false;
// if (isEnhanced) break;
// }
// }
// bsEnhanced.DataSource = _Enhanced;
// }
//}
void btnPC_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "Are you sure you want to add Applicability to this Working Draft?", "Add Applicability", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes)
{
btnApplicability.Visible = true;
tiApplicability.Visible = true;
Button btnPC = (Button)sender;
btnPC.Visible = false;
btnApplicability_Click(sender, e);
}
}
// The following code was added to fix Bug B2013-117
void ppTxtBxPDFLoc_TextChanged(object sender, EventArgs e)
{
@@ -733,7 +894,7 @@ namespace VEPROMS
{
// Show or hide the labels containing the default values
//if (!_Initializing)
defaultSettingsVisiblity();
defaultSettingsVisiblity();
}
/// <summary>
@@ -834,9 +995,9 @@ namespace VEPROMS
{
if (defaultText != null && !(defaultText.Equals("")))
{
string deftext = string.Format("{0}", defaultText);
lbl.Text = deftext;
cmbo.WatermarkText = deftext;
string deftext = string.Format("{0}", defaultText);
lbl.Text = deftext;
cmbo.WatermarkText = deftext;
}
}
@@ -891,7 +1052,7 @@ namespace VEPROMS
}
Cursor = Cursors.WaitCursor;
SelectedROFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(rdi, dva, _DocVersionConfig.MyDocVersion, SelectedROFst,DoProgressBarRefresh);
ROFst newrofst = ROFstInfo.UpdateRoFst(rdi, dva, _DocVersionConfig.MyDocVersion, SelectedROFst, DoProgressBarRefresh);
SelectedROFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ppBtnUpRoVals.Enabled = _DocVersionConfig.MyDocVersion.NewerRoFst;
Cursor = Cursors.Default;
@@ -1127,8 +1288,8 @@ namespace VEPROMS
{
MiniConfig cfg = new MiniConfig();
cfg.Name = "New Applicability";
if (_Apples == null)
_Apples = new List<MiniConfig>();
if (_Apples == null)
_Apples = new List<MiniConfig>();
_Apples.Add(cfg);
bsApples.DataSource = null;
bsApples.DataSource = _Apples;
@@ -1153,8 +1314,115 @@ namespace VEPROMS
dlgPhoneList dlgPL = new dlgPhoneList(_DocVersionConfig);
dlgPL.ShowDialog();
}
}
private void btnEnhanced_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiEnhanced, btnEnhanced);
}
private void lbEnhanced_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_Initializing && lbEnhanced.SelectedIndex > -1)
{
bsMiniEnhanced.DataSource = bsEnhanced.Current as EnhancedMiniConfig;
cbxEnhVersions.SelectedIndex = lbEnhanced.SelectedIndex;
}
}
}
[XmlRoot("Enhanced")]
public class EnhancedMiniConfig
{
private static int lastindex = 0;
private bool _isDeleted;
[XmlIgnore]
public bool IsDeleted
{
get { return _isDeleted; }
set { _isDeleted = value; }
}
private bool _isDirty;
[XmlIgnore]
public bool IsDirty
{
get { return _isDirty; }
set { _isDirty = value; }
}
private int _index;
[XmlAttribute("index")]
public int Index
{
get { return _index; }
set { _index = value; IsDirty = true; }
}
private int _versionID;
[XmlAttribute("VersionID")]
public int VersionID
{
get { return _versionID; }
set { _versionID = value; IsDirty = true; }
}
private string _versionPathName;
[XmlAttribute("VersionPathName")]
public string VersionPathName
{
get { return _versionPathName; }
set { _versionPathName = value; IsDirty = true; }
}
private string _name;
[XmlAttribute("Name")]
public string Name
{
get { return _name; }
set { _name = value; IsDirty = true; }
}
private string _type;
[XmlAttribute("Type")]
public string Type
{
get { return _type; }
set { _type = value; IsDirty = true; }
}
private string _pdfToken;
[XmlAttribute("PdfToken")]
public string PdfToken
{
get { return _pdfToken; }
set { _pdfToken = value; IsDirty = true; }
}
private string _pdfXOffset;
[XmlAttribute("PdfXOffset")]
public string PdfXOffset
{
get { return _pdfXOffset; }
set { _pdfXOffset = value; IsDirty = true; }
}
public EnhancedMiniConfig()
{
_index = --lastindex;
_versionID = -1;
_versionPathName = string.Empty;
_name = string.Empty;
_type = string.Empty;
_pdfToken = string.Empty;
_pdfXOffset = string.Empty;
_isDirty = false;
}
public EnhancedMiniConfig(int index, int versionid, string id, string versionPathName, string name, string type, string pdftoken, string pdfxoffset)
{
_index = index;
_versionID = versionid;
_versionPathName = versionPathName;
_name = name;
_type = type;
_pdfToken = pdftoken;
_pdfXOffset = pdfxoffset;
_isDirty = false;
}
public override string ToString()
{
return Name;
}
}
[XmlRoot("Slave")]
public class MiniConfig
{
@@ -1273,7 +1541,7 @@ namespace VEPROMS
_otherText = string.Empty;
_isDirty = false;
}
public MiniConfig(int index,string id,string name,string number,string text,string procedurenumber,string setid,string setname,string otherid,string othername,string othernumber,string othertext)
public MiniConfig(int index, string id, string name, string number, string text, string procedurenumber, string setid, string setname, string otherid, string othername, string othernumber, string othertext)
{
_index = index;
_iD = id;