예제 #1
0
 static void Indent(this HTMLTableRowElement row, int indent)
 {
     for (int n = 0; n < indent; n++)
     {
         var cell = new HTMLTableDataCellElement();
         cell.Style.BorderRight = "1px solid black";
         row.AppendChild(cell);
     }
 }
예제 #2
0
        private HTMLTableRowElement Row(HTMLElement el, int colspan)
        {
            var row = new HTMLTableRowElement();
            var td  = new HTMLTableDataCellElement();

            td.SetAttribute("colspan", colspan.ToString());
            td.AppendChild(el);
            row.AppendChild(td);
            return(row);
        }
예제 #3
0
        private HTMLTableRowElement Row(params HTMLElement[] elements)
        {
            var row = new HTMLTableRowElement();

            foreach (var el in elements)
            {
                row.AppendChild(el.WithinTableDataCell());
            }
            return(row);
        }
예제 #4
0
        public static void CreateCell(HTMLTableElement table, params Node[] toAppend)
        {
            var row1 = new HTMLTableRowElement();

            table.AppendChild(row1);
            var cell1 = new HTMLTableDataCellElement();

            foreach (var append in toAppend)
            {
                cell1.AppendChild(append);
            }
            row1.AppendChild(cell1);
        }
        protected override List <HTMLElement> GenerateElement(TestDescriptor item)
        {
            var res = new List <HTMLElement>();

            var row1 = new HTMLTableRowElement();


            row1.ClassList.Add(this._count % 2 == 0?"whiteRow":"greyRow"); // alternate
            if (item.Success)
            {
                row1.ClassList.Add("passedTest"); // failed test row
            }
            var cell1 = row1.InsertCell();
            var cell2 = row1.InsertCell();
            var cell3 = row1.InsertCell();

            // CELL1
            cell1.ClassName = item.Success ? "test-ok" : "test-ko";
            // row index
            cell1.AppendChild(new HTMLUnknownElement("strong")
            {
                InnerHTML = $"{this._count +1} {item.Name}"
            });

//            cell1.AppendChild(new HTMLSpanElement()
//            {
//                InnerHTML = $"{item.Name}"
//            });

            cell1.AppendChild(new HTMLBRElement());

            cell1.AppendChild(new HTMLUnknownElement("i")
            {
                InnerHTML = $" {item.NameDescription}",
                ClassName = "w3-text-grey"
            });
            // ----------

            // CELL2
            cell2.AppendChild(new HTMLUnknownElement("i")
            {
                ClassName = "fa fa-object-group"
            });

            cell2.AppendChild(new HTMLSpanElement()
            {
                InnerHTML = $"{item.Group}"
            });

            cell2.AppendChild(new HTMLBRElement());


            cell2.AppendChild(new HTMLUnknownElement("i")
            {
                InnerHTML = $" {item.GroupDescription}",
                ClassName = "w3-text-grey"
            });
            // ----------

            // CELL3
            cell3.ClassName = "w3-right";
            cell3.AppendChild(new HTMLUnknownElement("i")
            {
                ClassName = "fa fa-clock-o"
            });

            cell3.AppendChild(new HTMLSpanElement()
            {
                InnerHTML = $"{item.Time} ms"
            });
            // ----------

            this._count++;
            res.Add(row1);

            if (item.Success)
            {
                return(res);
            }

            var row2 = new HTMLTableRowElement();

            row2.ClassName = this._count % 2 == 0 ? "whiteRow":"greyRow";
            var cell = row2.InsertCell();

            cell.ColSpan   = 3;
            cell.ClassName = "test-ko inner-row";

            cell.AppendChild(new HTMLParagraphElement()
            {
                ClassName = "error-message"
            }).AppendChild(new HTMLUnknownElement("i")
            {
                ClassName = "w3-text-grey",
                InnerHTML = item.Error
            });

            cell.AppendChild(new HTMLUnknownElement("pre")
            {
                InnerHTML = item.Stack
            });

            res.Add(row2);

            return(res);
        }
