This commit is contained in:
@@ -12,6 +12,7 @@ namespace Volian.Controls.Library
|
||||
public partial class DisplayRO : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private ROFST _CurROFST = null;
|
||||
private ROFST _MyROFST;
|
||||
public ROFST MyROFST
|
||||
{
|
||||
@@ -22,12 +23,21 @@ namespace Volian.Controls.Library
|
||||
LoadTree();
|
||||
}
|
||||
}
|
||||
private bool _Modify = false;
|
||||
public bool Modify
|
||||
private string _CurROLink;
|
||||
public string CurROLink
|
||||
{
|
||||
get { return _Modify; }
|
||||
set { _Modify = value; }
|
||||
get { return _CurROLink; }
|
||||
set
|
||||
{
|
||||
_CurROLink = value;
|
||||
if (_CurROLink != null)
|
||||
{
|
||||
UpdateROTree();
|
||||
_SavCurROLink = _CurROLink;
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _SavCurROLink;
|
||||
private ItemInfo _CurItem;
|
||||
public ItemInfo CurItem
|
||||
{
|
||||
@@ -35,7 +45,6 @@ namespace Volian.Controls.Library
|
||||
set { _CurItem = value; }
|
||||
}
|
||||
private DisplayRTB _MyRTB;
|
||||
|
||||
public DisplayRTB MyRTB
|
||||
{
|
||||
get { return _MyRTB; }
|
||||
@@ -47,15 +56,14 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public DisplayRO(ROFST rofst, ItemInfo curitm, bool modify, DisplayRTB rtb)
|
||||
{
|
||||
_MyROFST = rofst;
|
||||
_CurItem = curitm;
|
||||
_Modify = modify;
|
||||
_MyRTB = rtb;
|
||||
InitializeComponent();
|
||||
LoadTree();
|
||||
}
|
||||
//public DisplayRO(ROFST rofst, ItemInfo curitm, bool modify, DisplayRTB rtb)
|
||||
//{
|
||||
// _MyROFST = rofst;
|
||||
// _CurItem = curitm;
|
||||
// _MyRTB = rtb;
|
||||
// InitializeComponent();
|
||||
// LoadTree();
|
||||
//}
|
||||
#endregion
|
||||
#region Events
|
||||
private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
@@ -77,6 +85,7 @@ namespace Volian.Controls.Library
|
||||
private void LoadChildren(TreeNode tn)
|
||||
{
|
||||
object tag = tn.Tag;
|
||||
if (tn.FirstNode != null && tn.FirstNode.Text != "VLN_DUMMY_FOR_TREE") return; // already loaded.
|
||||
if (tn.FirstNode != null && tn.FirstNode.Text == "VLN_DUMMY_FOR_TREE") tn.FirstNode.Remove();
|
||||
ROFST.rochild[] chld = null;
|
||||
|
||||
@@ -125,6 +134,8 @@ namespace Volian.Controls.Library
|
||||
private void LoadTree()
|
||||
{
|
||||
if (_MyROFST == null) return;
|
||||
if (_MyROFST == _CurROFST) return;
|
||||
_CurROFST = _MyROFST;
|
||||
for (int i = 0; i < _MyROFST.myHdr.myDbs.Length; i++)
|
||||
{
|
||||
TreeNode tn = new TreeNode(_MyROFST.myHdr.myDbs[i].dbiTitle);
|
||||
@@ -141,7 +152,63 @@ namespace Volian.Controls.Library
|
||||
tn.Nodes.Add(tmp);
|
||||
}
|
||||
}
|
||||
private void btnInsertRO_Click(object sender, EventArgs e)
|
||||
private void UpdateROTree()
|
||||
{
|
||||
// walk down from root of tree, expanding values in the string
|
||||
// that represents the ro link.
|
||||
string tmpstr = _CurROLink;
|
||||
int sp = tmpstr.IndexOf(" "); // because parse of ro info is wrong!!
|
||||
int rousageid = System.Convert.ToInt32(tmpstr.Substring(0, sp));
|
||||
string roid = tmpstr.Substring(sp + 1, tmpstr.Length - sp - 1);
|
||||
string db = roid.Substring(0, 4);
|
||||
|
||||
ROFST.rochild rochld = MyROFST.GetRoChild(roid.Substring(0, 12).ToUpper());
|
||||
// use this to walk up tree until database - this is used to expand tree.
|
||||
List<int> path = new List<int>();
|
||||
int myid = rochld.ID;
|
||||
while (myid > 0)
|
||||
{
|
||||
path.Insert(0,myid);
|
||||
myid = rochld.ParentID;
|
||||
rochld = MyROFST.GetRoChildFromID(myid);
|
||||
if (rochld.ID == -1) myid = -1;
|
||||
}
|
||||
TreeNode tnExpand = null;
|
||||
int titm = System.Convert.ToInt32(db);
|
||||
// find database first
|
||||
foreach (TreeNode tn in tvROFST.Nodes)
|
||||
{
|
||||
ROFST.rodbi thisdb = (ROFST.rodbi)tn.Tag;
|
||||
if (thisdb.dbiID == titm)
|
||||
{
|
||||
LoadChildren(tn);
|
||||
tnExpand = tn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tnExpand == null) return; // something went wrong?
|
||||
// use the path id list to load/find the treeview's nodes.
|
||||
foreach (int citm in path)
|
||||
{
|
||||
if (citm != System.Convert.ToInt32(db))
|
||||
{
|
||||
LoadChildren(tnExpand);
|
||||
tnExpand.Expand();
|
||||
foreach (TreeNode tn in tnExpand.Nodes)
|
||||
{
|
||||
ROFST.rochild chld = (ROFST.rochild)tn.Tag;
|
||||
if (chld.ID == citm)
|
||||
{
|
||||
tnExpand = tn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tnExpand != null) tvROFST.SelectedNode = tnExpand;
|
||||
}
|
||||
private void btnSaveRO_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (tbROValue.Text == null || tbROValue.Text == "")
|
||||
{
|
||||
@@ -157,5 +224,11 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void btnCancelRO_Click(object sender, EventArgs e)
|
||||
{
|
||||
_CurROLink = _SavCurROLink;
|
||||
UpdateROTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user