/// <summary> /// Default constructor /// Create an HTML object that hosts an instance of a tool /// </summary> /// <param name="htmlTool">HTML Tool import</param> public HTMLObject(HTMLTool htmlTool) { int val = Project.CurrentProject.IncrementedCounter; this.Set(automaticNameName, String.Format("object{0}", val)); this.Set(automaticIdName, String.Format("idObject{0}", val)); this.Set(masterObjectName, ""); this.Set(toolName, htmlTool.Path + "/" + htmlTool.Title); this.Width = htmlTool.Width; this.Height = htmlTool.Height; this.ConstraintWidth = htmlTool.ConstraintWidth; this.ConstraintHeight = htmlTool.ConstraintHeight; this.Title = ExtensionMethods.CloneThis(htmlTool.Title); this.HTML = htmlTool.HTML; this.Set(eventsName, htmlTool.Events.Clone()); this.Set(javascriptName, htmlTool.JavaScript.Clone()); this.Set(javascriptOnloadName, htmlTool.JavaScriptOnLoad.Clone()); this.Set(cssListName, new CSSList(htmlTool.CSSList.List)); // rename the principal css element this.CSSList.RenamePrincipalCSS(htmlTool.Id, this.Id); this.Set(attributesName, htmlTool.Attributes.Clone()); this.Attributes.RenameId(this.Id); this.Attributes.HasId = false; }
/// <summary> /// Remove an html tool /// </summary> /// <param name="t">html tool</param> public void Remove(HTMLTool t) { Accessor a = new Accessor(Project.ToolsName, t.Unique); this.Hierarchy.Find(Project.ToolsName).Remove(a); this.Tools.Remove(t); }
/// <summary> /// Add a tool /// given a specific path to organize project's element /// </summary> /// <param name="t">tool</param> /// <param name="path">path</param> public void Add(HTMLTool t, string path) { this.Tools.Add(t); string u = this.Unique.ComputeNewString(); t.Unique = u; Accessor a = new Accessor(Project.ToolsName, u); string[] splitted = path.Split('/'); this.Hierarchy.Find(Project.ToolsName).Find(splitted.Take(splitted.Count() - 1)).AddLeaf(a); t.Path = String.Join("/", splitted.Take(splitted.Count() - 1).ToArray()) + "/"; t.Title = splitted.Last(); }
/// <summary> /// Constructor for an accessor with a tool /// </summary> /// <param name="t">tool list</param> /// <param name="u">unique name to search</param> public Accessor(List <HTMLTool> t, string u) { HTMLTool h = t.Find(x => x.Unique == u); if (h != null) { this.Set(dataTypeName, Project.ToolsName); this.Set(uniqueName, u); } else { throw new IndexOutOfRangeException(); } }
/// <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())); } }
public FolderTool Find(string toolPath) { Library.FolderTool currentFolder = this; string[] list = toolPath.Split('/'); IEnumerator el = list.GetEnumerator(); string last = String.Empty; if (el.MoveNext()) { do { if (!String.IsNullOrEmpty(last)) { currentFolder = currentFolder.Folders.Find(a => { return(a.Name == last); }); if (currentFolder == null) { throw new ArgumentException(Localization.Strings.GetString("ExceptionPathNotExists"), "toolPath"); } } if (!String.IsNullOrEmpty((string)el.Current)) { last = (string)el.Current; } }while (el.MoveNext()); } if (!String.IsNullOrEmpty(last)) { HTMLTool tool = currentFolder.Tools.Find(a => a.Name == last); if (tool == null) { throw new ArgumentException(Localization.Strings.GetString("ExceptionToolNotExists"), "toolPath"); } else { return(currentFolder); } } else { throw new ArgumentException(Localization.Strings.GetString("ExceptionIncompletPath"), "toolPath"); } }
public void Import(string oldPath, FolderTool from) { foreach (FolderTool folder in from.Folders) { FolderTool newFolder = this.Folders.Find(a => { return(a.Name == folder.Name); }); if (newFolder == null) { newFolder = new FolderTool(); newFolder.Path = oldPath; newFolder.Name = folder.Name; this.Folders.Add(newFolder); } newFolder.Import(oldPath + System.IO.Path.AltDirectorySeparatorChar + folder.Name, folder); } foreach (HTMLTool tool in from.Tools) { HTMLTool newTool = tool.Clone() as HTMLTool; this.Tools.Add(newTool); } }
/// <summary> /// Clone this object /// </summary> /// <returns>cloned object</returns> public object Clone() { HTMLTool tool = new HTMLTool(); tool.ConstraintWidth = this.ConstraintWidth; tool.ConstraintHeight = this.ConstraintHeight; tool.Width = this.Width; tool.Height = this.Height; tool.Title = ExtensionMethods.CloneThis(this.Title); tool.Path = ExtensionMethods.CloneThis(this.Path); tool.HTML = ExtensionMethods.CloneThis(this.HTML); tool.Set(eventsName, this.Events.Clone()); tool.Set(javascriptName, this.JavaScript.Clone()); tool.Set(javascriptOnloadName, this.JavaScriptOnLoad.Clone()); tool.CSSList.List.AddRange(from CodeCSS c in this.CSSList.List select c.Clone() as CodeCSS); tool.CSSList.RenamePrincipalCSS(this.Id, tool.Id); tool.Set(attributesName, this.Attributes.Clone()); tool.Attributes.RenameId(tool.Id); tool.Attributes.HasId = false; return(tool); }
private void supprimerToolStripMenuItem3_Click(object sender, EventArgs e) { TreeNode t = this.prv_currentNodeContext; if (t != null) { if (t.Tag != null) { if (t.Tag is Library.HTMLTool) { DialogResult dr = MessageBox.Show(Translate("SuppressText"), Translate("SuppressTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == System.Windows.Forms.DialogResult.Yes) { Library.HTMLTool tool = t.Tag as Library.HTMLTool; Project.CurrentProject.Remove(tool); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } } } } }
/// <summary> /// Generate the content /// </summary> /// <param name="list">list of sized rectangle</param> internal void GenerateContent(List <AreaSizedRectangle> list) { if (this.Type == RefObject.MasterPage) { MasterPage mp = this.Destination; mp.HorizontalZones.Clear(); mp.MakeZones(list); this.FillContainerObject(mp.HorizontalZones, mp.Objects); SizeCompute.ComputeMasterPage(Project.CurrentProject, mp); } else if (this.Type == RefObject.Page) { Page p = this.Destination; MasterPage mp = this.SecondObject; p.MasterPageName = mp.Name; mp.HorizontalZones.Clear(); mp.MakeZones(list); this.FillContainerObject(mp.HorizontalZones, mp.Objects); SizeCompute.ComputePage(Project.CurrentProject, p); } else if (this.Type == RefObject.MasterObject) { MasterObject mo = this.Destination; mo.HorizontalZones.Clear(); mo.MakeZones(list); this.FillContainerObject(mo.HorizontalZones, mo.Objects); SizeCompute.ComputeMasterObject(Project.CurrentProject, mo); } else if (this.Type == RefObject.Tool) { HTMLTool obj = this.Destination; MasterObject mo = this.SecondObject; mo.HorizontalZones.Clear(); mo.MakeZones(list); this.FillContainerObject(mo.HorizontalZones, mo.Objects); SizeCompute.ComputeHTMLObject(Project.CurrentProject, new HTMLObject(obj)); } }
/// <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"); } }
/// <summary> /// Returns the CSS output /// </summary> /// <param name="resolveConfig">true if resolve configuration</param> /// <returns>css</returns> public string CSSOutput(bool resolveConfig) { return(HTMLTool.CSSOutput(this.CSSList.List, resolveConfig)); }
/// <summary> /// Create a destination object and store its into the project /// </summary> /// <param name="proj">project</param> /// <param name="width">width value</param> /// <param name="height">height value</param> /// <param name="h">horizontal count</param> /// <param name="v">vertical count</param> public void CreateDestination(Library.Project proj, uint width, uint height, uint h, uint v) { if (this.Destination == null) { if (this.Type == RefObject.MasterPage) { MasterPage mp = new MasterPage(); mp.Name = this.Name; mp.ConstraintHeight = EnumConstraint.FIXED; mp.Height = height; mp.ConstraintWidth = EnumConstraint.FIXED; mp.Width = width; mp.CountColumns = h; mp.CountLines = v; proj.MasterPages.Add(mp); this.Destination = mp; string[] splitted = mp.ElementTitle.Split('/'); string path = String.Join("/", splitted.Take(splitted.Count() - 1)); mp.Name = splitted.Last(); proj.Add(mp, path); } else if (this.Type == RefObject.Page) { MasterPage mp = new Library.MasterPage(); Page p = new Library.Page(); if (Library.Project.AddPage(proj, p, this.Name)) { mp.Name = "MasterPage_" + System.IO.Path.GetFileNameWithoutExtension(p.Name); mp.ConstraintHeight = EnumConstraint.FIXED; mp.Height = height; mp.ConstraintWidth = EnumConstraint.FIXED; mp.Width = width; mp.CountColumns = h; mp.CountLines = v; proj.MasterPages.Add(mp); p.MasterPageName = mp.Name; p.ConstraintHeight = EnumConstraint.FIXED; p.Height = height; p.ConstraintWidth = EnumConstraint.FIXED; p.Width = width; this.SecondObject = mp; this.Destination = p; } else { throw new ArgumentException(Localization.Strings.GetString("ExceptionPageNotCreated")); } } else if (this.Type == RefObject.MasterObject) { MasterObject mo = new MasterObject(); mo.Title = this.Name; mo.ConstraintHeight = EnumConstraint.FIXED; mo.Height = height; mo.ConstraintWidth = EnumConstraint.FIXED; mo.Width = width; mo.CountColumns = h; mo.CountLines = v; this.Destination = mo; string[] splitted = mo.ElementTitle.Split('/'); string path = String.Join("/", splitted.Take(splitted.Count() - 1)); mo.Name = splitted.Last(); proj.Add(mo, path); } else if (this.Type == RefObject.Tool) { MasterObject mo = new Library.MasterObject(); HTMLTool t = new HTMLTool(); if (Library.Project.AddTool(proj, t, this.Name)) { mo.Name = "MasterObject_" + t.Title; mo.ConstraintHeight = EnumConstraint.FIXED; mo.Height = height; mo.ConstraintWidth = EnumConstraint.FIXED; mo.Width = width; mo.CountColumns = h; mo.CountLines = v; t.ConstraintHeight = EnumConstraint.FIXED; t.ConstraintWidth = EnumConstraint.FIXED; t.Width = width; t.Height = height; this.SecondObject = mo; this.Destination = t; } else { throw new ArgumentException(Localization.Strings.GetString("ExceptionToolNotCreated")); } } } else { if (this.Type == RefObject.MasterPage) { MasterPage mp = this.Destination; for (int index = mp.Objects.Count - 1; index >= 0; --index) { if (proj.Instances.Contains(mp.Objects[index])) { proj.Remove(mp.Objects[index]); } } mp.ConstraintHeight = EnumConstraint.FIXED; mp.Height = height; mp.ConstraintWidth = EnumConstraint.FIXED; mp.Width = width; mp.CountColumns = h; mp.CountLines = v; } else if (this.Type == RefObject.Page) { Page p = this.Destination; MasterPage mp = this.SecondObject; for (int index = mp.Objects.Count - 1; index >= 0; --index) { if (proj.Instances.Contains(mp.Objects[index])) { proj.Remove(mp.Objects[index]); } } for (int index = p.Objects.Count - 1; index >= 0; --index) { if (proj.Instances.Contains(p.Objects[index])) { proj.Remove(p.Objects[index]); } } mp.ConstraintHeight = EnumConstraint.FIXED; mp.Height = height; mp.ConstraintWidth = EnumConstraint.FIXED; mp.Width = width; mp.CountColumns = h; mp.CountLines = v; p.ConstraintHeight = EnumConstraint.FIXED; p.Height = height; p.ConstraintWidth = EnumConstraint.FIXED; p.Width = width; } else if (this.Type == RefObject.MasterObject) { MasterObject mo = this.Destination; for (int index = mo.Objects.Count - 1; index >= 0; --index) { if (proj.Instances.Contains(mo.Objects[index])) { proj.Remove(mo.Objects[index]); } } mo.ConstraintHeight = EnumConstraint.FIXED; mo.Height = height; mo.ConstraintWidth = EnumConstraint.FIXED; mo.Width = width; mo.CountColumns = h; mo.CountLines = v; } else if (this.Type == RefObject.Tool) { HTMLTool t = this.Destination; MasterObject mo = this.SecondObject; for (int index = mo.Objects.Count - 1; index >= 0; --index) { if (proj.Instances.Contains(mo.Objects[index])) { proj.Remove(mo.Objects[index]); } } mo.ConstraintHeight = EnumConstraint.FIXED; mo.Height = height; mo.ConstraintWidth = EnumConstraint.FIXED; mo.Width = width; mo.CountColumns = h; mo.CountLines = v; t.ConstraintHeight = EnumConstraint.FIXED; t.ConstraintWidth = EnumConstraint.FIXED; t.Width = width; t.Height = height; } } }
/// <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); }
private void treeView1_DoubleClick(object sender, EventArgs e) { TreeNode currentSelection = this.treeView1.GetNodeAt(this.treeView1.PointToClient(MousePosition)); if (currentSelection != null) { this.treeView1.SelectedNode = currentSelection; } if (this.treeView1.SelectedNode != null) { if (this.treeView1.SelectedNode.Tag != null) { // sauvegarde selected node this.prv_currentNodeContext = this.treeView1.SelectedNode; if (this.treeView1.SelectedNode.Tag is Library.MasterPage) { Library.MasterPage mp = this.treeView1.SelectedNode.Tag as Library.MasterPage; MasterPageView window = new MasterPageView(mp.Name); window.Text = String.Format(Translate("MasterPageTitle"), mp.Name); window.FormClosed += window_FormClosed; window.MdiParent = this; window.MasterPage = mp; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.MasterObject) { Library.MasterObject mo = this.treeView1.SelectedNode.Tag as Library.MasterObject; MasterObjectView window = new MasterObjectView(mo.Title); window.Text = String.Format(Translate("MasterObjectTitle"), mo.Title); window.FormClosed += window_FormClosed; window.MdiParent = this; window.MasterObject = mo; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.SculptureObject) { Library.SculptureObject so = this.treeView1.SelectedNode.Tag as Library.SculptureObject; SculptureView window = new SculptureView(); window.Text = String.Format(Translate("SculptureTitle"), so.Title); window.FormClosed += window_FormClosed; window.MdiParent = this; window.SculptureObject = so; if (window.SculptureObject.Cadres.Count == 0) { window.SculptureObject.Cadres.Add(new CadreModel()); } window.CurrentCadreModel.CurrentObject = window.SculptureObject.Cadres[0]; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.HTMLTool) { Library.HTMLTool t = this.treeView1.SelectedNode.Tag as Library.HTMLTool; ToolView view = new ToolView(t.Title); view.Text = String.Format(Translate("ToolTitle"), t.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLTool = t; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.HTMLObject) { HTMLObject obj = this.treeView1.SelectedNode.Tag as Library.HTMLObject; if (!String.IsNullOrEmpty(obj.MasterObjectName)) { ObjectView view = new ObjectView(obj.Title); view.Text = String.Format(Translate("ObjectTitle"), obj.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLObject = obj; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else { SimpleObjectView view = new SimpleObjectView(obj.Title); view.Text = String.Format(Translate("ObjectTitle"), obj.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLObject = obj; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } } else if (this.treeView1.SelectedNode.Tag is Library.Page) { Page p = this.treeView1.SelectedNode.Tag as Library.Page; PageView view = new PageView(p.Name); view.Text = String.Format(Translate("PageTitle"), p.Name); view.FormClosed += window_FormClosed; view.MdiParent = this; view.Page = p; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.Configuration) { ConfigView cv = new ConfigView(); cv.FormClosed += window_FormClosed; cv.Datas = (this.treeView1.SelectedNode.Tag as Library.Configuration).Elements; cv.ShowDialog(); } else if (this.treeView1.SelectedNode.Tag is List <string> ) { if (this.treeView1.SelectedNode.Name == "JavaScriptUrls") { JavaScriptUrls ju = new JavaScriptUrls(); ju.FormClosed += window_FormClosed; ju.Datas = (this.treeView1.SelectedNode.Tag as List <string>); ju.ShowDialog(); } else if (this.treeView1.SelectedNode.Name == "CSSUrls") { CSSUrls cu = new CSSUrls(); cu.FormClosed += window_FormClosed; cu.Datas = (this.treeView1.SelectedNode.Tag as List <string>); cu.ShowDialog(); } } } } }