public NodeDataObject ChangeTo(NodeDataObject sourceObject)
 {
     NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("DetailText");
     dataObject.DataItem.Path = sourceObject.DataItem.Path;
     //在数据库中创建对象
     dataObject.AccessObject.Create(dataObject.DataItem);
     return dataObject;
 }
 public NodeDataObject ChangeTo(NodeDataObject sourceObject,String EFConnectionString)
 {
     NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("OnlyText", EFConnectionString);
     dataObject.DataItem.Path = sourceObject.DataItem.Path;
     //在数据库中删除记录
     sourceObject.AccessObject.DeleteDataInfoObject(sourceObject.DataItem);
     return dataObject;
 }
Example #3
0
        public InterfaceLibrary.NodeDataObject ChangeTo(InterfaceLibrary.NodeDataObject sourceObject, String EFConnectionString)
        {
            NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("Folder", EFConnectionString);

            dataObject.DataItem.Path = sourceObject.DataItem.Path;
            //在数据库中创建对象
            dataObject.AccessObject.Create(dataObject.DataItem);
            return(dataObject);
        }
        public InterfaceLibrary.NodeDataObject ChangeTo(InterfaceLibrary.NodeDataObject sourceObject, String EFConnectionString)
        {
            NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("OnlyText", EFConnectionString);

            dataObject.DataItem.Path = sourceObject.DataItem.Path;
            //在数据库中删除记录
            sourceObject.AccessObject.DeleteDataInfoObject(sourceObject.DataItem);
            return(dataObject);
        }
        public InterfaceLibrary.NodeDataObject ChangeTo(InterfaceLibrary.NodeDataObject sourceObject, String EFConnectionString)
        {
            FolderInfo     folderInfo = sourceObject.DataItem as FolderInfo;
            NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("DetailText", EFConnectionString);
            DetailTextInfo detailInfo = dataObject.DataItem as DetailTextInfo;

            detailInfo.Path    = sourceObject.DataItem.Path;
            detailInfo.Text    = folderInfo.Text;
            detailInfo.RTFText = folderInfo.RTFText;
            //在数据库中删除记录
            sourceObject.AccessObject.DeleteDataInfoObject(folderInfo);
            //在数据库中创建对象
            dataObject.AccessObject.Create(detailInfo);
            return(dataObject);
        }
Example #6
0
 /// <summary>
 /// 依据数据库连接字串(EntityFramework格式)创建合适的IDataAcess对象
 /// </summary>
 /// <param name="NodeType"></param>
 /// <param name="EFConnectionString"></param>
 /// <returns></returns>
 public static IDataAccess CreateNodeAccessObject(String NodeType,String EFConnectionString)
 {
     NodeDataObject nodeDataObject = new NodeDataObject();
     if (NodeType == "OnlyText")
     {
         return null;
     }
     if (NodeType == "Folder")
     {
         return new FolderAccess(EFConnectionString);
     }
     if (NodeType == "DetailText")
     {
         return new DetailTextAccess(EFConnectionString);
     }
     return null;
 }
