public override void OnInspectorGUI()
        {
            ListDataBinder binder = target as ListDataBinder;

            binder.EditorBind();

            if (definerDrawer == null)
            {
                definerDrawer = new DataDefinerDrawer(binder.Source);
            }
            definerDrawer.Draw(binder.BindVM, binder.BindData, typeof(IList));

            binder.Template = (GameObject)EditorGUILayout.ObjectField("Template:", binder.Template, typeof(GameObject), true);
            if (binder.Template == null || binder.Template.GetComponent <ListTemplateBinder>() == null)
            {
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                style.normal.textColor = Color.red;
                if (binder.Template == null)
                {
                    EditorGUILayout.LabelField("template can not be null.", style);
                }
                else
                {
                    EditorGUILayout.LabelField("template game object must have ListTemplateBinder.", style);
                }
            }
            else
            {
                IData data = binder.Source.GetData(binder.BindVM);
                if (data != null && data is IListData)
                {
                    IListData list = (IListData)data;
                    if (list.Count <= 0)
                    {
                        GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                        style.normal.textColor = Color.red;
                        EditorGUILayout.LabelField("source list data must instantiate with one element at least.", style);
                    }
                    else
                    {
                        binder.Template.GetComponent <ListTemplateBinder>().ItemSource.Key = binder.Source.Key;
                    }
                }
            }

            binder.Optimize = EditorGUILayout.Toggle("Optimize:", binder.Optimize);
            if (binder.Optimize)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Canvas:", binder.Canvas, typeof(Canvas), true);
                EditorGUILayout.ObjectField("ViewPort:", binder.ViewPort, typeof(RectTransform), true);
                EditorGUILayout.ObjectField("ScrollRect:", binder.ScrollRect, typeof(ScrollRect), true);
                EditorGUILayout.ObjectField("LayoutGroup:", binder.LayoutGroup, typeof(LayoutGroup), true);
                EditorGUILayout.IntField("PageRowsCount:", binder.PageRowsCount);
                EditorGUILayout.IntField("RowItemsCount:", binder.RowItemsCount);
                EditorGUILayout.IntField("StepRowsCount:", binder.StepRowsCount);
                EditorGUI.EndDisabledGroup();
            }
        }
예제 #2
0
        public static IListData Parse(Type t, object data, Action <object, object> onParseItem = null)
        {
            if (!typeof(IData).IsAssignableFrom(t))
            {
                return(null);
            }

            Type      instanceType = typeof(ListData <>).MakeGenericType(t);
            IListData obj          = (IListData)Activator.CreateInstance(instanceType);

            obj.ParseObject(data, onParseItem);
            return(obj);
        }
예제 #3
0
        public override void UnBind()
        {
            base.UnBind();

            this.itemsCount = 0;
            for (int i = 0; i < this.transform.childCount; i++)
            {
                Destroy(this.transform.GetChild(i).gameObject);
            }

            if (this.sourceData != null)
            {
                (this.sourceData as IData).RemoveValueChangedListener(this.SourceDataChanged);
                this.sourceData.FocusIndexChanged -= FocusIndexChanged;
                this.sourceData = null;
            }
        }
예제 #4
0
        Select
            (IQueryData <T, U> query,
            int maxdepth = 1, int top = 0, IListData <T, U> datas = null)
        {
            var parameters = new List <SqlParameter>();

            var querycolumns = _sqlbuilder.GetQueryColumns(query, null, null, maxdepth, 0);
            var queryjoins   = _sqlbuilder.GetQueryJoins(query, new List <string>()
            {
                query.Description.Name
            }, maxdepth, 0);

            var selectcommandtext = _sqlcommandbuilder.Select(_sqlbuilder.GetSelectColumns(querycolumns),
                                                              _sqlbuilder.GetFrom(queryjoins, query.Description.Name),
                                                              _sqlbuilder.GetWhere(querycolumns, parameters), top);

            return(Select(selectcommandtext, CommandType.Text, parameters, maxdepth, datas));
        }
예제 #5
0
        public static IListData GenerateVMData(LuaTable luaData)
        {
            LuaTable  listLua  = luaData.Get <LuaTable>("__vm_value");
            LuaTable  first    = listLua.Get <int, LuaTable>(1);
            IListData listData = CreateListDataInstanceWithItemLuaTable(first);

            listData.DisableValueChangeHandler = true;
            listLua.ForEach <int, LuaTable>(delegate(int index, LuaTable item)
            {
                listData.Add(XLuaData.GenerateDataWithLuaTable(item));
            });
            listData.DisableValueChangeHandler = false;
            listData.InvokeValueChanged();

            luaData.Set <string, Action <LuaTable> >("__vm_list_add", delegate(LuaTable item) {
                listData.AddItem(XLuaData.GenerateDataWithLuaTable(item));
            });

            luaData.Set <string, Action <int, LuaTable> >("__vm_list_insert", delegate(int index, LuaTable item) {
                listData.InsertItem(index - 1, XLuaData.GenerateDataWithLuaTable(item));
            });

            luaData.Set <string, Action>("__vm_list_pop", delegate() {
                listData.RemoveAt(listData.Count - 1);
            });

            luaData.Set <string, Action <int> >("__vm_list_remove", delegate(int index) {
                listData.RemoveAt(index - 1);
            });

            luaData.Set <string, Action>("__vm_list_reorder", delegate() {
                listData.DisableValueChangeHandler = true;
                LuaTable newListLua = luaData.Get <LuaTable>("__vm_value");
                listData.Clear();
                newListLua.ForEach <int, LuaTable>(delegate(int index, LuaTable item)
                {
                    listData.Add(XLuaData.GenerateDataWithLuaTable(item));
                });
                listData.DisableValueChangeHandler = false;
                listData.InvokeValueChanged();
            });

            return(listData);
        }
