protected CProject(SerializationInfo info, StreamingContext context) { //this.FileList = (ArrayList)info.GetValue("FileList", typeof(ArrayList)); //this.DirList = (ArrayList)info.GetValue("DirList", typeof(ArrayList)); g.LogDebug("CPROJECT::ctor: Enter (Deserialization)"); try { g.LogDebug("CPROJECT::ctor: Trying to get file version"); int proj_filever = (int)info.GetValue("___PROJECT_FILE_VERSION", typeof(int)); if (proj_filever != 1) { g.LogDebug("CPROJECT::ctor: Failed"); throw new Exception("The project is from an older version of TorqueDev / Codeweaver that is completely incompatible with the current version."); } } catch { g.LogDebug("CPROJECT::ctor: Failed"); throw new Exception("The project is from an older version of TorqueDev / Codeweaver that is completely incompatible with the current version."); } /* Try to load the new file collection data; if not, we need to convert */ try { g.LogDebug("CPROJECT::ctor: Load directory and file information"); this.FileList = (FileCollection)info.GetValue("FileList_V2", typeof(FileCollection)); this.DirList = (DirectoryCollection)info.GetValue("DirList_V2", typeof(DirectoryCollection)); } catch { g.LogDebug("CPROJECT::ctor: Failed; need to update project file"); DialogResult result = MessageBox.Show("This project contains data from an older version of TorqueDev / Codewaver (namely, the " + "way projects store file and directory data has changed). Do you want to update your project file to the latest version? " + "(Note: Selecting 'no' will leave you with a blank project)", "Project Conversion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); this.FileList = new FileCollection(); this.DirList = new DirectoryCollection(); if (result == DialogResult.Yes) { // Convert the old data ArrayList oldfiles = (ArrayList)info.GetValue("FileList", typeof(ArrayList)); ArrayList olddirs = (ArrayList)info.GetValue("DirList", typeof(ArrayList)); foreach (CProject.File oldfile in oldfiles) { this.FileList.Add(oldfile); } foreach (CProject.Directory olddir in olddirs) { this.DirList.Add(olddir); } } } g.LogDebug("CPROJECT::ctor: Loading project properties"); //this._TokenObjList = (Hashtable)info.GetValue("TokenObject", typeof(Hashtable)); this.ProjectName = (string)info.GetValue("#ProjectName#", typeof(string)); //this.ProjectPath = (string)info.GetValue("#FullRootPath#", typeof(string)); this.ProjectPath = System.IO.Directory.GetCurrentDirectory(); // Try to load the debugger data; if nothing, just quit try { g.LogDebug("CPROJECT::ctor: Loading debugger properties"); this.DebugEnabled = (bool)info.GetValue("DebugEn", typeof(bool)); this.DebugExe = (string)info.GetValue("DebugExe", typeof(string)); this.DebugParams = (string)info.GetValue("DebugParams", typeof(string)); this.DebugPasswd = (string)info.GetValue("DebugPasswd", typeof(string)); this.DebugPort = (int)info.GetValue("DebugPort", typeof(int)); } catch {} // Try to load the last open file list; if not, just quit try { g.LogDebug("CPROJECT::ctor: Loading previous state"); this.OpenFiles = (FileCollection)info.GetValue("OpenFiles", typeof(FileCollection)); this.OpenFilesState = (byte[])info.GetValue("OpenFilesState", typeof(byte[])); } catch {} // Deserialize the macro list try { g.LogDebug("CPROJECT::ctor: Reloading macros"); ArrayList macrolist = new ArrayList(); this.MacroList = new Hashtable(); macrolist = (ArrayList)info.GetValue("SerializedMacroList", typeof(ArrayList)); foreach (CProject.SerializedMacro sermac in macrolist) { MemoryStream mem = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(sermac.MacroXML)); System.Xml.XmlTextReader xmlread = new System.Xml.XmlTextReader(mem); ActiproSoftware.SyntaxEditor.Commands.MacroCommand newcmd = new ActiproSoftware.SyntaxEditor.Commands.MacroCommand(); newcmd.ReadFromXml(xmlread); xmlread.Close(); mem.Close(); CProject.Macro newmac = new CProject.Macro(sermac.MacroName, newcmd); newmac.MacroNum = sermac.MacroNum; this.MacroList.Add(newmac.MacroName, newmac); } } catch (Exception exc) { g.LogDebug("CPROJECT::ctor: Failed"); MessageBox.Show("Error in loading saved macros. Some macros may not be available.\n\n" + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // Try to see if the project type is set try { g.LogDebug("CPROJECT::ctor: Loading project type"); this.ProjectType = Convert.ToInt16(info.GetValue("#ProjectType#", typeof(short))); } catch { g.LogDebug("CPROJECT::ctor: Failed"); MessageBox.Show("This project is from an older version of TorqueDev / Codeweaver and does not include a project type definition. It has automatically been set to \"TGE\". You will need to edit the project properties to change the project type to the appropriate value.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ProjectType = 0; } // Grab the variable watch list if we can try { g.LogDebug("CPROJECT::ctor: Loading watch list"); this.VarWatchList = (ArrayList)info.GetValue("WatchVars", typeof(ArrayList)); } catch {} // Take care of the new debug options try { g.LogDebug("CPROJECT::ctor: Loading debug auto insert info"); this.DebugAutoInsert = Convert.ToBoolean(info.GetValue("DebugAutoInsert", typeof(bool))); this.DebugMainCs = (string)(info.GetValue("DebugMainCs", typeof(string))); } catch { // Reset the debugging info if we've failed to // convert the new debug settings MessageBox.Show("This project does not contain extended debug information (due to conversion from an older version of TorqueDev). " + "The project's debug information will be cleared. You can run the new Debug Wizard available from the \"Debug\" menu to " + "define the debugger settings.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DebugExe = ""; this.DebugEnabled = false; this.DebugParams = ""; this.DebugPasswd = ""; this.DebugPort = 8777; this.DebugAutoInsert = false; this.DebugMainCs = ""; } // See if we can get the last project finds/replaces try { g.LogDebug("CPROJECT::ctor: Loading finds/replaces"); this.Finds = (ArrayList)info.GetValue("RecentFinds", typeof(ArrayList)); this.Replaces = (ArrayList)info.GetValue("RecentReplaces", typeof(ArrayList)); } catch { } // Clean up any foreign files that are left in the project g.LogDebug("CPROJECT::ctor: Remove foreign files"); FileList.CleanUpForeigns(); }