Ejemplo n.º 1
0
        public override Gwen.Control.TableRow Create(object item)
        {
            if (item == null)
            {
                return(null);
            }
            if (item is KeyValuePair <object, object> )
            {
                if (((KeyValuePair <object, object>)item).Value == null)
                {
                    return(null);
                }
            }

            Gwen.Control.TableRow row = CreateRow();

            SetRow(Table, row, item);

            return(row);
        }
Ejemplo n.º 2
0
        public static void SetRow(Gwen.Control.Table table, Gwen.Control.TableRow row, object item)
        {
            string[] displayMembers = table.DisplayMembers;

            if (displayMembers == null || displayMembers.Length == 0)
            {
                string text = item.ToString();
                row.Text     = text;
                row.Name     = text;
                row.UserData = item;
            }
            else
            {
                if (!(item is KeyValuePair <object, object>))
                {
                    throw new ScriptRuntimeException("Expecting table item");
                }

                var keyValuePair = (KeyValuePair <object, object>)item;

                MoonSharp.Interpreter.Table luaTable = keyValuePair.Value as MoonSharp.Interpreter.Table;
                if (luaTable == null)
                {
                    throw new ScriptRuntimeException("Expecting table");
                }

                string col = luaTable[displayMembers[0]].ToString();
                row.Name     = col;
                row.UserData = item;
                row.SetCellText(0, col);

                for (int i = 1; i < displayMembers.Length; i++)
                {
                    row.SetCellText(i, luaTable[displayMembers[i]].ToString());
                }
            }
        }