public override bool afterAdd()
        {
            List <AgcBase> list = new List <AgcBase>();

            for (int i = 0; i < mRbList.Length; i++)
            {
                String[] kv = mRbList[i].Split(mSeparate);
                if (kv.Length != 2)
                {
                    continue;
                }

                AgcRadioButton agcCb = new AgcRadioButton(i, kv[1].Trim(), kv[0].Trim());
                list.Add(agcCb);
                agcrbList.Add(agcCb);
                agcrbDic[agcCb.Tag.ToString()] = agcCb;
            }
            list.AddRange(mAttachList);
            AgcSetting setting = new AgcSetting(true);

            setting.MarginButtom = 0;
            setting.SpacingY     = 0;
            mAgcCenter           = new AgcCenter <AgcCheckbox>(this.MPanel, setting, list);
            return(true);
        }
        private void init(Control container)
        {
            mType = typeof(T);
            TAG   = mType.Name;
            PropertyInfo[] mPropertyInfo = typeof(T).GetProperties();
            List <AgcBase> attachList    = new List <AgcBase>();

            try
            {
                mAgcSetting = (Attribute.GetCustomAttribute(mType, typeof(AgcSetting)) as AgcSetting);
            }
            catch (Exception)
            {
                mAgcSetting = new AgcSetting();
            }

            foreach (PropertyInfo pi in mPropertyInfo)
            {
                try
                {
                    Attribute attr = Attribute.GetCustomAttribute(pi, typeof(AgcBase));
                    if (attr != null)
                    {
                        AgcBase ab = (attr as AgcBase);
                        if (ab.isAttach)
                        {
                            attachList.Add(ab);
                        }
                        else
                        {
                            baseList.Add(ab);
                        }
                        propDic[pi.Name] = ab;
                    }
                }
                catch (System.Exception ex)
                {
                    throw new Exception(String.Format("{0} 获取控件配置出错:", mType) + ex.Message);
                }
            }

            if (attachList.Count > 0)
            {
                foreach (AgcBase var in attachList)
                {
                    try
                    {
                        (getControl(var.attachProp) as IAgcAttach).attach(var);
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("{0}: {1} 附加的属性名对应的控件未实现接口AGC.interfaces.IAgcAttach" + e.Message, TAG, var.Title));
                    }
                }
            }

            mContainer = container;
            mGanerator = new AgcGanerator(mContainer, mAgcSetting);
        }
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="container">需要生成控件的容器</param>
 /// <param name="agcSetting">生成配置</param>
 /// <param name="slots">需要额外添加的控件集合</param>
 public AgcCenter(Control container, AgcSetting agcSetting, List <AgcBase> slots)
 {
     mContainer = container;
     foreach (AgcBase ab in slots)
     {
         propDic.Add(ab.Tag.ToString(), ab);
     }
     baseList.AddRange(slots);
     mGanerator = new AgcGanerator(mContainer, agcSetting);
     this.generate();
 }
示例#4
0
 public AgcGanerator(Control container, AgcSetting agcSetting)
 {
     mContainer = container;
     mSetting   = agcSetting;
     init();
 }