This commit is contained in:
919
PROMS/Volian.Controls.Library/DisplaySearch.cs
Normal file
919
PROMS/Volian.Controls.Library/DisplaySearch.cs
Normal file
@@ -0,0 +1,919 @@
|
||||
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;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class DisplaySearch : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private List<DocVersionInfo> lstCheckedDocVersions = new List<DocVersionInfo>();
|
||||
private List<int> lstCheckedStepTypes = new List<int>();
|
||||
|
||||
private bool _AlwaysDisableSets; // true if there is only 1 item in tree/combo for sets
|
||||
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 saveGrpPanSearchResults;
|
||||
private ItemInfoList _SearchResults;
|
||||
public ItemInfoList SearchResults
|
||||
{
|
||||
get { return _SearchResults; }
|
||||
set
|
||||
{
|
||||
|
||||
_SearchResults = value;
|
||||
DisplayResults();
|
||||
}
|
||||
}
|
||||
private string _DisplayMember = "SearchPath";
|
||||
|
||||
//public string Status
|
||||
//{
|
||||
// get { return tsslStatus.Text; }
|
||||
// set { tsslStatus.Text = value; Application.DoEvents(); }
|
||||
//}
|
||||
|
||||
public DocVersionInfo Mydocversion
|
||||
{
|
||||
get { return _mydocversion; }
|
||||
set { _mydocversion = value; }
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
private ItemInfo _CurrentProcedure;
|
||||
#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;
|
||||
gpSrchText.Style.BackColor = Color.Yellow;
|
||||
|
||||
// start out with the procedure and type selection windows colasped
|
||||
xpSetToSearch.Expanded = false;
|
||||
xpStepTypes.Expanded = false;
|
||||
}
|
||||
|
||||
private void LoadSearchTextListBox()
|
||||
{
|
||||
cbxTextSearchText.Items.Clear();
|
||||
cbxTextSearchAnnotation.Items.Clear();
|
||||
//TODO: load saved search strings from user settings
|
||||
}
|
||||
|
||||
public void advTreeStepTypesFillIn()
|
||||
{
|
||||
DevComponents.AdvTree.Node topnode = new DevComponents.AdvTree.Node();
|
||||
advTreeStepTypes.Nodes.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;
|
||||
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
|
||||
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 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
|
||||
}
|
||||
}
|
||||
|
||||
public void advTreeProcSetsFillIn()
|
||||
{
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
_AlwaysDisableSets = true;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
par.Nodes.Add(newnode);
|
||||
newnode.Tag = fic;
|
||||
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
|
||||
|
||||
// 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_BeforeSelectNode);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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_BeforeSelectNode(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];
|
||||
tn.Nodes.Add(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
ProgressBar_Clear();
|
||||
}
|
||||
#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 cbSrchAnnoText_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
gpSrchAnnoText.Enabled = cbSrchAnnoText.Checked;
|
||||
}
|
||||
|
||||
private void cbxTextSearchAnnotation_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (!cbxTextSearchAnnotation.Text.Equals(string.Empty))
|
||||
{
|
||||
string tstr = cbxTextSearchAnnotation.Text;
|
||||
if (!cbxTextSearchAnnotation.Items.Contains(tstr))
|
||||
cbxTextSearchAnnotation.Items.Add(tstr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void gpSrchAnnoText_EnabledChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (gpSrchAnnoText.Enabled)
|
||||
gpSrchAnnoText.Style.BackColor = Color.Yellow;
|
||||
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
|
||||
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;
|
||||
cmbResultsStyle.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnPrnSrchRslts.Enabled = false;
|
||||
cmbResultsStyle.Enabled = false;
|
||||
}
|
||||
|
||||
lbSrchResults.SelectedIndex = -1;
|
||||
_LoadingList = false;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
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)
|
||||
{
|
||||
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
|
||||
if (_ItemInfo != null)
|
||||
_TabControl.OpenItem(_ItemInfo); // open the corresponding procedure text
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
DisplayResults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Search
|
||||
private string[] BuildSearchString()
|
||||
{
|
||||
// the search query needs '<DocVerID>,...<DocVerID>','<StepTypeID>,...,<StepTypeID>','<TextToSearch>'
|
||||
string[] strRtnStr = { "", "", "" };
|
||||
// append list of document versions to search
|
||||
if (lstCheckedDocVersions.Count > 0)
|
||||
{
|
||||
// get list of doc versions to search
|
||||
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
|
||||
{
|
||||
strRtnStr[0] += string.Format("{0},", dvi.ItemID.ToString());
|
||||
}
|
||||
strRtnStr[0] = strRtnStr[0].Remove(strRtnStr[0].LastIndexOf(','), 1);
|
||||
}
|
||||
|
||||
// append list of step types to search
|
||||
// TODO: need type number to search in attachments (word documents)
|
||||
if (lstCheckedStepTypes.Count > 0)
|
||||
{
|
||||
// get list of selected types
|
||||
foreach (int typ in lstCheckedStepTypes)
|
||||
{
|
||||
strRtnStr[1] += string.Format("{0},", (typ + 20000));
|
||||
}
|
||||
strRtnStr[1] = strRtnStr[1].Remove(strRtnStr[1].LastIndexOf(','), 1);
|
||||
}
|
||||
|
||||
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0])
|
||||
{ // Text Search
|
||||
strRtnStr[2] += string.Format("{0}", cbxTextSearchText.Text); // append text to search
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1])
|
||||
{ // Annotation Search
|
||||
strRtnStr[2] += ((AnnotationTypeSearch)cbxAnnoTypes.SelectedValue).ID;
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[2])
|
||||
{ // RO Search
|
||||
// TODO: the "1:" is hard coded for now. This is the ID to the corresponding
|
||||
// RO.FST from the Association record
|
||||
ROFSTLookup.rochild[] chld = null;
|
||||
if (cmboTreeROs.SelectedNode != null)
|
||||
{
|
||||
ROFSTLookup.rochild ch;
|
||||
if (cmboTreeROs.SelectedNode.Tag is ROFSTLookup.rodbi)
|
||||
{
|
||||
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)cmboTreeROs.SelectedNode.Tag;
|
||||
strRtnStr[2] += "1:" + 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
|
||||
strRtnStr[2] += "1:" + GetROsToSearch(chld);
|
||||
if (strRtnStr[2].EndsWith(","))
|
||||
strRtnStr[2] = strRtnStr[2].Substring(0, strRtnStr[2].Length - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strRtnStr;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
string[] strSearchText = null;
|
||||
lbSrchResults.DataSource = null;
|
||||
lbSrchResults.Items.Clear();
|
||||
toolTip1.SetToolTip(lbSrchResults, null);
|
||||
|
||||
strSearchText = BuildSearchString();
|
||||
Cursor savcursor = Cursor;
|
||||
Cursor = Cursors.WaitCursor;
|
||||
SearchResults = null;
|
||||
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0]) // Text Search
|
||||
{
|
||||
bool includeRTFformat = false;
|
||||
bool includeSpecialChars = false;
|
||||
if (cbxSrchTypeUsage.Checked) // find just the usage of the selected types
|
||||
{
|
||||
if (lstCheckedStepTypes.Count ==0) //(strSearchText[1].Equals(""))
|
||||
{
|
||||
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
|
||||
{
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(strSearchText[0], strSearchText[1], "", cbxCaseSensitive.Checked, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars);
|
||||
cmbResultsStyle.SelectedIndex = 1; //display step locations in results
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strSearchText[2].Equals(""))
|
||||
{
|
||||
MessageBox.Show("Please enter some search text, then click the Search button", "No Search Text");
|
||||
cbxTextSearchText.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(strSearchText[0], strSearchText[1], strSearchText[2], cbxCaseSensitive.Checked, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars);
|
||||
cmbResultsStyle.SelectedIndex = 3; // display step text in results
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) // Annotation Search
|
||||
{
|
||||
if (cbSrchAnnoText.Checked && cbxTextSearchAnnotation.Text.Equals(string.Empty))
|
||||
{
|
||||
MessageBox.Show("Please enter some search text, then click the Search button", "No Search Text");
|
||||
cbxTextSearchAnnotation.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResults = ItemInfoList.GetListFromAnnotationSearch(strSearchText[0], strSearchText[1], strSearchText[2], cbSrchAnnoText.Checked ? cbxTextSearchAnnotation.Text : "", cbxCaseSensitiveAnnoText.Checked);
|
||||
UpdateAnnotationSearchResults();
|
||||
cmbResultsStyle.SelectedIndex = 2; // display annotation text in results
|
||||
}
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[2]) // RO Search
|
||||
{
|
||||
SearchResults = ItemInfoList.GetListFromROSearch(strSearchText[0], strSearchText[1], strSearchText[2]);
|
||||
cmbResultsStyle.SelectedIndex = 1; // display procedure number, title, section, step in results
|
||||
}
|
||||
DisplayResults();
|
||||
Cursor = savcursor;
|
||||
if (SearchResults != null && SearchResults.Count == 0)
|
||||
{
|
||||
MessageBox.Show("No Matches Found.", "Search");
|
||||
}
|
||||
}
|
||||
|
||||
private void cbxTextSearchText_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (!cbxTextSearchText.Text.Equals(string.Empty))
|
||||
{
|
||||
string tstr = cbxTextSearchText.Text;
|
||||
if (!cbxTextSearchText.Items.Contains(tstr))
|
||||
cbxTextSearchText.Items.Add(tstr);
|
||||
}
|
||||
}
|
||||
|
||||
private void cbxSrchTypeUsage_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
gpSrchText.Enabled = !cbxSrchTypeUsage.Checked;
|
||||
if (!cbxSrchTypeUsage.Checked && lstCheckedStepTypes.Count == 0)
|
||||
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
|
||||
else
|
||||
{
|
||||
xpStepTypes.Expanded = true;
|
||||
if (lstCheckedStepTypes.Count == 0)
|
||||
xpStepTypes.TitleStyle.BackColor1.Color = Color.Crimson;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void gpSrchText_EnabledChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (gpSrchText.Enabled)
|
||||
gpSrchText.Style.BackColor = Color.Yellow;
|
||||
else
|
||||
gpSrchText.Style.BackColor = saveGpSrchTextColor;
|
||||
}
|
||||
|
||||
private void tabROSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (lstCheckedDocVersions.Count == 0)
|
||||
{
|
||||
xpSetToSearch.Expanded = true;
|
||||
xpSetToSearch.TitleStyle.BackColor1.Color = Color.Crimson;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ProcSetSelection
|
||||
|
||||
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 (Mydocversion == null)
|
||||
{
|
||||
Mydocversion = (DocVersionInfo)n.Tag;
|
||||
advTreeStepTypesFillIn();
|
||||
}
|
||||
if (MyROFSTLookup == null)
|
||||
MyROFSTLookup = Mydocversion.DocVersionAssociations[0].MyROFst.ROFSTLookup;
|
||||
}
|
||||
else
|
||||
{
|
||||
n.Style = null;
|
||||
lstCheckedDocVersions.Remove((DocVersionInfo)n.Tag);
|
||||
}
|
||||
// Enable the RO combo list only if at least one procedure set node
|
||||
// is selected
|
||||
cmboTreeROs.Enabled = (lstCheckedDocVersions.Count > 0);
|
||||
if (lstCheckedDocVersions.Count > 0)
|
||||
{
|
||||
xpSetToSearch.TitleText = string.Format("{0} Procedure Sets Selected", lstCheckedDocVersions.Count);
|
||||
xpSetToSearch.TitleStyle.BackColor1.Color = Color.PapayaWhip;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpSetToSearch.TitleText = "Select Procedure Sets to Search";
|
||||
xpSetToSearch.TitleStyle.BackColor1.Color = saveXpSetToSearchColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void xpSetToSearch_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
|
||||
{
|
||||
if (lstCheckedDocVersions.Count == 0)
|
||||
if (xpSetToSearch.Expanded)
|
||||
xpSetToSearch.TitleText = "Select Procedure Sets to Search";
|
||||
else
|
||||
{
|
||||
xpSetToSearch.TitleText = "Click Here to Select Procedure Sets";
|
||||
xpSetToSearch.TitleStyle.BackColor1.Color = saveXpSetToSearchColor;
|
||||
}
|
||||
}
|
||||
#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);
|
||||
}
|
||||
if (lstCheckedStepTypes.Count > 0)
|
||||
{
|
||||
xpStepTypes.TitleText = string.Format("{0} Step Styles Selected",lstCheckedStepTypes.Count);
|
||||
xpStepTypes.TitleStyle.BackColor1.Color = Color.PapayaWhip;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpStepTypes.TitleText = "Select Types To Search";
|
||||
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void xpStepTypes_ExpandedChanged(object sender, ExpandedChangeEventArgs e)
|
||||
{
|
||||
if (lstCheckedStepTypes.Count == 0)
|
||||
if (xpStepTypes.Expanded)
|
||||
xpStepTypes.TitleText = "Select Types To Search";
|
||||
else
|
||||
{
|
||||
xpStepTypes.TitleText = "Click Here To Search By Types";
|
||||
xpStepTypes.TitleStyle.BackColor1.Color = saveXpStepTypeTitleColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
Reference in New Issue
Block a user