コード例 #1
0
ファイル: HTMLGenerator.cs プロジェクト: zackLore/ZKIT
        //TODO: finish this
        #region GenerateReportPage()
        public string GenerateReportPage()//NOT FINISHED - Copied from GenerateDoc but not yet modified
        {
            StringBuilder html = new StringBuilder();

            html.Append(DOCTYPE).Append(Environment.NewLine);

            HTMLTagBase doc = StartDoc();

            HTMLTagBase head = new HTMLTagBase();

            head.TagName = "head";
            //*****add reference links here
            head.InnerHTML += CreateScriptLinks();

            doc.Children.Add(head);

            HTMLTagBase body = new HTMLTagBase();

            body.TagName = "body";
            body.Elements.Add("onload", "loadData();");
            body.Children.Add(CreateHeader());

            HTMLTagBase links = new HTMLTagBase();

            links.TagName = "div";
            links.Elements.Add("class", "links");
            links.Children.Add(CreateLinks());

            HTMLTagBase content = new HTMLTagBase();

            content.TagName = "div";
            content.Class   = "content";//TODO: Remove
            content.Elements.Add("class", "content");

            HTMLTagBase mainContent = new HTMLTagBase();

            mainContent.TagName = "div";
            mainContent.Elements.Add("id", "content");

            content.Children.Add(mainContent);
            //content.Children.Add(CreateForm());

            body.Children.Add(links);
            body.Children.Add(content);

            doc.Children.Add(body);

            html.Append(doc.GenerateTag());

            //Tags.Add(doc);

            return(html.ToString());
        }
コード例 #2
0
ファイル: XMLGenerator.cs プロジェクト: zackLore/ZKIT
        //================================================================================================================================================
        // Public Methods
        //================================================================================================================================================
        #region GenerateDoc
        public string GenerateDoc()
        {
            StringBuilder xml = new StringBuilder();

            xml.Append(DOCTYPE).Append(Environment.NewLine);

            //Project Tag
            HTMLTagBase proj = new HTMLTagBase();

            proj.TagName = ProjectRef.GetType().Name.ToString().ToLower();
            proj.Elements.Add("name", DocumentName);

            foreach (var t in ProjectRef.Tools)
            {
                HTMLTagBase tool = new HTMLTagBase();
                tool.TagName = t.GetType().Name.ToString().ToLower();
                tool.Elements.Add("name", t.Name);

                foreach (var o in t.Objects)
                {
                    HTMLTagBase ob = new HTMLTagBase();
                    ob.TagName = o.GetType().Name.ToString().ToLower();
                    ob.Elements.Add("name", o.Name);

                    foreach (var p in o.Properties)
                    {
                        HTMLTagBase prop = new HTMLTagBase();
                        prop.TagName = p.GetType().Name.ToString().ToLower();
                        prop.Elements.Add("name", p.Name);
                        prop.Elements.Add("type", p.PropertyType.Name.ToString());//May need to change to handle the propery object
                        if (p.DefaultValue != null)
                        {
                            prop.Elements.Add("default_value", p.DefaultValue.ToString());
                        }
                        if (p.DefaultColor != null)
                        {
                            prop.Elements.Add("default_color", p.DefaultColor.ToString());
                        }

                        ob.Children.Add(prop);
                    }
                    tool.Children.Add(ob);
                }
                proj.Children.Add(tool);
            }

            //Create the xml content
            xml.Append(proj.GenerateTag());

            return(xml.ToString());
        }
コード例 #3
0
ファイル: HTMLGenerator.cs プロジェクト: zackLore/ZKIT
        //================================================================================================================================================
        // Public Methods
        //================================================================================================================================================
        #region GenerateDoc
        public string GenerateDoc()
        {
            StringBuilder html = new StringBuilder();

            html.Append(DOCTYPE).Append(Environment.NewLine);

            HTMLTagBase doc = StartDoc();

            HTMLTagBase head = new HTMLTagBase();

            head.TagName = "head";
            //*****add scripts and styles here
            //head.Children.Add(CreateStyle());
            //head.InnerHTML = CreateStyle();//TODO: Remove
            //head.InnerHTML += Environment.NewLine;
            //*****add javascript links here
            head.InnerHTML += CreateScriptLinks();

            doc.Children.Add(head);

            HTMLTagBase body = new HTMLTagBase();

            body.TagName = "body";
            body.Children.Add(CreateHeader());

            HTMLTagBase links = new HTMLTagBase();

            links.TagName = "div";
            links.Elements.Add("class", "links");
            links.Children.Add(CreateLinks());

            HTMLTagBase content = new HTMLTagBase();

            content.TagName = "div";
            content.Class   = "content";  //TODO: Remove
            content.Elements.Add("class", "content");
            content.Children.Add(CreateForm());

            body.Children.Add(links);
            body.Children.Add(content);

            doc.Children.Add(body);

            //html.Append(doc.OutputTag());//TODO: Remove
            html.Append(doc.GenerateTag());

            Tags.Add(doc);

            return(html.ToString());
        }
