예제 #1
0
        /// <summary>
        /// Generate an HTML TABLE tag for actual website
        /// 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 GenerateProductionTable(Page refPage, MasterPage masterRefPage, List <MasterObject> objects, ParentConstraint parentConstraint)
        {
            OutputHTML output = new OutputHTML();
            CodeCSS    myCss  = new CodeCSS(this.CSS);
            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);

            myCss.Ids = "#" + myId;
            Routines.SetCSSPart(myCss, cs);

            string tag;

            this.Attributes.ToHTML("tr", myId, myCss, this.Events, output.CSS, out tag);
            output.HTML.Append(tag);

            foreach (VerticalZone vz in this.VerticalZones)
            {
                OutputHTML zone = vz.GenerateProductionTable(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());
            }
            output.HTML.Append("</tr>");

            output.JavaScript.Append(this.JavaScript.GeneratedCode);
            output.JavaScriptOnLoad.Append(this.JavaScriptOnLoad.GeneratedCode);
            return(output);
        }
        /// <summary>
        /// Static constructor from a css, the total number of lines and columns
        /// </summary>
        /// <param name="css">css</param>
        /// <param name="totalLines">total number of lines</param>
        /// <param name="totalColumns">total number of columns</param>
        /// <returns>Border constraint</returns>
        public static BorderConstraint CreateBorderConstraint(CodeCSS css, uint totalLines, uint totalColumns)
        {
            uint borderWidth  = (uint)(css.Border.Left + css.Border.Right + css.Padding.Left + css.Padding.Right + css.Margin.Left + css.Margin.Right);
            uint borderHeight = (uint)(css.Border.Top + css.Border.Bottom + css.Padding.Top + css.Padding.Bottom + css.Margin.Top + css.Margin.Bottom);

            return(new BorderConstraint(borderWidth, borderHeight, totalLines, totalColumns));
        }
        /// <summary>
        /// Remove css properties
        /// with this id
        /// </summary>
        /// <param name="id">id</param>
        public void RemoveCSS(string id)
        {
            CodeCSS css = this.List.Find(x => x.Ids == id);

            if (css != null)
            {
                this.List.Remove(css);
            }
        }
        /// <summary>
        /// Rename a css element
        /// </summary>
        /// <param name="currentId">current id</param>
        /// <param name="nextId">new id</param>
        public void RenamePrincipalCSS(string currentId, string nextId)
        {
            CodeCSS objCSS = this.List.Find(x => x.Ids == "#" + currentId);

            if (objCSS != null)
            {
                objCSS.Ids = "#" + nextId;
            }
        }
예제 #5
0
        /// <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>
 /// Print the html tag
 /// </summary>
 /// <param name="tag">tag</param>
 /// <param name="onclick">onclick event</param>
 /// <param name="name">name</param>
 /// <param name="title">title</param>
 /// <param name="css">css</param>
 /// <param name="htmlEvents">events</param>
 /// <param name="cssPart">css</param>
 /// <param name="output">output</param>
 /// <returns>true if success</returns>
 public bool ToHTML(string tag, string onclick, string name, string title, CodeCSS css, Events htmlEvents, StringBuilder cssPart, out string output)
 {
     this.SetValues();
     output  = "<";
     output += tag;
     if (!String.IsNullOrEmpty(onclick))
     {
         output += " " + onclick;
     }
     if (!String.IsNullOrEmpty(name))
     {
         output += " name=\"" + name + "\"";
     }
     output += " " + "title=\"" + title + "\"";
     if (this.HasId)
     {
         output += " id=\"" + this.Id + "\"";
     }
     if (this.HasClass)
     {
         output += " class=\"" + this.Class + "\"";
     }
     if (!this.HasId && !this.HasClass)
     {
         string cssCode = css.GenerateCSS(true, false, true);
         if (!String.IsNullOrEmpty(cssCode))
         {
             output += " style=\"" + cssCode.Replace(Environment.NewLine, "") + "\"";
         }
     }
     else
     {
         if (this.IsUsingClassForCSS)
         {
             css.Ids = "." + this.Class;
             cssPart.Append(css.GenerateCSS(true, true, true));
         }
         else
         {
             css.Ids = "#" + this.Id;
             cssPart.Append(css.GenerateCSS(true, true, true));
         }
     }
     if (htmlEvents.Count > 0)
     {
         output += " " + htmlEvents.ToHTMLString();
     }
     output += ">";
     return(true);
 }
