コード例 #1
0
        private void menuTransformToolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode t = this.prv_currentNodeContext;

            if (t != null)
            {
                if (t.Tag != null)
                {
                    if (t.Tag is Library.MasterObject)
                    {
                        DialogResult dr = MessageBox.Show(Translate("TransformTool"), Translate("TransformToolTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == System.Windows.Forms.DialogResult.Yes)
                        {
                            HTMLTool     tool = new HTMLTool();
                            MasterObject mo   = t.Tag as MasterObject;
                            OutputHTML   html = mo.GenerateProduction();
                            tool.HTML                  = html.HTML.ToString();
                            tool.JavaScript.Code       = html.JavaScript.ToString();
                            tool.JavaScriptOnLoad.Code = html.JavaScriptOnLoad.ToString();
                            string error;
                            CSSValidation.CSSValidate(html.CSS.ToString(), false, tool.CSSList.List, out error);
                            tool.Width            = mo.Width;
                            tool.Height           = mo.Height;
                            tool.ConstraintWidth  = mo.ConstraintWidth;
                            tool.ConstraintHeight = mo.ConstraintHeight;
                            Project.CurrentProject.Add(tool, "generated/" + mo.Title);
                            Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString());
                            Project.CurrentProject.ReloadProject();
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Generate actual website from a page and its objects
        /// </summary>
        /// <param name="refPage">page reference</param>
        /// <param name="masterRefPage">master page reference</param>
        /// <param name="objects">object list</param>
        /// <param name="parentConstraint">parent constraint</param>
        /// <returns>html output</returns>
        public OutputHTML GenerateProduction(Page refPage, MasterPage masterRefPage, 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);
                    Routines.MoveConstraint(newParent, selectedMo.Width, selectedMo.Height, selectedMo.ConstraintWidth, selectedMo.ConstraintHeight);
                    OutputHTML output = selectedMo.GenerateProduction(refPage, masterRefPage, 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);
            }
        }