This commit is contained in:
161
PROMS/Volian.Controls.Library/DisplayRO.cs
Normal file
161
PROMS/Volian.Controls.Library/DisplayRO.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
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;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class DisplayRO : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private ROFST _MyROFST;
|
||||
public ROFST MyROFST
|
||||
{
|
||||
get { return _MyROFST; }
|
||||
set
|
||||
{
|
||||
_MyROFST = value;
|
||||
LoadTree();
|
||||
}
|
||||
}
|
||||
private bool _Modify = false;
|
||||
public bool Modify
|
||||
{
|
||||
get { return _Modify; }
|
||||
set { _Modify = value; }
|
||||
}
|
||||
private ItemInfo _CurItem;
|
||||
public ItemInfo CurItem
|
||||
{
|
||||
get { return _CurItem; }
|
||||
set { _CurItem = value; }
|
||||
}
|
||||
private DisplayRTB _MyRTB;
|
||||
|
||||
public DisplayRTB MyRTB
|
||||
{
|
||||
get { return _MyRTB; }
|
||||
set { _MyRTB = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Constructors
|
||||
public DisplayRO()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public DisplayRO(ROFST rofst, ItemInfo curitm, bool modify, DisplayRTB rtb)
|
||||
{
|
||||
_MyROFST = rofst;
|
||||
_CurItem = curitm;
|
||||
_Modify = modify;
|
||||
_MyRTB = rtb;
|
||||
InitializeComponent();
|
||||
LoadTree();
|
||||
}
|
||||
#endregion
|
||||
#region Events
|
||||
private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node.Tag is ROFST.rochild)
|
||||
{
|
||||
ROFST.rochild chld = (ROFST.rochild)e.Node.Tag;
|
||||
if (chld.type == 1 && chld.value != null) tbROValue.Text = chld.value;
|
||||
else tbROValue.Text = null;
|
||||
}
|
||||
else
|
||||
tbROValue.Text = null;
|
||||
}
|
||||
|
||||
private void tvROFST_BeforeExpand(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
LoadChildren(e.Node);
|
||||
}
|
||||
private void LoadChildren(TreeNode tn)
|
||||
{
|
||||
object tag = tn.Tag;
|
||||
if (tn.FirstNode != null && tn.FirstNode.Text == "VLN_DUMMY_FOR_TREE") tn.FirstNode.Remove();
|
||||
ROFST.rochild[] chld = null;
|
||||
|
||||
if (tn.Tag is ROFST.rodbi)
|
||||
{
|
||||
ROFST.rodbi db = (ROFST.rodbi)tn.Tag;
|
||||
chld = db.children;
|
||||
}
|
||||
else if (tn.Tag is ROFST.rochild)
|
||||
{
|
||||
ROFST.rochild ch = (ROFST.rochild)tn.Tag;
|
||||
chld = ch.children;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("error - no type");
|
||||
return;
|
||||
}
|
||||
// if children, add dummy node
|
||||
if (chld != null && chld.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < chld.Length; i++)
|
||||
{
|
||||
TreeNode 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.
|
||||
Console.WriteLine("ro junk");
|
||||
else if (chld[i].type == 1 && chld[i].value == null)
|
||||
{
|
||||
tmp = new TreeNode(chld[i].title);
|
||||
tmp.Tag = chld[i];
|
||||
tn.Nodes.Add(tmp);
|
||||
TreeNode sub = new TreeNode("VLN_DUMMY_FOR_TREE");
|
||||
tmp.Nodes.Add(sub);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = new TreeNode(chld[i].title);
|
||||
tmp.Tag = chld[i];
|
||||
tn.Nodes.Add(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadTree()
|
||||
{
|
||||
if (_MyROFST == null) return;
|
||||
for (int i = 0; i < _MyROFST.myHdr.myDbs.Length; i++)
|
||||
{
|
||||
TreeNode tn = new TreeNode(_MyROFST.myHdr.myDbs[i].dbiTitle);
|
||||
tn.Tag = _MyROFST.myHdr.myDbs[i];
|
||||
tvROFST.Nodes.Add(tn);
|
||||
AddDummyGroup(_MyROFST.myHdr.myDbs[i], tn);
|
||||
}
|
||||
}
|
||||
private void AddDummyGroup(ROFST.rodbi rodbi, TreeNode tn)
|
||||
{
|
||||
if (rodbi.children != null && rodbi.children.Length > 0)
|
||||
{
|
||||
TreeNode tmp = new TreeNode("VLN_DUMMY_FOR_TREE");
|
||||
tn.Nodes.Add(tmp);
|
||||
}
|
||||
}
|
||||
private void btnInsertRO_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (tbROValue.Text == null || tbROValue.Text == "")
|
||||
{
|
||||
MessageBox.Show("Must select an RO Value from the tree.");
|
||||
return;
|
||||
}
|
||||
Object obj = tvROFST.SelectedNode.Tag;
|
||||
if (obj is ROFST.rochild)
|
||||
{
|
||||
ROFST.rochild roch = (ROFST.rochild) obj;
|
||||
string linktxt = string.Format("#Link:ReferencedObject: #xx {0}", roch.roid);
|
||||
_MyRTB.InsertRO(tbROValue.Text, linktxt);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user