예제 #6
0
        Select
            (string commandtext, CommandType commandtype = CommandType.Text, IList <SqlParameter> parameters = null,
            int maxdepth = 1, IListData <T, U> datas = null)
        {
            var enumeration = new List <U>();

            var select = Select(commandtext, commandtype, parameters, maxdepth, (datas?.Entities != null ? datas?.Entities : new ListEntity <T>()));

            if (select.result.Success && select.entities?.Count() > 0)
            {
                foreach (var instance in MapEntities(select.entities, maxdepth))
                {
                    enumeration.Add(instance);
                }

                return(select.result, enumeration);
            }

            return(select.result, default(IList <U>));
        }
예제 #7
0
 public void EditorBind()
 {
     if (!Application.isPlaying)
     {
         this.BindData = null;
         this.BindVM   = this.GetComponentInParent <VMBehaviour>(true);
         if (this.BindVM != null)
         {
             this.BindVM.EditorCollect();
             if (this.GetComponentInParent <ListTemplateBinder>(true) != null)
             {
                 IData     data = this.GetComponentInParent <ListTemplateBinder>(true).ItemSource.GetData(this.BindVM);
                 IListData list = data as IListData;
                 if (list != null && list.Count > 0)
                 {
                     this.BindData = list.GetAt(0);
                 }
             }
         }
     }
 }
예제 #8
0
        public override void Bind(VMBehaviour vm, IData data)
        {
            base.Bind(vm, data);

            if (Source == null)
            {
                return;
            }

            if (data == null)
            {
                return;
            }

            this.sourceData = Source.GetData(data) as IListData;
            if (this.sourceData == null)
            {
                return;
            }

            this.DoBind();
        }