예제 #6
0
 internal DataRow(DataColumnCollection columns)
 {
     Columns = columns;
     data    = new List <object>(Columns.Count);
     Element = new HTMLTableRowElement();
 }
예제 #7
0
파일: Drawer.cs 프로젝트: Zaid-Ajaj/Demos
        public Drawer(Options settings, Mandelbrot calculator)
        {
            this.Settings = settings;
            this.Calculator = calculator;

            // the actual canvas element
            var canvas = new HTMLCanvasElement();
            canvas.Width = 900;
            canvas.Height = 500;

            DrawButton = new HTMLButtonElement
            {
                InnerHTML = "Draw the Mandelbrot fractal",
                OnClick = (ev) =>
                {
                    StartDraw(canvas);
                }
            };

            DrawButton.SetAttribute("style", "font-size:18px;height: 60px;  width:95%; border: 2px solid black; cursor: pointer");

            // Iteration controls
            RadiusElement = GetInputNumberElement(null, this.Settings.MaxRadius, 3, 0.5);
            IterationCountElement = GetInputNumberElement(null, this.Settings.MaxIterations, 4, 100, 0, 100000);
            // Color controls
            ColorMapCheckbox = GetCheckboxElement(this.Settings.UseColorMap);
            ColorScaleElement = GetInputNumberElement(ColorMapCheckbox, this.Settings.ColorScale, 5, 1000);
            ColorOffsetElement = GetInputNumberElement(ColorMapCheckbox, this.Settings.ColorOffset, 4, 10);

            // Julia sets
            JuliaSetCheckbox = GetCheckboxElement(this.Settings.UseJuliaSet);
            JuliaImElement = GetInputNumberElement(JuliaSetCheckbox, this.Settings.JuliaSetParameter.Im, 5, 0.005, null);
            JuliaReElement = GetInputNumberElement(JuliaSetCheckbox, this.Settings.JuliaSetParameter.Re, 5,  0.005, null);

            // Viewport controls
            XMinElement = GetInputNumberElement(null, this.Settings.XMin, 5, 0.005, -5.0);
            XMaxElement = GetInputNumberElement(null, this.Settings.XMax, 5, 0.005, 0.0);
            YMinElement = GetInputNumberElement(null, this.Settings.YMin, 5, 0.005, -5.0);
            YMaxElement = GetInputNumberElement(null, this.Settings.YMax, 5, 0.005, 0.0);

            var paramsColumn = new HTMLTableDataCellElement();
            var canvasColumn = new HTMLTableDataCellElement();
            paramsColumn.SetAttribute("valign", "top");
            canvasColumn.SetAttribute("valign", "top");
            canvasColumn.AppendChild(canvas);

            var layoutRow = new HTMLTableRowElement();
            layoutRow.AppendChildren(paramsColumn, canvasColumn);

            var layout = new HTMLTableElement();

            var paramsTable = new HTMLTableElement();
            paramsTable.AppendChildren(
                Row(Label("XMin: "), XMinElement),
                Row(Label("XMax: "), XMaxElement),
                Row(Label("YMin: "), YMinElement),
                Row(Label("YMax: "), YMaxElement),
                Row(Label("Escape radius: "), RadiusElement),
                Row(Label("Iteration count: "), IterationCountElement),
                Row(Label("Use color map: "), ColorMapCheckbox),
                Row(Label("Color scale: "), ColorScaleElement),
                Row(Label("Color offset: "), ColorOffsetElement),
                Row(Label("Use Julia set: "), JuliaSetCheckbox),
                Row(Label("Im: "), JuliaImElement),
                Row(Label("Re: "), JuliaReElement),
                Row(new HTMLHRElement(), 2),
                Row(DrawButton, 2)
            );

            paramsColumn.AppendChild(paramsTable);

            layout.AppendChild(layoutRow);
            Document.Body.AppendChild(layout);
        }
예제 #8
0
파일: Drawer.cs 프로젝트: Zaid-Ajaj/Demos
 private HTMLTableRowElement Row(HTMLElement el, int colspan)
 {
     var row = new HTMLTableRowElement();
     var td = new HTMLTableDataCellElement();
     td.SetAttribute("colspan", colspan.ToString());
     td.AppendChild(el);
     row.AppendChild(td);
     return row;
 }
