/// <summary> /// Remove a html object /// </summary> /// <param name="o">htmlObject</param> public void Remove(HTMLObject o) { Accessor a = new Accessor(Project.InstancesName, o.Unique); this.Hierarchy.Find(Project.InstancesName).Remove(a); this.Instances.Remove(o); if (o.BelongsTo != null) { // ce serait un master object MasterObject mo = this.MasterObjects.Find(x => { return(x.Name == o.BelongsTo); }); if (mo != null) { mo.Objects.Remove(o); } else { Page p = this.Pages.Find(x => { return(x.Name == o.BelongsTo); }); if (p != null) { p.Objects.Remove(o); } else { // il appartient plutot à un tool MasterPage mp = this.MasterPages.Find(x => { return(x.Name == o.BelongsTo); }); if (mp != null) { mp.Objects.Remove(o); } } } } }
/// <summary> /// Copy properties /// </summary> /// <param name="obj">html object</param> public void CopyProperties(HTMLObject obj) { obj.Title = this.Name; if (this.Width >= 0) { obj.ConstraintWidth = EnumConstraint.FIXED; obj.Width = (uint)this.Width; } else { obj.ConstraintWidth = EnumConstraint.AUTO; obj.Width = 0; } if (this.Height >= 0) { obj.ConstraintHeight = EnumConstraint.FIXED; obj.Height = (uint)this.Height; } else { obj.ConstraintHeight = EnumConstraint.AUTO; obj.Height = 0; } obj.CSS.Padding = new Rectangle(this.WidthPadding, this.WidthPadding, this.HeightPadding, this.HeightPadding); obj.CSS.Border = new Rectangle(this.WidthBorder, this.WidthBorder, this.HeightBorder, this.HeightBorder); obj.CSS.BackgroundColor = new CSSColor(this.Background); obj.CSS.BorderBottomColor = obj.CSS.BorderLeftColor = obj.CSS.BorderRightColor = obj.CSS.BorderTopColor = new CSSColor(this.Border); }
/// <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> /// Copy constructor /// </summary> /// <param name="obj">object to copy</param> private HTMLObject(HTMLObject obj) { int val = Project.CurrentProject.IncrementedCounter; this.Set(automaticNameName, String.Format("object{0}", val)); this.Set(automaticIdName, String.Format("idObject{0}", val)); this.Set(toolName, ExtensionMethods.CloneThis(obj.ToolFullPath)); this.Set(masterObjectName, ExtensionMethods.CloneThis(obj.MasterObjectName)); this.Width = obj.Width; this.Height = obj.Height; this.ConstraintWidth = obj.ConstraintWidth; this.ConstraintHeight = obj.ConstraintHeight; this.Title = ExtensionMethods.CloneThis(obj.Title); this.Container = ExtensionMethods.CloneThis(obj.Container); this.HTML = ExtensionMethods.CloneThis(obj.HTML); this.Set(eventsName, obj.Events.Clone()); this.Set(javascriptName, obj.JavaScript.Clone()); this.Set(javascriptOnloadName, obj.JavaScriptOnLoad.Clone()); this.Set(cssListName, new CSSList((from CodeCSS c in this.CSSList.List select c.Clone() as CodeCSS).ToList())); this.CSSList.RenamePrincipalCSS(obj.Id, this.Id); this.Set(attributesName, obj.Attributes.Clone()); this.Attributes.RenameId(this.Id); this.Attributes.HasId = false; }
/// <summary> /// Add an instance /// given a specific path to organize project's element /// </summary> /// <param name="i">instance</param> /// <param name="path">path</param> public void Add(HTMLObject i, string path) { this.Instances.Add(i); string u = this.Unique.ComputeNewString(); i.Unique = u; Accessor a = new Accessor(Project.InstancesName, u); this.Hierarchy.Find(Project.InstancesName).Find(path.Split('/')).AddLeaf(a); }
/// <summary> /// Create a RefObject that contains what is your construction /// for this granne /// </summary> /// <param name="proj">project to use</param> /// <returns>a RefObject class</returns> public RefObject CreateRefObject(Project proj) { HTMLObject obj = Project.InstanciateSculptureTool(proj, this.model); if (obj != null) { return(new RefObject(RefObject.Tool, obj.Name, obj)); } else { return(null); } }
/// <summary> /// Constructor for an accessor with an instance /// </summary> /// <param name="o">instance list</param> /// <param name="u">unique name to search</param> public Accessor(List <HTMLObject> o, string u) { HTMLObject h = o.Find(x => x.Unique == u); if (h != null) { this.Set(dataTypeName, Project.InstancesName); this.Set(uniqueName, u); } else { throw new IndexOutOfRangeException(); } }
/// <summary> /// Computes a constraint adjustement size /// for a vertical area /// </summary> /// <param name="p">project with related elements</param> /// <param name="vz">vertical area</param> /// <param name="objects">list of html objects</param> /// <returns>an adjustement size for vertical area</returns> public static AdjustementSize ComputeVerticalZones(Project p, VerticalZone vz, List <HTMLObject> objects) { HTMLObject found = objects.Find(a => a.Container == vz.Name); if (found != null) { int nonClientWidth = found.CSS.Padding.Left + found.CSS.Padding.Right + found.CSS.Border.Left + found.CSS.Border.Right + found.CSS.Margin.Left + found.CSS.Margin.Right; int nonClientHeight = found.CSS.Padding.Top + found.CSS.Padding.Bottom + found.CSS.Border.Top + found.CSS.Border.Bottom + found.CSS.Margin.Top + found.CSS.Margin.Bottom; uint width = found.Width; if (nonClientWidth > 0) { width += Convert.ToUInt32(nonClientWidth); } else if (width > Convert.ToUInt32(nonClientWidth)) { width -= Convert.ToUInt32(nonClientWidth); } uint height = found.Height; if (nonClientHeight > 0) { height += Convert.ToUInt32(nonClientHeight); } else if (height > Convert.ToUInt32(nonClientHeight)) { height -= Convert.ToUInt32(nonClientHeight); } // set information AdjustementSize container = new AdjustementSize(vz.ConstraintWidth, vz.ConstraintHeight, vz.Width, vz.Height); AdjustementSize content = new AdjustementSize(found.ConstraintWidth, found.ConstraintHeight, width, height); // compute SizeCompute.CheckConstraints(container, content); // update information vz.ConstraintWidth = container.ConstraintWidth; vz.ConstraintHeight = container.ConstraintHeight; vz.Width = container.Width; vz.Height = container.Height; found.ConstraintWidth = content.ConstraintWidth; found.ConstraintHeight = content.ConstraintHeight; } return(new AdjustementSize(vz.ConstraintWidth, vz.ConstraintHeight, vz.Width, vz.Height)); }
/// <summary> /// Default constructor /// </summary> /// <param name="objectType">an object type name</param> /// <param name="instanceName">an instance name</param> /// <param name="source">a source object</param> public RefObject(string objectType, string instanceName, HTMLObject source) { this.Set(objectTypeName, objectType); this.Set(titleName, instanceName); this.Set(directObjectName, source); }
/// <summary> /// Create an adjustement size agains a html object /// </summary> /// <param name="p">project to get relative object contained from given html object</param> /// <param name="obj">Html object related</param> /// <returns>adjustement size</returns> public static AdjustementSize ComputeHTMLObject(Project p, HTMLObject obj) { if (obj.IsMasterObject) { MasterObject mo = p.MasterObjects.Find(a => a.Name == obj.MasterObjectName); if (mo != null) { int nonClientWidth = mo.CSS.Padding.Left + mo.CSS.Padding.Right + mo.CSS.Border.Left + mo.CSS.Border.Right + mo.CSS.Margin.Left + mo.CSS.Margin.Right; int nonClientHeight = mo.CSS.Padding.Top + mo.CSS.Padding.Bottom + mo.CSS.Border.Top + mo.CSS.Border.Bottom + mo.CSS.Margin.Top + mo.CSS.Margin.Bottom; uint width = mo.Width; if (nonClientWidth > 0) { width += Convert.ToUInt32(nonClientWidth); } else if (width > Convert.ToUInt32(nonClientWidth)) { width -= Convert.ToUInt32(nonClientWidth); } uint height = mo.Height; if (nonClientHeight > 0) { height += Convert.ToUInt32(nonClientHeight); } else if (height > Convert.ToUInt32(nonClientHeight)) { height -= Convert.ToUInt32(nonClientHeight); } // set information AdjustementSize container = new AdjustementSize(obj.ConstraintWidth, obj.ConstraintHeight, obj.Width, obj.Height); AdjustementSize content = new AdjustementSize(mo.ConstraintWidth, mo.ConstraintHeight, width, height); // compute SizeCompute.CheckConstraints(container, content); // update information obj.ConstraintWidth = container.ConstraintWidth; obj.ConstraintHeight = container.ConstraintHeight; obj.Width = container.Width; obj.Height = container.Height; mo.ConstraintWidth = content.ConstraintWidth; mo.ConstraintHeight = content.ConstraintHeight; } } else { int nonClientWidth = obj.CSS.Padding.Left + obj.CSS.Padding.Right + obj.CSS.Border.Left + obj.CSS.Border.Right + obj.CSS.Margin.Left + obj.CSS.Margin.Right; int nonClientHeight = obj.CSS.Padding.Top + obj.CSS.Padding.Bottom + obj.CSS.Border.Top + obj.CSS.Border.Bottom + obj.CSS.Margin.Top + obj.CSS.Margin.Bottom; uint width = obj.Width; if (nonClientWidth > 0) { width += Convert.ToUInt32(nonClientWidth); } else if (width > Convert.ToUInt32(nonClientWidth)) { width -= Convert.ToUInt32(nonClientWidth); } uint height = obj.Height; if (nonClientHeight > 0) { height += Convert.ToUInt32(nonClientHeight); } else if (height > Convert.ToUInt32(nonClientHeight)) { height -= Convert.ToUInt32(nonClientHeight); } // set information AdjustementSize container = new AdjustementSize(obj.ConstraintWidth, obj.ConstraintHeight, obj.Width, obj.Height); AdjustementSize content = new AdjustementSize(obj.ConstraintWidth, obj.ConstraintHeight, width, height); // compute SizeCompute.CheckConstraints(container, content); // update information obj.ConstraintWidth = container.ConstraintWidth; obj.ConstraintHeight = container.ConstraintHeight; obj.Width = container.Width; obj.Height = container.Height; obj.ConstraintWidth = content.ConstraintWidth; obj.ConstraintHeight = content.ConstraintHeight; } return(new AdjustementSize(obj.ConstraintWidth, obj.ConstraintHeight, obj.Width, obj.Height)); }
/// <summary> /// Clone this object /// </summary> /// <returns>cloned object</returns> public object Clone() { HTMLObject newObject = new HTMLObject(this); return(newObject); }