This commit is contained in:
2008-10-03 11:09:04 +00:00
parent a775337ba0
commit 4ea65e4bf6
10 changed files with 361 additions and 220 deletions

View File

@@ -22,6 +22,8 @@ public struct FormatData
{
public string Name;
public string PurchaseOptions;
public string PSI;
public string TPL;
//public XtraFlgs XtraFlags;
public VE_Font FontData;
public Symbol[] Symbols;
@@ -1393,8 +1395,10 @@ namespace fmtxml
public FormatData BaseFormat;
public bool HasBase;
public FormatData MyFormat;
public FmtFileToXml(FmtFileToXml gendata, string nm)
public string MyPath;
public FmtFileToXml(FmtFileToXml gendata, string nm, string path)
{
MyPath = path;
if (gendata == null)
HasBase = false;
else
@@ -1404,7 +1408,7 @@ namespace fmtxml
}
BuildDictionaryText();
fmtName = nm;
//if (fmtName.ToUpper() != "OHLP" && fmtName.ToUpper() != "BASE") return;
//if (fmtName.ToUpper() != "FNPDEV" && fmtName.ToUpper() != "BASE") return;
try
{
LoadFormatFile(nm + ".fmt", ref SubXtraFlags);
@@ -1953,7 +1957,7 @@ namespace fmtxml
{
return (i * 12); // row_in_points = input * 72/6, row = input * 12
}
public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags)
public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags, string fname)
{
int[] tmpshort3 = new int[3];
ArrayList stringoffsets = new ArrayList();
@@ -1986,7 +1990,15 @@ namespace fmtxml
xtraflag[i] = brFmt.ReadInt16();
AddFlags(ref XtraFlags, i, xtraflag[i]);
}
// if this format has an associated PSI or TPL file, just read in the string & save
// it.
string otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".tpl";
if (File.Exists(otherfile))
fmtdata.TPL = File.ReadAllText(otherfile);
otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".ini";
if (File.Exists(otherfile))
fmtdata.PSI = File.ReadAllText(otherfile);
fmtdata.PurchaseOptions = ((E_PurchaseOptions)brFmt.ReadInt16()).ToString();
fmtdata.ProcData.ProcForeColor = "Black";
fmtdata.ProcData.ProcBackColor = "White";
@@ -3725,12 +3737,12 @@ namespace fmtxml
string sResults = "fmt_xml\\" + lfmtname + "f.xml";
xsl.Transform(destfile, sResults); // Perform Transform
xsl.Load(Application.StartupPath + "\\removeempty.XSL");
string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml";
xsl.Transform(sResults, sResults2);
File.Delete(sResults);
xsl.Transform(sResults2, sResults);
File.Delete(sResults2);
xsl.Load(Application.StartupPath + "\\removeempty.XSL");
string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml";
xsl.Transform(sResults, sResults2);
File.Delete(sResults);
xsl.Transform(sResults2, sResults);
File.Delete(sResults2);
}
catch (Exception e)
@@ -3794,9 +3806,9 @@ namespace fmtxml
// read in data & put into correct place of structures.
// for test string fnm = "E:\\proms.net\\exe\\fmtxml\\" + fname;
string fnm = "E:\\ve-proms\\format\\" + fname;
string fnm = MyPath + @"\" + fname;
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags);
bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags, fname);
if (!HasBase) InitSymbols(ref fmtdata);
else fmtdata.Symbols = null;
if (success)
@@ -3813,17 +3825,17 @@ namespace fmtxml
success = WriteOutXml(fmtdata);
// For each sub-format, load the entire file & compare to parent contents
DirectoryInfo di = new DirectoryInfo("E:\\ve-proms\\format");
DirectoryInfo di = new DirectoryInfo(MyPath);
string substr = fname.Substring(0, fname.IndexOf('.')) + ".x*";
FileInfo[] fis = di.GetFiles(substr);
foreach (FileInfo fi in fis)
{
//this.listBox1.Items.Add(fi.Name);
fmtName = fi.Name;
fnm = "E:\\ve-proms\\format\\" + fi.Name;
fnm = MyPath + @"\" + fi.Name;
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
FormatData subdata = new FormatData();
success = ReadInFmtFile(ref subdata, ref SubXtraFlags);
success = ReadInFmtFile(ref subdata, ref SubXtraFlags, fi.Name);
if (success)
{
DoStepInheritance(ref subdata.StepData);
@@ -4061,7 +4073,8 @@ namespace fmtxml
// Background/Deviation Documents - check for E_PurchaseOptions.(ENHANCEDBACKGROUNDS or ENHANCEDDEVIATIONS)
// # - Related Caution or Note number
// ~ - Linked Step Number
if ((po.IndexOf("ENHANCEDBACKGROUNDS")>-1) || (po.IndexOf("ENHANCEDDEVIATIONS")>-1))
if ((po.ToUpper().IndexOf("ENHANCEDBACKGROUNDS") > -1) || (po.ToUpper().IndexOf("ENHANCEDDEVIATIONS") > -1))
{
wkstr = wkstr.Replace("#", "{LNK C/N Num}");
wkstr = wkstr.Replace("~", "{LNK Step Num}");
@@ -4125,6 +4138,8 @@ namespace fmtxml
if (mainFmt.FontData.FontStyle == subFmt.FontData.FontStyle) subFmt.FontData.FontStyle = null;
}
if (mainFmt.PurchaseOptions == subFmt.PurchaseOptions) subFmt.PurchaseOptions = null;
if (mainFmt.PSI == subFmt.PSI) subFmt.PSI = null;
if (mainFmt.TPL == subFmt.TPL) subFmt.TPL = null;
if (mainFmt.EditData.EMode == subFmt.EditData.EMode) subFmt.EditData.EMode = null;
if (mainFmt.EditData.PromptForCautionType != null && mainFmt.EditData.PromptForCautionType == subFmt.EditData.PromptForCautionType) subFmt.EditData.PromptForCautionType = "null";
if (mainFmt.SectData.StepSectionData.TopRow == subFmt.SectData.StepSectionData.TopRow) subFmt.SectData.StepSectionData.TopRow = 0;