Exemplo n.º 1
0
 //================================================================================================================================================
 // Constructors
 //================================================================================================================================================
 #region HTMLTagBase()
 public HTMLTagBase()
 {
     Children.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(
         delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
     {
         if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
         {
             if (sender.GetType() == typeof(HTMLTagBase))
             {
                 HTMLTagBase temp = (HTMLTagBase)sender;
                 temp.Parent      = this;
             }
         }
     }
         );
 }
Exemplo n.º 2
0
 public HTMLTagBase StartDoc()
 {
     HTMLTagBase htmlTag = new HTMLTagBase();
     htmlTag.TagName = "html";
     
     return htmlTag;
 }
Exemplo n.º 3
0
        public HTMLTagBase CreateStyle()
        {
            HTMLTagBase style = new HTMLTagBase();
            style.TagName = "style";
            StringBuilder styleText = new StringBuilder();
            styleText.Append(".icon").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("height:40px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("width:120px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("font-size:20px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("position:absolute;").Append(Environment.NewLine);
            styleText.Append("  ").Append("left:0px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("background:#AAAAAA;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".header").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("height:40px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("width:1028px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("margin:0 auto;").Append(Environment.NewLine);
            styleText.Append("  ").Append("background:#777777;").Append(Environment.NewLine);
            styleText.Append("  ").Append("position:relative;").Append(Environment.NewLine);
            styleText.Append("  ").Append("left:0px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("top:0px;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".content").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("width:1028px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("margin:0 auto;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".links").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("height:25px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("width:1028px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("margin:0 auto;").Append(Environment.NewLine);
            styleText.Append("  ").Append("background:#DDDDDD;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".links ul").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("list-style: none;").Append(Environment.NewLine);
            styleText.Append("  ").Append("padding: 2;").Append(Environment.NewLine);
            styleText.Append("  ").Append("margin:2;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".links li").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("display: inline;").Append(Environment.NewLine);
            styleText.Append("  ").Append("float: left;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".links a").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("text-decoration: none;").Append(Environment.NewLine);
            styleText.Append("  ").Append("display: block;").Append(Environment.NewLine);
            styleText.Append("  ").Append("color: #000000;").Append(Environment.NewLine);
            styleText.Append("  ").Append("background:#DDDDDD;").Append(Environment.NewLine);
            styleText.Append("  ").Append("width: 100px;").Append(Environment.NewLine);
            styleText.Append("  ").Append("font-family: arial;").Append(Environment.NewLine);
            styleText.Append("  ").Append("font-size: 1.1em;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            styleText.Append(".links a:hover").Append(Environment.NewLine).Append("{").Append(Environment.NewLine);
            styleText.Append("  ").Append("background: #EEEEEE;").Append(Environment.NewLine);
            styleText.Append("  ").Append("color: #333333;").Append(Environment.NewLine);
            styleText.Append("}").Append(Environment.NewLine);

            style.InnerHTML = styleText.ToString();

            return style;
        }
Exemplo n.º 4
0
        //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();
        }
Exemplo n.º 5
0
        private HTMLTagBase CreateLinks()
        {
            HTMLTagBase links = new HTMLTagBase();
            links.TagName = "ul";

            foreach (var o in ToolRef.Objects)
            {
                HTMLTagBase listItem = new HTMLTagBase();
                listItem.TagName = "li";

                HTMLTagBase link = new HTMLTagBase();
                link.TagName = "a";
                link.Elements.Add("href", o.Name + ".html");
                link.InnerHTML = o.Name;

                listItem.Children.Add(link);
                links.Children.Add(listItem);
            }

            HTMLTagBase li = new HTMLTagBase();
            li.TagName = "li";

            HTMLTagBase l = new HTMLTagBase();
            l.TagName = "a";
            l.Elements.Add("href", "Reports.html");
            l.InnerHTML = "Reports";

            li.Children.Add(l);
            links.Children.Add(li);

            return links;
        }
Exemplo n.º 6
0
        public HTMLTagBase CreateHeader()
        {
            HTMLTagBase iconTag = new HTMLTagBase();
                iconTag.TagName = "div";
            iconTag.Elements.Add("id", "icon");
            iconTag.Elements.Add("class", "icon");
                iconTag.Id = "icon";//TODO: Remove
                iconTag.Class = "icon";//TODO: Remove
            iconTag.InnerHTML = ProjectName;

            //add link functionality here

            HTMLTagBase header = new HTMLTagBase();
                header.TagName = "div";
            header.Elements.Add("id", "header");
            header.Elements.Add("class", "header");
                header.Id = "header";//TODO: Remove
            header.Class = "header";//TODO: Remove
            header.Children.Add(iconTag);

            return header;
        }
Exemplo n.º 7
0
        //TODO: rework this to handle multiple objects
        #region CreateForm()
        public HTMLTagBase CreateForm()
        {
            HTMLTagBase form = new HTMLTagBase();
            form.TagName = "form";

            foreach (var o in ToolRef.Objects)
            {
                HTMLTagBase lbl = new HTMLTagBase();
                lbl.TagName = "h2";
                lbl.InnerHTML = o.Name;

                HTMLTagBase br = new HTMLTagBase() { TagName = "br" };

                form.Children.Add(lbl);
                form.Children.Add(br);

                //output table here
                HTMLTagBase table = new HTMLTagBase();
                table.TagName = "table";
                foreach (var p in o.Properties)
                {
                    HTMLTagBase row = new HTMLTagBase();
                    row.TagName = "tr";

                    HTMLTagBase cell1 = new HTMLTagBase();
                        cell1.TagName = "td";
                        cell1.InnerHTML = p.Name;

                    HTMLTagBase cell2 = new HTMLTagBase();
                        cell2.TagName = "td";

                    HTMLTagBase txtBox = new HTMLTagBase();
                        txtBox.TagName = "input";
                        txtBox.TagType = "text";//TODO: Remove
                    txtBox.Elements.Add("type", "text");
                        txtBox.Id = p.PropertyId;//TODO: Remove
                    txtBox.Elements.Add("id", p.PropertyId);

                    cell2.Children.Add(txtBox);

                    row.Children.Add(cell1);
                    row.Children.Add(cell2);

                    table.Children.Add(row);
                }
                form.Children.Add(table);

                HTMLTagBase save = new HTMLTagBase();
                save.TagName = "input";
                save.TagType = "button";//TODO: Remove
                save.Elements.Add("type", "button");
                save.Value = "Save";//TODO: Remove
                save.Elements.Add("value", "Save");
                save.Events.Add(new Event() { Name = "click", Content = @"alert('Hi honey bunny!')" });//TODO: Remove
                save.Elements.Add("onclick", "save();");

                form.Children.Add(br);
                form.Children.Add(save);

            }
            return form;
        }
Exemplo n.º 8
0
        //================================================================================================================================================
        // 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();
        }
Exemplo n.º 9
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;
            }
        }
Exemplo n.º 10
0
        //================================================================================================================================================
        // 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();
        }
Exemplo n.º 11
0
        //DOES NOT WORK
        public HTMLTagBase GenDoc(object thing)
        {
            HTMLTagBase tag = new HTMLTagBase();

            Type myType = thing.GetType();
            IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());

            foreach (PropertyInfo pInfo in props)
            {
                object propValue = pInfo.GetValue(thing, null);

                string propString = pInfo.ToString();
                Type propType = pInfo.PropertyType;
                string propName = propString.Split(' ')[1];

                if (propName == "Name")
                {
                    tag.TagName = propValue.ToString();
                    continue;
                }

                if(propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
                {
                    Type t = propType.GetElementType();
                    //foreach (var item in propValue)
                    //{

                    //}
                }

                if (propType.IsArray)
                {
                    Array a = (Array)propValue;
                    foreach (var item in a)
                    {
                        tag.Children.Add(GenDoc(pInfo));
                    }
                }

                if (!propType.IsPrimitive)
                {
                    tag.Children.Add(GenDoc(pInfo));
                }
                else
                {
                    tag.InnerHTML += propValue;
                }
             }

            return tag;
        }