Exemple #1
0
        public static HTMLTableDataCellElement WithinTableDataCell(this HTMLElement el)
        {
            var td = new HTMLTableDataCellElement();

            td.AppendChild(el);
            return(td);
        }
Exemple #2
0
        public static HTMLTableDataCellElement WithinTableDataCell(this HTMLElement el)
        {
            var td = new HTMLTableDataCellElement();

            td.SetAttribute("valign", "top");
            td.AppendChild(el);
            return(td);
        }
 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);
     }
 }
Exemple #4
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);
        }
        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);
        }
Exemple #6
0
        public object this[int columnIndex] {
            get {
                if (columnIndex < 0 || columnIndex > Columns.Count - 1)
                {
                    return(null);
                }

                return(data[columnIndex]);
            } set {
                if (columnIndex < 0)
                {
                    return;
                }
                if (columnIndex > Columns.Count - 1)
                {
                    return;
                }

                if (columnIndex > data.Count - 1)
                {
                    for (int i = data.Count; i < columnIndex + 1; i++)
                    {
                        var dc = new HTMLTableDataCellElement();

                        if (i == columnIndex)
                        {
                            data.Add(value);
                            dc.innerText = (value + "");

                            Element.appendChild(dc);

                            return;
                        }
                        else
                        {
                            Element.appendChild(dc);
                            data.Add(null);
                        }
                    }
                }
                else
                {
                    Element.children[columnIndex].As <HTMLElement>().innerText = (value + "");
                    data[columnIndex] = value;
                }
            }
        }
        /// <summary>
        /// Support function for button creation.
        /// </summary>
        /// <param name="parentNode">Container the button should be added to.</param>
        /// <param name="label">Button label.</param>
        /// <param name="opt_className">Class name for button, which will be used
        /// in addition to "goog-date-picker-btn".</param>
        private HTMLElement createButton_(HTMLTableDataCellElement parentNode, string label,
                                          string opt_className = null)
        {
            var classes = new JsArray <string>()
            {
                le.getCssName(this.getBaseCssClass(), "btn")
            };

            if (opt_className != null)
            {
                classes.Push(opt_className);
            }
            var el = this.getDomHelper().createElement(goog.dom.TagName.BUTTON);

            el.ClassName = classes.Join(" ");
            el.AppendChild(this.getDomHelper().createTextNode(label));
            parentNode.AppendChild(el);
            return(el);
        }
Exemple #8
0
        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);
        }
Exemple #9
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;
 }
Exemple #10
0
 public static HTMLTableDataCellElement WithinTableDataCell(this HTMLElement el)
 {
     var td = new HTMLTableDataCellElement();
     td.AppendChild(el);
     return td;
 }
        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);
        }
Exemple #12
0
        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);
        }