Example #7
0
        /// <summary>
        /// 依据节点类型创建"空白"的数据信息对象,其HasBeenLoadFromStorage属性为false
        /// (无需数据存储的节点,如OnlyText例此,其HasBeenLoadFromStorage始终为true)
        /// </summary>
        /// <param name="NodeType"></param>
        /// <returns></returns>
        public static NodeDataObject CreateDataInfoNode(String NodeType,String EFConnectionString)
        {
            NodeDataObject nodeDataObject = new NodeDataObject();
            if (NodeType == "OnlyText")
            {
                nodeDataObject.DataItem = new OnlyTextInfo() { MainWindow=_mainWindow };
                nodeDataObject.AccessObject = null;
            }
            if (NodeType == "Folder")
            {
                FolderInfo info = new FolderInfo() { MainWindow = _mainWindow };
                FolderAccess access = new FolderAccess(EFConnectionString) ;
                info.SetRootControlDataAccessObj(access);

                nodeDataObject.DataItem =info ;
                //设置数据未装入标记
                nodeDataObject.DataItem.HasBeenLoadFromStorage = false;

                nodeDataObject.AccessObject =access ;

            }
            if (NodeType == "DetailText")
            {
                DetailTextInfo info = new DetailTextInfo() { MainWindow = _mainWindow };
                DetailTextAccess accessObj= new DetailTextAccess(EFConnectionString);

                info.SetRootControlDataAccessObj(accessObj);
                nodeDataObject.DataItem=info;
                //设置数据未装入标记
                nodeDataObject.DataItem.HasBeenLoadFromStorage = false;

                nodeDataObject.AccessObject = accessObj;

            }
            return nodeDataObject;
        }
 /// <summary>
 /// 依据节点类型创建"空白"的数据信息对象,其HasBeenLoadFromStorage属性为false
 /// (无需数据存储的节点,如OnlyText例此,其HasBeenLoadFromStorage始终为true)
 /// </summary>
 /// <param name="NodeType"></param>
 /// <returns></returns>
 public static NodeDataObject CreateDataInfoNode(String NodeType)
 {
     NodeDataObject nodeDataObject = new NodeDataObject();
     if (NodeType == "OnlyText")
     {
         nodeDataObject.DataItem = new OnlyTextInfo();
         nodeDataObject.AccessObject = null;
     }
     if (NodeType == "Folder")
     {
         nodeDataObject.DataItem = new FolderInfo();
         //设置数据未装入标记
         nodeDataObject.DataItem.HasBeenLoadFromStorage = false;
         nodeDataObject.AccessObject = new FolderAccess();
     }
     if (NodeType == "DetailText")
     {
         nodeDataObject.DataItem=new DetailTextInfo();
         //设置数据未装入标记
         nodeDataObject.DataItem.HasBeenLoadFromStorage = false;
         nodeDataObject.AccessObject=new DetailTextAccess();
     }
     return nodeDataObject;
 }
        /// <summary>
        /// 添加节点
        /// 成功返回新节点,不成功,返回null
        /// 新节点自动展开且选中
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="nodeText"></param>
        /// <param name="nodeIcon"></param>
        /// <returns></returns>
        private TreeViewIconsItem addNode(AddNodeCategory addType, TreeViewIconsItem selectedNode, String nodeText, NodeDataObject nodeDataObject)
        {
            if (selectedNode != null)
            {
                selectedNode.IsExpanded = true;
            }

            TreeViewIconsItem treeNode = new TreeViewIconsItem(this, nodeDataObject);
            treeNode.HeaderText = nodeText;
            treeNode.Icon = nodeDataObject.DataItem.NormalIcon;
            //自动展开
            treeNode.IsExpanded = true;
            switch (addType)
            {
                case AddNodeCategory.AddRoot:
                    treeNode.Path = "/" + nodeText + "/";
                    nodeDataObject.DataItem.Path = treeNode.Path;
                    tree.Items.Add(treeNode);
                    nodesManager.nodes.Add(treeNode);
                    break;
                case AddNodeCategory.AddChild:
                    if (selectedNode != null)
                    {
                        treeNode.Path = selectedNode.Path + nodeText + "/";
                        nodeDataObject.DataItem.Path = treeNode.Path;
                        selectedNode.Items.Add(treeNode);
                        nodesManager.nodes.Add(treeNode);
                    }
                    else
                    {
                        return null;
                    }
                    break;
                case AddNodeCategory.AddSibling:
                    if (selectedNode != null && selectedNode.Parent != null)
                    {
                        //如果选中节点是顶层节点
                        if (selectedNode.Parent == tree)
                        {
                            treeNode.Path = "/" + nodeText + "/";
                            nodeDataObject.DataItem.Path = treeNode.Path;
                            tree.Items.Add(treeNode);
                        }
                        else
                        {
                            //不是顶层节点
                            TreeViewIconsItem parent = selectedNode.Parent as TreeViewIconsItem;
                            treeNode.Path = parent.Path + nodeText + "/";
                            nodeDataObject.DataItem.Path = treeNode.Path;
                            parent.Items.Add(treeNode);
                        }
                        nodesManager.nodes.Add(treeNode);
                    }
                    else  //当前没有选中节点或选中节点没有父亲
                    {
                        return null;
                    }

                    break;
                default:
                    break;
            }
            if (_autoSelectNewNode)
            {
                treeNode.IsSelected = true;
            }

            //更新树的存储
            String treeXml = saveToXmlString();
            MainTreeRepository.SaveTree(treeXml);

            return treeNode;
        }
 /// <summary>
 /// 添加兄弟节点,如果参数中有为null或空串的,或者当前TreeView中没有选中的节点,返回null
 /// </summary>
 /// <param name="nodeText"></param>
 /// <param name="nodeIcon"></param>
 /// <returns></returns>
 public TreeViewIconsItem AddSibling(String nodeText, NodeDataObject nodeDataObject)
 {
     if (String.IsNullOrEmpty(nodeText) || tree.SelectedItem == null)
     {
         return null;
     }
     return addNode(AddNodeCategory.AddSibling, tree.SelectedItem as TreeViewIconsItem, nodeText, nodeDataObject);
 }
 /// <summary>
 /// 添加根节点,如果参数中有为null或空串的,返回null
 /// </summary>
 /// <param name="nodeText"></param>
 /// <param name="nodeIcon"></param>
 /// <returns></returns>
 public TreeViewIconsItem AddRoot(String nodeText, NodeDataObject nodeDataObject)
 {
     if (String.IsNullOrEmpty(nodeText) )
     {
         return null;
     }
     return addNode(AddNodeCategory.AddRoot, null, nodeText, nodeDataObject);
 }