示例#1
0
    public void AddItem()
    {
        InputTextDialog.Open(
            delegate(byte[] bts)
        {
            //创建文件夹
            IoBuffer ib = new IoBuffer();
            ib.PutBytes(bts);
            string inputFieldText = ib.GetString();
            if (!BeFolderOpen)
            {
                OpenFolder();                                 //没打开的先打开再创建,否则位置错乱
            }
            var ti = TreeItem.Create(inputFieldText, this, MyTreeContainer);


            //nafio add 170623 这段代码有点冗余应该赋值一次就可以,类似重复的代码也需要整理下
//				if (null != MyMenuList.CurSelItem &&
//					!MyMenuList.CurSelItem.Equals (ti))
//				{
//					MyMenuList.CurSelItem.DeSelect();
//				}

            ti.TreeItemID = GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].CreateKVList(MyTreeContainer.Name);


            MyTreeContainer.CurSelItem = ti;
            //ti.OnSelect ();

            Log.i("TreeFolder", "AddItem", "新建item name:" + inputFieldText + " id:" + ti.TreeItemID, BeShowLog);
        }
            );
    }
示例#2
0
    /// <summary>
    /// 使用数据填充具体item项
    /// 这个是app开始从配置中读数据
    /// 不需要向sql写入
    /// </summary>
    /// <param name="ib">Ib.</param>
    public void AddItemByData(IoBuffer ib)
    {
        string name     = ib.GetString();
        string id       = ib.GetString();
        var    treeItem = TreeItem.Create(name, this, MyTreeContainer);

        treeItem.TreeItemID = id;
    }
示例#3
0
    /// <summary>
    /// 这里的黏贴是treeItme的黏贴,不存在文件夹整体黏贴的说法
    /// treefolder的黏贴跟TreeItem有些不同(除了这些不同其他都相同,跟treeitem paste的操作类似)
    /// treeItem是把黏贴项放到自己之前
    /// treefoler是把黏贴项放到自己内部所有元素之后
    /// </summary>
    public void Paste()
    {
        //这里要判定黏贴板上是否有数据
        if (MyTreeContainer.CurCopyItem == null)
        {
            Log.i("TreeItem", "Paste", "黏贴的数据为null,不该出现的状态", BeShowLog);
            return;
        }

        if (!BeFolderOpen)
        {
            OpenFolder();               //没打开的先打开再创建,否则位置错乱
        }
        //创建新位置的item的ui,ui节点名称与黏贴板上的一致
        var ti = TreeItem.Create(MyTreeContainer.CurCopyItem.Name, this, MyTreeContainer);

        //如果是剪切,要删除前一个状态
        if (MyTreeContainer.CurCopyItem.BeCut)
        {
            Log.i("TreeItem", "Paste", "开始黏贴", BeShowLog);
            MyTreeContainer.CurCopyItem.BeCut = false;
            MyTreeContainer.CurCopyItem.DelItem(false);
            ti.TreeItemID = MyTreeContainer.CurCopyItem.TreeItemID;//黏贴的话id保持不变
        }
        else//如果是copy,要新生成sql数据,拿到ID,然后再插入数据
        {
            //step1 创建一个空的默认数据  新建sql并拿回新id
            string   kvType           = this.MyTreeContainer.Name;
            string[] _defaultDate     = GEditorConfig.GetKVDefaultValueData(kvType);
            string[] _fullDefaultDate = GEditorConfig.GetFullKVDefaultValueData(kvType, _defaultDate);
            int      newID            = GEditorDataMgr.CreateKVSqlData(kvType, _fullDefaultDate);

            ti.TreeItemID = newID.ToString();
            Log.i("TreeFolder", "Paste", "新建数据完毕返回 newID:" + newID, BeShowLog);
            //step2 获取旧数据 根据treeItem.ID(被copy的那个item的sql数据id)查询copy的数据
            //string[] rowNames = GEditorConfig.GetKVRowNames(kvType);
            string[] copyDate = GEditorDataMgr.QueryKVSqlData(kvType /*,rowNames*/, Convert.ToInt32(MyTreeContainer.CurCopyItem.TreeItemID));

            //step3 向新建的空位置添加旧数据,id使用新id
            copyDate[1] = newID.ToString();//特别注意这里是第一个元素,不是第0个,可以参考SQLiteHelper4DataEditor的说明

            string[] Col_Names_InSql = SQLiteHelper4DataEditor.Get_Col_Names_InSql(kvType);

            GEditorDataMgr.ModifyKVSqlData(kvType, Col_Names_InSql, copyDate, newID);
        }
        //黏贴要要清理黏贴版,这里暂时逻辑为无论剪切还是复制,每到黏贴时都要请客剪贴板
        MyTreeContainer.CurCopyItem = null;

        Log.i("TreeItem", "Paste", "黏贴的item ID:" + ti.TreeItemID, BeShowLog);
    }