/// <summary> /// Save project into file /// </summary> /// <param name="p">project object to save</param> /// <param name="path">path of file</param> /// <param name="fileName">file name</param> public static void Save(Project p, string path, string fileName) { FileInfo fi = new FileInfo(Path.Combine(path, fileName)); if (fi.Exists) { fi.CopyTo(Path.Combine(path, Path.GetFileNameWithoutExtension(fileName) + ".bak"), true); } ++p.Revision; p.ModificationDate = DateTime.Now; p.CadreModelCounter = CadreModel.counter; p.UniqueId = Attributes.uniqueId.Counter; p.UniqueClass = Attributes.uniqueClass.Counter; string errorText; if (Save(fi, p, out errorText)) { p.Set(hasErrorSaveName, false); } else { p.Set(hasErrorSaveName, true); p.Set(errorReasonName, errorText); FileInfo oldFi = new FileInfo(Path.Combine(path, Path.GetFileNameWithoutExtension(fileName) + ".bak")); if (oldFi.Exists) { oldFi.CopyTo(Path.Combine(path, fileName), true); } } }
/// <summary> /// Check sculpture generation /// </summary> /// <param name="proj">project</param> public static void EnsureSculptureGeneration(Project proj) { if (proj.ToolImage == null) { // créer un tool image HTMLTool newToolImage = new HTMLTool(); newToolImage.ConstraintHeight = EnumConstraint.AUTO; newToolImage.ConstraintWidth = EnumConstraint.AUTO; proj.Set(sculptureToolImageName, newToolImage); newToolImage.CSS.Body.Add("background-position", "center"); newToolImage.CSS.Body.Add("background-repeat", "no-repeat"); Project.AddTool(proj, proj.ToolImage, "/#sculpture/image"); } if (proj.ToolText == null) { // créer un tool texte HTMLTool newToolText = new HTMLTool(); newToolText.ConstraintHeight = EnumConstraint.AUTO; newToolText.ConstraintWidth = EnumConstraint.AUTO; proj.Set(sculptureToolTextName, newToolText); Project.AddTool(proj, proj.ToolText, "/#sculpture/texte"); } }