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();
                        }
                    }
                }
            }
        }
 private void GenerateProduction(Library.Project f, string destinationDirectory)
 {
     ConfigDirectories.AddProductionFolder(f.Title, "", destinationDirectory);
     foreach (Page p in f.Pages)
     {
         OutputHTML html = p.GenerateProduction();
         ConfigDirectories.AddProductionFolder(f.Title, p.Folder, destinationDirectory);
         FileStream fs = new FileStream(Path.Combine(destinationDirectory,
                                                     ConfigDirectories.RemoveLeadSlash(p.Folder),
                                                     ConfigDirectories.RemoveLeadSlash(p.Name)),
                                        FileMode.Create);
         StreamWriter sw = new StreamWriter(fs);
         sw.WriteLine(html.HTML.ToString());
         sw.Close();
         sw.Dispose();
         fs.Close();
         fs.Dispose();
     }
     foreach (Library.File s in f.Files)
     {
         ConfigDirectories.AddProductionFile(f.Title,
                                             Path.Combine(s.Folder, s.FileName),
                                             Path.Combine(ConfigDirectories.GetBuildFolder(f.Title), s.Folder, s.FileName), destinationDirectory);
     }
 }
        /// <summary>
        /// Render a window
        /// </summary>
        /// <param name="window">window to render</param>
        public void RenderControl(UXWindow window)
        {
            string previous;

            Projects.Activate(projectName, out previous);
            Page p = new Page();

            window.Get("Constraint-Width", (x, y) =>
            {
                EnumConstraint c;
                if (Enum.TryParse <EnumConstraint>(y.Value, out c))
                {
                    p.ConstraintWidth = c;
                }
                else
                {
                    p.ConstraintWidth = EnumConstraint.AUTO;
                }
            });
            window.Get("Constraint-Height", (x, y) =>
            {
                EnumConstraint c;
                if (Enum.TryParse <EnumConstraint>(y.Value, out c))
                {
                    p.ConstraintHeight = c;
                }
                else
                {
                    p.ConstraintHeight = EnumConstraint.AUTO;
                }
            });
            window.Get("Disposition", (s, v) =>
            {
                p.Disposition = Enum.Parse(typeof(Disposition), v.Value);
            });
            window.Get("Width", (x, y) => { p.Width = Convert.ToUInt32(y.Value); });
            window.Get("Height", (x, y) => { p.Height = Convert.ToUInt32(y.Value); });
            MasterPage mp = new MasterPage();

            RenderCSSProperties(window, mp.CSS);
            mp.Name             = "masterPage_" + window.Name;
            mp.Width            = 100;
            mp.Height           = 100;
            mp.ConstraintWidth  = EnumConstraint.RELATIVE;
            mp.ConstraintHeight = EnumConstraint.RELATIVE;
            mp.CountColumns     = 1;
            mp.CountLines       = 1;
            mp.Meta             = "<meta name='viewport' content='initial-scale=1, maximum-scale=1, user-scalable=no'/>";


            HTMLTool   def = this.project.Tools.Find(x => x.Path == "html" && x.Name == "default");
            HTMLObject obj = new HTMLObject(def);

            obj.Container = "globalContainer";
            mp.Objects.Add(obj);
            this.project.Instances.Add(obj);

            List <AreaSizedRectangle> rects = new List <AreaSizedRectangle>();
            AreaSizedRectangle        sz    = new AreaSizedRectangle(0, 0, 1, 1, 0, 0);

            rects.Add(sz);
            mp.MakeZones(rects);
            this.project.MasterPages.Add(mp);

            p.MasterPageName = mp.Name;
            p.Name           = window.FileName;

            currentPage       = p;
            currentMasterPage = mp;
            currentContainer  = mp.HorizontalZones[0].VerticalZones[0].Name;
            currentObject     = currentPage;

            foreach (IUXObject child in window.Children)
            {
                RenderControl(child);
            }

            using (FileStream fs = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p.Name), FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    OutputHTML o = currentPage.GenerateProduction();
                    sw.Write(o.HTML);
                    sw.Close();
                }
                fs.Close();
            }
            Projects.Reactivate(previous);
        }