예제 #9
0
파일: Drawer.cs 프로젝트: Zaid-Ajaj/Demos
 private HTMLTableRowElement Row(params HTMLElement[] elements)
 {
     var row = new HTMLTableRowElement();
     foreach(var el in elements)
         row.AppendChild(el.WithinTableDataCell());
     return row;
 }
예제 #10
0
        public static void ShowTableDemo()
        {
            var div = new HTMLDivElement();

            var table = new HTMLTableElement();

            table.CreateTHead();
            var tHeadRow = new HTMLTableRowElement();

            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Name"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Position"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Office"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Age"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "StartDate"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Salary"
            });
            table.THead.AppendChild(tHeadRow);
            var tBody = new HTMLTableSectionElement(TableSectionType.Body);

            table.AppendChild(tBody);
            div.AppendChild(table);

            var data = Script.Get("tabledemoJsonData").ToDynamic();

            foreach (var dataRow in data)
            {
                var row = new HTMLTableRowElement();
                row.OnMouseEnter = (ev) => { row.ClassList.Add("highlight"); };
                row.OnMouseLeave = (ev) => { row.ClassList.Remove("highlight"); };

                row.OnMouseDown = (ev) => {
                    if (row.ClassList.Contains("selected"))
                    {
                        row.ClassList.Remove("selected");
                    }
                    else
                    {
                        row.ClassList.Add("selected");
                    }
                };

                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Name
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Position
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Office
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Age
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.StartDate
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Salary
                });
                tBody.AppendChild(row);
            }
            div.Dialog(new DialogParameter()
            {
                Title = "Datatable Demo", Width = 960, Height = 600
            });

            div.DialogEventResize(
                (ev, ui) =>
            {
                table.DataTableDraw();
            }
                );



            table.DataTable(new DataTableParameter()
            {
                ScrollCollapse = true, ScrollY = "100%"
            });


            table.DataTableDraw();

            //Bridge.jQuery2.jQuery.Ajax(new Bridge.jQuery2.AjaxOptions
            //{
            //    Url = "TextFile1.txt",
            //    ContentType = "application/json; charset=utf-8",
            //    Success = delegate (dynamic data, string str, Bridge.jQuery2.jqXHR jqxhr)
            //    {
            //        var row = new HTMLTableRowElement();
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Name });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Position });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Office });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Age });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.StartDate });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Salary });
            //        tBody.AppendChild(row);
            //    }
            //});
        }
