/// <summary> /// Insert horizontal areas /// </summary> /// <param name="hZones">horizontal area list</param> /// <param name="content">content</param> public void InsertHorizontalZones(List <HorizontalZone> hZones, RefObject content) { bool added = false; for (int index = 0; index < hZones.Count; ++index) { if (index > this.indexX) { HorizontalZone newH = new HorizontalZone(); newH.ConstraintHeight = EnumConstraint.FIXED; newH.ConstraintWidth = EnumConstraint.FIXED; newH.Width = (this.sizeX * (uint)Granne.TrueRectangle.Width + this.shiftRight - this.shiftLeft); newH.Height = (this.sizeY * (uint)Granne.TrueRectangle.Height + this.shiftBottom - this.shiftTop); this.InsertVerticalZones(newH.VerticalZones, content); hZones.Insert(index, newH); added = true; break; } } if (!added) { HorizontalZone newH = new HorizontalZone(); newH.ConstraintHeight = EnumConstraint.FIXED; newH.ConstraintWidth = EnumConstraint.FIXED; newH.Width = (this.sizeX * (uint)Granne.TrueRectangle.Width + this.shiftRight - this.shiftLeft); newH.Height = (this.sizeY * (uint)Granne.TrueRectangle.Height + this.shiftBottom - this.shiftTop); this.InsertVerticalZones(newH.VerticalZones, content); hZones.Add(newH); } }
/// <summary> /// Computes all vertical areas from an horizontal area /// </summary> /// <param name="p">project with related elements</param> /// <param name="hz">horizontal zone</param> /// <param name="objects">list of html objects</param> /// <returns></returns> public static AdjustementSize ComputeHorizontalZones(Project p, HorizontalZone hz, List <HTMLObject> objects) { SizeCompute.CheckConstraints(hz); foreach (VerticalZone vz in hz.VerticalZones) { AdjustementSize ads = SizeCompute.ComputeVerticalZones(p, vz, objects); } return(new AdjustementSize(hz.ConstraintWidth, hz.ConstraintHeight, hz.Width, hz.Height)); }
/// <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> /// 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> /// Copy Constructor /// </summary> /// <param name="hz">horizontal zone source</param> private HorizontalZone(HorizontalZone hz) { int val = Project.CurrentProject.IncrementedCounter; this.Set(automaticNameName, String.Format("horiz{0}", val)); this.Set(automaticIdName, String.Format("idHoriz{0}", val)); this.ConstraintWidth = hz.ConstraintWidth; this.ConstraintHeight = hz.ConstraintHeight; this.Width = hz.Width; this.Height = hz.Height; this.CountLines = hz.CountLines; foreach (VerticalZone vz in hz.VerticalZones) { this.VerticalZones.Add(vz.Clone() as VerticalZone); } this.Set(eventsName, hz.Events.Clone()); this.Set(javascriptName, hz.JavaScript.Clone()); this.Set(javascriptOnloadName, hz.JavaScriptOnLoad.Clone()); this.Set(cssName, hz.CSS.Clone()); this.Set(attributesName, hz.Attributes.Clone()); this.Attributes.RenameId(this.Id); this.Attributes.HasId = false; }
/// <summary> /// Computes a constraint adjustement size /// for an horizontal area /// </summary> /// <param name="hz">Horizontal area</param> /// <returns>an adjustement size for horizontal area</returns> private static AdjustementSize CheckConstraints(HorizontalZone hz) { IEnumerator <VerticalZone> e = hz.VerticalZones.GetEnumerator(); int nCol = 0; bool aligned = true; if (e.MoveNext()) { nCol = e.Current.CountLines; while (e.MoveNext()) { if (nCol != e.Current.CountLines) { aligned = false; break; } } } uint totalWidth = 0; uint maxHeight = 0; AdjustementSize container = new AdjustementSize(hz.ConstraintWidth, hz.ConstraintHeight, hz.Width, hz.Height); e.Reset(); while (e.MoveNext()) { int nonClientWidth = e.Current.CSS.Padding.Left + e.Current.CSS.Padding.Right + e.Current.CSS.Border.Left + e.Current.CSS.Border.Right + e.Current.CSS.Margin.Left + e.Current.CSS.Margin.Right; int nonClientHeight = e.Current.CSS.Padding.Top + e.Current.CSS.Padding.Bottom + e.Current.CSS.Border.Top + e.Current.CSS.Border.Bottom + e.Current.CSS.Margin.Top + e.Current.CSS.Margin.Bottom; uint width = e.Current.Width; if (nonClientWidth > 0) { width += Convert.ToUInt32(nonClientWidth); } else if (width > Convert.ToUInt32(nonClientWidth)) { width -= Convert.ToUInt32(nonClientWidth); } uint height = e.Current.Height; if (nonClientHeight > 0) { height += Convert.ToUInt32(nonClientHeight); } else if (height > Convert.ToUInt32(nonClientHeight)) { height -= Convert.ToUInt32(nonClientHeight); } // set information AdjustementSize content = new AdjustementSize(e.Current.ConstraintWidth, e.Current.ConstraintHeight, width, height); // compute SizeCompute.CheckConstraints(container, content); // update information switch (content.ConstraintWidth) { case EnumConstraint.FIXED: totalWidth += content.Width; break; case EnumConstraint.RELATIVE: break; } switch (content.ConstraintHeight) { case EnumConstraint.FIXED: if (maxHeight < content.Height) { maxHeight = content.Height; } break; case EnumConstraint.RELATIVE: break; } e.Current.ConstraintWidth = content.ConstraintWidth; e.Current.ConstraintHeight = content.ConstraintHeight; } hz.ConstraintWidth = container.ConstraintWidth; hz.ConstraintHeight = container.ConstraintHeight; hz.Width = totalWidth; hz.Height = maxHeight; if (!aligned) { hz.ConstraintHeight = EnumConstraint.AUTO; } return(new AdjustementSize(hz.ConstraintWidth, hz.ConstraintHeight, hz.Width, hz.Height)); }
/// <summary> /// Clone this object /// </summary> /// <returns>cloned object</returns> public object Clone() { HorizontalZone newObject = new HorizontalZone(this); return(newObject); }