Пример #1
0
 public void TabItemCreate_Ok()
 {
     TabItem.Create(new Dictionary <string, object?>()
     {
         ["Url"] = null
     });
     TabItem.Create(new Dictionary <string, object?>()
     {
         ["Url"] = new NullString()
     });
 }
Пример #2
0
    /// <summary>
    /// 编辑器初始化,重要流程
    /// </summary>
    private void InitGEditor()
    {
        //创建Tab管理器
        TabContainer = new TabContainer(TabContainer.TabLayoutType.horizontal, TabPanel);
        TabContainer.TabSelectEvent   = OnTabSelect;
        TabContainer.TabDeSelectEvent = OnTabDeSelect;

        //创建Tree管理器
        if (null == TreeContainerDic)
        {
            TreeContainerDic = new Dictionary <string, TreeContainer> ();
        }

        //创建列表管理器
        if (null == KVContainerDic)
        {
            KVContainerDic = new Dictionary <string, KVContainer>();
        }

        //加载tab数据,根据数据创建打开tab
        //检测是否存在tab.config配置文件,如果没有,就使用默认打开项目(GEditorEnum.OPENED_EDITORS)
        string tabCfgPath     = GEditorEnum.EDITOR_DATA_ROOTURL + GEditorEnum.EDITOR_TAB_CONFIG_NAME;
        bool   beTabCfgExists = FileHelper.BeFileExists(tabCfgPath);

        //VLog.I("tabCfgPaht:"+tabCfgPath+" beExis:"+beTabCfgExists);
        string[,] _CurOpenedTabs = null;
        if (beTabCfgExists)
        {
            _CurOpenedTabs = GEditorDataMgr.LoadTabConfig(tabCfgPath);                        //非首次,使用tab.config中记录的数据
        }
        else
        {
            _CurOpenedTabs = GEditorEnum.OPENED_EDITORS;         //首次打开,不存tab.config相关记录,使用默认打开tab页
        }
        for (int i = 0; i < _CurOpenedTabs.GetLength(0); i++)
        {
            //根据数创建tab项
            TabData tabData = new TabData();
            tabData.Name    = _CurOpenedTabs[i, 0];
            tabData.RefName = _CurOpenedTabs[i, 1];
            tabData.Index   = i;

            var tabItem = TabItem.Create(tabData, TabPanel, TabContainer);
            TabContainer.Add(tabItem);

            //根据现有打开的tab,创建对应的tree项
            string        treeCfgPath        = GEditorEnum.EDITOR_DATA_ROOTURL + GEditorEnum.EDITOR_TREE_CONFIG_NAME + tabData.RefName + ".config";
            bool          beTreeConfigExists = FileHelper.BeFileExists(treeCfgPath);
            TreeContainer treeContainer      = new TreeContainer();
            if (beTreeConfigExists)            //treeConfig配表存在,从配表载入TreeContainer
            {
                byte[] bs = GEditorDataMgr.LoadOneTreeConfig(treeCfgPath);
                treeContainer.CreateByData(tabData.RefName, TreePanel, TreePanel, 0, 0, bs);
                TreeContainerDic.Add(tabData.RefName, treeContainer);
            }
            else            //treeConfig配表不存在存在,创建新的根节点
            {
                treeContainer.Create(tabData.RefName, TreePanel, TreePanel, 0, 0);
                TreeContainerDic.Add(tabData.RefName, treeContainer);
            }
            treeContainer.Hide();            //创建完先隐藏,等等具体tab被选中时才显示


            //设置tabitem初始选中状态,这句需要放在TreeContainer被创建之后,
            //因为Beselect一旦被执行,就会执行切换TreeContainer的操作,如果TreeContainer还没被创建,就会出错
            if (i == 0)
            {
                tabItem.BeSelecte = true;
            }
            else
            {
                tabItem.BeSelecte = false;
            }


            //创建KVContainer,打开几个tab创建几个,跟tree类似
            KVContainerDic.Add(tabData.RefName, new KVContainer(KeyValuePanel, KeyPanel, ValuePanel, tabData.RefName));
        }

        //打开数据库,保持长连接
        GEditorDataMgr.ConnectSql();

        //判定是否是首次打开editor,如果是创建sql table,并创建首次打开标示文件app.config
        GEditorDataMgr.CheckSQLTableExist();
    }