added more robust logic to handle outside transitions supporting logic to add an additional annotation when multiple possibilities for an outside transition is possible
		
			
				
	
	
		
			128 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			128 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
// ========================================================================
 | 
						|
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.          
 | 
						|
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 | 
						|
// ------------------------------------------------------------------------
 | 
						|
// $Workfile: $     $Revision: $                                           
 | 
						|
// $Author: $   $Date: $                                                   
 | 
						|
//                                                                         
 | 
						|
// $History: $                                                             
 | 
						|
// ========================================================================
 | 
						|
 | 
						|
using System;
 | 
						|
using System.IO;
 | 
						|
using System.Collections;
 | 
						|
using System.Text;
 | 
						|
using System.Windows.Forms;
 | 
						|
using System.Xml;
 | 
						|
using System.Xml.Serialization;
 | 
						|
using VEPROMS.CSLA.Library;
 | 
						|
 | 
						|
namespace Utils
 | 
						|
{
 | 
						|
	/// <summary>
 | 
						|
	/// Summary description for CurSet.
 | 
						|
	/// </summary>
 | 
						|
	public class CurSet
 | 
						|
	{
 | 
						|
        private int NUMCBTEXTYPE = 5;   // number of changebar text types.
 | 
						|
		public string PathName;
 | 
						|
        private string DefaultPlantFmt;
 | 
						|
 | 
						|
		public CurSet(string pname)
 | 
						|
		{
 | 
						|
			PathName = pname;
 | 
						|
            DefaultPlantFmt = null;
 | 
						|
		}
 | 
						|
 | 
						|
		private string ReadTheString(BinaryReader bw, int maxlen)
 | 
						|
		{
 | 
						|
			StringBuilder retStr = new StringBuilder(maxlen+1);
 | 
						|
			// read a series of characters until a null is found.
 | 
						|
			char ac;
 | 
						|
			bool done = false;
 | 
						|
			while(done==false)
 | 
						|
			{
 | 
						|
				ac = bw.ReadChar();
 | 
						|
				if (ac=='\0') 
 | 
						|
					done=true;
 | 
						|
				else
 | 
						|
					retStr.Append(ac);
 | 
						|
			}
 | 
						|
			return retStr.ToString();
 | 
						|
		}
 | 
						|
 | 
						|
		public FolderConfig Convert(FolderConfig cfg)
 | 
						|
		{
 | 
						|
			BinaryReader br;
 | 
						|
			ArrayList DefaultUserCBMsg = new ArrayList(2);
 | 
						|
			FileStream fs;
 | 
						|
			FileInfo fi = new FileInfo(PathName);
 | 
						|
			try
 | 
						|
			{
 | 
						|
				fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
 | 
						|
				br = new BinaryReader(fs,System.Text.ASCIIEncoding.ASCII);
 | 
						|
			}
 | 
						|
			catch (Exception e)
 | 
						|
			{
 | 
						|
				DataLoader.frmLoader._MyLog.ErrorFormat("Error migrating {0} Curset.dat, error = {1}", PathName, e.Message);
 | 
						|
				return cfg;
 | 
						|
			}
 | 
						|
 | 
						|
            try
 | 
						|
			{
 | 
						|
                sbyte tmpsbyte;
 | 
						|
                string tmpstring;
 | 
						|
				tmpsbyte=br.ReadSByte();                    // DefaultDestination not used
 | 
						|
				
 | 
						|
                // the next byte has three settings embedded in it, the type of change
 | 
						|
                // bar (Print_ChangeBar), the change bar location and its text.
 | 
						|
                tmpsbyte= br.ReadSByte();
 | 
						|
                cfg.Print_ChangeBar = (PrintChangeBar)((int)tmpsbyte > 2 ? 3 : (int)tmpsbyte);
 | 
						|
				if (tmpsbyte > 2)
 | 
						|
				{
 | 
						|
					cfg.Print_ChangeBarLoc = (PrintChangeBarLoc)((tmpsbyte - 3) / NUMCBTEXTYPE);
 | 
						|
					int ts = (tmpsbyte - 3) % NUMCBTEXTYPE;
 | 
						|
					cfg.Print_ChangeBarText = (PrintChangeBarText)((tmpsbyte - 3) % NUMCBTEXTYPE);
 | 
						|
				}
 | 
						|
				else
 | 
						|
				{
 | 
						|
					cfg.Print_ChangeBarLoc = PrintChangeBarLoc.WithText;
 | 
						|
					cfg.Print_ChangeBarText = PrintChangeBarText.DateChgID;
 | 
						|
				}
 | 
						|
                cfg.Print_NumCopies=br.ReadSByte();
 | 
						|
				cfg.Print_Pagination=(PrintPagination) br.ReadSByte();
 | 
						|
				tmpstring = ReadTheString(br,4);            // DefaultPrinter not used
 | 
						|
				cfg.Format_Plant = ReadTheString(br,10);
 | 
						|
                DefaultPlantFmt = cfg.Format_Plant;
 | 
						|
                tmpstring = ReadTheString(br, 128);         // DefaultDestFName not used
 | 
						|
                tmpsbyte = br.ReadSByte();                  // DefaultPlotterType not used
 | 
						|
                tmpsbyte = br.ReadSByte();                  // DefaultPlotterPort not used
 | 
						|
				tmpsbyte = br.ReadSByte();                  // DefaultCIEType not used.
 | 
						|
				for (int i=0;i<8;i++)                       // DefPenColors[8] not used
 | 
						|
                    tmpsbyte = br.ReadSByte();
 | 
						|
				cfg.Print_Watermark = (PrintWatermark)br.ReadSByte();
 | 
						|
                cfg.Print_UserCBMess1 = ReadTheString(br, 10);
 | 
						|
                cfg.Print_UserCBMess2 = ReadTheString(br, 10);
 | 
						|
				tmpsbyte = br.ReadSByte();                 // DontPrintStatusTree not used
 | 
						|
                cfg.Print_UserFormat = ReadTheString(br, 10);
 | 
						|
                //tmpsbyte = br.ReadSByte();
 | 
						|
                //cfg.Print_Duplex = tmpsbyte == 0 ? true : false;
 | 
						|
				if (cfg.Print_UserFormat.Trim() != string.Empty)
 | 
						|
					DefaultPlantFmt += " " + cfg.Print_UserFormat;
 | 
						|
				br.Close();
 | 
						|
			}
 | 
						|
			catch(Exception e)
 | 
						|
			{
 | 
						|
				if(br!=null) br.Close();
 | 
						|
				DataLoader.frmLoader._MyLog.ErrorFormat("Error migrating {0} Curset.dat, error = {1}", PathName, e.Message);
 | 
						|
			}
 | 
						|
			fs.Close();
 | 
						|
            return cfg;
 | 
						|
		}
 | 
						|
        public string GetDefFmt()
 | 
						|
        {
 | 
						|
            return DefaultPlantFmt;
 | 
						|
        }
 | 
						|
	}
 | 
						|
}
 |