예제 #1
0
        /// <summary>
        /// 数据转换到控件
        /// </summary>
        protected ToolsBarSetting DataConvterCtrl(ToolsBarData BarData)
        {
            string          pathbase = Lemon.GetCSFRootDirectory();
            ToolsBarSetting result   = new ToolsBarSetting();

            //工具栏
            foreach (TBar tbar in BarData.Bars)
            {
                ToolsBar newBar = new ToolsBar();
                newBar.ParentFormName = tbar.ParentFormName;
                newBar.ToolsBarCode   = tbar.ToolsBarCode;
                newBar.ToolsBarName   = tbar.ToolsBarName;
                result.Bars.Add(newBar);
            }
            //按钮
            foreach (TButton tbtn in BarData.Buttons)
            {
                ToolsButton newBtn = new ToolsButton();
                newBtn.AssemblyPath  = pathbase + tbtn.Assembly;
                newBtn.FullClassName = tbtn.FullClassName;
                newBtn.GroupName     = tbtn.GroupName;
                newBtn.ItemImage     = pathbase + tbtn.ItemImage;
                newBtn.ItemIndex     = tbtn.ItemIndex;
                newBtn.Title         = tbtn.Title;
                newBtn.ToolsBarCode  = tbtn.ToolsBarCode;
                IControlToolsButton elm = Lemon.GetInstance <IControlToolsButton>(newBtn.AssemblyPath, newBtn.FullClassName);
                if (elm != null)
                {
                    newBtn.UIElement = elm;
                    result.Buttons.Add(newBtn);
                }
                else
                {
                    Lemon.SendMsgDebug("配置的工具栏按钮" + newBtn.ToolsBarCode + "没有实现IUIElement接口");
                }
            }
            //下拉框
            foreach (TComboBox tcb in BarData.ComboBoxs)
            {
                ToolsComboBox newCb = new ToolsComboBox();
                newCb.GroupName    = tcb.GroupName;
                newCb.ItemIndex    = tcb.ItemIndex;
                newCb.ToolsBarCode = tcb.ToolsBarCode;
                IControlToolsComoBoxItem cbelm = Lemon.GetInstance <IControlToolsComoBoxItem>(tcb.Assembly, tcb.FullClassName);
                if (cbelm != null)
                {
                    newCb.UIElement = cbelm;
                }
                else
                {
                    Lemon.SendMsgDebug("配置的工具栏下拉框" + newCb.ToolsBarCode + "没有实现IUIElement接口");
                }
                foreach (TComboBoxItem ti in tcb.Items)
                {
                    ToolsComboBoxItem newItem = new ToolsComboBoxItem();
                    ti.Assembly      = pathbase + ti.Assembly;
                    newItem.ItemData = ti;
                    IControlToolsComoBoxItem elm = Lemon.GetInstance <IControlToolsComoBoxItem>(ti.Assembly, ti.FullClassName);
                    if (elm != null)
                    {
                        newItem.UIElement = elm;
                        newCb.Items.Add(newItem);
                    }
                    else
                    {
                        Lemon.SendMsgDebug("配置的工具栏下拉框的选项" + ti.Title + "没有实现IUIElement接口");
                    }
                }
                result.ComboBoxs.Add(newCb);
            }
            //分栏
            foreach (TSeparator tsep in BarData.Separator)
            {
                ToolsSeparator newSep = new ToolsSeparator();
                newSep.GroupName    = tsep.GroupName;
                newSep.ItemIndex    = tsep.ItemIndex;
                newSep.ToolsBarCode = tsep.ToolsBarCode;
                result.Separator.Add(newSep);
            }
            return(result);
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Data"></param>
 public ToolsBarFactroy(ToolsBarData Data)
 {
     BarSetting = DataConvterCtrl(Data);
 }