This commit is contained in:
2009-01-27 15:48:51 +00:00
parent d548cf9b29
commit 9edcad0c66
4 changed files with 2255 additions and 2551 deletions

View File

@@ -15,9 +15,9 @@ namespace Volian.Controls.Library
public partial class DisplayRO : UserControl
{
#region Properties
private ROFST _CurROFST = null;
private ROFST _MyROFST;
public ROFST MyROFST
private ROFstInfo _CurROFST = null;
private ROFstInfo _MyROFST;
public ROFstInfo MyROFST
{
get { return _MyROFST; }
set
@@ -130,7 +130,7 @@ namespace Volian.Controls.Library
}
#endregion
#region Events
ROFST.rochild selectedChld;
ROFSTLookup.rochild selectedChld;
private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e)
{
tbROValue.Text = null;
@@ -139,9 +139,9 @@ namespace Volian.Controls.Library
btnSaveRO.Enabled = false;
btnPreviewRO.Enabled = false;
if (e.Node.Tag is ROFST.rochild)
if (e.Node.Tag is ROFSTLookup.rochild)
{
ROFST.rochild chld = (ROFST.rochild)e.Node.Tag;
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)e.Node.Tag;
selectedChld = chld;
if (chld.value != null)
{
@@ -209,16 +209,16 @@ namespace Volian.Controls.Library
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;
ROFSTLookup.rochild[] chld = null;
if (tn.Tag is ROFST.rodbi)
if (tn.Tag is ROFSTLookup.rodbi)
{
ROFST.rodbi db = (ROFST.rodbi)tn.Tag;
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
chld = db.children;
}
else if (tn.Tag is ROFST.rochild)
else if (tn.Tag is ROFSTLookup.rochild)
{
ROFST.rochild ch = (ROFST.rochild)tn.Tag;
ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
chld = ch.children;
}
else
@@ -275,15 +275,15 @@ namespace Volian.Controls.Library
if (_MyROFST == _CurROFST) return;
tvROFST.Nodes.Clear();
_CurROFST = _MyROFST;
for (int i = 0; i < _MyROFST.myHdr.myDbs.Length; i++)
for (int i = 0; i < _MyROFST.ROFSTLookup.myHdr.myDbs.Length; i++)
{
TreeNode tn = new TreeNode(_MyROFST.myHdr.myDbs[i].dbiTitle);
tn.Tag = _MyROFST.myHdr.myDbs[i];
TreeNode tn = new TreeNode(_MyROFST.ROFSTLookup.myHdr.myDbs[i].dbiTitle);
tn.Tag = _MyROFST.ROFSTLookup.myHdr.myDbs[i];
tvROFST.Nodes.Add(tn);
AddDummyGroup(_MyROFST.myHdr.myDbs[i], tn);
AddDummyGroup(_MyROFST.ROFSTLookup.myHdr.myDbs[i], tn);
}
}
private void AddDummyGroup(ROFST.rodbi rodbi, TreeNode tn)
private void AddDummyGroup(ROFSTLookup.rodbi rodbi, TreeNode tn)
{
if (rodbi.children != null && rodbi.children.Length > 0)
{
@@ -304,7 +304,7 @@ namespace Volian.Controls.Library
if (roid.Length == 16)
multValSel = true;
ROFST.rochild rochld = MyROFST.GetRoChild(roid.Substring(0, 12).ToUpper());
ROFSTLookup.rochild rochld = MyROFST.ROFSTLookup.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;
@@ -312,7 +312,7 @@ namespace Volian.Controls.Library
{
path.Insert(0,myid);
myid = rochld.ParentID;
rochld = MyROFST.GetRoChildFromID(myid);
rochld = MyROFST.ROFSTLookup.GetRoChildFromID(myid);
if (rochld.ID == -1) myid = -1;
}
TreeNode tnExpand = null;
@@ -320,7 +320,7 @@ namespace Volian.Controls.Library
// find database first
foreach (TreeNode tn in tvROFST.Nodes)
{
ROFST.rodbi thisdb = (ROFST.rodbi)tn.Tag;
ROFSTLookup.rodbi thisdb = (ROFSTLookup.rodbi)tn.Tag;
if (thisdb.dbiID == titm)
{
LoadChildren(tn);
@@ -338,7 +338,7 @@ namespace Volian.Controls.Library
tnExpand.Expand();
foreach (TreeNode tn in tnExpand.Nodes)
{
ROFST.rochild chld = (ROFST.rochild)tn.Tag;
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)tn.Tag;
if (chld.ID == citm)
{
tnExpand = tn;
@@ -359,7 +359,7 @@ namespace Volian.Controls.Library
tnExpand.Expand();
foreach (TreeNode tn in tnExpand.Nodes)
{
ROFST.rochild chld = (ROFST.rochild)tn.Tag;
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)tn.Tag;
if (chld.roid == roid)
{
tnExpand = tn;
@@ -378,20 +378,31 @@ namespace Volian.Controls.Library
return;
}
Object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFST.rochild)
if (obj is ROFSTLookup.rochild)
{
ROFST.rochild roch = (ROFST.rochild) obj;
ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj;
if (_MyRTB != null) // if null, it's Word attachment
{
_MyRTB.inRoAdd = true;
if (CheckROSelection(roch))
{
//string linktxt = string.Format("#Link:ReferencedObject: #xx {0}", roch.roid);
string ROID = roch.roid;
RoUsage ro = RoUsage.MakeRoUsage(MyRTB.MyItemInfo.MyContent.Get(), ROID, null);
string linktxt = string.Format(@"#Link:ReferencedObject:{0} {1}", ro.ROUsageID, ROID);
// Resolve symbols and scientific notation in the RO return value
_MyRTB.InsertRO(ConvertSymbolsAndStuff(tbROValue.Text), linktxt);
using (RODb rodb = RODb.Get(_MyROFST.MyRODb.RODbID))
{
// saving of selstart & end is a work around - the Makerousage updates contentinfo object
// which caused the selection in _MyRTB to be changed. This inserted the ro at an incorrect
// location in the string.
int selstart = _MyRTB.SelectionStart;
int sellen = _MyRTB.SelectionLength;
RoUsage ro = RoUsage.MakeRoUsage(MyRTB.MyItemInfo.MyContent.Get(), ROID, null, rodb);
string linktxt = string.Format(@"#Link:ReferencedObject:{0} {1} {2}", ro.ROUsageID, ROID, rodb.RODbID);
// Resolve symbols and scientific notation in the RO return value
_MyRTB.SelectionStart = selstart;
_MyRTB.SelectionLength = sellen;
_MyRTB.InsertRO(ConvertSymbolsAndStuff(tbROValue.Text), linktxt);
}
}
_MyRTB.inRoAdd = false;
}
else // we're in an Word attachment
{
@@ -407,7 +418,7 @@ namespace Volian.Controls.Library
}
}
private bool CheckROSelection(ROFST.rochild selectedRO)
private bool CheckROSelection(ROFSTLookup.rochild selectedRO)
{
bool goodToGo = true;
bool replacingRO = (_SavCurROLink != null);
@@ -466,23 +477,21 @@ namespace Volian.Controls.Library
private void btnPreviewRO_Click(object sender, EventArgs e)
{
if (selectedChld.type == 8) // intergrated graphic
if (selectedChld.type == 8) // integrated graphic
{
string ropth = _CurROFST.GetFstPath();
ropth = ropth.Substring(0, ropth.LastIndexOf('\\') + 1);
string fname = selectedChld.value.Substring(0, selectedChld.value.IndexOf('\n'));
int thedot = fname.LastIndexOf('.');
if (thedot == -1 || (thedot != (fname.Length - 4)))
fname += string.Format(".{0}", MyROFST.GetDefaultGraphicExtension());
string imgfile = ropth + fname;
if (File.Exists(imgfile))
fname += string.Format(".{0}", MyROFST.MyRODb.RODbConfig.GetDefaultGraphicExtension());
ROImageInfo tmp = ROImageInfo.GetByROFstID_FileName(MyROFST.ROFstID, fname);
if (tmp !=null)
{
PreviewROImage pvROImg = new PreviewROImage(imgfile, selectedChld.title);
PreviewROImage pvROImg = new PreviewROImage(tmp.Content, selectedChld.title);
pvROImg.ShowDialog();
}
else
MessageBox.Show(string.Format("{0}", imgfile), "Cannot Find Image File");
MessageBox.Show("Cannot Find Image Data");
}
else if (selectedChld.type == 2) // table
{
@@ -796,25 +805,6 @@ namespace Volian.Controls.Library
}
#endregion // utils
//private void AddToROUsage(ROFST.rochild roch)
//{
// if (instance < dt.Rows.Count)
// {
// //DataRow dr = dt.Rows[instance];
// string ROID = roch.roid;
// RoUsage ro = RoUsage.MakeRoUsage(content, ROID, null, DateTime.Now, "Migration");
// string results = string.Format(@"{0}{1}\v #Link:ReferencedObject:{2} {3}\v0",
// '\x15', rofst.GetRoValue(ROID.Substring(0, 12).ToUpper()), ro.ROUsageID, ROID);
// rotxt.Append(results);
// instance++;
// }
// else
// {
// log.Error("Error setting RO data in text field");
// log.ErrorFormat("proc number = {0}, oldstepsequence = {1}, instance = {2}", ProcNumber, seqcvt, instance);
// }
//}
#endregion
}
}