This commit is contained in:
@@ -58,8 +58,8 @@ namespace Volian.Controls.Library
|
||||
get { return _RangeColor; }
|
||||
set { _RangeColor = value; }
|
||||
}
|
||||
private DisplayRTB _MyRTB; // Current MyDisplayRTB, i.e. insert transition to it.
|
||||
public DisplayRTB MyRTB
|
||||
private StepRTB _MyRTB; // Current MyDisplayRTB, i.e. insert transition to it.
|
||||
public StepRTB MyRTB
|
||||
{
|
||||
get { return _MyRTB; }
|
||||
set
|
||||
@@ -148,11 +148,40 @@ namespace Volian.Controls.Library
|
||||
// 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)
|
||||
stpitm = selitm;
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -162,6 +191,68 @@ namespace Volian.Controls.Library
|
||||
|
||||
SetControlsEnabling();
|
||||
}
|
||||
private void tvInitHiliteRange(bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel)
|
||||
{
|
||||
_RangeNode1 = (VETreeNode) tvTran.SelectedNode;
|
||||
_RangeNode2 = null;
|
||||
// get first treenode at this level
|
||||
VETreeNode tn = (VETreeNode)tvTran.Nodes[0];
|
||||
|
||||
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++)
|
||||
{
|
||||
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
|
||||
|
||||
VETreeNode tnExpand = null;
|
||||
while (tnExpand == null && tn != null)
|
||||
{
|
||||
ItemInfo ii = (ItemInfo)tn.VEObject;
|
||||
if (ii.ItemID == path[uplevel].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.Expand();
|
||||
foreach (VETreeNode ctn in tnExpand.Nodes)
|
||||
{
|
||||
ItemInfo ii = (ItemInfo)ctn.VEObject;
|
||||
if (ii.ItemID == path[i].ItemID)
|
||||
{
|
||||
tmp = ctn;
|
||||
if (i == 0) _RangeNode2 = tmp;
|
||||
}
|
||||
}
|
||||
tnExpand = tmp;
|
||||
}
|
||||
}
|
||||
tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
|
||||
}
|
||||
private void vlnTreeComboSetsFillIn(ItemInfo prcitm)
|
||||
{
|
||||
// from this procedure, walk up the tree storing the FolderInfos. This is done
|
||||
@@ -285,6 +376,9 @@ namespace Volian.Controls.Library
|
||||
for (int i = 0; i < ttl.Count; i++)
|
||||
listBoxTranFmt.Items.Add(ttl[i].TransFormat);
|
||||
listBoxTranFmt.SelectedIndex = _TranFmtIndx;
|
||||
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
|
||||
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
|
||||
}
|
||||
private void tvTranFillIn(ItemInfo startitm)
|
||||
{
|
||||
@@ -385,14 +479,11 @@ namespace Volian.Controls.Library
|
||||
|
||||
// check for range - if no range, then range button/label & step tree selections should be
|
||||
// 'cleared/invisble'.
|
||||
_DoingRange = false;
|
||||
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast) _DoingRange = true;
|
||||
btnTranRangeClear.Visible = _DoingRange;
|
||||
lblxTranRangeTip.Visible = _DoingRange;
|
||||
lblxTranRangeTip.BackColor = _RangeColor;
|
||||
// if any previous nodes selected for range - clear them here
|
||||
if (!_DoingRange && _RangeNode1 != null) ClearRangeTransition();
|
||||
if (_DoingRange && _RangeNode1 == null) InitRangeTransition();
|
||||
// Always allow for step selection if there are items.
|
||||
if (tvTran.Nodes.Count>0)tvTran.Enabled = true;
|
||||
}
|
||||
@@ -524,6 +615,8 @@ namespace Volian.Controls.Library
|
||||
if (chldrn != null && chldrn.Count > 0) cbTranSectsFillIn((ItemInfo)chldrn[0], sectstartid);
|
||||
}
|
||||
_TranFmtIndx = listBoxTranFmt.SelectedIndex;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
|
||||
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
|
||||
SetControlsEnabling();
|
||||
}
|
||||
private void btnUp1_Click(object sender, EventArgs e)
|
||||
@@ -692,12 +785,6 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region VariousSupportMethods
|
||||
private void InitRangeTransition()
|
||||
{
|
||||
if (_InitializingTrans) MessageBox.Show("To do, initialize range node highlighting in tree");
|
||||
// find rnage nodes to be highlighted & send it to tvTranRangeHilites to actually do the highlighting...
|
||||
|
||||
}
|
||||
private void ClearRangeTransition()
|
||||
{
|
||||
if (_RangeNode1 == null && _RangeNode2 == null) return;
|
||||
@@ -737,26 +824,27 @@ namespace Volian.Controls.Library
|
||||
node2 = node1;
|
||||
node1 = t;
|
||||
}
|
||||
|
||||
// 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 tmp1 = node1;
|
||||
VETreeNode tmp2 = node2;
|
||||
VETreeNode top1 = node1;
|
||||
VETreeNode top2 = node2;
|
||||
// loop, walking up node2's tree checking against node1. If not found, go to node1
|
||||
// parent, etc.
|
||||
bool foundcommon = false;
|
||||
while (!foundcommon && tmp1 != null)
|
||||
while (!foundcommon && top1 != null)
|
||||
{
|
||||
while (!foundcommon & tmp2 != null)
|
||||
while (!foundcommon & top2 != null)
|
||||
{
|
||||
if (tmp1.Parent == tmp2.Parent) foundcommon = true;
|
||||
else tmp2 = (VETreeNode)tmp2.Parent;
|
||||
if (top1.Parent == top2.Parent) foundcommon = true;
|
||||
else top2 = (VETreeNode)top2.Parent;
|
||||
}
|
||||
if (!foundcommon)
|
||||
{
|
||||
tmp2 = node2;
|
||||
tmp1 = (VETreeNode)tmp1.Parent;
|
||||
top2 = node2;
|
||||
top1 = (VETreeNode)top1.Parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,28 +855,26 @@ namespace Volian.Controls.Library
|
||||
cur.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
cur = (VETreeNode)(cur.NextNode == null ? cur.Parent : cur.NextNode);
|
||||
// if these nodes were at the same level, then stop after the current node = range2
|
||||
if (cur == tmp1) cur = null; // stop at top
|
||||
if (cur == tmp2) tmp1 = cur = null;
|
||||
if (cur == top1) cur = null; // stop at top
|
||||
if (cur == top2) top1 = cur = null;
|
||||
}
|
||||
// set background for highest level between two nodes.
|
||||
cur = tmp1==null?null:(VETreeNode)tmp1.NextNode;
|
||||
cur = top1==null?null:(VETreeNode)top1.NextNode;
|
||||
while (cur != null)
|
||||
{
|
||||
cur.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
cur = (VETreeNode)cur.NextNode;
|
||||
if (cur == tmp2) cur = null;
|
||||
|
||||
cur = (cur == top2) ? null : (VETreeNode)cur.NextNode;
|
||||
}
|
||||
// finish subtree of second node in range.
|
||||
cur = tmp2==node2?null:node2;
|
||||
cur = top2==node2?null:node2;
|
||||
while (cur != null)
|
||||
{
|
||||
cur.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
cur = (VETreeNode)(cur.PrevNode == null ? cur.Parent : cur.PrevNode);
|
||||
if (cur == tmp2) cur = null; // stop at top
|
||||
if (cur == top2) cur = null; // stop at top
|
||||
}
|
||||
// hilite last selection..
|
||||
tmp2.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
top2.BackColor = on ? _RangeColor : tvTran.BackColor;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
Reference in New Issue
Block a user