예제 #7
0
        /// <summary>
        /// Generate design from a page and its objects
        /// </summary>
        /// <param name="refPage">page reference</param>
        /// <param name="objects">object list</param>
        /// <param name="parentConstraint">parent constraint</param>
        /// <returns>html output</returns>
        public OutputHTML GenerateDesign(Page refPage, List <MasterObject> objects, ParentConstraint parentConstraint)
        {
            if (this.IsMasterObject)
            {
                MasterObject selectedMo = Project.CurrentProject.MasterObjects.Find(mo => { return(mo.Name == this.MasterObjectName); });
                if (selectedMo != null)
                {
                    // calcul de la taille maximum de l'objet
                    ParentConstraint newParent = new ParentConstraint(this.Name, parentConstraint);
                    newParent.maximumWidth  = selectedMo.Width;
                    newParent.maximumHeight = selectedMo.Height;
                    Routines.MoveConstraint(newParent, selectedMo.Width, selectedMo.Height, selectedMo.ConstraintWidth, selectedMo.ConstraintHeight);
                    OutputHTML output = selectedMo.GenerateDesign(refPage, objects, newParent);
                    return(output);
                }
                else
                {
                    throw new KeyNotFoundException(String.Format(Localization.Strings.GetString("ExceptionMasterObjectNotExists"), this.MasterObjectName, this.Title));
                }
            }
            else
            {
                OutputHTML html  = new OutputHTML();
                CodeCSS    myCss = new CodeCSS(this.CSS);
                string     myId  = "obj" + Project.IncrementedTraceCounter.ToString();

                ParentConstraint newInfos = Routines.ComputeObject(parentConstraint, this);
                Routines.SetObjectDisposition(newInfos, myCss, newInfos);
                ConstraintSize cs = new ConstraintSize(newInfos.constraintWidth, newInfos.precedingWidth, newInfos.maximumWidth, newInfos.constraintHeight, newInfos.precedingHeight, newInfos.maximumHeight);
                myCss.Ids = "#" + myId;
                Routines.SetCSSPart(myCss, cs);
                string tag;
                this.Attributes.ToHTML("div", myId, myCss, this.Events, html.CSS, out tag);

                html.HTML.Append(tag);

                html.HTML.Append(this.GeneratedHTML);

                html.HTML.Append("</div>");

                html.AppendCSS(this.CSSList.GetListWithoutPrincipal(this.Id));
                html.JavaScript.Append(this.JavaScript.GeneratedCode);
                html.JavaScriptOnLoad.Append(this.JavaScriptOnLoad.GeneratedCode);
                return(html);
            }
        }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="code">css source</param>
 public CodeCSS(CodeCSS code)
 {
     this.Ids = ExtensionMethods.CloneThis(code.Ids);
     this.BackgroundImageURL = ExtensionMethods.CloneThis(code.BackgroundImageURL);
     this.BackgroundColor    = ExtensionMethods.CloneThis(code.BackgroundColor);
     this.BorderLeftColor    = ExtensionMethods.CloneThis(code.BorderLeftColor);
     this.BorderRightColor   = ExtensionMethods.CloneThis(code.BorderRightColor);
     this.BorderTopColor     = ExtensionMethods.CloneThis(code.BorderTopColor);
     this.BorderBottomColor  = ExtensionMethods.CloneThis(code.BorderBottomColor);
     this.ForegroundColor    = ExtensionMethods.CloneThis(code.ForegroundColor);
     this.Padding            = ExtensionMethods.CloneThis(code.Padding);
     this.Margin             = ExtensionMethods.CloneThis(code.Margin);
     this.Border             = ExtensionMethods.CloneThis(code.Border);
     foreach (string key in code.Body.AllKeys)
     {
         this.Body.Add(key, code.Body[key]);
     }
 }
 /// <summary>
 /// Add a new CSS Properties
 /// </summary>
 /// <param name="props"></param>
 public void AddCSS(CodeCSS props)
 {
     this.List.Add(props);
 }
        /// <summary>
        /// Static constructor from a parent border constraint, a css, the number of lines and columns
        /// </summary>
        /// <param name="parent">parent constraint</param>
        /// <param name="css">css</param>
        /// <param name="countLines">number of lines</param>
        /// <param name="countColumns">number of columns</param>
        /// <returns>Border constraint</returns>
        public static BorderConstraint CreateBorderConstraint(BorderConstraint parent, CodeCSS css, uint countLines, uint countColumns)
        {
            uint borderWidth  = (uint)(css.Border.Left + css.Border.Right + css.Padding.Left + css.Padding.Right + css.Margin.Left + css.Margin.Right);
            uint borderHeight = (uint)(css.Border.Top + css.Border.Bottom + css.Padding.Top + css.Padding.Bottom + css.Margin.Top + css.Margin.Bottom);

            return(new BorderConstraint(parent, borderWidth, borderHeight, countLines, countColumns));
        }
