This commit is contained in:
parent
c26e539b15
commit
d19352acb6
@ -55,7 +55,7 @@ namespace Volian.Controls.Library
|
||||
private VETreeNode _RangeNode2;
|
||||
// Use _RangeColor to show highlighting for steps selected in range. This is set from
|
||||
// calling methods from application settings. If not default to aquamarine.
|
||||
private Color _RangeColor = Color.LightGreen;
|
||||
private Color _RangeColor = Color.LightGray;
|
||||
public Color RangeColor
|
||||
{
|
||||
get { return _RangeColor; }
|
||||
@ -161,115 +161,118 @@ namespace Volian.Controls.Library
|
||||
if (_CurrentProcedure.Sections != null)
|
||||
{
|
||||
cbTranSectsFillIn(secitm, secitm == null ? -1 : secitm.ItemID);
|
||||
|
||||
// Fill step items, passing in the active step to the selected item, or the first
|
||||
// step if the selection was not at the step level.
|
||||
ItemInfo stpitm = null;
|
||||
ItemInfo rngitm = null;
|
||||
bool rangeSameLevel = true;
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
if (selitm.MyContent.Type >= 20000)
|
||||
{
|
||||
// if this is a range, find the 'outermost' range step, i.e. the highest level
|
||||
// in the tree.
|
||||
|
||||
if (_DoingRange)
|
||||
{
|
||||
ItemInfo itm1 = selitm;
|
||||
ItemInfo itm2 = _CurTrans.MyItemRangeID;
|
||||
while (!itm1.IsHigh)
|
||||
{
|
||||
i1++;
|
||||
itm1 = itm1.MyParent;
|
||||
}
|
||||
while (!itm2.IsHigh)
|
||||
{
|
||||
i2++;
|
||||
itm2 = itm2.MyParent;
|
||||
}
|
||||
|
||||
if (i1 != i2) rangeSameLevel = false;
|
||||
stpitm = (i1 <= i2) ? selitm : _CurTrans.MyItemRangeID;
|
||||
rngitm = (stpitm == selitm) ? _CurTrans.MyItemRangeID : selitm;
|
||||
tvInitHiliteRange(); //rangeSameLevel, stpitm, rngitm, (i1 < i2) ? i2 : i1);
|
||||
}
|
||||
else
|
||||
stpitm = selitm;
|
||||
}
|
||||
else if (secitm != null && secitm.Steps != null && secitm.Steps.Count > 0)
|
||||
stpitm = selitm.Steps[0];
|
||||
tvTranFillIn(stpitm);
|
||||
if (_DoingRange) tvInitHiliteRange(rangeSameLevel, stpitm, rngitm, (i1 < i2) ? i2 : i1);
|
||||
if (!_DoingRange) tvTranFillIn(stpitm); // range code fills in tree.
|
||||
//if (_DoingRange) tvInitHiliteRange(rangeSameLevel, stpitm, rngitm, (i1 < i2) ? i2 : i1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cbTranSects.Items.Clear();
|
||||
tvTran.Nodes.Clear();
|
||||
}
|
||||
|
||||
SetControlsEnabling();
|
||||
}
|
||||
private void tvInitHiliteRange(bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel)
|
||||
private void tvInitHiliteRange() //bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel)
|
||||
{
|
||||
_RangeNode1 = _CurTrans != null ? (VETreeNode)tvTran.SelectedNode : null;
|
||||
_RangeNode2 = null;
|
||||
// get first treenode at this level
|
||||
VETreeNode tn = (VETreeNode)tvTran.Nodes[0];
|
||||
ItemInfo toItm = _CurTrans.MyItemToID;
|
||||
ItemInfo rngItm = null;
|
||||
// figure out whether at same level, have same parent and have same HLS:
|
||||
ItemInfo itm1 = _CurTrans.MyItemToID;
|
||||
ItemInfo itm2 = _CurTrans.MyItemRangeID;
|
||||
bool samHLS = itm1.MyHLS.ItemID == itm2.MyHLS.ItemID;
|
||||
int lev1 = 0;
|
||||
int lev2 = 0;
|
||||
while (!itm1.IsHigh)
|
||||
{
|
||||
lev1++;
|
||||
itm1 = itm1.MyParent;
|
||||
}
|
||||
while (!itm2.IsHigh)
|
||||
{
|
||||
lev2++;
|
||||
itm2 = itm2.MyParent;
|
||||
}
|
||||
bool samLevel = lev1 == lev2;
|
||||
// For each range item, go to common level's parent.
|
||||
int cnt = lev1+1;
|
||||
ItemInfo sameParent1 = _CurTrans.MyItemToID;
|
||||
ItemInfo sameParent2 = _CurTrans.MyItemRangeID;
|
||||
while (cnt != 0)
|
||||
{
|
||||
if (sameParent1.IsHigh) break;
|
||||
sameParent1 = sameParent1.MyParent;
|
||||
}
|
||||
cnt = lev2+1;
|
||||
while (cnt != 0)
|
||||
{
|
||||
if (sameParent2.IsHigh) break;
|
||||
sameParent2 = sameParent2.MyParent;
|
||||
}
|
||||
tvTranFillIn(sameParent1); // if HLS, fill in from there, or it will fill in from common parent
|
||||
|
||||
// now add nodes for the subtrees so that highlighting can be done. Do 'to' item
|
||||
// first. If 'range' item is at same level, won't need to do anymore processing.
|
||||
ItemInfo toItem = sameParent1.Ordinal<=sameParent2.Ordinal?_CurTrans.MyItemToID:_CurTrans.MyItemRangeID;
|
||||
ItemInfo rngItem = sameParent1.Ordinal<=sameParent2.Ordinal?_CurTrans.MyItemRangeID:_CurTrans.MyItemToID;
|
||||
|
||||
if (rangeSameLevel)
|
||||
{
|
||||
// look at all children looking for the 'rngitm'.
|
||||
while (_RangeNode2 == null)
|
||||
{
|
||||
ItemInfo ii = (ItemInfo)tn.VEObject;
|
||||
if (ii.ItemID == rngitm.ItemID) _RangeNode2 = tn;
|
||||
tn = (VETreeNode)tn.NextNode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Node that is outermost in tree between the two range items is 'stpitm', so need to expand tree from
|
||||
// 'rngitm's parents down to rngitm. Make a list with the path from the range item to the selected item.
|
||||
List<ItemInfo> path = new List<ItemInfo>();
|
||||
ItemInfo parRng = rngitm;
|
||||
for (int i = 0; i < uplevel+1; i++)
|
||||
ItemInfo parRng = toItem;
|
||||
for (int i = 0; i < lev1+1; i++)
|
||||
{
|
||||
path.Insert(i, parRng);
|
||||
parRng = (ItemInfo)parRng.ActiveParent;
|
||||
}
|
||||
|
||||
// find each node to expand in the tree. look at all children looking for the items in the path list
|
||||
|
||||
// Find sameParent1 in tree, expand down to toItem:
|
||||
tvFillInRangeNodes(path, (VETreeNode)tvTran.Nodes[0], lev1, true);
|
||||
path.Clear();
|
||||
parRng = rngItem;
|
||||
for (int i = 0; i < lev2 + 1; i++)
|
||||
{
|
||||
path.Insert(i, parRng);
|
||||
parRng = (ItemInfo)parRng.ActiveParent;
|
||||
}
|
||||
tvFillInRangeNodes(path, (VETreeNode)tvTran.Nodes[0], lev2, false);
|
||||
tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
|
||||
tvTran.SelectedNode = _RangeNode1;
|
||||
}
|
||||
private void tvFillInRangeNodes(List<ItemInfo> path, VETreeNode tn, int level, bool to)
|
||||
{
|
||||
VETreeNode tnExpand = null;
|
||||
while (tnExpand == null && tn != null)
|
||||
{
|
||||
ItemInfo ii = (ItemInfo)tn.VEObject;
|
||||
if (ii.ItemID == path[uplevel].ItemID) tnExpand = tn;
|
||||
if (ii.ItemID == path[level].ItemID) tnExpand = tn;
|
||||
tn = (VETreeNode)tn.NextNode;
|
||||
}
|
||||
if (tnExpand == null)
|
||||
{
|
||||
MessageBox.Show("Error in highlighting step range.");
|
||||
return;
|
||||
}
|
||||
VETreeNode tmp = null;
|
||||
// Expand levels of subtree until second node in range.
|
||||
for (int i = uplevel-1; i >= 0; i--)
|
||||
tnExpand.LoadChildren(false);
|
||||
if (level > 0)
|
||||
{
|
||||
tnExpand.Expand();
|
||||
foreach (VETreeNode ctn in tnExpand.Nodes)
|
||||
tvFillInRangeNodes(path, (VETreeNode)tnExpand.Nodes[0], level - 1, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo ii = (ItemInfo)ctn.VEObject;
|
||||
if (ii.ItemID == path[i].ItemID)
|
||||
{
|
||||
tmp = ctn;
|
||||
if (i == 0) _RangeNode2 = tmp;
|
||||
if (to)
|
||||
_RangeNode1 = tnExpand;
|
||||
else
|
||||
_RangeNode2 = tnExpand;
|
||||
}
|
||||
}
|
||||
tnExpand = tmp;
|
||||
}
|
||||
}
|
||||
tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
|
||||
}
|
||||
private void vlnTreeComboSetsFillIn(ItemInfo prcitm)
|
||||
{
|
||||
// from this procedure, walk up the tree storing the FolderInfos. This is done
|
||||
@ -413,11 +416,12 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_CurTrans == null)
|
||||
{
|
||||
if (!startitm.IsHigh)
|
||||
{
|
||||
startitm = startitm.MyParent;
|
||||
selitm = startitm;
|
||||
}
|
||||
//if (!startitm.IsHigh)
|
||||
//{
|
||||
// startitm = startitm.MyParent;
|
||||
// selitm = startitm;
|
||||
//}
|
||||
selitm = startitm.MyHLS;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -431,10 +435,13 @@ namespace Volian.Controls.Library
|
||||
tvTran.Nodes.Add(tvn);
|
||||
nost = tvn;
|
||||
}
|
||||
startitm = startitm.FirstSibling;
|
||||
if (startitm.IsInRNO)
|
||||
startitm = selitm.FirstSibling; // if in RNO tree, start out with HLS
|
||||
else
|
||||
startitm = selitm!=null? selitm.FirstSibling:startitm.FirstSibling;
|
||||
while (startitm != null)
|
||||
{
|
||||
VETreeNode tvn = new VETreeNode(startitm);
|
||||
VETreeNode tvn = new VETreeNode(startitm, false);
|
||||
tvn.Tag = startitm;
|
||||
int active = this.tvTran.Nodes.Add(tvn);
|
||||
if (nost == null && startitm.ItemID == selitm.ItemID) tvTran.SelectedNode = tvTran.Nodes[active];
|
||||
@ -468,6 +475,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
secitm = (secitm.NextItemCount > 0 ? secitm.NextItems[0] : null);
|
||||
}
|
||||
|
||||
}
|
||||
private void cbTranProcsFillIn(ItemInfo prcitm)
|
||||
{
|
||||
@ -703,7 +711,7 @@ namespace Volian.Controls.Library
|
||||
// true fixes empty expand, but allows for transitions 'way down' in RNO tree. HVJ & PAL wanted to
|
||||
// allow this (12/2/09)
|
||||
tn.ChildrenLoaded = false;
|
||||
tn.LoadChildren(true);
|
||||
tn.LoadChildren(false);
|
||||
}
|
||||
private void cbTranSects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
@ -964,9 +972,9 @@ namespace Volian.Controls.Library
|
||||
node1.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
return;
|
||||
}
|
||||
|
||||
// If node2 is below node1 in the tree switch them... get to high level step &
|
||||
// then just walk down tree.
|
||||
// then just walk down tree - this happens when user is making selection, not when
|
||||
// selected transitions is being highlighted.
|
||||
ItemInfo itm1 = (ItemInfo)node1.VEObject;
|
||||
ItemInfo itm2 = (ItemInfo)node2.VEObject;
|
||||
while (!itm1.IsHigh) itm1 = itm1.MyParent;
|
||||
@ -991,7 +999,6 @@ namespace Volian.Controls.Library
|
||||
|
||||
// Turn Hilighting on/off (depending on bool argument) between the two nodes
|
||||
// they may be at different tree levels.
|
||||
|
||||
// find common parent level first and save the 'top parent' node for each selection.
|
||||
VETreeNode top1 = node1;
|
||||
VETreeNode top2 = node2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user