protected void SetUp() { _stylesXML = new InStyles(); _storyXML = new InStory(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputStyles = Common.PathCombine(_outputPath, "Resources"); _outputSpread = Common.PathCombine(_outputPath, "Spreads"); projInfo.TempOutputFolder = _outputPath; _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); _inputCSS1 = Common.DirectoryPathReplace(_testFolderPath + "/input/Page1.css"); _inputCSS2 = Common.DirectoryPathReplace(_testFolderPath + "/input/Page2.css"); _facingPages.Add("Spread_1.xml"); _facingPages.Add("Spread_2.xml"); _facingPages.Add("Spread_3.xml"); _singlePages.AddRange(_facingPages); _singlePages.Add("Spread_4.xml"); _singlePages.Add("Spread_5.xml"); _columnClass.Add("t1"); _columnClass.Add("t2"); _columnClass.Add("t3"); }
static void Main(string[] args) { var story = new InStory(); // Create a room var room1 = story.Cell(); var room2 = story.Cell(); room2.shortDescription="anteroom"; // room2 is west of room1 story.westOf(room1, room2); // Create a player character var pc = story.player; // Put the character in the room room1.AddChild(pc); // Create an object var tmp = story.Object(); tmp.shortDescription = "my thing"; // Give it to the player pc.AddChild(tmp); // Print an inventory story.interp("list"); // Go to other room story.interp("go to anteroom"); story.interp("go east"); story.interp("west"); story.interp("south"); // Drop -- but don't say what story.interp("drop"); // Drop my thing story.interp("drop my thing"); // Drop my thing again story.interp("drop my thing"); // Print an inventory story.interp("list"); // Pick up thing story.interp("get thing"); // Try to pick up room story.interp("get anteroom"); story.interp("get west"); // Print an inventory story.interp("list"); // Dump the JSON var str = story.toJSON(); }
protected void SetUp() { _stylesXML = new InStyles(); _storyXML = new InStory(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); ClassProperty = _expected; //Note: All Reference address initialized here _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputStyles = Common.PathCombine(_outputPath, "Resources"); projInfo.TempOutputFolder = _outputPath; _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); }
/// <summary> /// Convert XHTML to ODT /// </summary> public bool Export(PublicationInformation projInfo) { PreExportProcess preProcessor = new PreExportProcess(projInfo); preProcessor.GetTempFolderPath(); preProcessor.InsertEmptyHeadwordForReversal(preProcessor.ProcessedXhtml); MergeProcessInXHTMLforMasterPage(preProcessor.ProcessedXhtml); preProcessor.PreserveSpace(); preProcessor.ImagePreprocess(true); preProcessor.ReplaceInvalidTagtoSpan("_AllComplexFormEntryBackRefs|LexEntryRef_PrimaryLexemes", "span"); preProcessor.InsertHiddenChapterNumber(); preProcessor.InsertHiddenVerseNumber(); preProcessor.GetDefinitionLanguage(); var exportTitle = GetExportTitle(); string fileName = exportTitle.ToString(); if (exportTitle.ToString() == string.Empty) { fileName = Path.GetFileNameWithoutExtension(projInfo.DefaultXhtmlFileWithPath); } projInfo.DefaultXhtmlFileWithPath = preProcessor.ProcessedXhtml; projInfo.DefaultCssFileWithPath = preProcessor.ProcessedCss; projInfo.ProjectPath = Path.GetDirectoryName(preProcessor.ProcessedXhtml); Dictionary <string, Dictionary <string, string> > cssClass = new Dictionary <string, Dictionary <string, string> >(); CssTree cssTree = new CssTree(); cssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true); cssClass = MergeProcessInCSSforMasterPage(projInfo.DefaultCssFileWithPath, cssClass); preProcessor.InsertEmptyXHomographNumber(cssClass); //To insert the variable for macro use InInsertMacro insertMacro = new InInsertMacro(); insertMacro.InsertMacroVariable(projInfo, cssClass); Dictionary <string, Dictionary <string, string> > idAllClass = new Dictionary <string, Dictionary <string, string> >(); InStyles inStyles = new InStyles(); idAllClass = inStyles.CreateIDStyles(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), cssClass); InGraphic inGraphic = new InGraphic(); inGraphic.CreateIDGraphic(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), cssClass, cssTree.cssBorderColor); InStory inStory = new InStory(); Dictionary <string, ArrayList> StyleName = inStory.CreateStory(projInfo, idAllClass, cssTree.SpecificityClass, cssTree.CssClassOrder); InMasterSpread inMasterSpread = new InMasterSpread(); ArrayList masterPageNames = inMasterSpread.CreateIDMasterSpread(Common.PathCombine(projInfo.TempOutputFolder, "MasterSpreads"), idAllClass, StyleName["TextVariables"]); InSpread inSpread = new InSpread(); inSpread.CreateIDSpread(Common.PathCombine(projInfo.TempOutputFolder, "Spreads"), idAllClass, StyleName["ColumnClass"]); InDesignMap inDesignMap = new InDesignMap(); inDesignMap.CreateIDDesignMap(projInfo.TempOutputFolder, StyleName["ColumnClass"].Count, masterPageNames, StyleName["TextVariables"], StyleName["CrossRef"], projInfo.ProjectInputType); InMetaData inMetaData = new InMetaData(); inMetaData.SetDateTimeinMetaDataXML(projInfo.TempOutputFolder); InPreferences inPreferences = new InPreferences(); inPreferences.CreateIDPreferences(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), idAllClass); SubProcess.AfterProcess(projInfo.ProjectFileWithPath); fileName = Common.ReplaceSymbolToUnderline(fileName); string ldmlFullName = Common.PathCombine(projInfo.DictionaryPath, fileName + ".idml"); Compress(projInfo.TempOutputFolder, ldmlFullName); Common.CleanupExportFolder(ldmlFullName, ".tmp,.de", "layout.css", String.Empty); CreateRAMP(projInfo); Common.CleanupExportFolder(ldmlFullName, ".css,.xhtml,.xml", String.Empty, String.Empty); if (projInfo.IsOpenOutput) { Launch(ldmlFullName); } return(true); }
/// <summary> /// This creates a normal form of the world given by the root /// </summary> /// <param name="root">The object that refers to everything else</param> /// <returns>null on error, otherwise the normalize representation</returns> static ZNormalForm buildNormalForm(InStory story) { // first, create the instance to hold it all var thing = new ZNormalForm(); // go thru and add stuff thing.addRelation("instance", (Dictionary<ZObject, ZObject>) story.relations[InStory._instance]); foreach (var item in story.relations) { if (item.Value is SparseGraph<ZObject>) thing.addRelation((string) item.Key.name, (SparseGraph<ZObject>) item.Value); } thing.add((ZObject)story.player); thing.rootObject = ((ZObject)story.player).name; return thing; }
/// <summary> /// Get the objects, esp root object /// </summary> /// <returns>The root object</returns> internal ZObject Objects(InStory story) { // Go thru an make the ZObjects; var newObjects=new Dictionary<object,object>(); foreach (var item in objects) { var d = (Dictionary<string,object>) item.Value; var n = new ZObject(); object obj; if (d.TryGetValue("shortDescription", out obj)) n.shortDescription = (string) obj; if (d.TryGetValue("nouns", out obj)) n.nouns = (object[]) obj; newObjects[item.Key] = n; } // Go thru and use the internal "special" forms for some objects newObjects[InStory. _instance.name] = InStory. _instance; newObjects[InStory. __kind.name] = InStory. __kind; newObjects[InStory. opposite.name] = InStory. opposite; newObjects[InStory. roomKind.name] = InStory. roomKind; newObjects[InStory. dirKind.name] = InStory. dirKind; newObjects[InStory. cellKind.name] = InStory. cellKind; newObjects[InStory.personKind.name] = InStory.personKind; objects = newObjects; // Go thru and replace references out special one replace(story.east); replace(story.west); replace(story.north); replace(story.south); // Link the table back together // Link each parent to child foreach (var I in children) { var obj = newObjects[I[0]]; var L = I. Length; for (int J = 1; J < L; J++) ((ZObject)obj).AddChild((ZObject) objects[I[J]]); } // And return the root object return (ZObject) objects[rootObject]; }
/// <summary> /// This converts the world into a JSON format /// </summary> /// <param name="root"></param> /// <returns></returns> internal static StringBuilder JSONSerialize(InStory story) { // First create the normal form var tmp = buildNormalForm(story); // Next create the temporary buffers to hold the JSON var serializer = new JavaScriptSerializer(); // Tell it to skip nulls and empties serializer.RegisterConverters(new JavaScriptConverter[] { new JSONConverter() }); var sb = new StringBuilder(); // Finally, Serialize the JSON serializer.Serialize(tmp, sb); return sb; }