예제 #11
0
        /// <summary>
        /// A master page has a thumbnail visual
        /// </summary>
        /// <returns>html output</returns>
        public OutputHTML GenerateThumbnail()
        {
            Page page = new Page();

            if (this.ConstraintWidth == EnumConstraint.RELATIVE || this.ConstraintHeight == EnumConstraint.RELATIVE)
            {
                DesignPage config = new DesignPage();
                config.constraintWidth  = this.ConstraintWidth;
                config.constraintHeight = this.ConstraintHeight;
                config.width            = this.Width;
                config.height           = this.Height;
                CodeCSS cssThumbnail = new CodeCSS(this.CSS);
                cssThumbnail.Body.Add("zoom", "0.4");
                config.cssList          = ExtensionMethods.CloneThis(this.CSSList);
                config.cssOnFile        = false;
                config.cssFile          = "";
                config.events           = this.Events;
                config.javascriptPart   = this.JavaScript;
                config.javascriptOnFile = false;
                config.javascriptFile   = "";
                config.onload           = this.JavaScriptOnLoad;
                config.zones            = this.HorizontalZones;
                config.includeContainer = false;
                return(Routines.GenerateDesignPageTable(page, this, config));
            }
            else
            {
                // il faut décider si l'on utilise une table ou des div
                // s'il existe une colonne dont countLines > countLines de l'horizontal alors on utilise une table
                // sinon on peut utiliser des div
                bool cannotUseDiv = false;
                foreach (HorizontalZone hz in this.HorizontalZones)
                {
                    bool sup = false;
                    foreach (VerticalZone vz in hz.VerticalZones)
                    {
                        if (vz.CountLines < hz.CountLines)
                        {
                            sup = true;
                        }
                    }
                    if (sup)
                    {
                        cannotUseDiv = true;
                        break;
                    }
                }
                OutputHTML html;
                DesignPage config = new DesignPage();
                config.constraintWidth  = this.ConstraintWidth;
                config.constraintHeight = this.ConstraintHeight;
                config.width            = this.Width;
                config.height           = this.Height;
                CodeCSS cssThumbnail = new CodeCSS(this.CSS);
                cssThumbnail.Body.Add("zoom", "0.4");
                this.CSSList.AddCSS(cssThumbnail);
                config.cssList          = this.CSSList;
                config.cssOnFile        = false;
                config.cssFile          = "";
                config.events           = this.Events;
                config.javascriptPart   = this.JavaScript;
                config.javascriptOnFile = false;
                config.javascriptFile   = "";
                config.onload           = this.JavaScriptOnLoad;
                config.zones            = this.HorizontalZones;
                config.includeContainer = false;
                if (cannotUseDiv)
                {
                    html = Routines.GenerateDesignPageTable(page, this, config);
                }
                else
                {
                    html = Routines.GenerateDesignPageDIV(page, this, config);
                }
                return(html);
            }
        }