/// <summary> /// Generate an HtmlObject from a sculpture object /// </summary> /// <param name="proj">project source</param> /// <param name="model">model</param> /// <returns>HTMLObject constructed</returns> public static HTMLObject InstanciateSculptureTool(Project proj, CadreModel model) { HTMLObject obj = null; Project.EnsureSculptureGeneration(proj); if (model.SelectedModelTypeObject.Type == CadreModelType.Image) { obj = new HTMLObject(proj.ToolImage); model.CopyProperties(obj); obj.CSS.BackgroundImageURL = model.SelectedModelTypeObject.Content; proj.Add(obj, "Sculptures"); } else if (model.SelectedModelTypeObject.Type == CadreModelType.Text) { obj = new HTMLObject(proj.ToolText); model.CopyProperties(obj); obj.HTML = model.SelectedModelTypeObject.Content; proj.Add(obj, "Sculptures"); } else if (model.SelectedModelTypeObject.Type == CadreModelType.Tool) { obj = new HTMLObject(model.SelectedModelTypeObject.DirectObject); model.CopyProperties(obj); proj.Add(obj, "Sculptures"); } else if (model.SelectedModelTypeObject.Type == CadreModelType.MasterObject) { obj = new HTMLObject(model.SelectedModelTypeObject.DirectObject); model.CopyProperties(obj); proj.Add(obj, "Sculptures"); } return(obj); }
/// <summary> /// Import selected files from an existing project /// </summary> /// <param name="src">project source</param> /// <param name="dest">project destination</param> private static void ImportFiles(Project src, Project dest) { Tree <string, Accessor> t = new Tree <string, Accessor>(src.Hierarchy.Find(Project.FilesName)); BindingList <KeyValuePair <IEnumerable <string>, Accessor> > b = new BindingList <KeyValuePair <IEnumerable <string>, Accessor> >(); Node <string, Accessor> destNode = dest.Hierarchy.Find(Project.FilesName); t.EnumerateSelected(b); foreach (KeyValuePair <IEnumerable <string>, Accessor> kv in b) { File f = kv.Value.GetObject(src); dest.Add(f, String.Join("/", kv.Key.Skip(1).ToArray())); } }
/// <summary> /// Import selected master pages from an existing project /// </summary> /// <param name="src">project source</param> /// <param name="dest">project destination</param> private static void ImportMasterPages(Project src, Project dest) { Tree <string, Accessor> t = new Tree <string, Accessor>(src.Hierarchy.Find(Project.MasterPagesName)); BindingList <KeyValuePair <IEnumerable <string>, Accessor> > b = new BindingList <KeyValuePair <IEnumerable <string>, Accessor> >(); Node <string, Accessor> destNode = dest.Hierarchy.Find(Project.MasterPagesName); t.EnumerateSelected(b); foreach (KeyValuePair <IEnumerable <string>, Accessor> kv in b) { // recherche des objets (soit des tools, soit des master objects) MasterPage srcMo = kv.Value.GetObject(src); dest.Add(srcMo, String.Join("/", kv.Key.Skip(1).ToArray())); } }
/// <summary> /// Import selected pages from an existing project /// </summary> /// <param name="src">project source</param> /// <param name="dest">project destination</param> private static void ImportPages(Project src, Project dest) { Tree <string, Accessor> t = new Tree <string, Accessor>(src.Hierarchy.Find(Project.PagesName)); BindingList <KeyValuePair <IEnumerable <string>, Accessor> > b = new BindingList <KeyValuePair <IEnumerable <string>, Accessor> >(); Node <string, Accessor> destNode = dest.Hierarchy.Find(Project.PagesName); t.EnumerateSelected(b); foreach (KeyValuePair <IEnumerable <string>, Accessor> kv in b) { Page page = kv.Value.GetObject(src); List <string> path = new List <string>(kv.Key.Skip(1)); path.Add(page.ElementTitle); dest.Add(page, String.Join("/", path)); } }
/// <summary> /// Import selected tools from an existing project /// </summary> /// <param name="src">project source</param> /// <param name="dest">project destination</param> private static void ImportTools(Project src, Project dest) { Tree <string, Accessor> t = new Tree <string, Accessor>(src.Hierarchy.Find(Project.ToolsName)); BindingList <KeyValuePair <IEnumerable <string>, Accessor> > b = new BindingList <KeyValuePair <IEnumerable <string>, Accessor> >(); Node <string, Accessor> destNode = dest.Hierarchy.Find(Project.ToolsName); t.EnumerateSelected(b); foreach (KeyValuePair <IEnumerable <string>, Accessor> kv in b) { HTMLTool tool = kv.Value.GetObject(src); tool = tool.Clone() as HTMLTool; List <string> path = new List <string>(kv.Key.Skip(1)); path.Add(tool.ElementTitle); dest.Add(tool, String.Join("/", path.ToArray())); } }
/// <summary> /// Add a file /// </summary> /// <param name="proj">project source</param> /// <param name="path">path for the directory of this file to copy</param> /// <param name="fileName">file name to add</param> /// <returns>true if added</returns> public static bool AddFile(Project proj, string path, string fileName) { FileInfo fi = new FileInfo(fileName); string path2 = CommonDirectories.ConfigDirectories.RemoveLeadBackslash(path); string f = CommonDirectories.ConfigDirectories.RemoveLeadBackslash(Path.GetFileName(fileName)); proj.Add(new File(f), path2); bool result; try { CommonDirectories.ConfigDirectories.AddFile(proj.Title, Path.Combine(CommonDirectories.ConfigDirectories.GetBuildFolder(proj.Title), path, f), fileName); result = true; } catch { result = false; } return(result); }
/// <summary> /// Add a new Page /// </summary> /// <param name="proj">concerned project</param> /// <param name="t">new tool</param> /// <param name="path">path for this page</param> /// <returns></returns> public static bool AddTool(Project proj, HTMLTool t, string path) { proj.Add(t, path); return(true); }
/// <summary> /// Add a new Page /// </summary> /// <param name="proj">concerned project</param> /// <param name="p">new page</param> /// <param name="path">path for this page</param> /// <returns></returns> public static bool AddPage(Project proj, Page p, string path) { proj.Add(p, path); return(true); }