예제 #9
0
        public void Bind(VMBehaviour vm, int index, IListData data)
        {
            this.index  = index;
            this.source = data;
            this.item   = this.source.GetAt(this.index);
            this.vm     = vm;

            for (int i = 0; i < dataBinders.Count; i++)
            {
                if (dataBinders[i].CanBind(this.vm, item))
                {
                    dataBinders[i].Bind(this.vm, item);
                }
            }

            for (int i = 0; i < commandBinders.Count; i++)
            {
                if (commandBinders[i].CanBindListItem(this.vm, this.index))
                {
                    commandBinders[i].BindListItem(this.vm, this.index);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            ListTemplateBinder binder = target as ListTemplateBinder;
            VMBehaviour        vm     = binder.GetComponentInParent <VMBehaviour>(true);

            if (definerDrawer == null)
            {
                definerDrawer = new DataDefinerDrawer(binder.ItemSource);
            }
            definerDrawer.Draw(vm, null, typeof(IList));

            IData     data = binder.ItemSource.GetData(vm);
            IListData list = data as IListData;

            if (list == null)
            {
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                style.normal.textColor = Color.red;
                EditorGUILayout.LabelField("no source list data.", style);
            }

            EditorGUILayout.LabelField("index: " + binder.Index);
        }
예제 #11
0
        public override void OnInspectorGUI()
        {
            BaseDataBinder binder = target as BaseDataBinder;

            binder.EditorBind();

            if (binder.GetComponentInParent <ListTemplateBinder>(true) != null)
            {
                ListTemplateBinder templateBinder = binder.GetComponentInParent <ListTemplateBinder>(true);
                IData     data = templateBinder.ItemSource.GetData(binder.BindVM);
                IListData list = data as IListData;
                if (list == null)
                {
                    GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                    style.normal.textColor = Color.red;
                    EditorGUILayout.LabelField("This is a binder within a list template. The template must have source list data bind.", style);
                    return;
                }
            }

            List <Component> components      = new List <Component>();
            List <Component> validComponents = new List <Component>();

            binder.GetComponents <Component>(components);
            for (int i = 0; i < components.Count; i++)
            {
                Component cpt     = components[i];
                Type      cptType = cpt.GetType();
                if (cptType != typeof(BaseCommandBinder) && cptType != typeof(BaseDataBinder) && cptType != typeof(ListDataBinder) && cptType != typeof(ListTemplateBinder) && cptType != typeof(VMDataBinder))
                {
                    validComponents.Add(cpt);
                }
            }
            components = validComponents;

            List <string> componentsStr = new List <string>();

            for (int i = 0; i < components.Count; i++)
            {
                componentsStr.Add(components[i].GetType().Name);
            }

            if (itemsExpand.Count == 0)
            {
                for (int i = 0; i < binder.BindItems.Count; i++)
                {
                    itemsExpand.Add(false);
                }
            }

            for (int i = 0; i < binder.BindItems.Count; i++)
            {
                BaseDataBinder.DataBinderItem item = binder.BindItems[i];

                string itemLabel = "Item " + i;
                switch (item.Type)
                {
                case BaseDataBinder.DataBinderItem.BindType.Property:
                    if (item.Component != null && !string.IsNullOrEmpty(item.Property))
                    {
                        itemLabel = item.Component.GetType().Name + "(" + item.Property + ")";
                    }
                    break;

                case BaseDataBinder.DataBinderItem.BindType.Active:
                    itemLabel = "Active";
                    break;

                case BaseDataBinder.DataBinderItem.BindType.Animation:
                    itemLabel = "Animation";
                    break;

                case BaseDataBinder.DataBinderItem.BindType.Animator:
                    itemLabel = "Animator(" + item.AnimatorLayer + ")";
                    break;
                }

                if (!string.IsNullOrEmpty(item.Definer.Key))
                {
                    itemLabel += " : " + item.Definer.Key;
                }

                EditorGUILayout.Space();

                GUIStyle style = new GUIStyle(EditorStyles.foldout);
                style.fontStyle = FontStyle.Bold;
                itemsExpand[i]  = EditorGUILayout.Foldout(itemsExpand[i], itemLabel, true, style);

                if (itemsExpand[i])
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Type:");
                    item.Type = (BaseDataBinder.DataBinderItem.BindType)EditorGUILayout.EnumPopup(item.Type);
                    EditorGUILayout.EndHorizontal();

                    Type propertyType = null;

                    switch (item.Type)
                    {
                    case BaseDataBinder.DataBinderItem.BindType.Property:
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Component:");
                        int componentIndex = components.IndexOf(item.Component);
                        componentIndex = EditorGUILayout.Popup(componentIndex, componentsStr.ToArray());
                        if (componentsStr.Count > 0 && componentIndex >= 0 && componentIndex < componentsStr.Count)
                        {
                            item.Component = components[componentIndex];
                        }
                        EditorGUILayout.EndHorizontal();

                        List <string> propertiesStr  = new List <string>();
                        List <Type>   propertiesType = new List <Type>();
                        if (item.Component != null)
                        {
                            Type           componentType = item.Component.GetType();
                            PropertyInfo[] properties    = componentType.GetProperties();
                            for (int j = 0; j < properties.Length; j++)
                            {
                                PropertyInfo property  = properties[j];
                                MethodInfo   setMethod = property.GetSetMethod();
                                if (setMethod != null && setMethod.IsPublic)
                                {
                                    foreach (Type t in BaseData.SupportDataType)
                                    {
                                        if (t.IsAssignableFrom(property.PropertyType))
                                        {
                                            propertiesStr.Add(property.Name);
                                            propertiesType.Add(property.PropertyType);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Property:");
                        int propertyIndex = propertiesStr.IndexOf(item.Property);
                        propertyIndex = EditorGUILayout.Popup(propertyIndex, propertiesStr.ToArray());
                        if (propertiesStr.Count > 0 && propertyIndex >= 0 && propertyIndex < propertiesStr.Count)
                        {
                            item.Property = propertiesStr[propertyIndex];
                            propertyType  = propertiesType[propertyIndex];
                        }
                        EditorGUILayout.EndHorizontal();

                        break;

                    case BaseDataBinder.DataBinderItem.BindType.Active:
                        propertyType = typeof(Boolean);
                        break;

                    case BaseDataBinder.DataBinderItem.BindType.Animation:
                        propertyType = typeof(String);
                        break;

                    case BaseDataBinder.DataBinderItem.BindType.Animator:
                        propertyType = typeof(String);
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("AnimatorLayer:");
                        item.AnimatorLayer = EditorGUILayout.IntField(item.AnimatorLayer);
                        EditorGUILayout.EndHorizontal();
                        break;
                    }

                    if (!definerDrawers.ContainsKey(item.Definer))
                    {
                        definerDrawers[item.Definer] = new DataDefinerDrawer(item.Definer);
                    }
                    definerDrawers[item.Definer].Draw(binder.BindVM, binder.BindData, propertyType);

                    if (GUILayout.Button("Del"))
                    {
                        binder.BindItems.RemoveAt(i);
                        itemsExpand.RemoveAt(i);
                    }
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button("Add"))
            {
                binder.BindItems.Add(new BaseDataBinder.DataBinderItem());
                itemsExpand.Add(true);
            }
        }
예제 #12
0
파일: ListDomain.cs 프로젝트: jrivam/demo
 public ListDomain(IListData <T, U> datas)
 {
     Datas = datas;
 }
예제 #13
0
 public AccountController(IListData data,
                          UserManager <ApplicationViewModel> userManager)
 {
     this.data    = data;
     _userManager = userManager;
 }