예제 #11
0
        public static async Task <LevelEditorReference> CreateReference(GameObject gameObject, HTMLTableElement table, int indent = 0)
        {
            if (gameObject.Name == null)
            {
                return(null);
            }
            HTMLTableRowElement row = new HTMLTableRowElement();

            row.Indent(indent);
            var cell = new HTMLTableDataCellElement();

            cell.Style.BorderBottom = "1px solid black";
            cell.AppendChild(new HTMLAnchorElement
            {
                InnerHTML = gameObject.Name,
                Href      = "javascript:void(0)",
                OnClick   = v => Select(gameObject)
            });
            cell.AppendChild(new Text(" "));
            var cross = new HTMLAnchorElement
            {
                OnClick = v => Remove(gameObject),
                Href    = "javascript:void(0)"
            };

            cross.AppendChild(LevelEditor.cross = LevelEditor.cross.CloneNode().As <HTMLImageElement>());
            cell.AppendChild(cross);
            row.AppendChild(cell);
            table.AppendChild(row);
            LevelEditorReference result = new LevelEditorReference
            {
                gameObject = gameObject,
                cells      = new Dictionary <string, HTMLElement>(),
                members    = new Dictionary <string, MemberInfo>()
            };
            string type;

            if (gameObject is Character)
            {
                type = "Character";
            }
            else if (gameObject is Shot)
            {
                type = "Shot";
            }
            else if (gameObject is RealGameObject)
            {
                type = "Real Thing";
            }
            else if (gameObject is DrawnGameObject)
            {
                type = "Illusion";
            }
            else if (gameObject is Movement)
            {
                type = "Movement by User";
            }
            else if (gameObject is Shoot_OnKey)
            {
                type = "Shooting by User";
            }
            else if (gameObject is Level)
            {
                type = "Level";
            }
            else
            {
                throw new Exception($"Type not allowed: {gameObject.GetType().FullName}");
            }
            row = new HTMLTableRowElement();
            row.Indent(indent);
            cell = new HTMLTableDataCellElement
            {
                InnerHTML = "Type"
            };
            HTMLTableDataCellElement cell2 = new HTMLTableDataCellElement
            {
                InnerHTML = type
            };

            result.cells.Add("Type", cell2);
            row.AppendChild(cell);
            row.AppendChild(cell2);
            table.AppendChild(row);
            List <MemberInfo> fields = new List <MemberInfo>(gameObject.GetType().GetFields());

            fields.AddRange(gameObject.GetType().GetProperties());
            foreach (var field in fields)
            {
                if (field.IsStatic)
                {
                    continue;
                }
                Type memberType;
                if (field is FieldInfo)
                {
                    memberType = ((FieldInfo)field).FieldType;
                }
                else if (field is PropertyInfo)
                {
                    memberType = ((PropertyInfo)field).PropertyType;
                }
                else
                {
                    throw new Exception();
                }
                var        customAttributes2 = (ObjectCreatorAttribute[])field.GetCustomAttributes(typeof(ObjectCreatorAttribute));
                string     s;
                GameObject o;
                if (allowed.Contains(memberType) || customAttributes2.Length == 1)
                {
                    object value;
                    if (field is FieldInfo)
                    {
                        value = ((FieldInfo)field).GetValue(gameObject);
                    }
                    else if (field is PropertyInfo)
                    {
                        value = ((PropertyInfo)field).GetValue(gameObject);
                    }
                    else
                    {
                        throw new Exception();
                    }
                    if (value == null)
                    {
                        continue;
                    }
                    if (customAttributes2.Length == 1)
                    {
                        value = await GameObject.Create(value);
                    }
                    row = new HTMLTableRowElement();
                    row.Indent(indent);
                    var    contentEditable = ContentEditable.True;
                    string valueString;
                    s = value as string;
                    if (s != null)
                    {
                        valueString = s;
                    }
                    else if (value is double)
                    {
                        valueString = ((double)value).ToString();
                    }
                    else
                    {
                        contentEditable = ContentEditable.False;
                        if (value is List <GameObject> )
                        {
                            valueString = "List of Objects";
                        }
                        else if (value is List <OnKeyEvent> )
                        {
                            valueString = "List of Key Press Actions";
                        }
                        else if (value is GameObject)
                        {
                            valueString = "Object";
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    string name             = field.Name;
                    var    customAttributes = (LevelEditorNameAttribute[])field.GetCustomAttributes(typeof(LevelEditorNameAttribute));
                    if (customAttributes.Length == 1)
                    {
                        name = customAttributes[0].LevelEditorName;
                    }
                    cell = new HTMLTableDataCellElement
                    {
                        InnerHTML = name
                    };
                    cell2 = new HTMLTableDataCellElement
                    {
                        ContentEditable = contentEditable,
                        InnerHTML       = valueString
                    };
                    result.cells.Add(field.Name, cell2);
                    result.members.Add(field.Name, field);
                    row.AppendChild(cell);
                    row.AppendChild(cell2);
                    table.AppendChild(row);
                    if (value is List <GameObject> || value is List <OnKeyEvent> )
                    {
                        foreach (GameObject _gameObject in (System.Collections.IList)(value as List <GameObject>) ?? (System.Collections.IList)(value as List <OnKeyEvent>))
                        {
                            await CreateReference(_gameObject, table, indent + 1);
                        }
                    }
                    o = value as GameObject;
                    if (o != null)
                    {
                        await CreateReference(o, table, indent + 1);
                    }
                }
            }
            row = new HTMLTableRowElement();
            row.Indent(indent);
            cell = new HTMLTableDataCellElement();
            cell.AppendChild(new HTMLButtonElement
            {
                InnerHTML = "Save Changes",
                OnClick   = e => SaveChanges(result)
            });
            row.AppendChild(cell);
            table.AppendChild(row);
            return(result);
        }
예제 #12
0
파일: Drawer.cs 프로젝트: wcarlo99/Demos
        public Drawer(Options settings, Mandelbrot calculator)
        {
            this.Settings   = settings;
            this.Calculator = calculator;

            // the actual canvas element
            var canvas = new HTMLCanvasElement();

            canvas.Width  = 900;
            canvas.Height = 500;

            DrawButton = new HTMLButtonElement
            {
                InnerHTML = "Draw the Mandelbrot fractal",
                OnClick   = (ev) =>
                {
                    StartDraw(canvas);
                }
            };

            DrawButton.SetAttribute("style", "font-size:18px;height: 60px;  width:95%; border: 2px solid black; cursor: pointer");

            // Iteration controls
            RadiusElement         = GetInputNumberElement(null, this.Settings.MaxRadius, 3, 0.5);
            IterationCountElement = GetInputNumberElement(null, this.Settings.MaxIterations, 4, 100, 0, 100000);
            // Color controls
            ColorMapCheckbox   = GetCheckboxElement(this.Settings.UseColorMap);
            ColorScaleElement  = GetInputNumberElement(ColorMapCheckbox, this.Settings.ColorScale, 5, 1000);
            ColorOffsetElement = GetInputNumberElement(ColorMapCheckbox, this.Settings.ColorOffset, 4, 10);

            // Julia sets
            JuliaSetCheckbox = GetCheckboxElement(this.Settings.UseJuliaSet);
            JuliaImElement   = GetInputNumberElement(JuliaSetCheckbox, this.Settings.JuliaSetParameter.Im, 5, 0.005, null);
            JuliaReElement   = GetInputNumberElement(JuliaSetCheckbox, this.Settings.JuliaSetParameter.Re, 5, 0.005, null);

            // Viewport controls
            XMinElement = GetInputNumberElement(null, this.Settings.XMin, 5, 0.005, -5.0);
            XMaxElement = GetInputNumberElement(null, this.Settings.XMax, 5, 0.005, 0.0);
            YMinElement = GetInputNumberElement(null, this.Settings.YMin, 5, 0.005, -5.0);
            YMaxElement = GetInputNumberElement(null, this.Settings.YMax, 5, 0.005, 0.0);

            var paramsColumn = new HTMLTableDataCellElement();
            var canvasColumn = new HTMLTableDataCellElement();

            paramsColumn.SetAttribute("valign", "top");
            canvasColumn.SetAttribute("valign", "top");
            canvasColumn.AppendChild(canvas);

            var layoutRow = new HTMLTableRowElement();

            layoutRow.AppendChildren(paramsColumn, canvasColumn);

            var layout = new HTMLTableElement();

            var paramsTable = new HTMLTableElement();

            paramsTable.AppendChildren(
                Row(Label("XMin: "), XMinElement),
                Row(Label("XMax: "), XMaxElement),
                Row(Label("YMin: "), YMinElement),
                Row(Label("YMax: "), YMaxElement),
                Row(Label("Escape radius: "), RadiusElement),
                Row(Label("Iteration count: "), IterationCountElement),
                Row(Label("Use color map: "), ColorMapCheckbox),
                Row(Label("Color scale: "), ColorScaleElement),
                Row(Label("Color offset: "), ColorOffsetElement),
                Row(Label("Use Julia set: "), JuliaSetCheckbox),
                Row(Label("Im: "), JuliaImElement),
                Row(Label("Re: "), JuliaReElement),
                Row(new HTMLHRElement(), 2),
                Row(DrawButton, 2)
                );

            paramsColumn.AppendChild(paramsTable);

            layout.AppendChild(layoutRow);
            Document.Body.AppendChild(layout);
        }