3044 lines
115 KiB
C#
Raw Blame History

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using DevComponents.DotNetBar;
using DevComponents.AdvTree;
using Volian.Base.Library;
using System.Text.RegularExpressions;
using JR.Utils.GUI.Forms;
namespace Volian.Controls.Library
{
public partial class DisplaySearch : UserControl
{
#region Events
public event DisplaySearchEvent PrintRequest;
private void OnPrintRequest(DisplaySearchEventArgs args)
{
if (PrintRequest != null)
PrintRequest(this, args);
}
public event DisplaySearchEvent SearchComplete;
private void OnSearchComplete(DisplaySearchEventArgs args)
{
if (SearchComplete != null)
SearchComplete(this, args);
}
#endregion
#region Properties
// C2020-033: SearchIncTransII represents the item that the transitions go to. It can be either the item the user
// tried to delete or that the user selected to get Incoming Transitions from tree view or ribbon.
private ItemInfo _SearchIncTransII = null;
public ItemInfo SearchIncTransII
{
get
{
return _SearchIncTransII;
}
set
{
_SearchIncTransII = value;
if (_SearchIncTransII != null) lblSrchIncTran.Text = _SearchIncTransII.Path;
else lblSrchIncTran.Text = "";
}
}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private string _strSrchText = "";
private List<DocVersionInfo> lstCheckedDocVersions = new List<DocVersionInfo>();
private List<int> lstCheckedStepTypes = new List<int>();
private List<string> lstCheckedStepTypesStr = new List<string>();
private AnnotationDetails _AnnotationDetails = null;
ItemInfo _ItemInfo = null;
private DisplayTabControl _TabControl;
private DocVersionInfo _MyDocVersion;
private Color saveXpSetToSearchColor;
private Color saveXpStepTypeTitleColor;
private Color saveGpSrchAnnoTextColor;
private Color saveGpSrchTextColor;
private Color saveGpFindROsColor;
private Color saveGrpPanSearchResults;
private ItemInfoList _SearchResults;
public ItemInfoList SearchResults
{
get { return _SearchResults; }
set
{
if (DesignMode) return; // B2019-043 need to check if we are just saving changes to the user interface
_SearchResults = value;
if (value != null) // Don't select an item from the list when it is updated
_SearchResults.ListChanged += new ListChangedEventHandler(_SearchResults_ListChanged);
DisplayResults();
}
}
void _SearchResults_ListChanged(object sender, ListChangedEventArgs e)
{
lbSrchResults.SelectedIndex = -1; // Don't select an item from the new list
lbSrchResultsIncTrans.SelectedIndex = -1;
}
private string _DisplayMember = "SearchPath";
//public string Status
//{
// get { return tsslStatus.Text; }
// set { tsslStatus.Text = value; Application.DoEvents(); }
//}
private bool _OpenDocFromSearch;
public bool OpenDocFromSearch
{
get { return _OpenDocFromSearch; }
//set { _OpenDocFromSearch = value; }
}
public DocVersionInfo Mydocversion
{
get { return _MyDocVersion; }
set
{
if (DesignMode) return; // B2019-043 need to check if we are just saving changes to the user interface
_MyDocVersion = value;
if (_MyDocVersion != null)
{
if (_MyDocVersion.DocVersionAssociationCount > 0)
{
// if the count variable is not consistent with the actual list count,
// do a refresh. There was a bug, B2012-040, that was not reproducable..
// so this is an attempt to fix it.
if (_MyDocVersion.DocVersionAssociations.Count == 0)
{
_MyDocVersion.RefreshDocVersionAssociations();
if (_MyDocVersion.DocVersionAssociations.Count == 0) return;
}
MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(_MyDocVersion);
_MyRODbID = _MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID;
}
}
else
MyROFSTLookup = null;
}
}
private ROFSTLookup _MyROFSTLookup;
public ROFSTLookup MyROFSTLookup
{
get { return _MyROFSTLookup; }
set
{
if (DesignMode) return; // B2019-043 need to check if we are just saving changes to the user interface
bool beforeIsNotNull = _MyROFSTLookup != null;
bool afterIsNotNull = value != null;
//if (!Visible) return; // don't reset anything if the form is invisible.
_MyROFSTLookup = value; // define the tree nodes based on this rofst
if(beforeIsNotNull || afterIsNotNull)LoadROComboTree();// B2017-215 Added logic so that database is not accessed during initialization.
}
}
private bool _LoadingList = false;
public bool LoadingList
{
get { return _LoadingList; }
set { _LoadingList = value; }
}
private int LastResultsMouseOverIndex = -1;
private ProgressBarItem _ProgressBar;
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set { _ProgressBar = value; }
}
#endregion
#region setup
public DisplaySearch()
{
InitializeComponent();
LoadSearchTextListBox();
saveXpSetToSearchColor = xpSetToSearch.TitleStyle.BackColor1.Color;
saveXpStepTypeTitleColor = xpStepTypes.TitleStyle.BackColor1.Color;
saveGpSrchAnnoTextColor = gpSrchAnnoText.Style.BackColor;
saveGpSrchTextColor = gpSrchText.Style.BackColor;
saveGpFindROsColor = gpFindROs.Style.BackColor;
gpSrchText.Style.BackColor = Color.Yellow;
saveGrpPanSearchResults = grpPanSearchResults.Style.BackColor;
// start out with the procedure and type selection windows colasped
xpSetToSearch.Expanded = false;
xpStepTypes.Expanded = false;
rbtnSrchTxt.Checked = true;
gpSrchAnnoText.Enabled = true;
cmbResultsStyle.Enabled = false;
tabSearchTypes.SelectedTabChanged += new TabStrip.SelectedTabChangedEventHandler(tabSearchTypes_SelectedTabChanged);
// Don't do this here. If you do then the /DB parameter has not yet been set, which will cause the database menu to be displayed
//SetupContextMenu(); // so that the symbol list is available without selecting a procedure set or procedure
}
void tabSearchTypes_SelectedTabChanged(object sender, TabStripTabChangedEventArgs e)
{
if(wordSectionTreeNode != null) //B2020-070 NULL reference check
wordSectionTreeNode.Enabled = true;
btnSearch.Enabled = true;
xpSetToSearch.Enabled = true;
xpStepTypes.Enabled = true;
lbSrchResults.Visible = true;
lbSrchResultsIncTrans.Visible = false;
cbxRnoOnly.Visible = true;
if (e.NewTab == tabIncTrans) // C2020-033: Incoming transitions
{
xpSetToSearch.Enabled = false;
xpStepTypes.Enabled = false;
lbSrchResults.Visible = false;
lbSrchResultsIncTrans.Visible = true;
lbSrchResultsIncTrans.CheckBoxesVisible = true;
lbSrchResultsIncTrans.AutoScroll = true;
btnSearch.Enabled = false; // C2021 - 002: disable search button - no functionality for Incoming Transitions
cbxRnoOnly.Visible = false;
}
else if (e.NewTab == tabROSearch)
{
LoadROComboTree();
}
else if (e.NewTab == tabTranSearch)
{
if (wordSectionTreeNode != null) //B2020-070 NULL reference check
{
wordSectionTreeNode.Enabled = false; // C2020-010: Disable Word Section choice for Transition search
wordSectionTreeNode.Checked = false;
}
btnSearch.Enabled = (cbxTranCategory.Items.Count > 0); // B2017-038 disable search button if no format selected
//enable-disable doc version nodes based on version type if selected
if (cbxTranVersion.SelectedIndex > -1)
{
if (dicExpandedFolderNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicExpandedFolderNodes.Keys)
{
DocVersionInfo dvi = (DocVersionInfo)n.Tag;
if (cbxTranVersion.Tag.ToString().Contains(dvi.VersionID.ToString()))
n.Enabled = true;
else
n.Enabled = false;
}
}
}
//setup transition format versions
this.Cursor = Cursors.WaitCursor;
if (myFormatVersionList == null)
{
this.Refresh();
myFormatVersionList = FormatVersionList.GetFormatVersions();
cbxTranVersion.DisplayMember = "Title";
int lastLastFormatID = 0;
foreach (FormatVersion fv in myFormatVersionList)
{
if (fv.FormatID != lastLastFormatID)
{
cbxTranVersion.Items.Add(fv);
lastLastFormatID = fv.FormatID;
}
}
cbxTranVersion.SelectedIndexChanged += new EventHandler(cbxTranVersion_SelectedIndexChanged);
cbxTranFormat.SelectedIndexChanged += new EventHandler(cbxTranFormat_SelectedIndexChanged);
}
this.Cursor = Cursors.Default;
}
else
{
foreach (DevComponents.AdvTree.Node n in dicExpandedFolderNodes.Keys)
n.Enabled = true;
if (dicSelectedFolderNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicSelectedFolderNodes.Keys)
{
n.Enabled = true;
}
dicSelectedFolderNodes.Clear();
}
}
}
void cbxTranFormat_SelectedIndexChanged(object sender, EventArgs e)
{
#region 1st cut
//if (cbxTranFormat.SelectedItem.ToString() == "All")
//{
// cbxTranCategory.Items.Clear();
// cbxTranCategory.Items.Add("All");
// cbxTranCategory.Items.Add("Internal");
// cbxTranCategory.Items.Add("External");
// cbxTranCategory.Items.Add("Outside");
// cbxTranCategory.SelectedIndex = 0;
//}
//else if (cbxTranFormat.SelectedItem.ToString().Contains("{Proc"))
//{
// cbxTranCategory.Items.Clear();
// cbxTranCategory.Items.Add("All");
// cbxTranCategory.Items.Add("External");
// cbxTranCategory.Items.Add("Outside");
// cbxTranCategory.SelectedIndex = 0;
//}
//else
//{
// cbxTranCategory.Items.Clear();
// cbxTranCategory.Items.Add("Internal");
// cbxTranCategory.SelectedIndex = 0;
//}
#endregion
#region 2nd cut
if (cbxTranFormat.SelectedItem.ToString().Contains("{Proc"))
{
cbxTranCategory.Items.Clear();
cbxTranCategory.Items.Add("All");
cbxTranCategory.Items.Add("External");
cbxTranCategory.Items.Add("Outside");
cbxTranCategory.SelectedIndex = 0;
}
else
{
cbxTranCategory.Items.Clear();
cbxTranCategory.Items.Add("All");
cbxTranCategory.Items.Add("Internal");
cbxTranCategory.Items.Add("External");
cbxTranCategory.Items.Add("Outside");
cbxTranCategory.SelectedIndex = 0;
}
#endregion
btnSearch.Enabled = true; // B2017-038 enable search button if when a format selected
}
FormatVersionList myFormatVersionList;
private void LoadSearchTextListBox()
{
// Setup SearchText Combo
cbxTextSearchText.Items.Clear();
if (Properties.Settings.Default["SearchList"] != null && Properties.Settings.Default.SearchList.Count > 0)
{
foreach (string str in Properties.Settings.Default.SearchList)
cbxTextSearchText.Items.Add(str);
}
// Setup SearchAnnotation Combo
cbxTextSearchAnnotation.Items.Clear();
if (Properties.Settings.Default["SearchAList"] != null && Properties.Settings.Default.SearchAList.Count > 0)
{
foreach (string str in Properties.Settings.Default.SearchAList)
cbxTextSearchAnnotation.Items.Add(str);
}
}
void cbxTranVersion_SelectedIndexChanged(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
string versionList = string.Empty;
string sep = string.Empty;
FormatVersion sfv = cbxTranVersion.SelectedItem as FormatVersion;
foreach (FormatVersion fv in myFormatVersionList)
{
if (fv.FormatID == sfv.FormatID)
{
versionList += sep + fv.VersionID;
sep = ",";
}
}
cbxTranVersion.Tag = versionList;
cbxTranFormatFillIn(versionList);
if (dicExpandedFolderNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicExpandedFolderNodes.Keys)
{
FolderInfo fi = (FolderInfo)n.Tag;
// if this folder has a docversion, use its id:
string svid = null;
if (fi.FolderDocVersionCount > 0)
svid = fi.FolderDocVersions[0].VersionID.ToString();
if (cbxTranVersion.Tag.ToString().Contains(svid))
n.Enabled = true;
else
n.Enabled = false;
}
}
List<DevComponents.AdvTree.Node> uncheckNodes = new List<Node>();
foreach (DevComponents.AdvTree.Node n in dicSelectedFolderNodes.Keys)
{
FolderInfo fi = (FolderInfo)n.Tag; // this was crashing in old version of code
// if this folder has a docversion, use its id:
string svid = null;
if (fi.FolderDocVersionCount > 0)
svid = fi.FolderDocVersions[0].VersionID.ToString();
if (svid !=null && !versionList.Contains(svid))
uncheckNodes.Add(n);
else
n.Enabled = true;
}
while (uncheckNodes.Count > 0)
{
uncheckNodes[0].Checked = false;
uncheckNodes[0].Enabled = false;
uncheckNodes.Remove(uncheckNodes[0]);
}
if (lstCheckedDocVersions.Count > 0)
{
if (FlexibleMessageBox.Show(this, "Do you want to expand to all relevant procedure sets for the selected format?", "Expand Procedure Sets", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
lstCheckedDocVersions.Clear();
foreach (DevComponents.AdvTree.Node n in dicSelectedFolderNodes.Keys)
uncheckNodes.Add(n);
while (uncheckNodes.Count > 0)
{
uncheckNodes[0].Checked = false;
uncheckNodes.Remove(uncheckNodes[0]);
}
dicSelectedFolderNodes.Clear();
}
}
this.Cursor = Cursors.Default;
}
private DevComponents.AdvTree.Node NewAdvTreeNode(string nodetext, bool selectable, bool chxbxvisable)
{
DevComponents.AdvTree.Node newnode;
newnode = new DevComponents.AdvTree.Node();
newnode.Text = nodetext;
newnode.Selectable = selectable;
AddCheckBox(chxbxvisable, newnode);//C2016-045 Allow Folders to be selected.
return newnode;
}
//C2016-045 Allow Folders to be selected.
private void AddCheckBox(bool chxbxvisable, DevComponents.AdvTree.Node newnode)
{
newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
newnode.CheckBoxThreeState = false;
newnode.CheckBoxVisible = chxbxvisable;
// Set newnode.Checked = parent.Checked
if(newnode.Parent != null)
newnode.Checked = newnode.Parent.Checked;
}
private Timer _TmrRefresh = null;
public Timer TmrRefresh
{
get
{
if (_TmrRefresh == null)
{
_TmrRefresh = new Timer();
_TmrRefresh.Interval = 1000;
_TmrRefresh.Tick += _TmrRefresh_Tick;
}
return _TmrRefresh;
}
}
// B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DisplaySearch _TmrRefresh_Tick", 399);
// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
void _TmrRefresh_Tick(object sender, EventArgs e)
{
_TimeActivity.Open();
TmrRefresh.Enabled = false;
if (!_fromLoad)AdvTreeStepTypesFillIn(); // Don't reload if coming from Load - this overwrites the load settings
_TimeActivity.Close();
}
public void StartAdvTreeStepTypesFillIn()// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
{
TmrRefresh.Enabled = true;
}
DevComponents.AdvTree.Node wordSectionTreeNode = null; // C2020-010: Disable Word Section choice for Transition search
public void AdvTreeStepTypesFillIn()
{
DevComponents.AdvTree.Node topnode = new DevComponents.AdvTree.Node();
advTreeStepTypes.Nodes.Clear();
lstCheckedStepTypes.Clear();
lstCheckedStepTypesStr.Clear();
topnode.Text = "Types";
advTreeStepTypes.Nodes.Add(topnode);
FormatData fmtdata = null;
// B2017-181: selecting/deselecting, and no nodes are selected was causing null reference when trying
// to access the DocVersion (none are selected), use the format off of the top folder:
if (_MyDocVersion == null)
{
FolderInfo fi = FolderInfo.Get(TopFolderID);
fmtdata = fi.ActiveFormat.PlantFormat.FormatData;
}
else
{
fmtdata = _MyDocVersion.ActiveFormat.PlantFormat.FormatData;
}
List<StepDataRetval> lstSrchStpTypes = fmtdata.GetSearchableSteps(); // list of searchable step types
if (lstSrchStpTypes != null && lstSrchStpTypes.Count > 0)
{
DevComponents.AdvTree.Node newnode;
advTreeStepTypes.Nodes.Clear();
// Add a dummy node for searching Word Sections (MS Word sections)
//newnode = new DevComponents.AdvTree.Node();
//newnode.Text = "Word Sections";
//newnode.Selectable = true;
//newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
//newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
//newnode.CheckBoxThreeState = false;
//newnode.CheckBoxVisible = true;
newnode = NewAdvTreeNode("WORD Sections", true, true); // C2020-010: Change Accessory Sections to Word Sections
wordSectionTreeNode = newnode;
// C2021-028: RNO Only search, disable Word section tree node
wordSectionTreeNode.Enabled = !(tabSearchTypes.SelectedTab == tabTranSearch || cbxRnoOnly.Checked);
advTreeStepTypes.Nodes.Add(newnode);
foreach (StepDataRetval sdr in lstSrchStpTypes)
{
StepDataList sdl = fmtdata.StepDataList; ;
StepData sd = sdl[sdr.Index]; // get the step type record
string parentName = sd.ParentType; // this gets the parent of the this step/substep type
//Console.WriteLine("{0} {1} - {2}", parentName,sd.Type,sdr.Name);
//newnode = new DevComponents.AdvTree.Node();
//newnode.Text = sdr.Name;
//newnode.Name = sd.Type; // this needed for the FindNodeByName() function
//newnode.Tag = sd;
//newnode.Selectable = true;
//newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
//newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
//newnode.CheckBoxThreeState = false;
//newnode.CheckBoxVisible = true;
if (parentName.Equals("Base"))
{
newnode = NewAdvTreeNode(sdr.Name, true, true);
newnode.Tag = sd;
newnode.Name = sd.Type;
DevComponents.AdvTree.Node pnode = NewAdvTreeNode(sd.Type, true, false); //create parent node (non selectable)
pnode.Name = sd.Type;
if (!sd.Type.Equals("Title")) // only use Title as a tree grouping to put Title with Text Right/Below substep types
pnode.Nodes.Add(newnode);
pnode.Nodes.Sort();
advTreeStepTypes.Nodes.Add(pnode);
}
else if (sd.Type.Equals("RNOType")) // B2019-016 Allow for search of RNO step types (when selecting types to search)
{
newnode = NewAdvTreeNode(sdr.Name, true, true);
newnode.Tag = sd;
newnode.Name = sd.Type;
advTreeStepTypes.Nodes.Add(newnode);
}
else
{
// B2016-236: for global search <20> change <20>AER<45> to <20>Left<66> in list of step types for figures
string nameInTree = sdr.Name;
if (sdr.Name.Contains("AER") && sdr.Name.ToUpper().Contains("FIGURE")) nameInTree = nameInTree.Replace("AER", "Left");
newnode = NewAdvTreeNode(nameInTree, true, true);
newnode.Name = sd.Type; // this needed for the FindNodeByName() function
newnode.Tag = sd;
// if the parent node exists in the tree, then add the new node to that parent
// else, it is a parent node, so add it as a new parent
DevComponents.AdvTree.Node parnode = advTreeStepTypes.FindNodeByName(parentName);
// Group by High Level Steps, Substeps, Cautions, Notes, Figures, Tables and Equations
while (!parentName.Equals("Base") && !parentName.Equals("Substep") && !parentName.Equals("High") &&
!parentName.Equals("Caution") && !parentName.Equals("Note") && !parentName.Equals("Table") &&
!parentName.Equals("Figure") && !parentName.Equals("Title") &&
!parentName.Equals("And") && !parentName.Equals("Or") && !parentName.Equals("Paragraph") && !parentName.Equals("Equation"))
{
StepData tmpsd = (StepData)parnode.Tag;
parentName = tmpsd.ParentType;
parnode = advTreeStepTypes.FindNodeByName(parentName);
}
if (parnode != null)
{
parnode.Nodes.Add(newnode);
parnode.Nodes.Sort(); // sort the second level of the tree
}
else
advTreeStepTypes.Nodes.Add(newnode);
}
}
advTreeStepTypes.Nodes.Sort(); // sort the first level of the tree
}
buildStepTypePannelTitle();
}
private int _TopFolderID = 1;
public int TopFolderID
{
get { return _TopFolderID; }
set { _TopFolderID = value; }
}
public void advTreeProcSetsFillIn(bool blSeachTabClicked)
{
DevComponents.AdvTree.Node topnode = null;
int cntnd = 0;
VETreeNode vtn = VETreeNode.GetFolder(TopFolderID);
FolderInfo fi = vtn.VEObject as FolderInfo;
int fiCount = fi.ChildFolderCount;
advTreeProcSets.Nodes.Clear();
lstCheckedDocVersions.Clear();
topnode = new DevComponents.AdvTree.Node();
topnode.Text = "Available Procedure Sets";
topnode.Tag = fi;
topnode.DataKey = fi.FolderID;
advTreeProcSets.Nodes.Add(topnode);
//advTreeProcSets.AfterNodeInsert += new TreeNodeCollectionEventHandler(advTreeProcSets_AfterNodeInsert);
if (fi.SortedChildFolders != null)
{
foreach (FolderInfo fic in fi.SortedChildFolders)
{
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
newnode.Text = fic.ToString();
newnode.Tag = fic;
newnode.DataKey = fi.FolderID;
AddCheckBox(true, newnode);//C2016-045 Allow Folders to be selected.
cntnd++;
if (fic.ChildFolderCount > 0 || fic.FolderDocVersionCount > 0) // allow for '+' for tree expansion
{
if (fic.ChildFolderCount > 0) // B2017-176: Do not display the Working Draft node (don't create dummy for expander)
{
DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
tnt.Text = "VLN_DUMMY";
newnode.Nodes.Add(tnt);
}
topnode.Nodes.Add(newnode);
}
}
}
else
{
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
newnode.Text = fi.ToString();
newnode.Tag = fi;
newnode.DataKey = fi.FolderID;
AddCheckBox(true, newnode);//C2016-045 Allow Folders to be selected.
topnode.Nodes.Add(newnode);
lstCheckedDocVersions.Add(Mydocversion);
buildSetToSearchPanelTitle();
}
// if nothing was added to the tree, just put in the node above the docversions...
if (advTreeProcSets.Nodes.Count == 0)
{
cntnd++;
fi = Mydocversion.MyFolder;
topnode = new DevComponents.AdvTree.Node();
topnode.Text = fi.ToString();
advTreeProcSets.Nodes.Add(topnode);
topnode.Tag = fi;
topnode.DataKey = fi.FolderID;
}
advTreeProcSets.BeforeExpand += new DevComponents.AdvTree.AdvTreeNodeCancelEventHandler(advTreeProcSets_BeforeExpand);
// position to the procedure set in the tree if we have a procedure open
if (Mydocversion != null)
advTreeProcSetsPreSelect();
else
advTreeProcSets.Nodes[0].SelectedCell = advTreeProcSets.Nodes[0].Cells[0]; // select the first node - fixes cosmetic problem
if (blSeachTabClicked)
cbxTextSearchText.Focus(); // set initial focus to enter search text
}
//void advTreeProcSets_AfterNodeInsert(object sender, TreeNodeCollectionEventArgs e)
//{
// IVEDrillDownReadOnly tmp = e.Node.Tag as IVEDrillDownReadOnly;
// if (tmp != null)
// {
// Console.WriteLine("Has Children {0} {1}", tmp.HasChildren, tmp.ToString());
// FolderInfo fi = tmp as FolderInfo;
// //if (fi != null)
// // Console.WriteLine("dvi Count {0}", fi.FolderDocVersionCount);
// }
// vlnStackTrace.ShowStackLocal(e.Node.Text,1,10);
//}
private Dictionary<DevComponents.AdvTree.Node, bool> dicSelectedFolderNodes = new Dictionary<DevComponents.AdvTree.Node, bool>();
private Dictionary<DevComponents.AdvTree.Node, bool> dicExpandedFolderNodes = new Dictionary<DevComponents.AdvTree.Node, bool>();
void advTreeProcSets_BeforeExpand(object sender, DevComponents.AdvTree.AdvTreeNodeCancelEventArgs e)
{
DevComponents.AdvTree.Node par = e.Node;
// get first child's text, if it has one & if the text is VLN_DUMMY, load children
DevComponents.AdvTree.Node tn = null;
if (par.Nodes.Count > 0) tn = par.Nodes[0];
if (tn.Text == "VLN_DUMMY") // expand this
{
par.Nodes.Clear();
Object obj = par.Tag;
if (!(obj is FolderInfo)) return; // should always be folderinfo on expand
FolderInfo fi = (FolderInfo)obj;
if (fi.ChildFolderCount > 0)
{
foreach (FolderInfo fic in fi.SortedChildFolders)
{
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
newnode.Text = fic.ToString();
newnode.Tag = fic;
newnode.DataKey = fic.FolderID;
par.Nodes.Add(newnode);
AddCheckBox(true, newnode);//C2016-045 Allow Folders to be selected.
newnode.Enabled = true;
if (fic.ChildFolderCount > 0) // B2017-176: Only expand if folder has folders (not working draft nodes)
{
DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
tnt.Text = "VLN_DUMMY";
newnode.Nodes.Add(tnt);
// B2017-176: Only expand if folder has folders (not working draft nodes): the following was moved from the code
// that would check if this should be enabled if seraching for transition types. The transition controls
// had a list of associated docversions, so needed to get the docversion in the folder:
if (tabSearchTypes.SelectedTab == tabTranSearch)
{
if (!dicSelectedFolderNodes.ContainsKey(newnode)) dicSelectedFolderNodes.Add(newnode, false);
// get the docversion for this folder, if it has one and determine whether it is enabled for transitions:
string svid = null;
if (fic.FolderDocVersionCount > 0)
svid = fic.FolderDocVersions[0].VersionID.ToString();
newnode.Enabled = svid != null && cbxTranVersion.Tag != null ? cbxTranVersion.Tag.ToString().Contains(svid) : false;
}
}
}
}
}
}
private Node LookInTree(NodeCollection monkeys, string bananna)
{
Node foundit = null;
foreach (Node chimp in monkeys)
{
if (chimp.Text.Equals(bananna))
{
foundit = chimp;
// need to select the node (cell) for it to be checked
chimp.SelectedCell = chimp.Cells[0];
if (chimp.Nodes.Count > 0)
chimp.Expand();
break;
}
chimp.Collapse();
}
return foundit;
}
private void advTreeProcSetsPreSelect()
{
bool keeplooking = true;
//build a stack (bread crumb trail) of where is procedure set came from within the tree.
Stack<string> crumbs = new Stack<string>();
//crumbs.Push(Mydocversion.Name); // ex: "working draft"
//crumbs.Push(Mydocversion.MyFolder.Name); // ex: "Emergency Procedures"
//crumbs.Push(Mydocversion.MyFolder.MyParent.Name); // ex: "STPNOC-South Texas"
//crumbs.Push(advTreeProcSets.Nodes[0].Text); //top node of my tree
//crumbs.Push(Mydocversion.Name); // ex: "working draft"
crumbs.Push(Mydocversion.MyFolder.Name); // ex: "Emergency Procedures"
FolderInfo fi = Mydocversion.MyFolder.MyParent;
while (fi != null)
{
if (fi.MyParent != null)
crumbs.Push(fi.Name);
fi = fi.MyParent;
}
crumbs.Push(advTreeProcSets.Nodes[0].Text); //top node of my tree
// now walk the tree, looking for the node names we saved in the stack.
NodeCollection monkeys = advTreeProcSets.Nodes;
while (keeplooking)
{
Node climber = LookInTree(monkeys, crumbs.Pop());
keeplooking = (climber != null && crumbs.Count > 0);
if (keeplooking)
monkeys = climber.Nodes;
if (!keeplooking && climber != null)
{
climber.Checked = true;
}
}
}
#endregion
#region ROFST Combo Tree
static private int _lastRoFstId = -1;
private void LoadROComboTree()
{
lblSrchRoMsg.Visible = false; // C2019-041: start out with no message about rofsts and folder(s) compatibility
// if only one docversion selected, this RoFst can be used. If more than one or none (none is all docversions), then check if they
// use the same RO fst. If not, put a message as the first tree node and return, otherwise, load the tree.
List<DocVersionInfo> dvilTmp = new List<DocVersionInfo>();
if (lstCheckedDocVersions == null || lstCheckedDocVersions.Count == 0)
{
DocVersionInfoList dvil = DocVersionInfoList.Get();
foreach (DocVersionInfo dvi in dvil) dvilTmp.Add(dvi);
}
else
dvilTmp = lstCheckedDocVersions;
bool same = true;
// get the first rofstId for comparing to the rest:
int rofstId = (dvilTmp.Count > 0)? (dvilTmp[0].DocVersionAssociations != null && dvilTmp[0].DocVersionAssociations.Count > 0) ? dvilTmp[0].DocVersionAssociations[0].ROFstID: -1 : -1;
// for remaining folder/docversions in the list, check if they have an associated rofst & if so, if it is the same as the first in list.
for (int i = 1; i < dvilTmp.Count; i++)
{
if (dvilTmp[i].DocVersionAssociations != null && dvilTmp[i].DocVersionAssociations.Count > 0)
{
if (rofstId != dvilTmp[i].DocVersionAssociations[0].ROFstID)
{
same = false;
break;
}
}
}
// rofsts for selected folder/docversions are not the same, cannot do an ro search:
if (!same)
{
DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node();
// C2019-041: if selected folders do not have the same ro.fst then clear the ro list and let user know.
cmboTreeROs.Nodes.Clear();
if (lstCheckedDocVersions == null || lstCheckedDocVersions.Count == 0)
lblSrchRoMsg.Text = "RO values are incompatible between the folders. This may be due to the RO values needing to be updated.";
else
lblSrchRoMsg.Text = "This folder(s) RO values are incompatible with the currently selected folder(s). This may be due to the RO values needing to be updated.";
lblSrchRoMsg.Visible = true;
_lastRoFstId = -1;
return;
}
// C2019-041: if requested rofst is same as last one, just return;
if (_lastRoFstId == rofstId) return;
lblSrchRoMsg.Refresh();
_lastRoFstId = rofstId; // C2019-041: Save this rofstid in case a new one is processed.
cmboTreeROs.Nodes.Clear();
this.cmboTreeROs.AdvTree.BeforeExpand += new DevComponents.AdvTree.AdvTreeNodeCancelEventHandler(this.cmboTreeROs_BeforeExpand);
cmboTreeROs.AdvTree.AfterExpand += new AdvTreeNodeEventHandler(AdvTree_AfterExpandorCollapse);
cmboTreeROs.AdvTree.AfterCollapse += new AdvTreeNodeEventHandler(AdvTree_AfterExpandorCollapse);
// populate the tree - only 1 folder/docversion is selected or all selected use the same rofst:
if (lstCheckedDocVersions != null && lstCheckedDocVersions.Count > 0)
{
_MyDocVersion = lstCheckedDocVersions[0];
if (_MyDocVersion.DocVersionAssociations != null && _MyDocVersion.DocVersionAssociations.Count > 0)
{
_MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(_MyDocVersion);
for (int i = 0; i < _MyROFSTLookup.myHdr.myDbs.Length; i++)
{
DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node();
tn.Text = _MyROFSTLookup.myHdr.myDbs[i].dbiTitle;
tn.Tag = _MyROFSTLookup.myHdr.myDbs[i];
cmboTreeROs.Nodes.Add(tn);
AddDummyGroup(_MyROFSTLookup.myHdr.myDbs[i], tn);
}
}
}
}
void AdvTree_AfterExpandorCollapse(object sender, AdvTreeNodeEventArgs e)
{
Node bottomNode = BottomTreeNode(cmboTreeROs.AdvTree.Nodes);
Node lastNode = cmboTreeROs.AdvTree.Nodes[cmboTreeROs.AdvTree.Nodes.Count - 1];
int top = cmboTreeROs.AdvTree.Nodes[0].Bounds.Top;
int bottom = bottomNode.Bounds.Bottom + 5;
int hScrollBarHeight = cmboTreeROs.AdvTree.HScrollBar != null ? cmboTreeROs.AdvTree.HScrollBar.Height : 0;
bottom = bottomNode.Bounds.Bottom + 5;
cmboTreeROs.AdvTree.Size = new Size(cmboTreeROs.AdvTree.Size.Width, Math.Min(525, bottom - top + hScrollBarHeight));
if (cmboTreeROs.AdvTree.VScrollBar != null && bottom < cmboTreeROs.AdvTree.Size.Height)
{
int yLookFor = (bottom - cmboTreeROs.AdvTree.Size.Height) + 2 * hScrollBarHeight;
Node topNode = FindTreeNodeAt(cmboTreeROs.AdvTree.Nodes, yLookFor);
if (topNode != null)
topNode.EnsureVisible();
}
}
private Node FindTreeNodeAt(NodeCollection nodes, int y)
{
foreach (Node node in nodes)
{
if (node.Bounds.Top <= y && node.Bounds.Bottom >= y)
return node;
if (node.Bounds.Top > y)
{
if (node.PrevNode != null && node.PrevNode.Expanded)
return FindTreeNodeAt(node.PrevNode.Nodes, y);
return node;
}
}
return null;
}
private Node BottomTreeNode(NodeCollection nodes)
{
Node bottomNode = nodes[nodes.Count - 1]; // Return bottom node in collection
if (bottomNode.Expanded) // If expanded return bottom child
return BottomTreeNode(bottomNode.Nodes);
return bottomNode;
}
private void AddDummyGroup(ROFSTLookup.rodbi rodbi, DevComponents.AdvTree.Node tn)
{
if (rodbi.children != null && rodbi.children.Length > 0)
{
DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node();
tmp.Text = "VLN_DUMMY_FOR_TREE";
tn.Nodes.Add(tmp);
}
}
private void cmboTreeROs_BeforeExpand(object sender, DevComponents.AdvTree.AdvTreeNodeCancelEventArgs e)
{
LoadChildren(e.Node);
}
private void LoadChildren(DevComponents.AdvTree.Node tn)
{
object tag = tn.Tag;
if (tn.HasChildNodes && tn.Nodes[0].Text != "VLN_DUMMY_FOR_TREE") return; // already loaded.
if (tn.HasChildNodes && tn.Nodes[0].Text == "VLN_DUMMY_FOR_TREE") tn.Nodes[0].Remove();
ROFSTLookup.rochild[] chld = null;
if (tn.Tag is ROFSTLookup.rodbi)
{
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
chld = db.children;
}
else if (tn.Tag is ROFSTLookup.rochild)
{
ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
chld = ch.children;
}
else
{
Console.WriteLine("error - no type");
return;
}
// if children, add dummy node
if (chld != null && chld.Length > 0)
{
ProgressBar_Initialize(chld.Length, tn.Text);
for (int i = 0; i < chld.Length; i++)
{
ProgressBar_SetValue(i);
DevComponents.AdvTree.Node tmp = null;
// if this is a group, i.e. type 0, add a dummy node
if (chld[i].type == 0 && chld[i].children == null)
//skip it.
// TODO: KBR how to handle this?
//Console.WriteLine("ro junk");
continue;
else if (chld[i].value == null)
{
tmp = new DevComponents.AdvTree.Node();
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node();
sub.Text = "VLN_DUMMY_FOR_TREE";
tmp.Nodes.Add(sub);
}
else
{
tmp = new DevComponents.AdvTree.Node();
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
}
}
}
ProgressBar_Clear();
}
private int FindIndex(NodeCollection nodes, string value)
{
int index = 0;
foreach (Node node in nodes)
{
if (GreaterValue(node.Text, value)) return index;
index++;
}
return index;
}
// private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
private bool GreaterValue(string value1, string value2)
{
return DisplayRO.GreaterValue(value1, value2);
//Match match1 = _RegExGetNumber.Match(value1);
//Match match2 = _RegExGetNumber.Match(value2);
//if (match1.Success && match2.Success) // Compare the numeric value
//{
// double dbl1 = double.Parse(match1.ToString());
// double dbl2 = double.Parse(match2.ToString());
// return dbl1 > dbl2;
//}
//return String.Compare(value1, value2, true) > 0;
}
private void cmboTreeROs_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmboTreeROs.SelectedIndex == -1 || cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rodbi)
cbxFndUnLnkROVals.Enabled = false;
else if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rochild)
{
ROFSTLookup.rochild ro = (ROFSTLookup.rochild)cmboTreeROs.SelectedNode.Tag;
cbxFndUnLnkROVals.Enabled = (ro.children == null);
}
if (!cbxFndUnLnkROVals.Enabled)
cbxFndUnLnkROVals.Checked = false;
}
private void gpFindROs_EnabledChanged(object sender, EventArgs e)
{
if (gpFindROs.Enabled)
gpFindROs.Style.BackColor = Color.Yellow;
else
gpFindROs.Style.BackColor = saveGpFindROsColor;
}
#endregion
#region Annotation Search
public void SetupAnnotationSearch(AnnotationDetails annotationDetails, DisplayTabControl tc)
{
_AnnotationDetails = annotationDetails;
List<AnnotationTypeSearch> annoTypes = new List<AnnotationTypeSearch>();
annoTypes.Add(new AnnotationTypeSearch("All Annotations", ""));
AnnotationTypeInfoList annoList = AnnotationTypeInfoList.Get();
foreach (AnnotationTypeInfo ati in annoList)
annoTypes.Add(new AnnotationTypeSearch(ati.Name, ati.TypeID.ToString()));
cbxAnnoTypes.DisplayMember = "Name";
cbxAnnoTypes.DataSource = annoTypes;
lbSrchResults.MouseMove += new MouseEventHandler(lbSrchResults_MouseMove);
_TabControl = tc;
}
private void cbxTextSearchAnnotation_Leave(object sender, EventArgs e)
{
InsertAnnotationSearchCriteria();
}
private void InsertAnnotationSearchCriteria()
{
if (!cbxTextSearchAnnotation.Text.Equals(string.Empty))
{
string tstr = cbxTextSearchAnnotation.Text;
if (!cbxTextSearchAnnotation.Items.Contains(tstr))
cbxTextSearchAnnotation.Items.Insert(0, tstr);
}
}
private void gpSrchAnnoText_EnabledChanged(object sender, EventArgs e)
{
if (gpSrchAnnoText.Enabled)
{
gpSrchAnnoText.Style.BackColor = Color.Yellow;
cbxTextSearchAnnotation.Focus();
}
else
gpSrchAnnoText.Style.BackColor = saveGpSrchAnnoTextColor;
}
#endregion
#region ProgressBar
private void ProgressBar_Initialize(int max, string desc)
{
if (_ProgressBar != null)
{
_ProgressBar.Maximum = max;
_ProgressBar.Text = desc;
_ProgressBar.TextVisible = true;
}
}
private void ProgressBar_SetValue(int curval)
{
if (_ProgressBar != null)
_ProgressBar.Value = curval;
}
private void ProgressBar_Clear()
{
if (_ProgressBar != null)
{
_ProgressBar.Text = "";
_ProgressBar.Maximum = 0;
_ProgressBar.Value = 0;
//_ProgressBar.TextVisible = false; // B2017-125 text was not always being displayed
}
}
#endregion
#region Search Results
private void DisplayResults()
{
_LoadingList = true;
// C2020-033: Incoming Transition tab. Note that this tab uses a different control for the search
// results, it uses the dotnetbar list that has check boxes. Because of this, various places throughout
// the code will check for what tab is displayed and will work eith the associated list box, either
// lbSrchResults or lbSrchResultsIncTrans
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DisplayMember = _DisplayMember;
else lbSrchResultsIncTrans.DisplayMember = _DisplayMember;
if (_SearchResults != null)
{
if (cbSorted.Checked)
{
Csla.SortedBindingList<ItemInfo> sortedResults = new Csla.SortedBindingList<ItemInfo>(_SearchResults);
sortedResults.ApplySort(_DisplayMember, ListSortDirection.Ascending);
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DataSource = sortedResults;
else lbSrchResultsIncTrans.DataSource = sortedResults;
}
else
{
//PopulatelbSrcResults(_SearchResults);
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DataSource = _SearchResults;
else lbSrchResultsIncTrans.DataSource = _SearchResults;
}
grpPanSearchResults.Text = string.Format("Search Results Found: {0}", _SearchResults.Count);
grpPanSearchResults.Style.BackColor = Color.LightGreen;// Color.YellowGreen; Color.DarkSeaGreen;
}
else
{
grpPanSearchResults.Text = "Search Results";
grpPanSearchResults.Style.BackColor = saveGrpPanSearchResults;
}
// Turn Print and Results display style on/off based on whether there are search results
if (_SearchResults != null && _SearchResults.Count > 0)
{
btnPrnSrchRslts.Enabled = true;
btnClearSearchResults.Enabled = true;
btnCopySearchResults.Enabled = true;
btnSaveSearchResults.Enabled = true;
cmbResultsStyle.Enabled = true;
}
else
{
btnPrnSrchRslts.Enabled = false;
btnClearSearchResults.Enabled = false;
btnCopySearchResults.Enabled = false;
btnSaveSearchResults.Enabled = false;
cmbResultsStyle.Enabled = false;
}
lbSrchResults.SelectedIndex = -1;
lbSrchResultsIncTrans.SelectedIndex = -1;
LastResultsMouseOverIndex = -1;
_LoadingList = false;
}
//private void PopulatelbSrcResults(ICollection<ItemInfo> _SearchResults)
//{
// foreach (ItemInfo ii in _SearchResults)
// {
// lbSrchResults.Items.Add(ii);
// }
// Console.WriteLine("{0} Populate", DateTime.Now);
//}
public void UpdateAnnotationSearchResults()
{
if (!LastSearchWasAnnotations) return; // B2019-119 only refresh annotation search results if an annotation search was done
// B2019-004: update search results list when an annotation is removed. (before bug fix, code method & code below was commented out)
string unitPrefix = "";
if (Mydocversion != null)
unitPrefix = Mydocversion.DocVersionConfig.Unit_ProcedureNumber;
if (unitPrefix.EndsWith("#"))
unitPrefix = unitPrefix.Replace("#", "");
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked, unitPrefix);
DisplayResults();
/*
AnnotationTypeInfo ati = cbxAnnoTypes.SelectedValue as AnnotationTypeInfo;
_LoadingList = true;
lbSrchResults.DataSource = ati.AnnotationTypeAnnotations;
lbSrchResults.SelectedIndex = -1;
LastResultsMouseOverIndex = -1;
if (lbSrchResults.Items.Count > 0)
btnPrnSrchRslts.Enabled = true;
else
btnPrnSrchRslts.Enabled = false;
_LoadingList = false;
* */
}
private void lbSrchResults_MouseMove(object sender, MouseEventArgs e)
{
int ResultsMouseOverIndex = lbSrchResults.IndexFromPoint(e.Location);
if (ResultsMouseOverIndex != -1 && ResultsMouseOverIndex != LastResultsMouseOverIndex)
{
ItemInfo ii = lbSrchResults.Items[ResultsMouseOverIndex] as ItemInfo;
if (cmbResultsStyle.Text == "Step Path" && !ii.IsRtfRaw)
toolTip1.SetToolTip(lbSrchResults, ii.DisplayText); // display the text in a tooltip
else
toolTip1.SetToolTip(lbSrchResults, ii.Path); // display location of corresponding procedure text in a tooltip
LastResultsMouseOverIndex = ResultsMouseOverIndex;
}
}
// B2021-018: Removed code that was tracking the number of items checked in the incoming transition
// listbox. Found that could just look at the CheckedItems.Count value. (Previous fixes
// that were removed are B2021-003 & part of C2020-033 (part was for permissions, which was not removed)
// C2020-033: lbSrchResultsIncTrans_ItemClicked is used to check permissions of a selection before allowing an
// item to be clicked and to turn on/off the btnTranCvtSelToTxt button for converting selected to test.
private void lbSrchResultsIncTrans_ItemClicked(object sender, EventArgs e)
{
ListBoxItem lbi = sender as ListBoxItem;
if (lbi != null)
{
ItemBindingData ibd = lbi.Tag as ItemBindingData;
ItemInfo ii = ibd.DataItem as ItemInfo;
bool allowNonAdmin = IncTranCvtPerm();
if (lbi.CheckState == CheckState.Checked && ii != null)
{
if (!allowNonAdmin && !UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion))
{
FlexibleMessageBox.Show("You do not have permission to edit the procedure, section, or step.",
"Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information);
lbi.CheckState = CheckState.Unchecked;
}
}
// B2021-018: use the CheckedItems.Count on the list box for the search results for
// incoming transitions to determine whether to enable the convert selected to text:
btnTranCvtSelToTxt.Enabled = (lbSrchResultsIncTrans.CheckedItems.Count > 0);
}
}
private void GrpPanSearchResults_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// B2021-004: If a multiple selection occurred in the results list for Incoming Transitions, tell user that
// processing is occurring
if (!lbSrchResultsIncTrans.Enabled) FlexibleMessageBox.Show("Processing a request to open a procedure. Try again when complete.",
"Try Again", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private bool _ProcessingSelectedValueChanged = false;
private void lbSrchResults_SelectedValueChanged(object sender, EventArgs e)
{
if (_LoadingList) return;
if (_ProcessingSelectedValueChanged) return;
_ProcessingSelectedValueChanged = true;
// B2021-004: Prevent multiple selections on the Incoming Transitions listbox (disable selections
// for the listbox until all processing is done, listbox is enabled at end of method)
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4])
{
lbSrchResultsIncTrans.Enabled = false;
lbSrchResultsIncTrans.UseWaitCursor = true;
}
ListBox mylb = sender as ListBox;
// If the list is being refreshed, then set the selection index to -1 (no selection)
if (mylb != null && _SearchResults.RefreshingList && mylb.SelectedIndex != -1)
mylb.SelectedIndex = -1;
else
{
_ItemInfo = (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) ? lbSrchResultsIncTrans.SelectedValue as ItemInfo : lbSrchResults.SelectedValue as ItemInfo;
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
{
// B2020-019: Don't set the CurrentAnnotation to an annotation in a procedure that cannot be opened.
AnnotationInfo tmpca = AnnotationInfo.Get(_ItemInfo.SearchAnnotationID);
DisplayTabItem dti = null;
if (tmpca != null) dti = _TabControl.OpenItem(tmpca.MyItem); // open the corresponding procedure text
if (dti != null)
{
_AnnotationDetails.CurrentAnnotation = tmpca;
_AnnotationDetails.FindCurrentAnnotation(); // position to corresponding row in annotation grid
}
}
else
{
if (_ItemInfo != null)
{
_OpenDocFromSearch = true;
DisplayTabItem dti = _TabControl.OpenItem(_ItemInfo); // open the corresponding procedure text
if (dti != null)
{
if (dti.MyDSOTabPanel != null)
dti.MyDSOTabPanel.SearchString = _strSrchText == null || _strSrchText == "" ? this.cbxTextSearchText.Text : _strSrchText;
if (dti.MyStepTabPanel != null)
dti.MyStepTabPanel.SearchString = _strSrchText == null || _strSrchText == "" ? this.cbxTextSearchText.Text : _strSrchText;
_OpenDocFromSearch = false;
}
}
}
}
_ProcessingSelectedValueChanged = false;
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4])
{
lbSrchResultsIncTrans.Enabled = true;
lbSrchResultsIncTrans.UseWaitCursor = false;
}
}
private void cmbResultsStyle_SelectedValueChanged(object sender, EventArgs e)
{
switch (cmbResultsStyle.Text)
{
case "Document Path":
_DisplayMember = "SearchDVPath";
break;
case "Step Path":
_DisplayMember = "ShortSearchPath";
break;
case "Annotation Text":
_DisplayMember = "SearchAnnotationText";
break;
case "Document Text":
_DisplayMember = "DisplayText";
break;
default:
_DisplayMember = "SearchPath";
break;
}
DisplayResults();
}
private void cbSorted_CheckedChanged(object sender, EventArgs e)
{
Cursor savcursor = Cursor;
Application.DoEvents();
Cursor = Cursors.WaitCursor;
//Console.WriteLine(string.Format("Checked = {0}", cbSorted.Checked));
DisplayResults();
Cursor = savcursor;
}
#endregion
#region Search
private string DVISearchList
{
get
{
// append list of document versions to search
if (lstCheckedDocVersions.Count > 0)
{
string strRtnStr = "";
// get list of doc versions to search
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
{
strRtnStr += string.Format(",{0}", dvi.VersionID.ToString());
}
return strRtnStr.Substring(1);
}
return "";
}
}
private string TypeSearchList
{
get
{
// append list of step types to search
if (lstCheckedStepTypes.Count > 0)
{
string strRtnStr = "";
// get list of selected types
foreach (int typ in lstCheckedStepTypes)
{
int tmp = typ;
if (tmp == 0)
tmp = 10000; // this is the accessory page type
else
tmp += 20000; // step/substep types
strRtnStr += string.Format(",{0}", tmp);
}
return strRtnStr.Substring(1);
}
return "";
}
}
private string TextSearchString
{
get
{
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0])
return ConvertSpecialChars(cbxTextSearchText.Text);//string.Format("{0}", cbxTextSearchText.Text);
return "";
}
}
private string AnnotationSearchType
{
get
{
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1])
return ((AnnotationTypeSearch)cbxAnnoTypes.SelectedValue).ID;
return "";
}
}
private string ROSearchList
{
get
{
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[2])
{ // RO Search
ROFSTLookup.rochild[] chld = null;
ROFSTLookup.rochild ch;
if (cmboTreeROs.SelectedNode != null)
{
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
{
ch = (ROFSTLookup.rochild)cmboTreeROs.SelectedNode.Tag;
_strSrchText = string.Format("{0}", ch.value);
return _strSrchText; // append RO Value text to search
}
else
{
if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rodbi)
{
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)cmboTreeROs.SelectedNode.Tag;
return _MyRODbID.ToString() + ":" + string.Format("{0}", db.dbiID.ToString("X4"));
}
else if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rochild)
{
ch = (ROFSTLookup.rochild)cmboTreeROs.SelectedNode.Tag;
chld = ch.children;
// build a list of ROs to search
return _MyRODbID.ToString() + ":" + GetROsToSearch(chld);
//return _MyRODbID.ToString() + ":" + ch.roid + "0000," + GetROsToSearch(chld);
//if (strRtnStr.EndsWith(","))
// strRtnStr = strRtnStr.Substring(0, strRtnStr.Length - 1);
}
}
}
}
return "";
}
}
private string ConvertSpecialChars(string str)
{
string rtnVal = str;
rtnVal = rtnVal.Replace("\u00A0", @"\u160?"); //convert \u00A0 to a hard space (\u00A0 shows as a blank in the search text field)
rtnVal = rtnVal.Replace("\n", @"\line "); //B2018-020 SQL content record has "\line " for the hard return
// Bug fix B2014-057
// if we are searching for a symbol character in all procedure sets MyDocVersion is null
// when MyDocVersion is null, get the symbol list directly from the PROMS base format (BaseAll.xml)
FormatData fmtdata = (_MyDocVersion != null) ? _MyDocVersion.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData;
if (fmtdata != null && fmtdata.SymbolList != null)
{
SymbolList sl = fmtdata.SymbolList;
if (sl != null)
{
foreach (Symbol sym in sl)
{
string rplace = string.Format(sym.Unicode < 256 ? @"\'{0:X2}" : @"\u{0}?", sym.Unicode); // bug fix B2014-057 we were not including the ? in the replace
rtnVal = rtnVal.Replace(((char)sym.Unicode).ToString(), rplace);
}
}
}
return rtnVal;
}
// Same funtion as GetROChildren in DisplayReport.cs
private string GetROsToSearch(ROFSTLookup.rochild[] chld)
{
string rtnstr = "";
if (chld == null) // get a single ROID
{
ROFSTLookup.rochild ro = (ROFSTLookup.rochild)cmboTreeROs.SelectedNode.Tag;
rtnstr += string.Format("{0}", ro.roid);
if (rtnstr.Length == 12) rtnstr += "0000"; // last four digits are used for multiple return values
}
else
{ // spin through the child list and get the ROIDs.
// if the child has children, then call this function recursivly
foreach (ROFSTLookup.rochild roc in chld)
{
if (roc.children != null)
rtnstr += GetROsToSearch(roc.children);
else
rtnstr += string.Format("{0},", roc.roid);
}
}
return rtnstr;
}
private bool _LastSearchWasAnnotations = false; // B2019-119 only refresh annotation search results if an annotation search was done
public bool LastSearchWasAnnotations
{
get { return _LastSearchWasAnnotations; }
set { _LastSearchWasAnnotations = value; }
}
private void btnSearch_Click(object sender, EventArgs e)
{
_fromLoad = false;
DateTime start = DateTime.Now;
Cursor savcursor = Cursor;
// keeps track of index into combo box for results style. This combo box may have 3 or 4
// items depending on whether annotations exist.
int cmbResultsStyleIndex = -1;
try
{
LastSearchWasAnnotations = false; // B2019-119 only refresh annotation search results if an annotation search was done
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4])
{
lbSrchResults.DataSource = null;
lbSrchResults.Items.Clear();
toolTip1.SetToolTip(lbSrchResults, null);
}
else // C2020-033: Incoming Transiiotns
{
lbSrchResultsIncTrans.DataSource = null;
lbSrchResultsIncTrans.Items.Clear();
toolTip1.SetToolTip(lbSrchResultsIncTrans, null);
}
Cursor = Cursors.WaitCursor;
SearchResults = null;
bool includeRTFformat = false;
bool includeSpecialChars = (TextSearchString != @"\?"); // true;
// Build list of selected types that were searched
string typstr = null;
foreach (string s in lstCheckedStepTypesStr) typstr = typstr == null ? s : typstr + ", " + s;
TypesSelected = "Filtered By: " + ((typstr != null) ? typstr : "All Step Types");
//TypesSelected = "Step Types Searched: " + ((typstr != null) ? typstr : "all step types");
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "all step types");
//TypesSelected = (typstr != null) ? "Searched Step Types: " + typstr : "Searched All Step Types";
string unitPrefix = "";
if(Mydocversion != null)
unitPrefix = Mydocversion.DocVersionConfig.Unit_ProcedureNumber;
if (unitPrefix.EndsWith("#"))
unitPrefix = unitPrefix.Replace("#", "");
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0]) // Text Search
{
if (cbxSrchTypeUsage.Checked) // find just the usage of the selected types
{
if (lstCheckedStepTypes.Count == 0)
{
FlexibleMessageBox.Show("Please select one or more types then press the Search button", "No Types Selected");
xpStepTypes.Expanded = true;
advTreeStepTypes.Focus();
xpStepTypes.TitleStyle.BackColor1.Color = Color.Crimson;
}
else
{
//string typstr = null;
//foreach (string s in lstCheckedStepTypesStr) typstr = typstr==null?s:typstr + ", " + s;
//ReportTitle = "Search for Selected Types"; //"Proms - Search by Type: " + typstr;
ReportTitle = "Step Element Report"; //"Proms - Search by Type: " + typstr;
TypesSelected = "Filtered By: " + typstr;
SearchString = null;
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars, unitPrefix, "", "");
cmbResultsStyleIndex = 1; //display step locations in results
}
}
else
{
//if (textSearchString.Equals(""))
//{
// MessageBox.Show("Please enter some search text, then click the Search button", "No Search Text");
// cbxTextSearchText.Focus();
//}
//else
//{
//ReportTitle = string.Format("Proms - {0} Search for '{1}'", cbxBooleanTxtSrch.Checked ? "Boolean" : "Text", TextSearchString);
ReportTitle = string.Format("Search for '{0}'", TextSearchString);
// C2020-009: Search - Allow search 'By Word'.
string byWordPrefix = "";
string byWordSuffix = "";
if (cbxByWord.Checked)
{
// Generate a prefix & suffix to be used in the sql query around the search string.
// If the search string starts (prefix)/ends(suffix) with a number, then use an expression that
// does not allow the preceding/following text to have a number, '.', letter or other rtf
// commands. If the search string starts/ends with a letter, then use an expression that does not
// find the preceding/following text that is text, i.e. a letter.
if (Regex.IsMatch(TextSearchString, @"^[\d\.]")) // starts with a number or '.' decimal pt
{
byWordPrefix = @"[^0-9a-zA-Z.vbpi:\\-]";
}
else if (Regex.IsMatch(TextSearchString, @"^[a-zA-Z]")) // starts with a letter
{
byWordPrefix = @"[^a-zA-Z]";
}
if (Regex.IsMatch(TextSearchString, @"[\d\.]$")) // ends with a number or decimal
{
byWordSuffix = @"[^0-9a-zA-Z.vbpi:\\-]";
}
else if (Regex.IsMatch(TextSearchString, @"[a-zA-Z]$")) // ends with a letter
{
byWordSuffix = @"[^a-zA-Z]";
}
}
SearchString = TextSearchString;
//TypesSelected = (typstr != null) ? "Searched Step Types: " + typstr : "Searched All Step Types";
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString /*.Replace(@"\",@"\u9586?")*/, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, byWordPrefix, byWordSuffix);
cmbResultsStyleIndex = 3; // display step text in results
//}
}
// C2019-001: Search in RNO steps only
if (cbxRnoOnly.Checked) GetInRNOResults();
}
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) // Annotation Search
{
LastSearchWasAnnotations = true; // B2019-119 only refresh annotation search results if an annotation search was done
SearchString = null;
//ReportTitle = string.Format("Proms - Annotation Search for '{0}'", cbxTextSearchAnnotation.Text);
if (cbxTextSearchAnnotation.Text == null || cbxTextSearchAnnotation.Text == "")
{
ReportTitle = string.Format("Find {0}{1}", cbxAnnoTypes.Text, (cbxAnnoTypes.SelectedIndex > 0) ? " Annotations" : "");
}
else
{
ReportTitle = string.Format("Search {0}{1} For '{2}'", cbxAnnoTypes.Text, (cbxAnnoTypes.SelectedIndex > 0) ? " Annotations" : "", cbxTextSearchAnnotation.Text);
}
//ReportTitle = string.Format("Search Annotations for '{0}'", cbxTextSearchAnnotation.Text);
//string srchStr = ConvertSpecialChars(cbxTextSearchAnnotation.Text);//cbxTextSearchAnnotation.Text;
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
//SearchResults = ItemInfoList.GetListFromAnnotationSearch(dviSearchList, typeSearchList, textSearchString, srchStr, cbxCaseSensitiveAnnoText.Checked);
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked, unitPrefix);
//UpdateAnnotationSearchResults();
cmbResultsStyleIndex = 2; // display annotation text in results
// C2019-001: Search in RNO steps only
if (cbxRnoOnlyAnnot.Checked) GetInRNOResults();
}
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[2]) // RO Search
{
SearchString = null;
//ReportTitle = "Proms - Referenced Object Search";
ReportTitle = string.Format("Search For Referenced Object:\n{0}", cmboTreeROs.Text);
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
{
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, "", "");
cmbResultsStyleIndex = 3; // display step text in results
}
else
{
SearchResults = ItemInfoList.GetListFromROSearch(DVISearchList, TypeSearchList, ROSearchList, unitPrefix);
cmbResultsStyleIndex = 3; // display step text in results
}
// C2019-001: Search in RNO steps only
if (cbxRnoOnlyRO.Checked) GetInRNOResults();
}
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[3]) //Transition Search
{
ReportTitle = string.Format("Search For Transitions: Transition Type: {0}, Transition Category: {1}", cbxTranFormat.SelectedItem, cbxTranCategory.SelectedItem);
string docVersionList = string.Empty;
if (lstCheckedDocVersions.Count == 0)
docVersionList = cbxTranVersion.Tag.ToString();
else
{
string sep = string.Empty;
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
{
docVersionList += sep + dvi.VersionID.ToString();
sep = ",";
}
}
// B2018-134 to search specifically for Outside Transitions, set docVeronList to empty string so that all procedure sets are considered
if (cbxTranCategory.SelectedItem.ToString() == "Outside")
docVersionList = "";
// added TypeSearchList for bug fix B2015-055
SearchResults = ItemInfoList.GetListFromTransitionSearch(docVersionList, cbxTranFormat.SelectedIndex - 1, cbxTranCategory.SelectedItem.ToString() == "All" ? "" : cbxTranCategory.SelectedItem.ToString(), TypeSearchList);
cmbResultsStyleIndex = 3; // display step text in results
// C2019-001: Search in RNO steps only
if (cbxRnoOnlyTrans.Checked) GetInRNOResults();
}
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4])
{
// C2020-033: Incoming Transitions: Make an iteminfolist from the list returned from
// GetExternalTransitionsToChildren (also gets transitions to the item itself)
// B2021-010: Use IncomingTranGetMergedTranList to get a complete list of incoming transitions (transitions to procedure
// were only included if there were NO transitions to items within procedure)
ReportTitle = string.Format("Search For Incoming Transitions to {0}: ", SearchIncTransII.Path);
SearchResults = IncomingTranGetMergedTranList();
cmbResultsStyleIndex = 1; //display step locations in results
if (SearchResults == null || SearchResults.Count == 0)
{
FlexibleMessageBox.Show("No Matches Found.", "Search");
}
}
if (SearchResults != null)
{
AddMessageForEmptyAnnotations();
if (cmbResultsStyleIndex == 3 && cmbResultsStyle.Items.Count == 3) cmbResultsStyleIndex--;
cmbResultsStyle.SelectedIndex = cmbResultsStyleIndex;
DisplayResults();
if (SearchResults != null && SearchResults.Count == 0)
{
FlexibleMessageBox.Show("No Matches Found.", "Search");
}
}
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm(); // C2020-033: does user have access to at least one item
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
string tmpmsg = (cbxBooleanTxtSrch.Checked && ex.Message.Contains("Syntax error") && ex.Message.Contains("full-text search")) ?
"Place \"\" around words that you are searching for, so that parser can better understand what you are trying to find" :
ex.Message;
FlexibleMessageBox.Show(tmpmsg, "Search Error: " + ex.GetType().Name);
}
finally
{
Cursor = savcursor;
}
//Console.WriteLine("{0} Milliseconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalMilliseconds);
OnSearchComplete(new DisplaySearchEventArgs(TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks)));
//if (VlnSettings.DebugMode)
// MessageBox.Show(string.Format("{0} Milliseconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalMilliseconds));
}
// C2019-001: Search in RNO steps only
private void GetInRNOResults()
{
bool first = true;
ItemInfoList iil = null;
foreach (ItemInfo ii in SearchResults)
{
if (ii.SearchPath.Contains(".RNO."))
{
if (first)
{
iil = new ItemInfoList(ii);
first = false;
}
else
{
iil.AddItem(ii);
}
}
}
SearchResults = iil;
// B2021-075 - put up none found message for RNO only
if (SearchResults == null || SearchResults.Count == 0)
{
FlexibleMessageBox.Show("No Matches Found.", "Search");
}
}
private void AddMessageForEmptyAnnotations()
{
bool hasAnnot = false;
foreach (ItemInfo ii in SearchResults)
{
if (ii.ItemAnnotations != null && ii.ItemAnnotationCount > 0)
{
// RHM - can an iteminfo have an itemannotationcount>0 and not have searchannotationtext.
if (ii.SearchAnnotationText == null) ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
}
if (ii.SearchAnnotationText == null) ii.SearchAnnotationText = "None - [" + ii.DisplayText + "]";
else
{
hasAnnot = true;
}
}
cmbResultsStyle.Items.Clear();
cmbResultsStyle.Items.Add(comboItem1);
cmbResultsStyle.Items.Add(comboItem2);
if (hasAnnot) cmbResultsStyle.Items.Add(comboItem3);
cmbResultsStyle.Items.Add(comboItem4);
}
private void cbxTextSearchText_Leave(object sender, EventArgs e)
{
InsertSearchCriteria();
}
private void InsertSearchCriteria()
{
if (!cbxTextSearchText.Text.Equals(string.Empty))
{
string tstr = cbxTextSearchText.Text;
// if its already exists in the list - remove it
if (cbxTextSearchText.Items.Contains(tstr))
cbxTextSearchText.Items.Remove(tstr);
// Add the new criteria to the top of the list
cbxTextSearchText.Items.Insert(0, tstr);
// set the text to the new criteria
cbxTextSearchText.Text = tstr;
// If there are more than 10 remove the last one
if (cbxTextSearchText.Items.Count > 10)
cbxTextSearchText.Items.RemoveAt(10);
}
}
private void cbxSrchTypeUsage_CheckedChanged(object sender, EventArgs e)
{
gpSrchText.Enabled = !cbxSrchTypeUsage.Checked;
if (!cbxSrchTypeUsage.Checked)
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
else
{
xpStepTypes.Expanded = true;
if (lstCheckedStepTypes.Count == 0)
xpStepTypes.TitleStyle.BackColor1.Color = Color.Crimson;
advTreeStepTypes.Focus();
}
}
private void rbtnSrchTxt_CheckedChanged(object sender, EventArgs e)
{
if (rbtnSrchTxt.Checked)
cbxTextSearchText.Focus();
}
private void gpSrchText_EnabledChanged(object sender, EventArgs e)
{
if (gpSrchText.Enabled)
gpSrchText.Style.BackColor = cbxBooleanTxtSrch.Checked ? Color.Orange : Color.Yellow;
else
gpSrchText.Style.BackColor = saveGpSrchTextColor;
}
private void tabStepTypeSearch_Click(object sender, EventArgs e)
{
if (rbtnSrchTxt.Checked)
{
cbxTextSearchText.Focus();
cbxBooleanTxtSrch_CheckedChanged(sender, e);
}
}
private void ProcessEnterKey(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r') // enter key pressed
{
e.Handled = true;
btnSearch_Click(sender, e);
if (sender == cbxTextSearchText)
InsertSearchCriteria();
else
InsertAnnotationSearchCriteria();
}
}
#endregion
#region ProcSetSelection
private int _MyRODbID;
private static bool checkingChildren = false;
private void advTreeProcSets_AfterCheck(object sender, DevComponents.AdvTree.AdvTreeCellEventArgs e)
{
// this method gets called if child nodes get checked by the code, return if doing this process.
if (checkingChildren) return;
DevComponents.AdvTree.Node n = advTreeProcSets.SelectedNode;
dicSelectedFolderNodes[n] = n.Checked;
// if this tree node is checked, and there are children, check the children too.
if (n.Checked)
{
checkingChildren = true;
if (n.Nodes != null && n.Nodes.Count > 0 && n.Nodes[0].Text != "VLN_DUMMY") CheckTreeNodeChildren(n.Nodes);
checkingChildren = false;
}
// if the selected folder has a docversion, handle it:
FolderInfo fi = (FolderInfo)n.Tag;
RefreshLstCheckedDocVersions();
RefreshStepTypes();// Refresh Step Types after Working Draft is checked.
if (lstCheckedDocVersions.Count == 1 && fi.FolderDocVersions != null && fi.FolderDocVersions.Count > 0)
{
Mydocversion = fi.FolderDocVersions[0];
StartAdvTreeStepTypesFillIn();// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
}
SetupContextMenu();
buildSetToSearchPanelTitle();
}
// check all folder nodes below this
private void CheckTreeNodeChildren(NodeCollection nodeCollection)
{
foreach (Node tn in nodeCollection)
{
if (!tn.Checked) tn.Checked = true;
if (tn.Nodes != null && tn.Nodes.Count > 0 && tn.Nodes[0].Text != "VLN_DUMMY") CheckTreeNodeChildren(tn.Nodes);
}
}
// The 'lstCheckedDocVersions' maintains a list of the docversions that are associated with folders that are checked
// on the search tree of folders, i.e. procedure sets that should be included in the search.
private void RefreshLstCheckedDocVersions()
{
lstCheckedDocVersions.Clear();
AddFromTreeNodes(advTreeProcSets.Nodes); // add docversions to the list
LoadROComboTree(); // reset the ro tree based on docversion selections.
}
private void AddFromTreeNodes(NodeCollection nodeCollection)
{
foreach (Node tn in nodeCollection)
AddFromTreeNode(tn);
}
private void AddFromTreeNode(Node tn)
{
if (tn.Checked)
{
tn.Style = DevComponents.AdvTree.NodeStyles.Apple; // sets green background on selected folder(s)
FolderInfo fi = (FolderInfo)tn.Tag;
// if this folder has a docversion, use its id:
if (tn.Nodes != null && tn.Nodes.Count > 0 && tn.Nodes[0].Text != "VLN_DUMMY") // Folder has been expanded, so add its docversion list
{
if (fi.FolderDocVersionCount > 0) lstCheckedDocVersions.Add(fi.FolderDocVersions[0]);
}
else // it has not been expanded process all below.
AddAllChildVersions(fi);
}
else // not checked, set style so no background color
tn.Style = null;
if (tn.Nodes != null) AddFromTreeNodes(tn.Nodes);
}
private void RemoveAllVersions(FolderInfo child)
{
RemoveAllChildVersions(child);
RefreshStepTypes(); // Refresh the Step Type TreeView
}
/// <summary>
/// RessetStepTypes - Clear Step Type Treeview
/// </summary>
private void ResetStepTypes()
{
ResetStepTypes("....select a procedure set for types to appear...");
}
private void ResetStepTypes(string str)
{
advTreeStepTypes.Nodes.Clear();
lstCheckedStepTypes.Clear();
lstCheckedStepTypesStr.Clear();
Node newnode = new DevComponents.AdvTree.Node();
newnode.Text = str;
advTreeStepTypes.Nodes.Add(newnode);
buildStepTypePannelTitle();
}
private void AddAllVersions(FolderInfo child)
{
AddAllChildVersions(child);
RefreshStepTypes();
}
/// <summary>
/// RefreshStepTypes - Updates the StepType TreeView to allow step types to be specified.
/// </summary>
private void RefreshStepTypes()
{
if (lstCheckedDocVersions.Count == 0)
{
ResetStepTypes();
return;
}
string formatName = lstCheckedDocVersions[0].ActiveFormat.Name;
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
{
if (formatName != dvi.ActiveFormat.Name)
{
ResetStepTypes("...folders selected include multiple formats");
return;
}
}
_MyDocVersion = lstCheckedDocVersions[0];
StartAdvTreeStepTypesFillIn();// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
}
// remove all docversion children
private void RemoveAllChildVersions(FolderInfo myFolderInfo)
{
if (myFolderInfo.FolderDocVersionCount > 0)
foreach(DocVersionInfo dvi in myFolderInfo.FolderDocVersions)
if(lstCheckedDocVersions.Contains (dvi))
lstCheckedDocVersions.Remove(dvi);
if (myFolderInfo.ChildFolders != null)
foreach (FolderInfo folderChild in myFolderInfo.ChildFolders)
RemoveAllChildVersions(folderChild);
}
// add all docversion children
private void AddAllChildVersions(FolderInfo myFolderInfo)
{
if (myFolderInfo.FolderDocVersionCount > 0)
foreach(DocVersionInfo dvi in myFolderInfo.FolderDocVersions)
if (!lstCheckedDocVersions.Contains(dvi))
lstCheckedDocVersions.Add(dvi);
if (myFolderInfo.ChildFolders != null)
foreach (FolderInfo folderChild in myFolderInfo.ChildFolders)
AddAllChildVersions(folderChild);
}
private void cbxTranFormatFillIn(string vid)
{
vid = vid.IndexOf(",") < 0 ? vid : vid.Substring(0, cbxTranVersion.Tag.ToString().IndexOf(","));
DocVersionInfo dvi = DocVersionInfo.Get(int.Parse(vid));
TransTypeList ttl = dvi.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList;
cbxTranFormat.Items.Clear();
cbxTranFormat.Items.Add("All");
for (int i = 0; i < ttl.MaxIndex; i++)
cbxTranFormat.Items.Add(new TransItem(ttl[i].TransMenu.Replace("?.", ""), ttl[i].TransFormat.Replace("?.", "")));
cbxTranFormat.SelectedIndex = 0;
cbxTranCategory.Items.Clear();
cbxTranCategory.Items.Add("All");
cbxTranCategory.Items.Add("Internal");
cbxTranCategory.Items.Add("External");
cbxTranCategory.Items.Add("Outside");
cbxTranCategory.SelectedIndex = 0;
/*
groupPanelTranFmt.Style.BackColor = (_CurTrans == null && _TranFmtIndx==0) ? Color.Yellow : Color.Orange;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
*/
}
private void xpSetToSearch_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
{
buildSetToSearchPanelTitle();
}
private void buildSetToSearchPanelTitle()
{
if (lstCheckedDocVersions.Count == 0)
{
xpSetToSearch.TitleText = string.Format("All Procedure Sets Selected");
xpSetToSearch.TitleStyle.BackColor1.Color = Color.PapayaWhip;
btnSearch.Enabled = true;
tabSearchTypes.Enabled = true; // enable all the search tabs
// xpSetToSearch.Expanded = true;
// xpSetToSearch.TitleStyle.BackColor1.Color = Color.Crimson;
// btnSearch.Enabled = false;
// tabSearchTypes.Enabled = false; // disable all the search tabs
// //if (xpSetToSearch.Expanded)
// xpSetToSearch.TitleText = "Select Procedure Sets to Search";
// //else
// // xpSetToSearch.TitleText = "Click Here to Select Procedure Sets";
// //xpSetToSearch.TitleStyle.BackColor1.Color = saveXpSetToSearchColor;
}
else //if (lstCheckedDocVersions.Count > 0)
{
// display the number of selected procedure sets whether pannel is expanded or not
xpSetToSearch.TitleText = string.Format("{0} Procedure Sets Selected", lstCheckedDocVersions.Count);
xpSetToSearch.TitleStyle.BackColor1.Color = Color.PapayaWhip;
btnSearch.Enabled = true;
tabSearchTypes.Enabled = true; // enable all the search tabs
}
}
private void advTreeProcSets_AfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
{
DevComponents.AdvTree.Node n = advTreeProcSets.SelectedNode;
if (advTreeStepTypes.Nodes.Count == 1 && n.Checked)
{
if (n.Tag is DocVersionInfo) // Only set MyDocVersion if it is a DocVersion
{
Mydocversion = (DocVersionInfo)n.Tag;
StartAdvTreeStepTypesFillIn();// B2016-258 Hang after selecting a procedure if the Step Type panel is open on the search panel
}
}
}
#endregion
#region StepTypeSelection
private void advTreeStepTypes_AfterCheck(object sender, DevComponents.AdvTree.AdvTreeCellEventArgs e)
{
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
DevComponents.AdvTree.Node n = advTreeStepTypes.SelectedNode;
if (n == null) return;
StepData sd = (StepData)n.Tag;
if (n.Checked)
{
n.Style = DevComponents.AdvTree.NodeStyles.Apple;
if (sd == null)
{
if (!lstCheckedStepTypesStr.Contains("WORD Sections"))
{
lstCheckedStepTypes.Add(0); //use zero to identify attachment search
lstCheckedStepTypesStr.Add("WORD Sections");
}
}
else
{
if (!lstCheckedStepTypesStr.Contains(advTreeStepTypes.SelectedNode.Text))
{
lstCheckedStepTypes.Add((int)sd.Index);
lstCheckedStepTypesStr.Add(advTreeStepTypes.SelectedNode.Text);
}
}
}
else
{
n.Style = null;
if (sd == null)
{
lstCheckedStepTypesStr.Remove("WORD Sections");
lstCheckedStepTypes.Remove(0);
}
else
{
lstCheckedStepTypes.Remove((int)sd.Index);
//lstCheckedStepTypesStr.Remove(sd.Type);
lstCheckedStepTypesStr.Remove(advTreeStepTypes.SelectedNode.Text);
}
}
buildStepTypePannelTitle();
// B2021-100: Enable/disable the RNO Only checkbox & WORD Sections tree node in Step Elements to Search.
// The only time the RNO Only checkbox is disabled is if the only selection in Step Elements to Search is WORD Sections.
cbxRnoOnly.Enabled = true;
if (OnlyWordSectTypeSel()) cbxRnoOnly.Checked = cbxRnoOnly.Enabled = false;
}
private void xpStepTypes_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
{
buildStepTypePannelTitle();
}
private void buildStepTypePannelTitle()
{
if (lstCheckedStepTypes.Count == 0)
{
if (xpStepTypes.Expanded)
{
xpStepTypes.TitleText = "Select Step Elements To Search";//"Select Types To Search";
advTreeStepTypes.Focus();
advTreeStepTypes.Nodes[0].SelectedCell = advTreeStepTypes.Nodes[0].Cells[0];
}
else
xpStepTypes.TitleText = "Click Here To Search By Step Element";//"Click Here To Search By Types";
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
}
else //lstCheckedStepTypes.Count > 0
{
// show how many selected whether pannel is expanded or not
//xpStepTypes.TitleText = string.Format("{0} Step Styles Selected", lstCheckedStepTypes.Count);
xpStepTypes.TitleText = string.Format("{0} Step Element{1} Selected", lstCheckedStepTypes.Count, (lstCheckedStepTypes.Count > 1)?"s":""); // B2018-132 changed second {0} to {1}
xpStepTypes.TitleStyle.BackColor1.Color = Color.PapayaWhip;
}
}
#endregion
#region ContextMenu
private void btnSym_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = (string)b.Text;
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = (string)b.Text;
}
private void cmFndTxtInsHardSp_Click(object sender, EventArgs e)
{
// We use \u00A0 to represent a hard space because it show in the search text field as a blank
// It will get translated to a real hard space character prior to searching
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = "\u00A0";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = "\u00A0";
}
// Changed to a public so that it could be called after the /DB parameter has been processed
public void SetupContextMenu()
{
galSymbols.SubItems.Clear();
// Bug fix B2014-057
// if we are searching for a symbol character in all procedure sets MyDocVersion is null
// when MyDocVersion is null, get the symbol list directly from the PROMS base format (BaseAll.xml)
// this will populate the context menu of the Search text entry field so that a symbol can be selected without first selecting a procedure set
FormatData fmtdata = (_MyDocVersion != null) ? _MyDocVersion.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData;
if (fmtdata != null && fmtdata.SymbolList != null)
{
SymbolList sl = fmtdata.SymbolList;
if (sl == null || sl.Count <= 0)
{
FlexibleMessageBox.Show("No symbols are available, check with administrator");
return;
}
foreach (Symbol sym in sl)
{
DevComponents.DotNetBar.ButtonItem btnCM = new DevComponents.DotNetBar.ButtonItem();
btnCM.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btnCM.Name = "btnCM" + sym.Unicode.ToString();
btnCM.Tooltip = sym.Desc;
btnCM.Tag = string.Format(@"{0}", sym.Unicode);
btnCM.FontBold = true;
btnCM.Click += new System.EventHandler(btnSym_Click);
galSymbols.SubItems.Add(btnCM);
}
}
}
private void cmFndTxtCut_Click(object sender, EventArgs e)
{
Clipboard.Clear();
DataObject myDO = new DataObject(DataFormats.Text, cbxTextSearchAnnotation.Focused ? cbxTextSearchAnnotation.SelectedText : cbxTextSearchText.SelectedText);
Clipboard.SetDataObject(myDO);
// Need to check which combo box activated the context menu so that we know where to take/put selected text
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = "";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = "";
}
private void cmFndTxtCopy_Click(object sender, EventArgs e)
{
// Need to check which combo box activated the context menu so that we know where to take/put selected text
DataObject myDO = new DataObject(DataFormats.Text, cbxTextSearchAnnotation.Focused ? cbxTextSearchAnnotation.SelectedText : cbxTextSearchText.SelectedText);
if (cbxTextSearchText.Focused || cbxTextSearchAnnotation.Focused)
{
Clipboard.Clear();
Clipboard.SetDataObject(myDO);
}
}
private bool OnlyWordSectTypeSel()
{
// B2021-100: Enable/disable the RNO Only checkbox & WORD Sections tree node in Step Elements to Search.
// lstCheckedStepTypes[x] = 0 for Word sections:
if (lstCheckedStepTypes != null && lstCheckedStepTypes.Count == 1 && lstCheckedStepTypes[0] == 0) return true;
return false;
}
private void CbxRnoOnly_Click(object sender, System.EventArgs e)
{
// C2021-028: RNO Only search, disable Word section tree node:
// B2021 - 100: Enable / disable the RNO Only checkbox &WORD Sections tree node in Step Elements to Search.
if (tabSearchTypes.SelectedTab == tabTranSearch) return;
wordSectionTreeNode.Enabled = true;
if (!cbxRnoOnly.Checked) // checked turning on
{
// Set enabling on WORD Sections tree node in Step Elements to Search. If either no items are selected in tree or
// just WORD Section is selected, then disable the WORD Section tree node. Otherwise, i.e. other step types are selected
// in tree, thus they must be searched using RNO Only so need to disable anything.
wordSectionTreeNode.Enabled = !(OnlyWordSectTypeSel() || (lstCheckedStepTypes != null && lstCheckedStepTypes.Count == 0));
if (!wordSectionTreeNode.Enabled) wordSectionTreeNode.Checked = false;
}
else // turning off - WORD Sections tree node is enabled.
wordSectionTreeNode.Enabled = true;
}
private void cmFndTxtPaste_Click(object sender, EventArgs e)
{
// Need to check which combo box activated the context menu so that we know where to take/put selected text
IDataObject myDO = Clipboard.GetDataObject();
//if (myDO.GetDataPresent(DataFormats.Rtf))
//{
// RichTextBox rtb = new RichTextBox();
// rtb.SelectedRtf = ItemInfo.StripLinks(myDO.GetData(DataFormats.Rtf).ToString());
// if (cbxTextSearchAnnotation.Focused)
// cbxTextSearchAnnotation.SelectedText = rtb.Text;
// else if (cbxTextSearchText.Focused)
// cbxTextSearchText.SelectedText = rtb.Text;// .SelectedText;//myDO.GetData(DataFormats.Text,true).ToString();
//}
//else if (myDO.GetDataPresent(DataFormats.Text))
if (myDO.GetDataPresent(DataFormats.Text))
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = Clipboard.GetText();
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = Clipboard.GetText();//myDO.GetData(DataFormats.Text).ToString();
}
private void btnCMIFindText_PopupOpen(object sender, PopupOpenEventArgs e)
{
// the context menu is available with just a mouse hover, even if the combo box does not have focus
// ... set the focus to which ever combo box initiated the context menu
if (tabAnnotationSearch.IsSelected)
{
if (!cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.Focus();
}
else if (tabStepTypeSearch.IsSelected)
{
if (!cbxTextSearchText.Focused)
cbxTextSearchText.Focus();
}
}
#endregion
private void buttonItem2_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = "*";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = "*";
}
private void buttonItem3_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = "?";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = "?";
}
private void buttonItem4_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = "?*";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = "?*";
}
private void cbxBooleanTxtSrch_CheckedChanged(object sender, EventArgs e)
{
// If the Boolean search is not working - run the following two commands in SQL:
// use veproms
// ALTER FULLTEXT INDEX ON Contents START FULL POPULATION
// ALTER FULLTEXT INDEX ON Documents START FULL POPULATION
// use master
//Boolean search uses a list of noise, or STOP, words. This list can be found
// in file: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\noiseenu.txt.
// Another file exists in that directory, tsenu.xml, this is a thesaurus. RHM tried
// to use around 2010, but couldn't get it to work for words like 'dg' versus 'diesel generator',
// and 'sg' versus 'steam generator'.
if (cbxBooleanTxtSrch.Checked)
{
gpSrchText.Style.BackColor = Color.Orange;
btnCMIFindText.SubItems[1].SubItems[2].Visible = false;
btnCMIFindText.SubItems[1].SubItems[3].Visible = true;
//cbxCaseSensitive.Checked = false;
//cbxCaseSensitive.Enabled = false;
//cbxIncROTextSrch.Checked = true;
//cbxIncROTextSrch.Enabled = false;
cbxCaseSensitive.Enabled = false;
cbxIncROTextSrch.Enabled = false;
}
else
{
gpSrchText.Style.BackColor = Color.Yellow;
btnCMIFindText.SubItems[1].SubItems[2].Visible = true;
btnCMIFindText.SubItems[1].SubItems[3].Visible = false;
//cbxCaseSensitive.Enabled = true;
//cbxIncROTextSrch.Enabled = true;
cbxCaseSensitive.Enabled = true;
cbxIncROTextSrch.Enabled = true;
}
}
private void cbxBooleanAnoTxtSrch_CheckedChanged(object sender, EventArgs e)
{
if (cbxBooleanAnoTxtSrch.Checked)
{
gpSrchAnnoText.Style.BackColor = Color.Orange;
btnCMIFindText.SubItems[1].SubItems[2].Visible = false;
btnCMIFindText.SubItems[1].SubItems[3].Visible = true;
}
else
{
gpSrchAnnoText.Style.BackColor = Color.Yellow;
btnCMIFindText.SubItems[1].SubItems[2].Visible = true;
btnCMIFindText.SubItems[1].SubItems[3].Visible = false;
}
}
private void btnAND_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = " AND ";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = " AND ";
}
private void btnOR_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = " OR ";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = " OR ";
}
private void btnNOT_Click(object sender, EventArgs e)
{
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = " NOT ";
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = " NOT ";
}
private void tabAnnotationSearch_Click(object sender, EventArgs e)
{
cbxAnnoTypes.Focus();
cbxBooleanAnoTxtSrch_CheckedChanged(sender, e);
}
private void btnClearSearchResults_Click(object sender, EventArgs e)
{
if (tabSearchTypes.SelectedTab == tabIncTrans) // C2020-033: Clear the Incoming Transitions list box
{
lbSrchResultsIncTrans.DataSource = null;
lbSrchResultsIncTrans.Items.Clear();
}
else
lbSrchResults.DataSource = null;
_SearchResults = null;
DisplayResults();
btnTranCvtAllToTxt.Enabled = false;
}
// A timer updated the step type tree but if it was loaded from xml the timer update overwrite what
// was loaded in from the xml file. Added a flag that gets set on load and set to false on new Search
private bool _fromLoad = false;
private void btnLoadSearchResults_Click(object sender, System.EventArgs e)
{
_fromLoad = true;
_LoadingList = true;
ofdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS";
if (ofdSearchResults.ShowDialog(this) == DialogResult.OK)
{
lbSrchResults.DataSource = null;
lbSrchResults.Items.Clear();
toolTip1.SetToolTip(lbSrchResults, null);
string unitPrefix = "";
if (Mydocversion != null)
unitPrefix = Mydocversion.DocVersionConfig.Unit_ProcedureNumber;
if (unitPrefix.EndsWith("#"))
unitPrefix = unitPrefix.Replace("#", "");
Cursor = Cursors.WaitCursor;
try // B2021-045: don't crash if xml file cannot be loaded.
{
SearchResults = ItemInfoList.GetByContentID(0);
// C2021-006: removed all file type options except xml
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(ofdSearchResults.FileName);
// B2020-107: Add missing attributes/nodes for loading of search results, include procsets & steptypes:
System.Xml.XmlNodeList nlp = xd.SelectNodes("search/procsets/set");
if (nlp != null)
{
DocVersionInfo tmpdvi = Mydocversion;
DocVersionInfo fromLoadFiledvi = null;
foreach (System.Xml.XmlNode nd in nlp)
{
int folderID = int.Parse(nd.Attributes.GetNamedItem("fid").InnerText);
FolderInfo fi = FolderInfo.Get(folderID);
_MyDocVersion = fi.FolderDocVersions[0];
if (fromLoadFiledvi == null) fromLoadFiledvi = _MyDocVersion;
advTreeProcSetsPreSelect();
}
foreach (System.Xml.XmlNode nd in nlp)
{
int folderID = int.Parse(nd.Attributes.GetNamedItem("fid").InnerText);
FolderInfo fi = FolderInfo.Get(folderID);
Node tnode = advTreeProcSets.FindNodeByDataKey(folderID);
if (tnode != null) tnode.Checked = true;
}
Mydocversion = tmpdvi == null ? fromLoadFiledvi : tmpdvi;
}
AdvTreeStepTypesFillIn();
System.Xml.XmlNodeList nl1 = xd.SelectNodes("search/StepType/type");
if (nl1 != null)
{
foreach (System.Xml.XmlNode nd in nl1)
{
string stptype = nd.Attributes.GetNamedItem("str").InnerText;
Node tnode = advTreeStepTypes.FindNodeByText(stptype);
if (tnode != null)
{
tnode.Checked = true;
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
lstCheckedStepTypesStr.Add(stptype);
StepData sd = (StepData)tnode.Tag;
lstCheckedStepTypes.Add((int)sd.Index);
}
}
string typstr = null;
foreach (string s in lstCheckedStepTypesStr) typstr = typstr == null ? s : typstr + ", " + s;
TypesSelected = "Filtered By: " + ((typstr != null) ? typstr : "All Step Types");
ReportTitle = "Step Element Report"; //"Proms - Search by Type: " + typstr;
TypesSelected = "Filtered By: " + typstr;
advTreeStepTypes.RefreshItems();
buildStepTypePannelTitle();
}
cmbResultsStyle.Text = xd.SelectSingleNode("search/results/@style").InnerText;
int sti = int.Parse(xd.SelectSingleNode("search/criteria/@index").InnerText);
switch (sti)
{
case 0: //text or steptypes
{
System.Xml.XmlNode xn = xd.SelectSingleNode("search/criteria/@text");
tabSearchTypes.SelectedTab = tabStepTypeSearch;
if (xn != null) // text search
{
cbxTextSearchText.Text = xn.InnerText;
cbxCaseSensitive.Checked = bool.Parse(xd.SelectSingleNode("search/criteria/@case").InnerText);
cbxIncROTextSrch.Checked = bool.Parse(xd.SelectSingleNode("search/criteria/@ro").InnerText);
cbxByWord.Checked = bool.Parse(xd.SelectSingleNode("search/criteria/@byword").InnerText);
}
else // B2020-107: Add in step type search
{
cbxSrchTypeUsage.Checked = true;
}
System.Xml.XmlNodeList nl = xd.SelectNodes("search/results/item");
foreach (System.Xml.XmlNode nd in nl)
{
int itemID = int.Parse(nd.Attributes.GetNamedItem("id").InnerText);
ItemInfo ii = ItemInfo.Get(itemID);
if (ii.SearchAnnotationText == null && ii.ItemAnnotations != null) ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
SearchResults.AddItemInfo(ii);
}
lbSrchResults.DataSource = SearchResults;
DisplayResults();
break;
}
case 1: //annotation
{
cbxAnnoTypes.Text = xd.SelectSingleNode("search/criteria/@type").InnerText;
cbxTextSearchAnnotation.Text = xd.SelectSingleNode("search/criteria/@text").InnerText;
cbxCaseSensitiveAnnoText.Checked = bool.Parse(xd.SelectSingleNode("search/criteria/@case").InnerText);
tabSearchTypes.SelectedTab = tabAnnotationSearch;
cmbResultsStyle.Text = xd.SelectSingleNode("search/results/@style").InnerText;
System.Xml.XmlNodeList nl = xd.SelectNodes("search/results/item");
foreach (System.Xml.XmlNode nd in nl)
{
int itemID = int.Parse(nd.Attributes.GetNamedItem("id").InnerText);
ItemInfo ii = ItemInfo.Get(itemID);
// B2020-107: The following was needed to set the Step Path result type for annotations
if (ii.SearchAnnotationText == null && ii.ItemAnnotations != null)
{
ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
ii.SearchAnnotationID = ii.ItemAnnotations[0].AnnotationID;
}
SearchResults.AddItemInfo(ii);
}
lbSrchResults.DataSource = SearchResults;
DisplayResults();
break;
}
case 2: //referenced object
case 3: // transitions
{
FlexibleMessageBox.Show(this, "Loading Referenced Objects and Transitions searches is under construction.", "Under Construction", MessageBoxButtons.OK);
break;
}
case 4: // Incoming transitions
{
tabSearchTypes.SelectedTab = tabIncTrans;
cmbResultsStyle.Text = xd.SelectSingleNode("search/results/@style").InnerText;
string tmpi = xd.SelectSingleNode("search/results/@toid").InnerText;
SearchIncTransII = ItemInfo.Get(Convert.ToInt32(tmpi));
System.Xml.XmlNodeList nl = xd.SelectNodes("search/results/item");
foreach (System.Xml.XmlNode nd in nl)
{
int itemID = int.Parse(nd.Attributes.GetNamedItem("id").InnerText);
ItemInfo ii = ItemInfo.Get(itemID);
if (ii.SearchAnnotationText == null && ii.ItemAnnotations != null) ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
SearchResults.AddItemInfo(ii);
}
lbSrchResultsIncTrans.DataSource = SearchResults;
DisplayResults();
break;
}
}
}
catch (Exception ex)
{
FlexibleMessageBox.Show("An error occurred while reading the xml file.\r\n\r\nThis can happen when the file selected for the Load is not saved\r\n" +
"from a PROMS Search or if some of the steps no longer exist.", "Search Load Failed", MessageBoxButtons.OK);
}
Cursor = Cursors.Default;
}
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm(); // C2020-033: does user have access to at least one item
_LoadingList = false;
}
private void btnSaveSearchResults_Click(object sender, System.EventArgs e)
{
ICollection<ItemInfo> myList = lbSrchResults.DataSource as ICollection<ItemInfo>;
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) myList = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>; // C2020-033: use Incoming transition list
if (tabSearchTypes.SelectedTabIndex == 2 || tabSearchTypes.SelectedTabIndex == 3) // ROs & Transitions are not coded yet
{
FlexibleMessageBox.Show(this, "Saving Referenced Objects and Transitions searches is under construction.", "Under Construction", MessageBoxButtons.OK);
return;
}
sfdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS";
if (sfdSearchResults.ShowDialog(this) == DialogResult.OK)
{
// C2021-006: removed all file type options except xml
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
System.Xml.XmlElement xe = xd.CreateElement("search");
xd.AppendChild(xe);
xe = xd.CreateElement("criteria");
xd.DocumentElement.AppendChild(xe);
System.Xml.XmlAttribute xa = xd.CreateAttribute("index");
int sti = tabSearchTypes.SelectedTabIndex;
xa.InnerText = sti.ToString();
xe.Attributes.SetNamedItem(xa);
// B2020-107: save procedures sets & step types
// do procsets selected
System.Xml.XmlElement xp = null;
System.Xml.XmlElement xst = null;
if (sti != 4) // C2020-033: no procsets or step types for Incoming transitions
{
if (lstCheckedDocVersions != null && lstCheckedDocVersions.Count > 0)
{
xp = xd.CreateElement("procsets");
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
{
System.Xml.XmlElement xee = xd.CreateElement("set");
xa = xd.CreateAttribute("fid");
xa.InnerText = dvi.MyFolder.FolderID.ToString();
xee.Attributes.SetNamedItem(xa);
xp.AppendChild(xee);
}
}
if (lstCheckedStepTypesStr != null && lstCheckedStepTypesStr.Count > 0)
{
xst = xd.CreateElement("StepType");
foreach (string str in lstCheckedStepTypesStr) // Limited by step types
{
System.Xml.XmlElement xee = xd.CreateElement("type");
xa = xd.CreateAttribute("str");
xa.InnerText = str;
xee.Attributes.SetNamedItem(xa);
xst.AppendChild(xee);
}
}
}
switch (sti)
{
case 0: //text
{
if (!cbxSrchTypeUsage.Checked) // text search
{
xa = xd.CreateAttribute("text");
xa.InnerText = cbxTextSearchText.Text;
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("case");
xa.InnerText = cbxCaseSensitive.Checked.ToString();
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("ro");
xa.InnerText = cbxIncROTextSrch.Checked.ToString();
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("byword");
xa.InnerText = cbxByWord.Checked.ToString();
xe.Attributes.SetNamedItem(xa);
xd.DocumentElement.AppendChild(xe);
}
if (xp != null) xd.DocumentElement.AppendChild(xp); // want criteria as first xml node
if (xst != null) xd.DocumentElement.AppendChild(xst); // do procsets & steptypes after
// do results
xe = xd.CreateElement("results");
xa = xd.CreateAttribute("style");
xa.InnerText = cmbResultsStyle.Text;
xe.Attributes.SetNamedItem(xa);
foreach (ItemInfo ii in myList)
{
System.Xml.XmlElement xee = xd.CreateElement("item");
xa = xd.CreateAttribute("id");
xa.InnerText = ii.ItemID.ToString();
xee.Attributes.SetNamedItem(xa);
xe.AppendChild(xee);
}
xd.DocumentElement.AppendChild(xe);
xd.Save(sfdSearchResults.FileName);
break;
}
case 1: //annotation
{
xa = xd.CreateAttribute("type");
xa.InnerText = cbxAnnoTypes.Text;
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("text");
xa.InnerText = cbxTextSearchAnnotation.Text;
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("case");
xa.InnerText = cbxCaseSensitiveAnnoText.Checked.ToString();
xe.Attributes.SetNamedItem(xa);
xd.DocumentElement.AppendChild(xe);
if (xp != null) xd.DocumentElement.AppendChild(xp); // want criteria as first xml node
if (xst != null) xd.DocumentElement.AppendChild(xst); // do procsets & steptypes after
xe = xd.CreateElement("results");
xa = xd.CreateAttribute("style");
xa.InnerText = cmbResultsStyle.Text;
xe.Attributes.SetNamedItem(xa);
foreach (ItemInfo ii in myList)
{
System.Xml.XmlElement xee = xd.CreateElement("item");
xa = xd.CreateAttribute("id");
xa.InnerText = ii.ItemID.ToString();
xee.Attributes.SetNamedItem(xa);
xe.AppendChild(xee);
}
xd.DocumentElement.AppendChild(xe);
xd.Save(sfdSearchResults.FileName);
break;
}
case 2: // ro
case 3: // transitions
{
FlexibleMessageBox.Show(this, "Saving Search Results for this search type is under construction.", "Under Construction", MessageBoxButtons.OK);
break;
}
case 4: // C2020-033: Incoming Transitions
{
// do results
xe = xd.CreateElement("results");
xa = xd.CreateAttribute("style");
xa.InnerText = cmbResultsStyle.Text;
xe.Attributes.SetNamedItem(xa);
xa = xd.CreateAttribute("toid");
xa.InnerText = SearchIncTransII.ItemID.ToString();
xe.Attributes.SetNamedItem(xa);
foreach (ItemInfo ii in myList)
{
System.Xml.XmlElement xee = xd.CreateElement("item");
xa = xd.CreateAttribute("id");
xa.InnerText = ii.ItemID.ToString();
xee.Attributes.SetNamedItem(xa);
xe.AppendChild(xee);
}
xd.DocumentElement.AppendChild(xe);
xd.Save(sfdSearchResults.FileName);
break;
}
}
}
}
private void btnCopySearchResults_Click(object sender, EventArgs e)
{
ICollection<ItemInfo> myList = lbSrchResults.DataSource as ICollection<ItemInfo>;
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) myList = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>;
StringBuilder sb = new StringBuilder();
sb.Append("\"Location\"\t\"Type\"\t\"Text\"\t\"High-Level\"\t\"Annotations\"");
List<int> ItemsProcessed = new List<int>();
foreach (ItemInfo myItem in myList)
{
if (!ItemsProcessed.Contains(myItem.ItemID))
{
ItemsProcessed.Add(myItem.ItemID);
sb.Append(string.Format("\r\n\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"", myItem.ShortPath, myItem.ToolTip,
myItem.DisplayText, !myItem.IsSection && !myItem.IsHigh ? (myItem.MyHLS == null ? "" : myItem.MyHLS.DisplayText) : ""));
if (myItem.ItemAnnotationCount > 0)
foreach (AnnotationInfo myAnnotation in myItem.ItemAnnotations)
sb.Append(string.Format("\t\"{0}\"", myAnnotation.SearchText));
}
}
Clipboard.Clear();
Clipboard.SetText(sb.ToString());
FlexibleMessageBox.Show("Results Copied to Clipboard", "Copy Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private string _ReportTitle;
public string ReportTitle
{
get { return _ReportTitle; }
set { _ReportTitle = value; }
}
private string _SearchString = null;
public string SearchString
{
get { return _SearchString; }
set { _SearchString = value; }
}
private string _TypesSelected;
public string TypesSelected
{
get { return _TypesSelected; }
set { _TypesSelected = value; }
}
private void btnPrnSrchRslts_Click(object sender, EventArgs e)
{
string sortedBy = "";
if (cbSorted.Checked)
sortedBy = string.Format("Sorted By: {0}", cmbResultsStyle.Text); //C2019-013 pass in sorted by information
ICollection<ItemInfo> srchres = lbSrchResults.DataSource as ICollection<ItemInfo>;
// C2020-033: If on the Incoming Transitions tab, use that list.
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) srchres = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>;
OnPrintRequest(new DisplaySearchEventArgs(ReportTitle, TypesSelected, SearchString, srchres,sortedBy));
}
private void panSearchButtons_Resize(object sender, EventArgs e)
{
cmbResultsStyle.Left = labelX1.Right + 3;
cmbResultsStyle.Width = btnClearSearchResults.Left - cmbResultsStyle.Left - 3;
}
// C2020-033: Convert All (that have permissions) Incoming Transitions to text
private void btnTranCvtAllToTxt_Click(object sender, EventArgs e)
{
List<int> itmsEditable = TranCvtCheckPermission(true); // Get list based on permissions
if (itmsEditable == null || itmsEditable.Count == 0) return;
TranCvtToTxt(itmsEditable);
fromTranCvtBtn = true;
UpdateSearchIncTransResults(); // B2021-009: Research after convert transitions to text
fromTranCvtBtn = false;
}
// C22020-033: Use IncTransCvtAllToTextPerm to see if user has at least edit permissions to 1 in list. This
// is used to see if Convert All button is enabled.
private bool IncTransCvtAllToTextPerm()
{
if (_SearchResults == null) return false;
int cnt = 0;
bool allowNonAdmin = IncTranCvtPerm();
foreach (ItemInfo ii in _SearchResults)
{
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) return true;
}
return false;
}
// C2020-033: Update the search panel for Incoming transitions. This gets called from the tree view & the ribbon
public void UpdateSearchIncTransResults()
{
//IncTransSelectedCount = 0;
tabSearchTypes.SelectedTab = tabSearchTypes.Tabs[4];
lbSrchResultsIncTrans.DataSource = null;
lbSrchResultsIncTrans.Items.Clear();
// Get item to do search for, either from tree or from editor
if (SearchIncTransII != null)
{
// B2021-010: Use IncomingTranGetMergedTranList to get a complete list of incoming transitions (transitions to procedure
// were only included if there were NO transitions to items within procedure)
SearchResults = IncomingTranGetMergedTranList();
ReportTitle = string.Format("Search For Incoming Transitions to {0}: ", SearchIncTransII.Path);
}
if (SearchResults != null && SearchResults.Count > 0)
{
AddMessageForEmptyAnnotations();
cmbResultsStyle.SelectedIndex = 1; //display step locations in results
DisplayResults();
}
else
{
btnPrnSrchRslts.Enabled = false;
btnClearSearchResults.Enabled = false;
btnCopySearchResults.Enabled = false;
btnSaveSearchResults.Enabled = false;
cmbResultsStyle.Enabled = false;
if (!fromTranCvtBtn) FlexibleMessageBox.Show("No Matches Found.", "Search"); // B2021-009: Research after convert transitions to text
}
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm();
btnTranCvtSelToTxt.Enabled = false;
btnSearch.Enabled = false; // C2021 - 002: disable search button - no functionality for Incoming Transitions
}
public bool IncTranCvtPerm()
{
FolderInfo topFolder = FolderInfo.Get(1);
FolderConfig fc = topFolder.MyConfig as FolderConfig;
return fc.General_IncTranCvtPerm;
}
// C2020-033: Before allowing conversion of Incoming Transitions to text, get list of results that the user has permission edit.
private List<int> TranCvtCheckPermission(bool all)
{
// check if a non-reader can convert transitions to text even if a reader - this is set by an administrator on the top
// folder properties dialog
bool allowNonAdmin = IncTranCvtPerm();
List<int> itmsEditable = new List<int>(); // return this list
int listCount = 0;
if (all) // Check all in list
{
listCount = _SearchResults.Count;
foreach (ItemInfo ii in _SearchResults)
{
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) itmsEditable.Add(ii.ContentID);
}
}
else // check only the items selected
{
listCount = lbSrchResultsIncTrans.CheckedItems.Count;
List<ListBoxItem> lbis = lbSrchResultsIncTrans.CheckedItems;
foreach (ListBoxItem lbi in lbis)
{
ItemBindingData tmpii = lbi.Tag as ItemBindingData;
ItemInfo ii = tmpii.DataItem as ItemInfo;
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) itmsEditable.Add(ii.ContentID);
}
}
// Prompt user if convert to text should continue. If some items cannot be edited, also state that
// not all can be converted to text. If count of itmsEditable & lbis are different some cannot be edited.
if (itmsEditable.Count == 0)
{
FlexibleMessageBox.Show("You do not have permission to edit any of the procedures, sections, and/or steps" + (all ? "." : " that are selected."),
"Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information);
return null;
}
else if (itmsEditable.Count != listCount)
{
DialogResult ans = FlexibleMessageBox.Show("You only have permission to edit some of the procedures, sections, and/or steps that are selected.procedures, sections, and/or steps" + (all ? "." : " that are selected.") +
"\r\n\r\n Should the conversion of the transitions to text continue?",
"Convert Transition to Text", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.No) return null;
}
else
{
DialogResult ans = FlexibleMessageBox.Show("Are you sure you want to convert the transitions to text?",
"Convert Transition to Text", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.No) return null;
}
return itmsEditable;
}
private bool fromTranCvtBtn = false;
// C2020-033: convert selected transitions to text
private void btnTranCvtSelToTxt_Click(object sender, EventArgs e)
{
// First see if all selected can be converted, i.e. user has permission to edit
List<ListBoxItem> lbis = lbSrchResultsIncTrans.CheckedItems;
List<int> itmsEditable = TranCvtCheckPermission(false);
if (itmsEditable == null || itmsEditable.Count == 0) return;
TranCvtToTxt(itmsEditable);
fromTranCvtBtn = true;
UpdateSearchIncTransResults(); // B2021-009: Research after convert transitions to text
fromTranCvtBtn = false;
}
// B2021-010: IncomingTranGetMergedTranList gets a complete list of incoming transitions (before fix transitions to procedure
// were only included if there were NO transitions to items within procedure, the GetExternalTransitionsToChildren query
// did not get transitions 'incoming to' the item itself)
private ItemInfoList IncomingTranGetMergedTranList()
{
ItemInfoList iil = null;
bool first = true;
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(SearchIncTransII.ItemID))
{
foreach (TransitionInfo ti in exTrans)
{
if (first)
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
iil = new ItemInfoList(tmp);
first = false;
}
else
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
iil.AddItem(tmp);
}
}
}
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(SearchIncTransII.ItemID))
{
foreach (TransitionInfo ti in exTrans)
{
if (first)
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
iil = new ItemInfoList(tmp);
first = false;
}
else
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
// B2021-014: if in list, don't add another
if (!iil.Contains(tmp))iil.AddItem(tmp);
}
}
}
return iil;
}
// C2020-033: For items in list, do the actual conversion of the Incoming Transition to text
private void TranCvtToTxt(List<int> itmsEditable)
{
ItemInfo trII = SearchIncTransII;
if (trII != null)
{
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(trII.ItemID))
{
foreach (TransitionInfo ti in exTrans)
{
// See if the 'item to' id is to be converted and if so do it. To figure this out,
// see if it is in the list itmsEditable.
if (itmsEditable.Contains(ti.FromID))
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
using (Content content = Content.Get(tmp.ContentID))
{
content.FixTransitionText(ti, true);
content.Save();
}
}
}
}
// B2021-010: Convert the text of transitions pointing (incoming) to the item itself
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(trII.ItemID))
{
foreach (TransitionInfo ti in exTrans)
{
// See if the 'item to' id is to be converted and if so do it. To figure this out,
// see if it is in the list itmsEditable.
if (itmsEditable.Contains(ti.FromID))
{
ContentInfo ci = ContentInfo.Get(ti.FromID);
ItemInfo tmp = ci.ContentItems[0];
using (Content content = Content.Get(tmp.ContentID))
{
content.FixTransitionText(ti, true);
content.Save();
}
}
}
}
}
}
}
#region Annoation Search Type Class
// this class is used to generate the list of annotations to search.
// this also allow us to add a dummy type which is used to search for all annotations
public class AnnotationTypeSearch
{
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
private string _ID;
public string ID
{
get { return _ID; }
set { _ID = value; }
}
public AnnotationTypeSearch(string name, string id)
{
_Name = name;
_ID = id;
}
}
#endregion
public class DisplaySearchEventArgs
{
private string _ReportTitle;
public string ReportTitle
{
get { return _ReportTitle; }
set { _ReportTitle = value; }
}
private string _SearchString = null;
public string SearchString
{
get { return _SearchString; }
set { _SearchString = value; }
}
private string _TypesSelected;
public string TypesSelected
{
get { return _TypesSelected; }
set { _TypesSelected = value; }
}
private string _SortedBy = null;
public string SortedBy // C2019-013 pass in sorted by information to print report
{
get { return _SortedBy; }
set { _SortedBy = value; }
}
private ICollection<ItemInfo> _MyItemInfoList;
public ICollection<ItemInfo> MyItemInfoList
{
get { return _MyItemInfoList; }
set { _MyItemInfoList = value; }
}
private TimeSpan _HowLong = TimeSpan.FromTicks(0);
public TimeSpan HowLong
{
get { return _HowLong; }
set { _HowLong = value; }
}
private string _PaperSize;
public string PaperSize // C2020-002 paper size is now set in the format files
{
get { return _PaperSize; }
set { _PaperSize = value; }
}
public DisplaySearchEventArgs(TimeSpan howLong)
{
HowLong = howLong;
}
public DisplaySearchEventArgs(string reportTitle, string typesSelected, string searchString, ICollection<ItemInfo> myItemInfoList, string sortedBy)
{
_ReportTitle = reportTitle;
_TypesSelected = typesSelected;
_MyItemInfoList = myItemInfoList;
_SearchString = searchString;
_SortedBy = sortedBy; // C2019-013 pass in sorted by information
foreach (ItemInfo tmpII in myItemInfoList)
if (tmpII != null && tmpII.ActiveFormat != null)
{
_PaperSize = tmpII.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
break;
}
}
}
public delegate void DisplaySearchEvent(object sender, DisplaySearchEventArgs args);
}