1596 lines
52 KiB
C#
1596 lines
52 KiB
C#
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;
|
|
|
|
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);
|
|
}
|
|
#endregion
|
|
#region Properties
|
|
private string _strSrchText = "";
|
|
private List<DocVersionInfo> lstCheckedDocVersions = new List<DocVersionInfo>();
|
|
private List<int> lstCheckedStepTypes = new List<int>();
|
|
|
|
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
|
|
{
|
|
_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
|
|
}
|
|
|
|
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
|
|
{
|
|
_MyDocVersion = value;
|
|
if (_MyDocVersion != null)
|
|
{
|
|
if (_MyDocVersion.DocVersionAssociationCount > 0)
|
|
{
|
|
MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.ROFSTLookup;
|
|
_MyRODbID = _MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private ROFSTLookup _MyROFSTLookup;
|
|
public ROFSTLookup MyROFSTLookup
|
|
{
|
|
get { return _MyROFSTLookup; }
|
|
set
|
|
{
|
|
//if (!Visible) return; // don't reset anything if the form is invisible.
|
|
_MyROFSTLookup = value; // define the tree nodes based on this rofst
|
|
LoadROComboTree();
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
|
|
newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
|
newnode.CheckBoxThreeState = false;
|
|
newnode.CheckBoxVisible = chxbxvisable;
|
|
return newnode;
|
|
}
|
|
|
|
public void advTreeStepTypesFillIn()
|
|
{
|
|
DevComponents.AdvTree.Node topnode = new DevComponents.AdvTree.Node();
|
|
advTreeStepTypes.Nodes.Clear();
|
|
lstCheckedStepTypes.Clear();
|
|
topnode.Text = "Types";
|
|
advTreeStepTypes.Nodes.Add(topnode);
|
|
|
|
FormatData 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 Accessory Sections (MS Word sections)
|
|
//newnode = new DevComponents.AdvTree.Node();
|
|
//newnode.Text = "Accessory Sections";
|
|
//newnode.Selectable = true;
|
|
//newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
|
|
//newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
|
//newnode.CheckBoxThreeState = false;
|
|
//newnode.CheckBoxVisible = true;
|
|
newnode = NewAdvTreeNode("Accessory Sections", true, true);
|
|
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;
|
|
pnode.Nodes.Add(newnode);
|
|
pnode.Nodes.Sort();
|
|
advTreeStepTypes.Nodes.Add(pnode);
|
|
}
|
|
else
|
|
{
|
|
newnode = NewAdvTreeNode(sdr.Name, 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
|
|
while (!parentName.Equals("Base") && !parentName.Equals("Substep") && !parentName.Equals("High") &&
|
|
!parentName.Equals("Caution") && !parentName.Equals("Note") && !parentName.Equals("Table") &&
|
|
!parentName.Equals("Figure"))
|
|
{
|
|
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();
|
|
}
|
|
|
|
public void advTreeProcSetsFillIn(bool blSeachTabClicked)
|
|
{
|
|
DevComponents.AdvTree.Node topnode = null;
|
|
int cntnd = 0;
|
|
VETreeNode vtn = VETreeNode.GetFolder(1);
|
|
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;
|
|
advTreeProcSets.Nodes.Add(topnode);
|
|
//advTreeProcSets.AfterNodeInsert += new TreeNodeCollectionEventHandler(advTreeProcSets_AfterNodeInsert);
|
|
|
|
|
|
foreach (FolderInfo fic in fi.ChildFolders)
|
|
{
|
|
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
|
|
newnode.Text = fic.ToString();
|
|
newnode.Tag = fic;
|
|
|
|
//int tmp;
|
|
//if (topnode == null)
|
|
//{
|
|
// newnode.Text = "Available Procedure Sets";
|
|
// tmp = advTreeProcSets.Nodes.Add(newnode);
|
|
// topnode = newnode;
|
|
//}
|
|
//else
|
|
//{
|
|
// newnode.Selectable = true;
|
|
// newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
|
|
// newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
|
// newnode.CheckBoxThreeState = false;
|
|
// newnode.CheckBoxVisible = true;
|
|
// tmp = topnode.Nodes.Add(newnode);
|
|
//}
|
|
cntnd++;
|
|
if (fic.ChildFolderCount > 0) // allow for '+' for tree expansion
|
|
{
|
|
DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
|
|
tnt.Text = "VLN_DUMMY";
|
|
newnode.Nodes.Add(tnt);
|
|
topnode.Nodes.Add(newnode);
|
|
}
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
|
|
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);
|
|
//}
|
|
|
|
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.ChildFolders)
|
|
{
|
|
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
|
|
newnode.Text = fic.ToString();
|
|
newnode.Tag = fic;
|
|
par.Nodes.Add(newnode);
|
|
if (fic.HasChildren) // allow for '+' for tree expansion
|
|
{
|
|
DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
|
|
tnt.Text = "VLN_DUMMY";
|
|
newnode.Nodes.Add(tnt);
|
|
}
|
|
}
|
|
}
|
|
else if (fi.FolderDocVersionCount > 0)
|
|
{
|
|
foreach (DocVersionInfo dv in fi.FolderDocVersions)
|
|
{
|
|
//if ((VersionTypeEnum)dv.VersionType == VersionTypeEnum.WorkingDraft)
|
|
//{
|
|
DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
|
|
newnode.Text = dv.ToString();
|
|
newnode.Tag = dv;
|
|
newnode.Selectable = true;
|
|
newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
|
|
newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
|
|
newnode.CheckBoxThreeState = false;
|
|
newnode.CheckBoxVisible = true;
|
|
par.Nodes.Add(newnode);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
private void LoadROComboTree()
|
|
{
|
|
if (_MyROFSTLookup == null) return;
|
|
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);
|
|
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];
|
|
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)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Search Results
|
|
private void DisplayResults()
|
|
{
|
|
_LoadingList = true;
|
|
lbSrchResults.DisplayMember = _DisplayMember;
|
|
if (_SearchResults != null)
|
|
{
|
|
if (cbSorted.Checked)
|
|
{
|
|
Csla.SortedBindingList<ItemInfo> sortedResults = new Csla.SortedBindingList<ItemInfo>(_SearchResults);
|
|
sortedResults.ApplySort(_DisplayMember, ListSortDirection.Ascending);
|
|
lbSrchResults.DataSource = sortedResults;
|
|
}
|
|
else
|
|
//PopulatelbSrcResults(_SearchResults);
|
|
lbSrchResults.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 (lbSrchResults.Items.Count > 0)
|
|
{
|
|
btnPrnSrchRslts.Enabled = true;
|
|
btnClearSearchResults.Enabled = true;
|
|
btnCopySearchResults.Enabled = true;
|
|
cmbResultsStyle.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnPrnSrchRslts.Enabled = false;
|
|
btnClearSearchResults.Enabled = false;
|
|
btnCopySearchResults.Enabled = false;
|
|
cmbResultsStyle.Enabled = false;
|
|
}
|
|
|
|
lbSrchResults.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()
|
|
//{
|
|
// //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")
|
|
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;
|
|
}
|
|
}
|
|
private void lbSrchResults_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (_LoadingList) return;
|
|
// If the list is being refreshed, then set the selection index to -1 (no selection)
|
|
if (_SearchResults.RefreshingList && lbSrchResults.SelectedIndex != -1)
|
|
lbSrchResults.SelectedIndex = -1;
|
|
else
|
|
{
|
|
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
|
|
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
|
|
{
|
|
_AnnotationDetails.CurrentAnnotation = AnnotationInfo.Get(_ItemInfo.SearchAnnotationID);
|
|
if (_AnnotationDetails.CurrentAnnotation != null)
|
|
_TabControl.OpenItem(_AnnotationDetails.CurrentAnnotation.MyItem); // open the corresponding procedure text
|
|
_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.MyDSOTabPanel != null)
|
|
dti.MyDSOTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
|
|
if (dti.MyStepTabPanel != null)
|
|
dti.MyStepTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
|
|
_OpenDocFromSearch = 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("D4"));
|
|
}
|
|
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);
|
|
//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", "");
|
|
FormatData fmtdata = _MyDocVersion.ActiveFormat.PlantFormat.FormatData;
|
|
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);
|
|
rtnVal = rtnVal.Replace(((char)sym.Unicode).ToString(), rplace);
|
|
}
|
|
}
|
|
return rtnVal;
|
|
}
|
|
|
|
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);
|
|
}
|
|
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 void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime start = DateTime.Now;
|
|
Cursor savcursor = Cursor;
|
|
try
|
|
{
|
|
lbSrchResults.DataSource = null;
|
|
lbSrchResults.Items.Clear();
|
|
toolTip1.SetToolTip(lbSrchResults, null);
|
|
Cursor = Cursors.WaitCursor;
|
|
SearchResults = null;
|
|
bool includeRTFformat = false;
|
|
bool includeSpecialChars = true;
|
|
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0]) // Text Search
|
|
{
|
|
if (cbxSrchTypeUsage.Checked) // find just the usage of the selected types
|
|
{
|
|
if (lstCheckedStepTypes.Count == 0)
|
|
{
|
|
MessageBox.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
|
|
{
|
|
ReportTitle = "PROMS2010 - Search by Type";
|
|
SearchString = null;
|
|
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars);
|
|
cmbResultsStyle.SelectedIndex = 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("PROMS2010 - {0} Search for '{1}'", cbxBooleanTxtSrch.Checked ? "Boolean" : "Text", TextSearchString);
|
|
SearchString = TextSearchString;
|
|
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars);
|
|
cmbResultsStyle.SelectedIndex = 3; // display step text in results
|
|
//}
|
|
}
|
|
}
|
|
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) // Annotation Search
|
|
{
|
|
SearchString = null;
|
|
ReportTitle = string.Format("PROMS2010 - Annotation Search for '{0}'", cbxTextSearchAnnotation.Text);
|
|
//string srchStr = ConvertSpecialChars(cbxTextSearchAnnotation.Text);//cbxTextSearchAnnotation.Text;
|
|
|
|
//SearchResults = ItemInfoList.GetListFromAnnotationSearch(dviSearchList, typeSearchList, textSearchString, srchStr, cbxCaseSensitiveAnnoText.Checked);
|
|
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked);
|
|
//UpdateAnnotationSearchResults();
|
|
cmbResultsStyle.SelectedIndex = 2; // display annotation text in results
|
|
}
|
|
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[2]) // RO Search
|
|
{
|
|
SearchString = null;
|
|
ReportTitle = "PROMS2010 - Referenced Object Search";
|
|
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
|
|
{
|
|
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars);
|
|
cmbResultsStyle.SelectedIndex = 3; // display step text in results
|
|
}
|
|
else
|
|
{
|
|
SearchResults = ItemInfoList.GetListFromROSearch(DVISearchList, TypeSearchList, ROSearchList);
|
|
cmbResultsStyle.SelectedIndex = 3; // display step text in results
|
|
}
|
|
}
|
|
DisplayResults();
|
|
if (SearchResults != null && SearchResults.Count == 0)
|
|
{
|
|
MessageBox.Show("No Matches Found.", "Search");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
while (ex.InnerException != null)
|
|
ex = ex.InnerException;
|
|
MessageBox.Show(ex.Message, "Search Error: " + ex.GetType().Name);
|
|
}
|
|
finally
|
|
{
|
|
Cursor = savcursor;
|
|
}
|
|
Console.WriteLine("{0} Milliseconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalMilliseconds);
|
|
//if (VlnSettings.DebugMode)
|
|
// MessageBox.Show(string.Format("{0} Milliseconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalMilliseconds));
|
|
}
|
|
|
|
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 void advTreeProcSets_AfterCheck(object sender, DevComponents.AdvTree.AdvTreeCellEventArgs e)
|
|
{
|
|
DevComponents.AdvTree.Node n = advTreeProcSets.SelectedNode;
|
|
if (n.Checked)
|
|
{
|
|
n.Style = DevComponents.AdvTree.NodeStyles.Apple;
|
|
lstCheckedDocVersions.Add((DocVersionInfo)n.Tag);
|
|
if (lstCheckedDocVersions.Count == 1)//Mydocversion == null)
|
|
{
|
|
Mydocversion = (DocVersionInfo)n.Tag;
|
|
advTreeStepTypesFillIn();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
n.Style = null;
|
|
lstCheckedDocVersions.Remove((DocVersionInfo)n.Tag);
|
|
if (lstCheckedDocVersions.Count == 1)
|
|
{
|
|
if (Mydocversion != lstCheckedDocVersions[0])
|
|
{
|
|
Mydocversion = lstCheckedDocVersions[0];
|
|
advTreeStepTypesFillIn();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (lstCheckedDocVersions.Count == 0)
|
|
Mydocversion = null;
|
|
// do this if either none, or more than one procedure set selected
|
|
advTreeStepTypes.Nodes.Clear();
|
|
lstCheckedStepTypes.Clear();
|
|
Node newnode = new DevComponents.AdvTree.Node();
|
|
newnode.Text = "....select a procedure set for types to appear...";
|
|
advTreeStepTypes.Nodes.Add(newnode);
|
|
buildStepTypePannelTitle();
|
|
}
|
|
}
|
|
//// Enable the RO combo list only if at least one procedure set node
|
|
//// is selected
|
|
//cmboTreeROs.Enabled = (lstCheckedDocVersions.Count > 0);
|
|
//gpFindROs.Enabled = cmboTreeROs.Enabled;
|
|
|
|
SetupContextMenu();
|
|
|
|
buildSetToSearchPanelTitle();
|
|
}
|
|
|
|
|
|
private void xpSetToSearch_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
|
|
{
|
|
buildSetToSearchPanelTitle();
|
|
}
|
|
|
|
private void buildSetToSearchPanelTitle()
|
|
{
|
|
if (lstCheckedDocVersions.Count == 0)
|
|
{
|
|
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)
|
|
{
|
|
Mydocversion = (DocVersionInfo)n.Tag;
|
|
advTreeStepTypesFillIn();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region StepTypeSelection
|
|
private void advTreeStepTypes_AfterCheck(object sender, DevComponents.AdvTree.AdvTreeCellEventArgs e)
|
|
{
|
|
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
|
|
DevComponents.AdvTree.Node n = advTreeStepTypes.SelectedNode;
|
|
StepData sd = (StepData)n.Tag;
|
|
if (n.Checked)
|
|
{
|
|
n.Style = DevComponents.AdvTree.NodeStyles.Apple;
|
|
if (sd == null)
|
|
lstCheckedStepTypes.Add(0); //use zero to identify attachment search
|
|
else
|
|
lstCheckedStepTypes.Add((int)sd.Index);
|
|
}
|
|
else
|
|
{
|
|
n.Style = null;
|
|
if (sd == null)
|
|
lstCheckedStepTypes.Remove(0);
|
|
else
|
|
lstCheckedStepTypes.Remove((int)sd.Index);
|
|
}
|
|
buildStepTypePannelTitle();
|
|
|
|
}
|
|
|
|
private void xpStepTypes_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
|
|
{
|
|
buildStepTypePannelTitle();
|
|
}
|
|
|
|
private void buildStepTypePannelTitle()
|
|
{
|
|
if (lstCheckedStepTypes.Count == 0)
|
|
{
|
|
if (xpStepTypes.Expanded)
|
|
{
|
|
xpStepTypes.TitleText = "Select Types To Search";
|
|
advTreeStepTypes.Focus();
|
|
advTreeStepTypes.Nodes[0].SelectedCell = advTreeStepTypes.Nodes[0].Cells[0];
|
|
}
|
|
else
|
|
xpStepTypes.TitleText = "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.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";
|
|
}
|
|
|
|
private void SetupContextMenu()
|
|
{
|
|
galSymbols.SubItems.Clear();
|
|
if (_MyDocVersion != null)
|
|
{
|
|
FormatData fmtdata = _MyDocVersion.ActiveFormat.PlantFormat.FormatData;
|
|
SymbolList sl = fmtdata.SymbolList;
|
|
if (sl == null || sl.Count <= 0)
|
|
{
|
|
MessageBox.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 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))
|
|
{
|
|
StepRTB stpRTB = new StepRTB();
|
|
stpRTB.SelectedRtf = myDO.GetData(DataFormats.Rtf).ToString();
|
|
if (cbxTextSearchAnnotation.Focused)
|
|
cbxTextSearchAnnotation.SelectedText = stpRTB.Text;
|
|
else if (cbxTextSearchText.Focused)
|
|
cbxTextSearchText.SelectedText = stpRTB.Text;// .SelectedText;//myDO.GetData(DataFormats.Text,true).ToString();
|
|
}
|
|
else 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 (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)
|
|
{
|
|
lbSrchResults.DataSource = null;
|
|
_SearchResults = null;
|
|
DisplayResults();
|
|
}
|
|
private void btnCopySearchResults_Click(object sender, EventArgs e)
|
|
{
|
|
ICollection<ItemInfo> myList = lbSrchResults.DataSource as ICollection<ItemInfo>;
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("\"Location\"\t\"Type\"\t\"Text\"\t\"High-Level\"\t\"Annotations\"");
|
|
foreach (ItemInfo myItem in myList)
|
|
{
|
|
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.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());
|
|
MessageBox.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 void btnPrnSrchRslts_Click(object sender, EventArgs e)
|
|
{
|
|
OnPrintRequest(new DisplaySearchEventArgs(ReportTitle, SearchString, lbSrchResults.DataSource as ICollection<ItemInfo>));
|
|
}
|
|
}
|
|
#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 ICollection<ItemInfo> _MyItemInfoList;
|
|
public ICollection<ItemInfo> MyItemInfoList
|
|
{
|
|
get { return _MyItemInfoList; }
|
|
set { _MyItemInfoList = value; }
|
|
}
|
|
public DisplaySearchEventArgs(string reportTitle, string searchString, ICollection<ItemInfo> myItemInfoList)
|
|
{
|
|
_ReportTitle = reportTitle;
|
|
_MyItemInfoList = myItemInfoList;
|
|
_SearchString = searchString;
|
|
}
|
|
}
|
|
public delegate void DisplaySearchEvent(object sender, DisplaySearchEventArgs args);
|
|
}
|