SourceCode/PROMS/VEPROMS User Interface/frmVersionsProperties.cs

2257 lines
77 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using VEPROMS.CSLA.Library;
using System.Drawing.Imaging;
using VEPROMS.Properties;
using Volian.Controls.Library;
using DescriptiveEnum;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using System.Xml.Serialization;
using Volian.Base.Library;
namespace VEPROMS
{
public partial class frmVersionsProperties : DevComponents.DotNetBar.Office2007Form
{
#region Fields
public bool _showApplicSearchResults = false;
public bool _refreshProcedureList = false;
private List<MiniConfig> _Apples;
private List<MiniConfig> _DeletedApples;
private List<EnhancedMiniConfig> _Enhanced;
private DocVersionConfig _DocVersionConfig;
// Default values
private string _DefaultFormatName = null;
private string _DefaultROPrefix = null;
private string _DefaultImagePrefix = null;
private string _DefaultWatermark = null;
private string _DefaultChgBarType = null;
private string _DefaultChgBarLoc = null;
private string _DefaultChgBarText = null;
private string _DefaultChgBarUsrMsg1 = null;
private string _DefaultChgBarUsrMsg2 = null;
private bool _DefaultDisableDuplex = false;
private DisplaySearch _DisplaySearch1 = null;
private bool _Initializing = false;
private System.IO.StreamWriter swROUpdate;
private ProgressBarItem _ProgressBar = null;
private RODbInfo _CurRoDbInfo = null;
private ROFstInfo _SelectedROFst;
private List<DocVersionInfo> NewEnhVersions = new List<DocVersionInfo>();
private bool doingNew = false;
private bool _EnhNeedToUnlink = false;
private int _InitialIndex = -2; // added as part of code change C2017-004. this also makes it consistent with section properties
private int? _cmbxformatOriginal = null;
#endregion
#region Properties
public DisplaySearch DisplaySearch1
{
get { return _DisplaySearch1; }
set { _DisplaySearch1 = value; }
}
// For the initial release, we are assuming there will be only one rofst for a docversion. Changes will be needed here if more than 1.
public ROFstInfo SelectedROFst
{
get
{
if (_SelectedROFst == null)
{
if (_DocVersionConfig.MyDocVersion.DocVersionAssociationCount < 1) return null;
_SelectedROFst = ROFstInfo.GetJustROFst(_DocVersionConfig.MyDocVersion.DocVersionAssociations[0].ROFstID);
}
return _SelectedROFst;
}
set { _SelectedROFst = value; }
}
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set { _ProgressBar = value; }
}
#endregion
#region Constructors
public frmVersionsProperties(DocVersionConfig docVersionConfig)
{
_DocVersionConfig = docVersionConfig;
docVersionConfig.RefreshMyEnhancedDocuments();
_Initializing = true;
InitializeComponent();
btnGeneral.PerformClick(); // always start with General tab or button
_Initializing = false;
//build the caption
this.Text = string.Format("{0} Properties", _DocVersionConfig.Name);
}
#endregion
#region Public Methods
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
string xml = null;
string srchtxt = null;
using (VlnFlexGrid myGrid = new VlnFlexGrid())
{
using (StringReader sr = new StringReader(args.OldGridXml))
{
myGrid.ReadXml(sr);
myGrid.KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross;
sr.Close();
}
string roid = myGrid.ROID;
int rodbid = myGrid.RODbId;
Font GridFont = myGrid.Font;
myGrid.Clear();
myGrid.ParseTableFromText(args.ROText, GridLinePattern.Single);
myGrid.AutoSizeCols();
myGrid.AutoSizeRows();
myGrid.MakeRTFcells();
myGrid.RODbId = rodbid;
myGrid.ROID = roid;
myGrid.IsRoTable = true;
using (StringWriter sw = new StringWriter())
{
myGrid.WriteXml(sw);
xml = sw.GetStringBuilder().ToString();
sw.Close();
}
srchtxt = myGrid.GetSearchableText();
}
List<string> retlist = new List<string>();
retlist.Add(srchtxt);
retlist.Add(xml);
return retlist;
}
#endregion
#region Private Methods
private void frmVersionsProperties_Load(object sender, EventArgs e)
{
_Initializing = true;
docVersionConfigBindingSource.DataSource = _DocVersionConfig;
//formatInfoListBindingSource.DataSource = FormatInfoList.Get();
imageCodecInfoBindingSource.DataSource = ImageCodecInfo.GetImageDecoders();
ppCmbxFormat.DataSource = null;
ppCmbxFormat.DisplayMember = "FullName";
ppCmbxFormat.ValueMember = "FullName";
ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList);
_cmbxformatOriginal = _DocVersionConfig.MyDocVersion.FormatID;
if (_DocVersionConfig.FormatSelection != null)
{
ppCmbxFormat.SelectedValue = _DocVersionConfig.FormatSelection;
ppBtnDefaultFmt.Visible = true; //bug fix B2016-102 make the default button visable if other the the default format is being used
}
else
{
ppCmbxFormat.SelectedIndex = -1; // default format
}
// Get the saved settings for this user
// Get setting telling us whether to display the default values on this property page
ppCbShwDefSettings.Checked = (Settings.Default["ShowDefaultVersionProp"] != null) ? Settings.Default.ShowDefaultVersionProp : false;
// Get the User's property page style "PropPageStyle" (this is a system wide user setting)
// 1 - Button Dialog (default)
// 2 - Tab Dialog
if ((int)Settings.Default["PropPageStyle"] == (int)PropPgStyle.Tab)
{
tcVersions.TabsVisible = true;
panVerBtns.Visible = false;
this.Width -= panVerBtns.Width;
}
// Get the default values for the property page information
FindDefaultValues();
ppCmbxChangeBarType.DataSource = EnumDetail<PrintChangeBar>.Details();
ppCmbxChangeBarType.DisplayMember = "Description";
ppCmbxChangeBarType.ValueMember = "EValue";
ppCmbxChangeBarType.SelectedIndex = -1;
ppCmbxChgBarPos.DataSource = EnumDetail<PrintChangeBarLoc>.Details();
ppCmbxChgBarPos.DisplayMember = "Description";
ppCmbxChgBarPos.ValueMember = "EValue";
ppCmbxChgBarPos.SelectedIndex = -1;
ppCmbxChgBarTxtType.DataSource = EnumDetail<PrintChangeBarText>.Details();
ppCmbxChgBarTxtType.DisplayMember = "Description";
ppCmbxChgBarTxtType.ValueMember = "EValue";
ppCmbxChgBarTxtType.SelectedItem = -1;
ppCmbxWatermark.DataSource = EnumDetail<PrintWatermark>.Details();
ppCmbxWatermark.DisplayMember = "Description";
ppCmbxWatermark.ValueMember = "EValue";
ppCmbxWatermark.SelectedIndex = -1;
ppCmbxPDFdtPrefix.DataSource = EnumDetail<PDFDTPrefix>.Details(); // C2018-033 dropdown for PDF Prefix date/time format
ppCmbxPDFdtPrefix.DisplayMember = "Description";
ppCmbxPDFdtPrefix.ValueMember = "EValue";
ppCmbxPDFdtPrefix.SelectedIndex = -1;
ppCmbxPDFdtSuffix.DataSource = EnumDetail<PDFDTSuffix>.Details(); // C2018-033 dropdown for PDF Suffix date/time format
ppCmbxPDFdtSuffix.ValueMember = "EValue";
ppCmbxPDFdtSuffix.SelectedIndex = -1;
ppCmbxProcSetType.DataSource = EnumDetail<VersionTypeEnum>.Details();
ppCmbxProcSetType.DisplayMember = "Description";
ppCmbxProcSetType.ValueMember = "EValue";
ppCmbxProcSetType.Enabled = false; // maybe enable this if used for version creation
ppCmbxMOSformat.DataSource = EnumDetail<MergedPdfsPageOf>.Details();
ppCmbxMOSformat.DisplayMember = "Description";
ppCmbxMOSformat.ValueMember = "EValue";
ppCmbxMOSformat.SelectedIndex = -1;
ppCmbxMOSfontName.DataSource = FontFamily.Families;// need font list
ppCmbxMOSfontName.ValueMember = "Name";
ppCmbxMOSfontName.SelectedIndex = -1;
ppCmbxMOScornerLoc.DataSource = EnumDetail<MergedPdfsPageNumCorner>.Details();
ppCmbxMOScornerLoc.DisplayMember = "Description";
ppCmbxMOScornerLoc.ValueMember = "EValue";
ppCmbxMOScornerLoc.SelectedIndex = -1;
// C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
ppCmbxMOSLandcornerLoc.DataSource = EnumDetail<MergedPdfsPageNumCorner>.Details();
ppCmbxMOSLandcornerLoc.DisplayMember = "Description";
ppCmbxMOSLandcornerLoc.ValueMember = "EValue";
ppCmbxMOSLandcornerLoc.SelectedIndex = -1;
// 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)
{
ppLblUnitNum.Visible = true;
ppTxbxUnitNum.Visible = true;
ppTxbxUnitNum.Text = _DocVersionConfig.Print_UnitNumberForPageList;
}
else
{
ppLblUnitNum.Visible = false;
ppTxbxUnitNum.Visible = false;
}
documentInfoListBindingSource.DataSource = DocumentInfoList.GetLibraries(false);
ppBtnRoDbBrowse.Visible = cmbRoDb.Visible = _DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0;
btnRoDbProperties.Visible = tbRoDb.Visible = !(_DocVersionConfig.MyDocVersion.DocVersionAssociationCount == 0);
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
// Set the auto duplex controls based on whether the format allows this:
// Note that the controls' visibility would not set correctly using the following two lines of code. That
// is why the more explicit logic was done.
//ppChbxDisAutoDuplex.Visible = _DocVersionConfig.MyDocVersion.MyFormat.PlantFormat.FormatData.PrintData.AllowDuplex;
//ppLblAutoDuplexDefault.Visible = ppBtnDeftDisAutoDuplx.Visible = ppLblAutoDuplexDefault.Visible;
if (_DocVersionConfig.MyDocVersion.MyFormat != null && _DocVersionConfig.MyDocVersion.MyFormat.PlantFormat.FormatData.PrintData.AllowDuplex)
{
ppChbxDisAutoDuplex.Visible = true;
ppLblAutoDuplexDefault.Visible = true;
ppBtnDeftDisAutoDuplx.Visible = true;
}
else
{
ppChbxDisAutoDuplex.Visible = false;
ppLblAutoDuplexDefault.Visible = false;
ppBtnDeftDisAutoDuplx.Visible = false;
}
//add new applicability stuff
if (_DocVersionConfig.Unit_Count > 0)
{
int k = _DocVersionConfig.SelectedSlave;
_Apples = new List<MiniConfig>();
for (int i = 1; i <= _DocVersionConfig.MaxSlaveIndex; i++)
{
_DocVersionConfig.SelectedSlave = i;
try
{
MiniConfig cfg = new MiniConfig(i, _DocVersionConfig.Unit_ID, _DocVersionConfig.Unit_Name, _DocVersionConfig.Unit_Number, _DocVersionConfig.Unit_Text, _DocVersionConfig.Unit_ProcedureNumber, _DocVersionConfig.Unit_ProcedureSetID, _DocVersionConfig.Unit_ProcedureSetName, _DocVersionConfig.Other_Unit_ID, _DocVersionConfig.Other_Unit_Name, _DocVersionConfig.Other_Unit_Number, _DocVersionConfig.Other_Unit_Text);
_Apples.Add(cfg);
}
catch { }
}
_DocVersionConfig.SelectedSlave = k;
bsApples.DataSource = _Apples;
}
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;
}
ppTxtBxPDFLoc.TextChanged += new EventHandler(ppTxtBxPDFLoc_TextChanged);
//end add new applicability stuff
lblProcSetRev.Visible = ppRTxtProcSetRev.Visible = _DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.MyStepSectionPrintData.UseXtraRevNumber;
// 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;
btnUnlinkDocVersion.Visible = false;
InitEnhanced();
// set the merge pdf settings: (moved to own method for C2021-047)
InitMergePdfSettings();
_Initializing = false;
}
private void InitMergePdfSettings()
{
// Page Settings
ppCmbxMOSformat.SelectedIndex = (int)_DocVersionConfig.Print_MergedPdfsPageOf;
if (_DocVersionConfig.Print_MergedPdfsPageOf == MergedPdfsPageOf.Other)
{
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSother.Enabled = true;
}
else
{
tbxMOSother.Enabled = false;
}
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSfontSz.Text = _DocVersionConfig.Print_MergedPdfsPageNumFontSize;
ppCmbxMOSfontName.DataSource = FontFamily.Families;
ppCmbxMOSfontName.DisplayMember = "Name";
if (_DocVersionConfig.Print_MergedPdfsPageNumFont == null || _DocVersionConfig.Print_MergedPdfsPageNumFont == string.Empty)
{
ppCmbxMOSfontName.SelectedIndex = -1;
}
else
{
ppCmbxMOSfontName.SelectedValue = _DocVersionConfig.Print_MergedPdfsPageNumFont;
}
ppChbxMOSview.Checked = _DocVersionConfig.Print_MergedPdfsViewAfter;
// Portrait Specific Settings
tbxMOSxloc.Text = _DocVersionConfig.Print_MergedPdfsPageNumLocX.ToString();
tbxMOSyloc.Text = _DocVersionConfig.Print_MergedPdfsPageNumLocY.ToString();
ppCmbxMOScornerLoc.SelectedIndex = (int)_DocVersionConfig.Print_MergedPdfsPageNumCorner;
// Landscape Settings for C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
tbxMOSLandxloc.Text = _DocVersionConfig.Print_MergedPdfsLandPageNumLocX.ToString();
tbxMOSLandyloc.Text = _DocVersionConfig.Print_MergedPdfsLandPageNumLocY.ToString();
ppCmbxMOSLandcornerLoc.SelectedIndex = (int)_DocVersionConfig.Print_MergedPdfsLandPageNumCorner;
}
private void InitEnhanced()
{
// if this working draft has no enhanced documents, then put display a button for creating the enhanced links -
// but only if there are enhanced docversions to link to.
// Otherwise, set up the form with the data as it is.
if (_DocVersionConfig.MyEnhancedDocuments == null || _DocVersionConfig.MyEnhancedDocuments.Count == 0)
{
// also check that the format for this docversion does NOT have enhanced back/dev, i.e. it's format is an enhanced
// document
if (!(((_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)))
{
bool validEmptyEnhancedExists = false;
// See if there are available (enhanced) DocVersions that can be linked to from this (source) DocVersion
DocVersionInfoList nonenhdvs = DocVersionInfoList.GetNonEnhancedDocVersions(); // this is a list of docversions that have no 'Enhanced' in config data
foreach (DocVersionInfo nonenhdv in nonenhdvs)
{
if (nonenhdv.VersionID != _DocVersionConfig.MyDocVersion.VersionID)
{
if (((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
validEmptyEnhancedExists = true;
break;
}
}
if (validEmptyEnhancedExists) break;
}
if (validEmptyEnhancedExists)
{
Button btnEnh = new Button();
btnEnh.Text = "Link to Enhanced Document(s)";
btnEnh.Width = 220;
btnEnh.Location = new Point(290, 271);
btnEnh.Parent = tcpGeneral;
btnEnh.Click += new EventHandler(btnEnh_Click);
}
}
btnEnhanced.Visible = false;
tiEnhanced.Visible = false;
return;
}
btnEnhanced.Visible = true;
tiEnhanced.Visible = true;
// 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);
ppChbxEnhancedAllowMods.Visible = isEnhanced;
// isEnhanced is an already existing enhanced document. Only allow the user to change the Pdf settings:
if (isEnhanced)
{
ppChbxEnhancedAllowMods.Checked = _DocVersionConfig.Enhanced_AllowMods; // B2020-004: allowmods only if this is an enhanced
_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;
btnNewEnh.Visible = false;
// when in an enhanced doc version, make visible the button that allows user to unlink, need to get its 'title'
// from the source.
DocVersionInfo srcDVInfo = DocVersionInfo.Get(_DocVersionConfig.MyEnhancedDocuments[0].VersionID);
DocVersionConfig srcDVConfig = srcDVInfo.MyConfig as DocVersionConfig;
DVEnhancedDocuments dveds = srcDVConfig.MyEnhancedDocuments;
string ename = null;
foreach (DVEnhancedDocument dved in dveds)
{
if (dved.VersionID == _DocVersionConfig.MyDocVersion.VersionID)
{
ename = dved.Name;
break;
}
}
if (ename != null)
{
btnUnlinkDocVersion.Visible = true;
btnUnlinkDocVersion.Text = string.Format("Remove All {0} Links", ename);
}
}
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;
btnUnlinkDocVersion.Visible = false; // no unlink button when on a Source Document
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;
// only allow new if there are available non-linked 'enhanced format' docversions.
int cntAvailForLinkEnh = 0;
DocVersionInfoList nonenhdvs = DocVersionInfoList.GetNonEnhancedDocVersions();
foreach (DocVersionInfo nonenhdv in nonenhdvs)
{
if (nonenhdv.VersionID != _DocVersionConfig.MyDocVersion.VersionID)
{
if (((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
cntAvailForLinkEnh++;
}
}
}
btnNewEnh.Visible = (cntAvailForLinkEnh > 0);
}
}
private void btnEnh_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "Are you sure you want to Link Enhanced Document(s) to this Working Draft?", "Add Enhanced Link", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
btnEnhanced.Visible = true;
tiEnhanced.Visible = true;
Button btnEnh = (Button)sender;
btnEnh.Visible = false;
btnEnhanced_Click(sender, e);
}
}
private 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
private void ppTxtBxPDFLoc_TextChanged(object sender, EventArgs e)
{
if (_Initializing == false)
_DocVersionConfig.Print_PDFLocation = ppTxtBxPDFLoc.Text;
}
private string AddSlaveNode(MiniConfig mc)
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(_DocVersionConfig.ToString());
System.Xml.XmlNodeList nl = xd.SelectNodes("//Slave");
int max = 0;
foreach (System.Xml.XmlNode n in nl)
{
max = int.Parse(n.Attributes.GetNamedItem("index").InnerText);
}
max++;
System.Xml.XmlNode nn = xd.CreateElement("Slave");
AddSlaveAttribute(nn, "index", max.ToString());
AddSlaveAttribute(nn, "ID", mc.ID);
AddSlaveAttribute(nn, "Name", mc.Name);
AddSlaveAttribute(nn, "Number", mc.Number);
AddSlaveAttribute(nn, "Text", mc.Text);
AddSlaveAttribute(nn, "ProcedureNumber", mc.ProcedureNumber);
AddSlaveAttribute(nn, "SetID", mc.SetID);
AddSlaveAttribute(nn, "SetName", mc.SetName);
AddSlaveAttribute(nn, "OtherID", mc.OtherID);
AddSlaveAttribute(nn, "OtherName", mc.OtherName);
AddSlaveAttribute(nn, "OtherNumber", mc.OtherNumber);
AddSlaveAttribute(nn, "OtherText", mc.OtherText);
System.Xml.XmlNode sn = xd.SelectSingleNode("//Slaves");
sn.AppendChild(nn);
return xd.OuterXml;
}
private void AddSlaveAttribute(System.Xml.XmlNode nn, string name, string value)
{
System.Xml.XmlAttribute xa = nn.OwnerDocument.CreateAttribute(name);
xa.InnerText = value;
nn.Attributes.SetNamedItem(xa);
}
private void btnVersionsPropOK_Click(object sender, EventArgs e)
{
docVersionConfigBindingSource.EndEdit(); // need to end the edit session first or any format selection chanage will not stick B2015-157
// if there is a change to the format, clean up any overridden formats that point to the selected item before saving the format change:
if (_DocVersionConfig.MyDocVersion.FormatID != _cmbxformatOriginal)
{
// clean up & then refresh the configs
string strdv = _DocVersionConfig.MyDocVersion.VersionID.ToString();
using (ContentInfoList cil = ContentInfoList.ClearOverrideFormatsByDocVersion(strdv, _cmbxformatOriginal, _DocVersionConfig.MyDocVersion.FormatID))
{
foreach (ContentInfo ci in cil)
{
using (Content c = ci.Get())
{
// first refresh configs because the ContentInfo.Refresh causes events to occur that refresh screen
// and if configs aren't done first, the screen refresh, if based on config data, will not be correct.
foreach (ItemInfo ii in ci.ContentItems)
{
ii.RefreshConfig();
}
ContentInfo.Refresh(c);
}
}
}
}
if (_DocVersionConfig.Unit_Count > 0 || (_Apples != null && _Apples.Count > 0))
{
if (_DeletedApples != null && _DeletedApples.Count > 0)
{
foreach (MiniConfig mc in _DeletedApples)
{
_DocVersionConfig.RemoveSlave(mc.Index);
}
}
foreach (MiniConfig mc in _Apples)
{
if (mc.IsDirty)
{
if (mc.Index < 0)
{
mc.Index = _DocVersionConfig.MaxSlaveIndex + 1;
_DocVersionConfig.AddSlave(mc.MyXml);
}
else
{
int k = _DocVersionConfig.SelectedSlave;
_DocVersionConfig.SelectedSlave = mc.Index;
_DocVersionConfig.Unit_ID = mc.ID;
_DocVersionConfig.Unit_Name = mc.Name;
_DocVersionConfig.Unit_Number = mc.Number;
_DocVersionConfig.Unit_Text = mc.Text;
_DocVersionConfig.Unit_ProcedureNumber = mc.ProcedureNumber;
_DocVersionConfig.Unit_ProcedureSetID = mc.SetID;
_DocVersionConfig.Unit_ProcedureSetName = mc.SetName;
_DocVersionConfig.Other_Unit_ID = mc.OtherID;
_DocVersionConfig.Other_Unit_Name = mc.OtherName;
_DocVersionConfig.Other_Unit_Number = mc.OtherNumber;
_DocVersionConfig.Other_Unit_Text = mc.OtherText;
_DocVersionConfig.SelectedSlave = k;
}
}
}
}
if (_Enhanced != null)
{
foreach (EnhancedMiniConfig emc in _Enhanced)
{
if (emc.IsDirty)
{
bool isnew = true;
foreach (DVEnhancedDocument dved in _DocVersionConfig.MyEnhancedDocuments)
{
if (dved.Type == Convert.ToInt32(emc.Type))
{
isnew = false;
dved.Name = emc.Name;
dved.PdfToken = emc.PdfToken;
try
{
dved.PdfX = Convert.ToInt32(emc.PdfXOffset);
}
catch (Exception ex)
{
dved.PdfX = 10;
}
}
}
if (isnew) // make new link for this and the enhanced it points to.
{
int ipdfx = 0;
try
{
ipdfx = Convert.ToInt32(emc.PdfXOffset);
}
catch (Exception ex)
{
ipdfx = (emc.PdfToken == null || emc.PdfToken == "") ? 0 : 10;
}
int itype = 0;
try
{
itype = Convert.ToInt32(emc.Type);
}
catch (Exception ex)
{
itype = 1;
}
// get index into combo box for doc version selected.
int selindx = cbxEnhVersions.SelectedIndex;
DocVersionInfo dvisel = NewEnhVersions[selindx];
_DocVersionConfig.MyEnhancedDocuments.Add(new DVEnhancedDocument(emc.Name, itype, dvisel.VersionID, ipdfx, emc.PdfToken));
using (DocVersion dv = DocVersion.Get(dvisel.VersionID))
{
DocVersionConfig dvc = dv.MyConfig as DocVersionConfig;
dvc.MyEnhancedDocuments.Add(new DVEnhancedDocument("Source", 0, (int)_DocVersionConfig.MyDocVersion.VersionID, 10, "S"));
dvc.SaveDVEnhancedDocuments();
dv.Config = dvc.ToString();
dv.Save();
DocVersionInfo.Refresh(dv);
}
}
}
}
// B2020-004: only set allow mods if this is an enhanced:
bool isEnhanced = (_DocVersionConfig.MyEnhancedDocuments != null && _DocVersionConfig.MyEnhancedDocuments.Count == 1 && _DocVersionConfig.MyEnhancedDocuments[0].Type == 0);
if (isEnhanced)
{
_DocVersionConfig.Enhanced_AllowMods = ppChbxEnhancedAllowMods.Checked;
}
_DocVersionConfig.SaveDVEnhancedDocuments();
}
_DocVersionConfig.Print_UnitNumberForPageList = ppTxbxUnitNum.Text;
// save the merge pdf settings:
_DocVersionConfig.Print_MergedPdfsPageOf = (MergedPdfsPageOf)ppCmbxMOSformat.SelectedIndex;
_DocVersionConfig.Print_MergedPdfsPageNumFormatOther = tbxMOSother.Text;
_DocVersionConfig.Print_MergedPdfsPageNumFont = (string)ppCmbxMOSfontName.SelectedValue;
_DocVersionConfig.Print_MergedPdfsPageNumFontSize = tbxMOSfontSz.Text;
_DocVersionConfig.Print_MergedPdfsPageNumLocX = float.Parse(tbxMOSxloc.Text);
_DocVersionConfig.Print_MergedPdfsPageNumLocY = float.Parse(tbxMOSyloc.Text);
_DocVersionConfig.Print_MergedPdfsPageNumCorner = (MergedPdfsPageNumCorner)ppCmbxMOScornerLoc.SelectedIndex;
// C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
_DocVersionConfig.Print_MergedPdfsLandPageNumLocX = float.Parse(tbxMOSLandxloc.Text);
_DocVersionConfig.Print_MergedPdfsLandPageNumLocY = float.Parse(tbxMOSLandyloc.Text);
_DocVersionConfig.Print_MergedPdfsLandPageNumCorner = (MergedPdfsPageNumCorner)ppCmbxMOSLandcornerLoc.SelectedIndex;
_DocVersionConfig.Print_MergedPdfsViewAfter = ppChbxMOSview.Checked;
// Save whether we should display the default values on this property page
Settings.Default.ShowDefaultVersionProp = ppCbShwDefSettings.Checked;
Settings.Default.Save();
DialogResult = DialogResult.OK;
_DocVersionConfig.MyDocVersion.Config = _DocVersionConfig.ToString();
_refreshProcedureList = true;
_DocVersionConfig.MyDocVersion.Save().Dispose();
if (_EnhNeedToUnlink)
{
this.Cursor = Cursors.WaitCursor;
_DocVersionConfig.MyDocVersion.MyDocVersionInfo.DoUnlinkEnhancedDocVersion();
this.Cursor = Cursors.Default;
}
// B2019-132 update the association count for this working draft
_DocVersionConfig.MyDocVersion.MyDocVersionInfo.RefreshDocVersionAssociations();
this.Close();
}
private void btnFldrPropCancel_Click(object sender, EventArgs e)
{
docVersionConfigBindingSource.CancelEdit();
this.Close();
}
/// <summary>
/// Use the ParentLookup to grab the default values
/// - set the watermark property (where applicable) of the control with that value
/// - set the default setting labels with that value
/// ** the default setting labels appear when the Show Default Values checkbox is checked by the user.
/// </summary>
private void FindDefaultValues()
{
_DocVersionConfig.ParentLookup = true;
// get default format
_DefaultFormatName = _DocVersionConfig.DefaultFormatSelection;
SetupDefault(_DefaultFormatName, ppLblFormatDefault, ppCmbxFormat);
// Get the default Change Bar Type
_DefaultChgBarType = _DocVersionConfig.Print_ChangeBar.ToString();
SetupDefault(EnumDescConverter.GetEnumDescription(_DocVersionConfig.Print_ChangeBar), ppLblChangeBarTypeDefault, ppCmbxChangeBarType);
// Get the default Change Bar Location
_DefaultChgBarLoc = _DocVersionConfig.Print_ChangeBarLoc.ToString();
SetupDefault(EnumDescConverter.GetEnumDescription(_DocVersionConfig.Print_ChangeBarLoc), ppLblChgBarPosDefault, ppCmbxChgBarPos);
// Get the default Change Bar text
_DefaultChgBarText = _DocVersionConfig.Print_ChangeBarText.ToString();
SetupDefault(EnumDescConverter.GetEnumDescription(_DocVersionConfig.Print_ChangeBarText), ppLblChgBarTxtTypeDefault, ppCmbxChgBarTxtType);
// Get the default User Change Bar Message 1
_DefaultChgBarUsrMsg1 = _DocVersionConfig.Print_UserCBMess1;
if (!(_DefaultChgBarUsrMsg1.Equals(string.Empty)))
{
ppLblChgBarUserMsgOneDefault.Text = string.Format("({0})", _DefaultChgBarUsrMsg1);
}
// Get the default User Change Bar Message 2
_DefaultChgBarUsrMsg2 = _DocVersionConfig.Print_UserCBMess2;
if (!(_DefaultChgBarUsrMsg2.Equals(string.Empty)))
{
ppLblChgBarUserMsgTwoDefault.Text = string.Format("{0}", _DefaultChgBarUsrMsg2);
}
// Get the ro path - there is no 'default'
if (_DocVersionConfig.MyDocVersion.DocVersionAssociationCount < 0 && _DocVersionConfig.MyDocVersion.DocVersionAssociations.Count == 0)
;// The line above refreshes the data
if (_DocVersionConfig.MyDocVersion.DocVersionAssociationCount > 0)
{
RODbInfo rdi = RODbInfo.GetJustRODB(SelectedROFst.RODbID);
tbRoDb.Text = string.Format("{0} ({1})", rdi.ROName, rdi.FolderPath);
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rdi); // C2017-003: make button visible if ro migration is doable
_CurRoDbInfo = rdi;
}
else
{
int selindx = -1;
cmbRoDb.Items.Clear();
int myrodbid = -1;
if (_DocVersionConfig.MyDocVersion.DocVersionAssociationCount >= 1) myrodbid = SelectedROFst.RODbID;
foreach (RODbInfo rdi in RODbInfoList.Get())
{
int i = cmbRoDb.Items.Add(string.Format("{0} ({1})", rdi.ROName, rdi.FolderPath));
if (rdi.RODbID == myrodbid)
{
selindx = i;
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rdi); // C2017-003: make button visible if ro migration is doable
_CurRoDbInfo = rdi;
}
}
if (cmbRoDb.Items.Count > 0)
cmbRoDb.SelectedIndex = selindx;
}
// Get the default Watermark
_DefaultWatermark = _DocVersionConfig.Print_Watermark.ToString();
SetupDefault(EnumDescConverter.GetEnumDescription(_DocVersionConfig.Print_Watermark), ppLblWatermarkDefault, ppCmbxWatermark);
// Get the default Disable Duplex
_DefaultDisableDuplex = _DocVersionConfig.Print_DisableDuplex;
ppLblAutoDuplexDefault.Text = string.Format("(Duplex {0})", (_DefaultDisableDuplex) ? "OFF" : "ON");
_DocVersionConfig.ParentLookup = false;
}
private void DoProgressBarRefresh(int value, int max, string text)
{
if (ProgressBar == null) return;
ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text;
Application.DoEvents();
}
private string InitialProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 0;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
}
private string FinalProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Maximum = 100;
ProgressBar.Value = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
}
private void ppBtnResetRoVals_Click(object sender, EventArgs e)
{
// This will not be supported in the first release. A discussion was held on 1/6/09 with MRC, JSJ, RHM &
// KBR & it was decided that we'd wait to see if users end up needing this. It can be done by going
// into the sql database and modify/delete records if needed.
}
private void cmbRoDb_SelectedIndexChanged(object sender, EventArgs e)
{
if (_Initializing)
return;
// The only way that a selected index can change on the rodb combo box is if there was no rofst
// to docversion association. If a selection is made, make that association and then change the
// combo box to a non-editable text box with button becoming a properties rather than browse.
// add the rofst for the selected rodb (note that it may already exist, and will use the current one.
// get the rodb from the selection - and then do an 'update rofst'...
RODbInfoList rdil = RODbInfoList.Get();
RODbInfo rdi = rdil[cmbRoDb.SelectedIndex];
ROFstInfo fst = null;
foreach (ROFstInfo inf in rdi.RODbROFsts)
{
if (fst == null || inf.ROFstID > fst.ROFstID)
{
fst = inf;
}
}
if (fst != null)
{
using (ROFst fst1 = fst.Get())
{
_DocVersionConfig.MyDocVersion.DocVersionAssociations.Add(fst1);
}
cmbRoDb.Visible = ppBtnRoDbBrowse.Visible = false;
tbRoDb.Visible = btnRoDbProperties.Visible = true;
tbRoDb.Text = string.Format("{0} ({1})", fst.MyRODb.ROName, fst.MyRODb.FolderPath);
// C2017-003: See if the selected ro databasew has been converted to sql and if not, make visible a button to convert the data.
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(fst.MyRODb);
_CurRoDbInfo = fst.MyRODb;
}
else
{
ROFst tmp = ROFstInfo.AddRoFst(rdi, _DocVersionConfig.MyDocVersion, DoProgressBarRefresh); // RHM Needs To Include Delegate
if (tmp == null)
{
MessageBox.Show("Invalid ro fst directory, use the Property dialog to fix directory path to ro.fst.");
frmRODbProperties dlgROProperties = new frmRODbProperties(_DocVersionConfig.MyDocVersion, rdi);
dlgROProperties.ProgressBar = ProgressBar;
if (dlgROProperties.ShowDialog() == DialogResult.OK)
{
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath);
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
}
else
{
return;
}
}
cmbRoDb.Visible = ppBtnRoDbBrowse.Visible = false;
tbRoDb.Visible = btnRoDbProperties.Visible = true;
tbRoDb.Text = string.Format("{0} ({1})", tmp.MyRODb.ROName, tmp.MyRODb.FolderPath);
// C2017-003: See if the selected ro database has been converted to sql and if not, make visible a button to convert the data.
RODbInfo rodbi = RODbInfo.GetJustRODB(tmp.MyRODb.RODbID);
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rodbi);
_CurRoDbInfo = rodbi;
}
}
private bool CanMigrateRoAccessToSql(RODbInfo rODbi)
{
// C2017-003: This method is used to determine whether RO data can be migrated from MS Access to sql server
// A command line argument 'RoInSql'. For now, this argument must be used to allow code to run for ro->sql. Later
// this will be changed so that if arugment is used, the program does NOT include button.
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("RoInSql")) return false;
// The following conditions must be true in order to migrate the ro data to sql. Only the first condition can be
// tested in this executable since the roall database is interfaced to by the roeditor & the program that migrates the data.
// The migration program will make the 2-4 tests, put up a message box if it cannot migrate & will send a failure back
// to this program, PROMS.
// 1) the user must be an admin and the rodb record's connection string must be 'cstring' (it is the connection string if data was migrated)
// 2) the roall database must exist when using the rodb record's connection string and this database must have the stored procedures
// 3) roall must be empty
// 4) the database must be the correct version
UserInfo ui = UserInfo.GetByUserID(VlnSettings.UserID);
if (!ui.IsAdministrator()) return false;
return (rODbi.DBConnectionString == "cstring");
}
private void ppBtnRoDbBrowse_Click(object sender, EventArgs e)
{
frmRODbProperties dlgROProperties = new frmRODbProperties(_DocVersionConfig.MyDocVersion, SelectedROFst == null ? null : SelectedROFst.MyRODb);
dlgROProperties.ParentLocation = Location;
// if a user has entered a valid rodb, then this docversion will be conntected to it - change
// to a non-editable text box and the button becomes a properties button rather than browse.
if (dlgROProperties.ShowDialog() == DialogResult.OK)
{
cmbRoDb.Items.Clear();
_DocVersionConfig.MyDocVersion.Reset_DocVersionAssociations();
if (_DocVersionConfig.MyDocVersion.DocVersionAssociations != null && _DocVersionConfig.MyDocVersion.DocVersionAssociationCount > 0)
{
cmbRoDb.Visible = ppBtnRoDbBrowse.Visible = false;
tbRoDb.Visible = btnRoDbProperties.Visible = true;
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath);
return;
}
RODbInfoList.Reset();
int selindx = -1;
int myrodbid = (SelectedROFst == null) ? -1 : SelectedROFst.RODbID;
foreach (RODbInfo rdi in RODbInfoList.Get())
{
int i = cmbRoDb.Items.Add(rdi.ROName + " (" + rdi.FolderPath + ")");
if (rdi.RODbID == myrodbid)
{
selindx = i;
}
}
if (cmbRoDb.Items.Count > 0)
cmbRoDb.SelectedIndex = selindx;
}
}
private void ppBtnPDFLoc_Click(object sender, EventArgs e)
{
PDFLocationBrowserDialog.SelectedPath = ppTxtBxPDFLoc.Text;
DialogResult dr = PDFLocationBrowserDialog.ShowDialog();
if (dr == DialogResult.OK) ppTxtBxPDFLoc.Text = PDFLocationBrowserDialog.SelectedPath;
}
private void ppBtnDefCbTxt1_Click(object sender, EventArgs e)
{
// Compare default setting with current setting
// Reset with the default and hide the default button and label
if (_DefaultChgBarUsrMsg1 != _DocVersionConfig.Print_UserCBMess1)
{
_DocVersionConfig.Print_UserCBMess1 = _DefaultChgBarUsrMsg1;
ppLblChgBarUserMsgOneDefault.Visible = false;
ppBtnDefCbTxt1.Visible = false;
}
}
private void ppBtnDefCbTxt2_Click(object sender, EventArgs e)
{
// Compare default setting with current setting
// Reset with the default and hide the default button and label
if (_DefaultChgBarUsrMsg2 != _DocVersionConfig.Print_UserCBMess2)
{
_DocVersionConfig.Print_UserCBMess2 = _DefaultChgBarUsrMsg2;
ppLblChgBarUserMsgTwoDefault.Visible = false;
ppBtnDefCbTxt2.Visible = false;
}
}
private void ppBtnDeftDisAutoDuplx_Click(object sender, EventArgs e)
{
ppChbxDisAutoDuplex.Checked = _DefaultDisableDuplex;
_DocVersionConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked;
ppBtnDeftDisAutoDuplx.Visible = false;
ppLblAutoDuplexDefault.Visible = false;
}
private void frmVersionsProperties_Shown(object sender, EventArgs e)
{
ppRTxtName.Focus();
}
private void ppRTxtName_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(ppRTxtName.Text))
{
MessageBox.Show("Cannot have a blank Name.");
return;
}
}
private void btnApplicability_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiApplicability, btnApplicability);
}
private void lbApplicabilities_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbApplicabilities.SelectedIndex > -1)
{
bsMiniApple.DataSource = bsApples.Current as MiniConfig;
btnDelApple.Enabled = true;
}
}
private void btnNewApple_Click(object sender, EventArgs e)
{
MiniConfig cfg = new MiniConfig();
cfg.Name = "New Applicability";
if (_Apples == null)
{
_Apples = new List<MiniConfig>();
}
_Apples.Add(cfg);
bsApples.DataSource = null;
bsApples.DataSource = _Apples;
lbApplicabilities.SelectedItem = cfg;
}
private bool ApplicIsUsed(MiniConfig cfg) // B2017-230 - don't allow user to remove an applicability that is being used (specified)
{
if (_showApplicSearchResults)
{
_showApplicSearchResults = false;
_DisplaySearch1.SearchResults = null;
}
Cursor.Current = Cursors.WaitCursor;
ItemInfoList placesUsed = ItemInfoList.GetListFromApplicabilitySearch(_DocVersionConfig.MyDocVersion.VersionID.ToString(), "", "", 0, ItemSearchIncludeLinks.Nothing, false, false, "", cfg.Index.ToString());
Cursor.Current = Cursors.Default;
if (placesUsed != null && placesUsed.Count > 0)
{ // B2017-230 give user option to save the locations in Global Search results
if (MessageBox.Show(string.Format("Cannot remove an Applicability that is being use in {0} places.\n\nDo you want to view locations via Search Results?\n\nThe Search panel will open when you exit the property page.", placesUsed.Count), "Applicability In Use", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_showApplicSearchResults = true;
_DisplaySearch1.SearchResults = placesUsed;
_DisplaySearch1.ReportTitle = string.Format("{0} Applicability", cfg.Name);
_DisplaySearch1.TypesSelected = string.Format("These Locations Specify The \"{0}\" Applicability", cfg.Name);
}
return true;
}
return false;
}
private void btnDelApple_Click(object sender, EventArgs e)
{
MiniConfig cfg = bsApples.Current as MiniConfig;
if (!ApplicIsUsed(cfg) && MessageBox.Show(string.Format("Are you sure you want to delete {0}", cfg.Name), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
if (_DeletedApples == null)
{
_DeletedApples = new List<MiniConfig>();
}
_DeletedApples.Add(cfg);
_Apples.Remove(cfg);
bsApples.DataSource = null;
bsApples.DataSource = _Apples;
// C2018-010: When removing an applicability, info on right side still contains old content. Do refreshes and reset datasource to fix this.
this.lbApplicabilities.Refresh();
if (_Apples != null && _Apples.Count > 0)
{
lbApplicabilities.SelectedIndex = 0;
bsMiniApple.DataSource = bsApples.Current as MiniConfig;
btnDelApple.Enabled = true;
}
}
}
private void btnPhoneList_Click(object sender, EventArgs e)
{
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 && !doingNew)
{
bsMiniEnhanced.DataSource = bsEnhanced.Current as EnhancedMiniConfig;
if (cbxEnhVersions.Items.Count >= lbEnhanced.Items.Count)
cbxEnhVersions.SelectedIndex = lbEnhanced.SelectedIndex;
}
}
private void btnNewEnh_Click(object sender, EventArgs e)
{
_Initializing = true;
doingNew = true;
// the 'New' button is only enabled for Source documents.
EnhancedMiniConfig cfg = new EnhancedMiniConfig();
cfg.Name = "New Enhanced";
// need to have a unique number for this enhanced link, find largest and then increment by 1.
int maxtype = -1;
if (_DocVersionConfig.MyEnhancedDocuments != null && _DocVersionConfig.MyEnhancedDocuments.Count > 0)
{
foreach (DVEnhancedDocument dve in _DocVersionConfig.MyEnhancedDocuments)
{
maxtype = Math.Max(maxtype, dve.Type);
}
}
maxtype = (maxtype < 0) ? 1 : maxtype + 1;
cfg.Type = maxtype.ToString();
if (_Enhanced == null) _Enhanced = new List<EnhancedMiniConfig>();
_Enhanced.Add(cfg);
bsEnhanced.DataSource = null;
bsEnhanced.DataSource = _Enhanced;
cbxEnhVersions.Items.Clear();
NewEnhVersions.Clear();
DocVersionInfoList nonenhdvs = DocVersionInfoList.GetNonEnhancedDocVersions(); // this is a list of docversions that have no 'Enhanced' in config data
foreach (DocVersionInfo nonenhdv in nonenhdvs)
{
if (nonenhdv.VersionID != _DocVersionConfig.MyDocVersion.VersionID)
{
if (((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((nonenhdv.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
NewEnhVersions.Add(nonenhdv);
cbxEnhVersions.Items.Add(nonenhdv.SearchDVPath);
}
}
}
if (cbxEnhVersions.Items.Count > 0)
{
cbxEnhVersions.Enabled = true;
cbxEnhVersions.SelectedIndex = 0;
}
else
{
cbxEnhVersions.Enabled = false;
}
bsMiniEnhanced.DataSource = cfg;
lbEnhanced.SelectedItem = cfg;
tbEnhType.Enabled = false;
btnNewEnh.Enabled = false; // for now, only do 1 at a time.
_Initializing = false;
}
private void btnUnlinkDocVersion_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "Are you sure you want to Unlink? Your documents will no longer link to Enhanced. NOTE that this processing occurs when 'OK' button is selected!", "Unlink", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_EnhNeedToUnlink = true; // do the unlink when 'OK' button is selected
}
}
private void ppCmbxFormat_DropDown(object sender, EventArgs e)
{
_Initializing = true;
// C2017-004 - if using the default format, position the dropdown to the default format
if (ppCmbxFormat.SelectedIndex == -1)
ppCmbxFormat.SelectedValue = _DefaultFormatName;
_Initializing = false;
}
private void ppCmbxFormat_DropDownClosed(object sender, EventArgs e)
{
// upon exit of the dropdown if the default format is selected - click the Default button
if ((string)(ppCmbxFormat.SelectedValue) == _DefaultFormatName)
{
ppBtnDefaultFmt.PerformClick();
ppCmbxChangeBarType.Focus();
}
}
private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e)
{
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)
if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue))
{
ppBtnDefaultFmt.Focus();
ppBtnDefaultFmt.PerformClick();
}
// 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;
}
// C2018-033 save the Prefix date/time format selection to config
private void ppCmbxPDFdtPrefix_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
if (ppCmbxPDFdtPrefix.SelectedIndex > 0)
{
ppTxtBxPdfPre.Enabled = false; // cannot have both entered text and a date/time format
}
else
{
_Initializing = true;
ppTxtBxPdfPre.Enabled = true; // not using the date/time format so allow for text entry
ppCmbxPDFdtPrefix.SelectedIndex = -1;
_DocVersionConfig.Print_PDFdtFilePrefix = 0; // this will force a database update (write)
_Initializing = false;
}
}
}
// C2018-033 save the Suffix date/time format selection to config
private void ppCmbxPDFdtSuffix_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
if (ppCmbxPDFdtSuffix.SelectedIndex > 0)
{
ppTxtBxPDFSuf.Enabled = false; // cannot have both entered text and a date/time format
}
else
{
_Initializing = true;
ppTxtBxPDFSuf.Enabled = true; // not using the date/time format so allow for text entry
ppCmbxPDFdtSuffix.SelectedIndex = -1;
_DocVersionConfig.Print_PDFdtFileSuffix = 0; // this will force a database update (write)
_Initializing = false;
}
}
}
private void ppCmbxMOSformat_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
// The Other textbox for defining the merged pdf file page of format is only enabled if the user
// has selected 'Other' as the format type.
if ((MergedPdfsPageOf)ppCmbxMOSformat.SelectedValue == MergedPdfsPageOf.Other)
{
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSother.Enabled = true;
}
else
{
tbxMOSother.Enabled = false;
}
}
}
// C2017-003: The button to migrate ro data from MS Access to sql server was clicked:
private void ppBtnRoToSql_Click(object sender, EventArgs e)
{
try
{
Application.DoEvents();
string exelocation = Application.ExecutablePath;
exelocation = exelocation.Substring(0, exelocation.LastIndexOf("\\")) + @"\RoAccessToSql.exe";
int indx = tbRoDb.Text.IndexOf(" (") + 2;
string accesspath = tbRoDb.Text.Substring(indx, tbRoDb.Text.Length - indx - 1);
if (accesspath.IndexOf(" ") > -1) // B2023-120 If there is a space in the path enclose path in double quotes.
{
accesspath = '"' + accesspath + '"';
}
string sqldb = Database.ActiveDatabase;
indx = Database.DBServer.IndexOf(" ");
string server = Database.DBServer.Substring(0, indx);
string args = @"/acc=" + accesspath + @" /sqldb=" + sqldb + @" /server=" + server;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(exelocation, args);
p.WaitForExit(); // without arguments, this will wait indefinitely
Application.DoEvents();
string _TmpFileForConnectStr = Path.GetTempPath() + @"\PromsConnect.txt";
if (File.Exists(_TmpFileForConnectStr)) // if conversion was done, the connection string will be added to the promsconnect.txt file
{
string constring = File.ReadAllText(_TmpFileForConnectStr);
if (constring != null && constring != "" && constring.ToUpper().Contains("DATA SOURCE"))
{
// read in the connection string & set for this rodbinfo
using (RODb rodbtmp = RODb.GetJustRoDb(_CurRoDbInfo.RODbID))
{
rodbtmp.DBConnectionString = File.ReadAllText(_TmpFileForConnectStr);
rodbtmp.Save();
}
// to be sure all aspects of program are using the converted database, tell user to restart:
MessageBox.Show(this, "Restart PROMS to have referenced object database migration take effect.", "", MessageBoxButtons.OK);
}
ppBtnRoToSql.Visible = false;
}
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
MessageBox.Show(ex.Message, "Migration Error: " + ex.GetType().Name);
}
}
#region (General Tab)
/// <summary>
/// This is the General button used on the button interface design
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void btnGeneral_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiGeneral, btnGeneral);
}
#endregion
#region (Referenced Objects)
/// <summary>
/// This is the Referenced Objects button used on the button interface design
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void btnRefObjs_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiRefObjs, btnRefObjs);
}
private void btnRoDbProperties_Click(object sender, EventArgs e)
{
frmRODbProperties dlgROProperties = new frmRODbProperties(_DocVersionConfig.MyDocVersion, SelectedROFst == null ? null : SelectedROFst.MyRODb);
dlgROProperties.ParentLocation = Location;
if (dlgROProperties.ShowDialog() == DialogResult.OK)
{
tbRoDb.Text = string.Format("{0} ({1})", SelectedROFst.MyRODb.ROName, SelectedROFst.MyRODb.FolderPath);
// only allow update if association, and the RO update was not done and/or not completed
ppBtnUpRoVals.Enabled = !_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst;
}
}
private void ppBtnUpRoVals_Click(object sender, EventArgs e)
{
InitialProgressBarMessage = "Updating ROs";
// use rodb directory path of the first rofst for the this document version. Bring up a file
// selection dialog starting with this path. The user can select another path.
// RHM question - we talked about just using the current path, but what is the current path when
// a docversion can have more than one rofst (for now, just use first?) - should I bring up a dialog?
if (_DocVersionConfig.MyDocVersion.DocVersionAssociations.Count < 1)
{
MessageBox.Show("Error Updating ro.fst.", "No associated ro.fst"); //B2017-125 added title to messagebox
return;
}
foreach (DocVersionAssociation dva in _DocVersionConfig.MyDocVersion.DocVersionAssociations)
{
// B2023-020: Link to RO data from new working draft crashes/various ro.fst issues. This code was using an
// non-loaded rodbid from the docversion association (query was changed to not return related rofst data
// to improve memory/performance). Instead, the SelectedROFst can be used to get the rodbid.
int rodbid = SelectedROFst==null?-1:SelectedROFst.RODbID;
if (rodbid < 1)
{
MessageBox.Show("Could not get associated ro.fst ", "No existing RO.FST");
return;
}
RODbInfo rdi = RODbInfo.Get(rodbid); // B2023-020: use the rodbid from the SelectedROFst
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath))
{
FinalProgressBarMessage = "No existing RO.FST";
MessageBox.Show("No existing ro.fst in path " + rdi.FolderPath + ". Check for invalid path", "No existing RO.FST"); //B2017-125 added title to messagebox
break;
}
Cursor = Cursors.WaitCursor;
// RO changes placed in file in the Documents\VEPROMS folder
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(_DocVersionConfig.MyDocVersion.MyDocVersionInfo));
DocVersion dv = _DocVersionConfig.MyDocVersion;
// B2022-026 RO Memory Reduction code - first load the new ro.fst so that we can assign the ROTableUpdate event to the correct roFstInfo
if (dv.ROfstLoadingFigures || dv.NewerRoFst) // B2017-125 see if loading figures was completed
{
ROFstInfo.UpdateRoFst(SelectedROFst.MyRODb, dv, SelectedROFst, DoProgressBarRefresh);
SelectedROFst = null; // set to null to force getting the updated ROfst
}
ContentInfo.StaticContentInfoChange += ContentInfo_StaticContentInfoChange; // write changes to a text file
SelectedROFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.RefreshROFst(_DocVersionConfig.MyDocVersion, SelectedROFst, DoProgressBarRefresh, null);
ContentInfo.StaticContentInfoChange -= ContentInfo_StaticContentInfoChange;
SelectedROFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
swROUpdate.Close();
ppBtnUpRoVals.Enabled = (!_DocVersionConfig.MyDocVersion.ROfstLastCompleted || _DocVersionConfig.MyDocVersion.NewerRoFst);
Cursor = Cursors.Default;
}
FinalProgressBarMessage = "ROs values updated";
}
// write the RO reference changes to a text file, include the old/new text, location, and the itemid of the step element
private void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (args.Type == "RO")
swROUpdate.Write(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
}
#endregion
#region (Output Settings)
/// <summary>
/// This is the Output Settings button used on the button interface design
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void btnOutputSettings_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiOutputSettings, btnOutputSettings);
}
/// <summary>
/// Selection in Watermark combo box changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppCmbxWatermark_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark);
ProcessCmbxSelectionEnumChanged(ppCmbxWatermark, wtr, ppBtnDefWatermark, ppLblWatermarkDefault);
}
}
/// <summary>
/// Reset to the parent setting.
/// Find the parent setting and assign it to _DocVersionConfig.Print_Watermark.
/// This will force the database to be updated.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ppBtnDefWatermark_Click(object sender, EventArgs e)
{
// Get the parent setting
PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark);
// Compare parent setting with current setting
if (wtr != _DocVersionConfig.Print_Watermark)
_DocVersionConfig.Print_Watermark = wtr; // this will force a database update (write)
ppCmbxWatermark.SelectedIndex = -1;
}
#endregion
#region (Format Settings)
/// <summary>
/// This is the Format Settings button used on the button interface design
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void btnFmtSettings_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiFmtSettings, btnFmtSettings);
// added for code change C2017-004 - select default format in dropdown list
if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section is set to the default format)
}
private void ppBtnDefaultFmt_Click(object sender, EventArgs e)
{
ppCmbxFormat.SelectedIndex = -1;
}
/// <summary>
/// If checked, will disable automatic duplexing (ex Foldout Pages)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ppChbxDisAutoDuplex_CheckedChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
_DocVersionConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked;
ppBtnDeftDisAutoDuplx.Visible = (_DefaultDisableDuplex != ppChbxDisAutoDuplex.Checked);
ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible;
}
}
/// <summary>
/// Enable or disable the user specified change bar options base on the type
/// of change bar selected.
/// </summary>
private void setEnabledUserSpecifiedChgBarCombos(PrintChangeBar pcb)
{
ppGpbxUserSpecCB.Enabled = (ppCmbxChangeBarType.SelectedValue != null &&
ppCmbxChangeBarType.SelectedValue.Equals(PrintChangeBar.WithUserSpecified)) ||
(ppCmbxChangeBarType.SelectedValue == null && pcb.Equals(PrintChangeBar.WithUserSpecified));
}
/// <summary>
/// Selection in Change Bar combo box changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppCmbxChangeBarType_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType);
ProcessCmbxSelectionEnumChanged(ppCmbxChangeBarType, pcb, ppBtnDefaultChgBar, ppLblChangeBarTypeDefault);
setEnabledUserSpecifiedChgBarCombos(pcb);
}
}
/// <summary>
/// Reset to the parent setting.
/// Find the parent setting and assign it to _DocVersionConfig.PrintChangeBar.
/// This will force the database to be updated.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ppBtnDefaultChgBar_Click(object sender, EventArgs e)
{
// Get the parent setting
PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType);
// Compare parent setting with current setting
if (pcb != _DocVersionConfig.Print_ChangeBar)
_DocVersionConfig.Print_ChangeBar = pcb; // this will force a database update (write)
ppCmbxChangeBarType.SelectedIndex = -1; //reset combo box to the default Change Bar setting
}
/// <summary>
/// Selection in Change Bar Position combo box changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppCmbxChgBarPos_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc);
ProcessCmbxSelectionEnumChanged(ppCmbxChgBarPos, cbl, ppBtnDefaultCbPos, ppLblChgBarPosDefault);
}
}
/// <summary>
/// Reset to the parent setting.
/// Find the parent setting and assign it to _DocVersionConfig.Print_ChangeBarLoc.
/// This will force the database to be updated.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ppBtnDefaultCbPos_Click(object sender, EventArgs e)
{
// Get the parent setting
PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc);
// Compare parent setting with current setting
if (cbl != _DocVersionConfig.Print_ChangeBarLoc)
_DocVersionConfig.Print_ChangeBarLoc = cbl; // this will force a database update (write)
ppCmbxChgBarPos.SelectedIndex = -1;
}
/// <summary>
/// Enable or disable the user specified change bar text based on the selected
/// change bar text type (selected in the user specific change bar grouping)
/// </summary>
private void setEnabledUserSpecifiedChgBarText()
{
// This string is used to check against our default setting to see if User Defined Changebar Text is active
string decUserDef = PrintChangeBarText.UserDef.ToString();
ppGpbxUserSpecTxt.Enabled = (ppCmbxChgBarTxtType.SelectedValue != null &&
ppCmbxChgBarTxtType.SelectedValue.Equals(PrintChangeBarText.UserDef)) ||
(ppCmbxChgBarTxtType.SelectedIndex == -1 && _DefaultChgBarText.Equals(decUserDef));
}
/// <summary>
/// Selection in Change Bar Text Type combo box changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppCmbxChgBarTxtType_SelectedValueChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText);
ProcessCmbxSelectionEnumChanged(ppCmbxChgBarTxtType, cbt, ppBtnDefCbTxtTyp, ppLblChgBarTxtTypeDefault);
setEnabledUserSpecifiedChgBarText();
}
}
/// <summary>
/// Reset to the parent setting.
/// Find the parent setting and assign it to _DocVersionConfig.Print_ChangeBarText.
/// This will force the database to be updated.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ppBtnDefCbTxtTyp_Click(object sender, EventArgs e)
{
// Get the parent setting
PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText);
// Compare parent setting with current setting
if (cbt != _DocVersionConfig.Print_ChangeBarText)
_DocVersionConfig.Print_ChangeBarText = cbt; // this will force a database update (write)
ppCmbxChgBarTxtType.SelectedIndex = -1;
}
/// <summary>
/// Selection in Change Bar User Message One text changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppTxbxChangeBarUserMsgOne_TextChanged(object sender, EventArgs e)
{
ppBtnDefCbTxt1.Visible = ((ppTxbxChangeBarUserMsgOne.Text != null) && !ppTxbxChangeBarUserMsgOne.Text.Equals(_DefaultChgBarUsrMsg1));
ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible;
}
/// <summary>
/// Selection in Change Bar User Message Two text changed.
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void ppTxbxChangeBarUserMsgTwo_TextChanged(object sender, EventArgs e)
{
ppBtnDefCbTxt2.Visible = ((ppTxbxChangeBarUserMsgTwo.Text != null) && !ppTxbxChangeBarUserMsgTwo.Text.Equals(_DefaultChgBarUsrMsg2));
ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible;
}
#endregion
#region (Generic Methods for the Form)
/// <summary>
/// This is a generic Enter Event function for use with all of the property page tabs.
/// Found that the visiblity value of buttons is not recorded until the property page in which it resides is diplayed.
/// Thus we need to call defaultSettingVisiblity() to check and set visiblity states.
/// </summary>
/// <param name="sender"> type object</param>
/// <param name="e">type EventArgs</param>
private void tabpage_Enter(object sender, EventArgs e)
{
// Show or hide the labels containing the default values
defaultSettingsVisiblity();
}
/// <summary>
/// Determines what labels (showing default values) are visable on the property pages
/// </summary>
private void defaultSettingsVisiblity()
{
ppLblDefSettingsInfo.Visible = ppCbShwDefSettings.Checked;
ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible;
ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible;
ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible;
ppLblChangeBarTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultChgBar.Visible;
ppLblChgBarPosDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultCbPos.Visible;
ppLblChgBarTxtTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxtTyp.Visible;
//ppLblPaginationDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefPagination.Visible;
ppLblWatermarkDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefWatermark.Visible;
ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible;
}
/// <summary>
/// For the Button Interface property page style, when a button is selected (pressed),
/// it will remain in the checked state even when a different button is selected. Thus
/// we must clear the checked state of the buttons when a button is selected, then set
/// the newly selected button's state to checked.
/// </summary>
private void ClearAllCheckedButtons()
{
btnGeneral.Checked = false;
btnRefObjs.Checked = false;
btnOutputSettings.Checked = false;
btnFmtSettings.Checked = false;
btnLibDocs.Checked = false;
btnApplicability.Checked = false;
btnMergedOutputSettngs.Checked = false; //B2019-074: turn off button when another is selected
}
/// <summary>
/// Select the corresponding tab and set the button's state to checked
/// </summary>
/// <param name="tab">Property Page Tab</param>
/// <param name="button">Corresponding Property Page Button</param>
private void ProcessButtonClick(TabItem tab, ButtonX button)
{
ClearAllCheckedButtons();
tcVersions.SelectedTab = tab;
button.Checked = true;
}
/// <summary>
/// Process a change in the enum combo box selection
/// </summary>
/// <param name="cmbx">Combo Box Name</param>
/// <param name="defstr">the default enum value</param>
/// <param name="button">button to reset to default value</param>
/// <param name="deflabel">label containing the default</param>
private void ProcessCmbxSelectionEnumChanged(ComboBoxEx cmbx, object enumval, ButtonX button, Label deflabel)
{
if (cmbx.SelectedIndex > -1 && cmbx.SelectedValue.Equals(enumval))
{
_Initializing = true;
button.Visible = true;
button.Focus();
button.PerformClick();
cmbx.SelectedIndex = -1; // This will hide the Default button
_Initializing = false;
}
button.Visible = (cmbx.SelectedValue != null);
deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible;
}
/// <summary>
/// Process a change in the combo box selection
/// </summary>
/// <param name="cmbx">Combo Box Name</param>
/// <param name="defstr">string containing default text</param>
/// <param name="button">button to reset to default value</param>
/// <param name="deflabel">label containing the default</param>
private void ProcessCmbxSelectedValueChange(ComboBoxEx cmbx, string defstr, ButtonX button, Label deflabel)
{
if (cmbx.SelectedIndex > -1 && !string.IsNullOrEmpty(defstr) && defstr.Equals(cmbx.SelectedValue))
{
button.Visible = true;
button.Focus();
button.PerformClick();
}
button.Visible = cmbx.SelectedValue != null;
deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible;
}
/// <summary>
/// Set the watermark and default label
/// </summary>
/// <param name="defaultText">The default text</param>
/// <param name="lbl">Label that displays the current default when view defaults is set</param>
/// <param name="cmboEx">Combo box with a watermark property</param>
private static void SetupDefault(string defaultText, Label lbl, ComboBoxEx cmbo)
{
if (!string.IsNullOrEmpty(defaultText))
{
string deftext = string.Format("{0}", defaultText);
lbl.Text = deftext;
cmbo.WatermarkText = deftext;
}
}
#endregion
#region (MergedOutputSettings)
private void btnMergedOutputSettngs_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiMergedOutputSettings, btnMergedOutputSettngs);
}
#endregion
#region Library Documents
/// <summary>
/// This is the Library Documents button used on the button interface design
/// </summary>
/// <param name="sender">object</param>
/// <param name="e">EventArgs</param>
private void btnLibDocs_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiLibDocs, btnLibDocs);
}
#endregion
#endregion
private void tbRoDb_TextChanged(object sender, EventArgs e)
{
}
private void ROPrefixBindingSource_CurrentChanged(object sender, EventArgs e)
{
}
}
#region EnhancedMiniConfig Class
[XmlRoot("Enhanced")]
public class EnhancedMiniConfig
{
#region Fields
private static int lastindex = 0;
private bool _isDeleted;
private bool _isDirty;
private int _index;
private int _versionID;
private string _versionPathName;
private string _name;
private string _type;
private string _pdfToken;
private string _pdfXOffset;
#endregion
#region Properties
[XmlIgnore]
public bool IsDeleted
{
get { return _isDeleted; }
set { _isDeleted = value; }
}
[XmlIgnore]
public bool IsDirty
{
get { return _isDirty; }
set { _isDirty = value; }
}
[XmlAttribute("index")]
public int Index
{
get { return _index; }
set { _index = value; IsDirty = true; }
}
[XmlAttribute("VersionID")]
public int VersionID
{
get { return _versionID; }
set { _versionID = value; IsDirty = true; }
}
[XmlAttribute("VersionPathName")]
public string VersionPathName
{
get { return _versionPathName; }
set { _versionPathName = value; IsDirty = true; }
}
[XmlAttribute("Name")]
public string Name
{
get { return _name; }
set { _name = value; IsDirty = true; }
}
[XmlAttribute("Type")]
public string Type
{
get { return _type; }
set { _type = value; IsDirty = true; }
}
[XmlAttribute("PdfToken")]
public string PdfToken
{
get { return _pdfToken; }
set { _pdfToken = value; IsDirty = true; }
}
[XmlAttribute("PdfXOffset")]
public string PdfXOffset
{
get { return _pdfXOffset; }
set { _pdfXOffset = value; IsDirty = true; }
}
#endregion
#region Constructors
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;
}
#endregion
#region Public Methods
public override string ToString()
{
return Name;
}
#endregion
}
#endregion
#region MiniConfig Class
[XmlRoot("Slave")]
public class MiniConfig
{
#region Fields
private static int lastindex = 0;
private bool _isDeleted;
private bool _isDirty;
private int _index;
private string _iD;
private string _name;
private string _number;
private string _text;
private string _procedureNumber;
private string _setID;
private string _setName;
private string _otherID;
private string _otherName;
private string _otherNumber;
private string _otherText;
#endregion
#region Properties
[XmlIgnore]
public bool IsDeleted
{
get { return _isDeleted; }
set { _isDeleted = value; }
}
[XmlIgnore]
public bool IsDirty
{
get { return _isDirty; }
set { _isDirty = value; }
}
[XmlAttribute("index")]
public int Index
{
get { return _index; }
set { _index = value; IsDirty = true; }
}
[XmlAttribute("ID")]
public string ID
{
get { return _iD; }
set { _iD = value; IsDirty = true; }
}
[XmlAttribute("Name")]
public string Name
{
get { return _name; }
set { _name = value; IsDirty = true; }
}
[XmlAttribute("Number")]
public string Number
{
get { return _number; }
set { _number = value; IsDirty = true; }
}
[XmlAttribute("Text")]
public string Text
{
get { return _text; }
set { _text = value; IsDirty = true; }
}
[XmlAttribute("ProcedureNumber")]
public string ProcedureNumber
{
get { return _procedureNumber; }
set { _procedureNumber = value; IsDirty = true; }
}
[XmlAttribute("SetID")]
public string SetID
{
get { return _setID; }
set { _setID = value; IsDirty = true; }
}
[XmlAttribute("SetName")]
public string SetName
{
get { return _setName; }
set { _setName = value; IsDirty = true; }
}
[XmlAttribute("OtherID")]
public string OtherID
{
get { return _otherID; }
set { _otherID = value; IsDirty = true; }
}
[XmlAttribute("OtherName")]
public string OtherName
{
get { return _otherName; }
set { _otherName = value; IsDirty = true; }
}
[XmlAttribute("OtherNumber")]
public string OtherNumber
{
get { return _otherNumber; }
set { _otherNumber = value; IsDirty = true; }
}
[XmlAttribute("OyherText")] // 11/3/21: Typo that is in data. Don't fix unless writing code to fix data
public string OtherText
{
get { return _otherText; }
set { _otherText = value; IsDirty = true; }
}
#endregion
#region Constructors
public MiniConfig()
{
_index = --lastindex;
_iD = string.Empty;
_name = string.Empty;
_number = string.Empty;
_text = string.Empty;
_procedureNumber = string.Empty;
_setID = string.Empty;
_setName = string.Empty;
_otherID = string.Empty;
_otherName = string.Empty;
_otherNumber = string.Empty;
_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)
{
_index = index;
_iD = id;
_name = name;
_number = number;
_text = text;
_procedureNumber = procedurenumber;
_setID = setid;
_setName = setname;
_otherID = otherid;
_otherName = othername;
_otherNumber = othernumber;
_otherText = othertext;
_isDirty = false;
}
#endregion
#region Public Methods
public override string ToString()
{
return Name;
}
public string MyXml
{
get { return GenericSerializer<MiniConfig>.StringSerialize(this); }
}
#endregion
}
#endregion
}