public UXProject(WebBrowser web) { this.web = web; currentProject = new Library.Project(); currentNode = currentProject.Hierarchy; this.OpenProject(); }
public static ListConverter ProjectFiles(DirectoryInfo di) { ListConverter listConverter = new ListConverter(); listConverter.Add(() => { List <HashConverter> list = new List <HashConverter>(); uint index = 0; foreach (FileInfo fi in di.GetFiles("*.bin")) { Marshalling.PersistentDataObject obj; if (Library.Project.Load(fi, out obj)) { Library.Project proj = obj as Library.Project; if (proj != null) { HashConverter h = HashConverter.ProjectItems(proj); h.Name = index.ToString(); h.Add(() => { return(new Dictionary <string, dynamic>() { { "index", index.ToString() }, { "project", proj } }); }); list.Add(h); ++index; } } } return(list); }); return(listConverter); }
public static ListConverter MakeUXhierarchyProject(Library.Project p, Library.Node <string, Library.Accessor> node) { ListConverter listConverter = new ListConverter(); listConverter.Add(() => { List <HashConverter> list = new List <HashConverter>(); list.Add(HashConverter.HierarchyItems(p, node)); return(list); }); return(listConverter); }
private void btnCreateMasterObject_Click(object sender, EventArgs e) { MasterObjectCreationForm creation = new MasterObjectCreationForm(); DialogResult dr = creation.ShowDialog(); if (dr == DialogResult.OK) { Library.Project proj = Library.Project.CurrentProject; MasterObjectCreationWindow window = new MasterObjectCreationWindow(creation.MasterObject); if (!creation.MasterObject.RelativeHeight) { window.Height = (int)creation.MasterObject.Height; } else { window.Height = 500; } if (!creation.MasterObject.RelativeWidth) { window.Width = (int)creation.MasterObject.Width; } else { window.Width = 500; } window.WindowState = FormWindowState.Normal; DialogResult dr2 = window.ShowDialog(); if (dr2 == DialogResult.OK) { string[] splitted = creation.MasterObject.Title.Split('/'); string path = String.Join("/", splitted.Take(splitted.Count() - 1).ToArray()); creation.MasterObject.Title = splitted.Last(); proj.Add(creation.MasterObject, path); Library.Project.Save(proj, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); proj.ReloadProject(); } int index = this.cmbMasterObjects.Items.Add(creation.txtTitle.Text); this.cmbMasterObjects.Text = creation.txtTitle.Text; } }
public static HashConverter ProjectItems(Library.Project proj) { HashConverter hash = new HashConverter(); return(proj.Export <Library.Project, HashConverter>(hash, (x) => { hash.Add(() => { Dictionary <string, dynamic> d = new Dictionary <string, dynamic>(); d.Add("Nom du projet", x.Title); d.Add("Date de création", x.CreationDate); d.Add("Date de modification", x.ModificationDate); d.Add("Révision", x.Revision); d.Add("Nombre de pages", x.Pages.Count); d.Add("Nombre de master pages", x.MasterPages.Count); d.Add("Nombre de master objets", x.MasterObjects.Count); d.Add("Nombre d'outils", x.Tools.Count); d.Add("Nombre de fichiers", x.Files.Count); return d; }); return hash; })); }
public static HashConverter HierarchyItems(Library.Project p, Library.Node <string, Library.Accessor> node) { HashConverter hash = new HashConverter(); if (node.Elements.Count() > 0) { foreach (Library.Leaf <Library.Accessor> leaf in node.Elements) { dynamic x = leaf.Object.GetObject(p); hash.Set(x.Unique, x.Name); } } else if (node.SubNodes.Count() > 0) { uint index = 0; foreach (Library.Node <string, Library.Accessor> sub in node.SubNodes) { hash.Set("index." + index.ToString(), sub.NodeValue); ++index; } } return(hash); }
private void click(object sender, EventArgs e) { AddObject add = new AddObject(); Library.Project proj = Library.Project.CurrentProject; DialogResult dr = add.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { HtmlElement obj = this.webBrowser1.Document.GetElementById("callback"); if (obj != null) { Library.HTMLObject item = new Library.HTMLObject(); item.Title = add.txtName.Text; item.Container = obj.GetAttribute("container"); if (!String.IsNullOrEmpty(add.SelectedMasterObject)) { item.MasterObjectName = add.SelectedMasterObject; Library.MasterObject mo = proj.MasterObjects.Find(a => a.Name == add.SelectedMasterObject); if (mo != null) { // recherche de l'objet container Library.IContainer objectContainer; if (proj.FindContainer(item.Container, out objectContainer, (List <Library.IContainer> containers, List <Library.IContent> objects, string searchName, out Library.IContainer found) => { return(this.MasterPage.SearchContainer(containers, objects, searchName, out found)); })) { item.Width = objectContainer.Width; item.Height = objectContainer.Height; item.ConstraintHeight = objectContainer.ConstraintHeight; item.ConstraintWidth = objectContainer.ConstraintWidth; } } } else if (add.Tool != null) { item = new Library.HTMLObject(add.Tool); item.Title = add.txtName.Text; item.Container = obj.GetAttribute("container"); // recherche de l'objet container Library.IContainer objectContainer; if (proj.FindContainer(item.Container, out objectContainer, (List <Library.IContainer> containers, List <Library.IContent> objects, string searchName, out Library.IContainer found) => { return(this.MasterPage.SearchContainer(containers, objects, searchName, out found)); })) { item.Width = objectContainer.Width; item.Height = objectContainer.Height; item.ConstraintHeight = objectContainer.ConstraintHeight; item.ConstraintWidth = objectContainer.ConstraintWidth; } } item.BelongsTo = this.mPage.Name; proj.Add(item, ""); this.mPage.Objects.Add(item); this.btnValidate1.SetDirty(); this.ReloadBrowser(); } } }
/// <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; } } }
public UXFramework.UXTree CreateTreeView(uint index, Library.Project p, Library.Node <string, Library.Accessor> projectTree) { Marshalling.MarshallingHash hash; List <UXFramework.UXRow> subtree = new List <UXFramework.UXRow>(); foreach (dynamic node in projectTree.Elements) { hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 20 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, { "ImageWidth", 16 }, { "ImageHeight", 16 } }); }); UXFramework.UXBox box1 = UXFramework.Creation.CreateBox(null, 16, 16); UXFramework.UXImage im2 = UXFramework.Creation.CreateImage(hash, "image", "left.png"); UXFramework.UXReadOnlyText ro = UXFramework.Creation.CreateReadOnlyText(null, "text", node.NodeValue); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 32 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, { "align", "left" }, { "Border", "2px solid Blue" } }); }); UXFramework.UXCell cLeaf1 = UXFramework.Creation.CreateCell(hash, box1); UXFramework.UXCell cLeaf3 = UXFramework.Creation.CreateCell(hash, im2); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Height", 25 }, { "Constraint-Height", "FIXED" }, { "align", "left" }, }); }); UXFramework.UXCell cLeaf2 = UXFramework.Creation.CreateCell(hash, ro); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "IsSelectable", true }, { "Background-Selectable", "#0B5395" }, { "Height", 25 }, { "Constraint-Height", "FIXED" }, }); }); UXFramework.UXRow row = UXFramework.Creation.CreateRow(3, hash, cLeaf1, cLeaf2, cLeaf3); row.SetUpdate(x => { Library.Node <string, Library.Accessor> n = x.GetProperty("ProjectRef").Value; n.IsSelected = true; currentNode = n; this.OpenProject(); }); subtree.Add(row); } if (projectTree.IsSelected) { foreach (Library.Node <string, Library.Accessor> sub in projectTree.SubNodes) { hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 20 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, { "ImageWidth", 16 }, { "ImageHeight", 16 } }); }); UXFramework.UXReadOnlyText ro1 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "+"); UXFramework.UXImage im2 = UXFramework.Creation.CreateImage(hash, "image", "left.png"); UXFramework.UXReadOnlyText ro = UXFramework.Creation.CreateReadOnlyText(null, "text", sub.NodeValue); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 32 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, { "Border", "2px solid Blue" } }); }); UXFramework.UXCell cNode1 = UXFramework.Creation.CreateCell(hash, ro1); UXFramework.UXCell cNode3 = UXFramework.Creation.CreateCell(hash, im2); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Height", 25 }, { "Constraint-Height", "FIXED" }, { "Disposition", "LEFT_MIDDLE" }, { "Border", "2px solid Blue" } }); }); UXFramework.UXCell cNode2 = UXFramework.Creation.CreateCell(hash, ro); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "IsSelectable", true }, { "Background-Selectable", "#0B5395" }, { "Height", 25 }, { "Constraint-Height", "FIXED" }, }); }); UXFramework.UXRow row = UXFramework.Creation.CreateRow(3, hash, cNode1, cNode2, cNode3); subtree.Add(row); } } hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 20 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, }); }); UXFramework.UXReadOnlyText ro2; if (projectTree.SubNodes.Count() > 0) { if (projectTree.IsSelected) { ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "-"); } else { ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "+"); } } else { ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", " "); } UXFramework.UXImage image2 = UXFramework.Creation.CreateImage(hash, "image", "left.png"); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Width", 32 }, { "Height", 25 }, { "Constraint-Width", "FIXED" }, { "Constraint-Height", "FIXED" }, { "Border", "2px solid Blue" } }); }); UXFramework.UXCell c3 = UXFramework.Creation.CreateCell(hash, ro2); UXFramework.UXCell c4 = UXFramework.Creation.CreateCell(hash, image2); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Height", 25 }, { "Constraint-Height", "FIXED" }, }); }); UXFramework.UXReadOnlyText roText = UXFramework.Creation.CreateReadOnlyText(hash, "text", projectTree.NodeValue); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Height", 25 }, { "Constraint-Height", "FIXED" }, { "Border", "2px solid Blue" }, { "Disposition", "LEFT_MIDDLE" }, }); }); UXFramework.UXCell c5 = UXFramework.Creation.CreateCell(hash, roText); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Id", "row" + index.ToString() }, { "IsSelectable", true }, { "IsClickable", true }, { "ProjectRef", projectTree }, { "Background-Selectable", "#0B5395" }, { "Background-Clickable", "#C8E3FB" }, { "Height", 25 }, { "Constraint-Height", "FIXED" }, { "Disposition", "LEFT_TOP" }, { "align", "left" }, { "valign", "top" } }); }); UXFramework.UXRow first = UXFramework.Creation.CreateRow(3, hash, c3, c5, c4); hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () => { return(new Dictionary <string, dynamic>() { { "Disposition", "LEFT_TOP" }, { "align", "left" }, { "valign", "top" }, { "Width", 220 }, { "Constraint-Width", "FIXED" }, { "ColumnCount", 3 }, { "LineCount", subtree.Count() + 1 }, }); }); UXFramework.UXTree tree = UXFramework.Creation.CreateTree(hash, "tree", first, subtree.ToArray()); return(tree); }