コード例 #4
0
        protected void OnGenerateCode(object parameter)
        {
            switch (CurrentTool.Language)
            {
            case "javascript":
                //Check for source files
                string fileStatus = DocumentCreator.AddFile(@"D:\Zkit\SourceFiles", @"Output\Scripts", "CommonObjects.js");

                //Create CSS
                CSSGenerator css       = new CSSGenerator(CurrentTool);
                string       cssStatus = DocumentCreator.CreateDocument(@"Output\Styles", (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project") + "Styles", "css", css.GenerateDoc(), true);

                PHPGenerator php = new PHPGenerator(CurrentTool);
                //set php info here
                php.DB     = "zkit";
                php.Pass   = "******";
                php.Server = "localhost";
                php.User   = "******";

                //Create PHP Scripts
                string phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "connect", "php", php.GenerateConnectDoc(), true);
                if (!String.IsNullOrWhiteSpace(phpStatus))
                {
                    MessageBox.Show(phpStatus);
                }
                phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "save_" + (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"), "php", php.GenerateSaveDoc(), true);
                if (!String.IsNullOrWhiteSpace(phpStatus))
                {
                    MessageBox.Show(phpStatus);
                }
                phpStatus = DocumentCreator.CreateDocument(@"Output\PHP", "load_" + (CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project"), "php", php.GenerateLoadDoc(), true);
                if (!String.IsNullOrWhiteSpace(phpStatus))
                {
                    MessageBox.Show(phpStatus);
                }

                //Create Javascript files
                JavascriptGenerator js = new JavascriptGenerator(CurrentTool);
                js.ProjectName = CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project";    //Needs to be the name of the objecst
                string jsStatus = DocumentCreator.CreateDocument(@"Output\Scripts", js.ProjectName, "js", js.GenerateDoc(), true);
                if (!String.IsNullOrWhiteSpace(jsStatus))
                {
                    MessageBox.Show(jsStatus);
                }
                jsStatus = DocumentCreator.CreateDocument(@"Output\Scripts", js.ProjectName + "_functions", "js", js.GenerateFunctionsDoc(), true);
                if (!String.IsNullOrWhiteSpace(jsStatus))
                {
                    MessageBox.Show(jsStatus);
                }

                HTMLGenerator g = CurrentTool.HTML;
                g.ProjectName = CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project";
                g.ToolRef     = CurrentTool;
                g.ScriptIncludes.Add("CommonObjects.js");
                g.ScriptIncludes.Add(js.ProjectName + ".js");
                g.ScriptIncludes.Add("https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js");
                g.ScriptIncludes.Add(g.ProjectName + "_functions.js");
                g.GenerateDoc();    //Creates begining point of doc

                //Load js objects
                var htmlTag = g.Tags.Where(x => x.TagName == "html").FirstOrDefault();
                if (htmlTag != null && htmlTag.GetType() == typeof(HTMLTagBase))
                {
                    var headTag = ((HTMLTagBase)htmlTag).Children.Where(x => x.TagName == "head").FirstOrDefault();
                    if (headTag != null)
                    {
                        var         scriptTag = ((HTMLTagBase)headTag).Children.Where(x => x.TagName == "script").FirstOrDefault();
                        HTMLTagBase script    = null;
                        if (scriptTag != null)
                        {
                            script = (HTMLTagBase)scriptTag;
                        }
                        else    //create a script tag
                        {
                            script         = new HTMLTagBase();
                            script.TagName = "script";
                            headTag.Children.Add(script);
                        }
                        List <string> names = new List <string>();
                        foreach (var o in CurrentTool.Objects)
                        {
                            names.Add(o.Name);
                        }
                        script.InnerHTML = JavascriptGenerator.GenerateInitFunction(names);
                    }

                    var bodyTag = ((HTMLTagBase)htmlTag).Children.Where(x => x.TagName == "body").FirstOrDefault();
                    if (bodyTag != null)
                    {
                        bodyTag.Elements.Add("onload", "initObjs();");
                    }
                }
                else    //no html tag found.  Something is wrong.
                {
                }

                string htmlDoc = g.ReOutputDoc();

                string status = DocumentCreator.CreateDocument("Output", CurrentTool.Parent != null ? ((Project)CurrentTool.Parent).Name : "Project", "html", htmlDoc, true);
                if (!String.IsNullOrWhiteSpace(status))
                {
                    MessageBox.Show(status);
                }

                //TODO: Finish adding all report elements - tags in reports.html, additional scripts
                //***** Create Report Document
                HTMLTagBase reportDoc     = g.CreateReportPage();
                var         reportHeadTag = ((HTMLTagBase)reportDoc).Children.Where(x => x.TagName == "head").FirstOrDefault();
                if (reportHeadTag != null)
                {
                    var         scriptTag = ((HTMLTagBase)reportHeadTag).Children.Where(x => x.TagName == "script").FirstOrDefault();
                    HTMLTagBase script    = null;
                    if (scriptTag != null)
                    {
                        script = (HTMLTagBase)scriptTag;
                    }
                    else    //create a script tag
                    {
                        script         = new HTMLTagBase();
                        script.TagName = "script";
                        reportHeadTag.Children.Add(script);
                    }
                    List <string> names = new List <string>();
                    foreach (var o in CurrentTool.Objects)
                    {
                        names.Add(o.Name);
                    }
                    script.InnerHTML = JavascriptGenerator.GenerateReportInitFunction(names, CurrentTool.Objects.ElementAt(0));
                }

                var reportBodyTag = ((HTMLTagBase)reportDoc).Children.Where(x => x.TagName == "body").FirstOrDefault();
                if (reportBodyTag != null)
                {
                    reportBodyTag.Elements["onload"] += "initObjs();";
                }

                status = DocumentCreator.CreateDocument("Output", "Reports", "html", reportDoc.GenerateTag(), true);
                if (!String.IsNullOrWhiteSpace(status))
                {
                    MessageBox.Show(status);
                }

                //***** Create SQL Scripts
                SQLGenerator sql       = new SQLGenerator(CurrentTool);
                string       sqlStatus = DocumentCreator.CreateDocument("Output", "CREATE_TABLES", "sql", sql.GenerateDoc(), true);

                MessageBox.Show("Files Created!");
                break;
            }
        }