/// <summary> /// Insert vertical areas /// </summary> /// <param name="vZones">vertical area list</param> /// <param name="content">content</param> public void InsertVerticalZones(List <VerticalZone> vZones, RefObject content) { bool added = false; for (int index = 0; index < vZones.Count; ++index) { if (index > this.indexX) { VerticalZone newV = new VerticalZone(); newV.ConstraintHeight = EnumConstraint.FIXED; newV.ConstraintWidth = EnumConstraint.FIXED; newV.Width = (this.sizeX * (uint)Granne.TrueRectangle.Width + this.shiftRight - this.shiftLeft); newV.Height = (this.sizeY * (uint)Granne.TrueRectangle.Height + this.shiftBottom - this.shiftTop); content.DirectObject.Container = newV.Name; vZones.Insert(index, newV); added = true; break; } } if (!added) { VerticalZone newV = new VerticalZone(); newV.ConstraintHeight = EnumConstraint.FIXED; newV.ConstraintWidth = EnumConstraint.FIXED; newV.Width = (this.sizeX * (uint)Granne.TrueRectangle.Width + this.shiftRight - this.shiftLeft); newV.Height = (this.sizeY * (uint)Granne.TrueRectangle.Height + this.shiftBottom - this.shiftTop); if (content != null) { content.DirectObject.Container = newV.Name; } vZones.Add(newV); } }
/// <summary> /// Render a single cell of a table /// </summary> /// <param name="cell">cell to render</param> public void RenderControl(UXCell cell) { VerticalZone v = new VerticalZone(); cell.Get("Width", (s, x) => { v.Width = Convert.ToUInt32(x.Value); }); cell.Get("Height", (s, x) => { v.Height = Convert.ToUInt32(x.Value); }); RenderCSSProperties(cell, v.CSS); cell.Get("Disposition", (s, x) => { v.Disposition = Enum.Parse(typeof(Disposition), x.Value); }); cell.Get("Constraint-Width", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { v.ConstraintWidth = c; } else { v.ConstraintWidth = EnumConstraint.AUTO; } }); cell.Get("Constraint-Height", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { v.ConstraintHeight = c; } else { v.ConstraintHeight = EnumConstraint.AUTO; } }); v.CountLines = 1; v.CountColumns = 1; this.currentObject.VerticalZones.Add(v); string previousContainer = this.currentContainer; dynamic previousObject = this.currentObject; this.currentContainer = v.Name; this.currentObject = this.currentMasterObject; foreach (IUXObject obj in cell.Children) { RenderControl(obj); } this.currentContainer = previousContainer; this.currentObject = previousObject; }
/// <summary> /// Generate an HTML DIV tag for design /// a given master page generates the page /// a page contains master objects related /// restricted objects in page are computed equally /// </summary> /// <param name="refPage">page reference</param> /// <param name="masterRefPage">master page reference</param> /// <param name="objects">master objects list</param> /// <param name="parentConstraint">parent constraint</param> /// <returns>html output</returns> public OutputHTML GenerateDesignDIV(Page refPage, MasterPage masterRefPage, List <MasterObject> objects, ParentConstraint parentConstraint) { OutputHTML output = new OutputHTML(); CodeCSS myCss = new CodeCSS(this.CSS); if (this.VerticalZones.Count > 0) { string myId = "horiz" + Project.IncrementedTraceCounter.ToString(); // compute size ParentConstraint newInfos = Routines.ComputeHorizontalZone(parentConstraint, this); ConstraintSize cs = new ConstraintSize(newInfos.constraintWidth, newInfos.precedingWidth, newInfos.maximumWidth, newInfos.constraintHeight, newInfos.precedingHeight, newInfos.maximumHeight); // set CSS part myCss.Ids = "#" + myId; Routines.SetCSSPart(myCss, cs); string tag; this.Attributes.ToHTML("div", myId, myCss, this.Events, output.CSS, out tag); output.HTML.Append(tag); List <VerticalZone> .Enumerator e = this.VerticalZones.GetEnumerator(); VerticalZone lastZone = null; if (e.MoveNext()) { do { if (lastZone != null) { OutputHTML zone = lastZone.GenerateDesignDIV(refPage, masterRefPage, objects, newInfos); output.HTML.Append(zone.HTML.ToString()); output.CSS.Append(zone.CSS.ToString()); output.JavaScript.Append(zone.JavaScript.ToString()); output.JavaScriptOnLoad.Append(zone.JavaScriptOnLoad.ToString()); } lastZone = e.Current; } while (e.MoveNext()); } if (lastZone != null) { OutputHTML last = lastZone.GenerateDesignDIV(refPage, masterRefPage, objects, newInfos); output.HTML.Append(last.HTML.ToString()); output.CSS.Append(last.CSS.ToString()); output.JavaScript.Append(last.JavaScript.ToString()); output.JavaScriptOnLoad.Append(last.JavaScriptOnLoad.ToString()); } output.HTML.Append("</div>"); output.JavaScript.Append(this.JavaScript.GeneratedCode); output.JavaScriptOnLoad.Append(this.JavaScriptOnLoad.GeneratedCode); } return(output); }
/// <summary> /// Construct all zones and compute total size /// </summary> /// <param name="c">column count</param> /// <param name="l">list count</param> /// <param name="list">list of rectangle the user supplied</param> /// <param name="hList">horizontal zones list</param> /// <param name="width">width</param> /// <param name="height">height</param> /// <param name="constraintWidth">constraint width</param> /// <param name="constraintHeight">constraint height</param> public static void MakeZones(uint c, uint l, List <AreaSizedRectangle> list, List <HorizontalZone> hList, uint width, uint height, EnumConstraint constraintWidth, EnumConstraint constraintHeight) { AreaSizedRectangle[,] indexes = new AreaSizedRectangle[c, l]; for (int index = 0; index < list.Count; ++index) { AreaSizedRectangle current = list[index]; indexes[current.StartWidth, current.StartHeight] = current; } double deltaWidth = width / (double)c; double deltaHeight = height / (double)l; // ranger les données dans la master page for (int pos_ligne = 0; pos_ligne < l; ++pos_ligne) { HorizontalZone hz; hz = new HorizontalZone(); hz.ConstraintWidth = constraintWidth; hz.ConstraintHeight = EnumConstraint.AUTO; hz.Width = width; int maxCountLines; uint maxHeight; maxHeight = 0; maxCountLines = 0; for (int pos_colonne = 0; pos_colonne < c; ++pos_colonne) { AreaSizedRectangle current = indexes[pos_colonne, pos_ligne]; if (current != null) { VerticalZone vz = new VerticalZone(); vz.CountLines = current.CountHeight; vz.CountColumns = current.CountWidth; vz.Width = Convert.ToUInt32(deltaWidth * current.CountWidth); vz.Height = Convert.ToUInt32(deltaHeight * current.CountHeight); vz.ConstraintWidth = constraintWidth; vz.ConstraintHeight = constraintHeight; hz.VerticalZones.Add(vz); if (maxCountLines < vz.CountLines) { maxCountLines = vz.CountLines; } if (maxHeight < vz.Height) { maxHeight = vz.Height; } } } hz.CountLines = maxCountLines; hz.Height = maxHeight; hList.Add(hz); } }
/// <summary> /// Render a selectable table /// </summary> /// <param name="data"></param> public void RenderControl(UXViewSelectableDataTable data) { MasterObject mo = new MasterObject(); RenderCSSProperties(data, mo.CSS); mo.Name = data.Name + "_outer_masterObject"; mo.Width = 100; mo.Height = 100; mo.ConstraintWidth = EnumConstraint.RELATIVE; mo.ConstraintHeight = EnumConstraint.RELATIVE; mo.CountColumns = 1; mo.CountLines = 1; mo.HTMLBefore = "<div id='" + mo.Name + "_in' onmouseout='javascript:LeaveArrow();'>"; mo.HTMLAfter = "</div>"; HorizontalZone h = new HorizontalZone(); h.ConstraintWidth = EnumConstraint.RELATIVE; h.ConstraintHeight = EnumConstraint.RELATIVE; h.Width = 100; h.Height = 100; h.CountLines = 1; mo.HorizontalZones.Add(h); VerticalZone v = new VerticalZone(); v.Width = 100; v.Height = 100; data.Get("Disposition", (s, x) => { v.Disposition = Enum.Parse(typeof(Disposition), x.Value); }); v.ConstraintWidth = EnumConstraint.RELATIVE; v.ConstraintHeight = EnumConstraint.RELATIVE; v.CountLines = 1; v.CountColumns = 1; h.VerticalZones.Add(v); this.project.MasterObjects.Add(mo); HTMLObject obj = new HTMLObject(mo); obj.Container = this.currentContainer; this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); currentContainer = mo.HorizontalZones[0].VerticalZones[0].Name; RenderControl(data as UXViewDataTable); }
/// <summary> /// Generate design /// </summary> /// <returns>output</returns> public OutputHTML GenerateDesign() { Page p = new Page(); MasterPage mp = new MasterPage(); HorizontalZone h = new HorizontalZone(); mp.HorizontalZones.Add(h); VerticalZone z = new VerticalZone(); h.VerticalZones.Add(z); ParentConstraint parent = new ParentConstraint(); parent.border = BorderConstraint.CreateBorderConstraint(this.CSS, (uint)this.CountLines, this.TotalCountColumns); return(Routines.GenerateProductionAny(GenerateProductionDIV(p, mp, parent))); }
/// <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)); }