Exemplo n.º 1
0
        public B GetComponent <B>(string memberName) where B : class, IOeipComponent
        {
            IOeipComponent oeipComponent = GetComponent(memberName);

            if (oeipComponent == null)
            {
                return(null);
            }
            return(oeipComponent as B);
        }
Exemplo n.º 2
0
 public override bool OnAddPanel <P>(IOeipComponent component, P panel)
 {
     if (panel == null)
     {
         return(false);
     }
     if (panel is FlowLayoutPanel)
     {
         UserControl userControl = component as UserControl;
         if (userControl == null)
         {
             return(false);
         }
         FlowLayoutPanel flowLayoutPanel = panel as FlowLayoutPanel;
         flowLayoutPanel.Controls.Add(userControl);
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 绑定一个结构/类到一个Panel上面
 /// </summary>
 /// <typeparam name="F"></typeparam>
 /// <param name="t"></param>
 /// <param name="panel"></param>
 /// <param name="onTemplate"></param>
 /// <param name="onAddPanel"></param>
 /// <param name="action"></param>
 public void Bind <P>(T t, P panel, Action <T> action = null)
 {
     obj        = t;
     attributes = OeipAttributeHelper.GetAttributes(t);
     onAction   = action;
     components = new List <IOeipComponent>();
     foreach (var attribute in attributes)
     {
         IOeipComponent component = CreateComponent(attribute);
         if (component == null)
         {
             continue;
         }
         bool bAdd = OnAddPanel(component, panel);
         if (!bAdd)
         {
             continue;
         }
         if (component is IOeipComponent <int> )
         {
             SetComponent <IOeipComponent <int>, int>(component as IOeipComponent <int>, attribute);
         }
         if (component is IOeipComponent <float> )
         {
             SetComponent <IOeipComponent <float>, float>(component as IOeipComponent <float>, attribute);
         }
         if (component is IOeipComponent <string> )
         {
             SetComponent <IOeipComponent <string>, string>(component as IOeipComponent <string>, attribute);
         }
         if (component is IOeipComponent <bool> )
         {
             SetComponent <IOeipComponent <bool>, bool>(component as IOeipComponent <bool>, attribute);
         }
         components.Add(component);
     }
     //更新所有控件值的显示
     Update();
     //让子类在这里也可以做些事
     OnBind();
 }
Exemplo n.º 4
0
 /// <summary>
 /// 如何把IOeipComponent类型UI组件添加到集合控件panel里
 /// </summary>
 /// <typeparam name="P"></typeparam>
 /// <param name="component"></param>
 /// <param name="panel"></param>
 /// <returns></returns>
 public abstract bool OnAddPanel <P>(IOeipComponent component, P panel);
Exemplo n.º 5
0
 private void OnValueChange <A>(A value, IOeipComponent <A> component)
 {
     component.ControlAttribute.SetValue(ref obj, value);
     onAction?.Invoke(obj);
     OnChangeEvent?.Invoke(this, component.ControlAttribute.Member.Name);
 }
Exemplo n.º 6
0
 public override bool OnAddPanel <P>(IOeipComponent component, P panel)
 {
     return(true);
 }