Пример #1
0
        /// <summary>
        /// 节点包含到项目中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void sdsite_ElementInclude(object sender, EventArgs <SimpleExIndexXmlElement> e)
        {
            BaseTreeNode eleNode = null;

            eleNode = this.GetNode(CurrentNode.FullPath);
            int eleIndex = eleNode.Index;

            BaseTreeNode parentNode = eleNode.Parent as BaseTreeNode;

            parentNode.RemoveChildNode(eleNode as BaseTreeNode);
            BaseTreeNode newNode = null;

            switch (e.Item.DataType)
            {
            case DataType.Channel:
                newNode = new ChannelNode(e.Item as ChannelSimpleExXmlElement);
                break;

            case DataType.Tmplt:
                newNode = new TmpltNode(e.Item as TmpltSimpleExXmlElement);
                break;

            case DataType.Page:
                newNode = new PageNode(e.Item as PageSimpleExXmlElement);
                break;

            case DataType.Folder:
            {
                switch (((FolderXmlElement)e.Item).FolderType)
                {
                case FolderType.ChannelFolder:
                    newNode = new ChannelFolderNode(e.Item as FolderXmlElement);
                    break;

                case FolderType.TmpltFolder:
                    newNode = new TmpltFolderNode(e.Item as TmpltFolderXmlElement);
                    break;

                case FolderType.ResourcesFolder:
                    newNode = new ResourceFolderNode(e.Item as FolderXmlElement);
                    break;
                }
                break;
            }

            case DataType.File:
                break;
            }
            //FileOutsideNode fileOutSideNode = new FileOutsideNode(e.Item.AbsoluteFilePath);
            parentNode.AddChildNode(newNode);
        }
Пример #2
0
        protected override void LoadChildNodes()
        {
            foreach (var node in Element.ChildNodes)
            {
                if (node is TmpltSimpleExXmlElement)
                {
                    TmpltNode tnode = (TmpltNode)AddElementNode((SimpleExIndexXmlElement)node);
                    if (tnode == null)
                    {
                        continue;
                    }

                    ///如果树是选择模板模式,则设置其Enabled状态
                    if (TreeView.TreeMode == TreeMode.SelectTmplt)
                    {
                        TmpltType tmpltType = (TmpltType)(int)TreeView.SelectTmpltType;

                        ///TmpltType.None的时候,可以选择所有模板,创建页面的类型根据选择的模板类型决定
                        if (tmpltType != TmpltType.None)
                        {
                            if (tnode.Element.TmpltType == tmpltType)
                            {
                                tnode.Enabled = true;
                            }
                            else
                            {
                                tnode.Enabled = false;
                            }
                        }
                    }
                }
                else if (node is FolderXmlElement)
                {
                    AddElementNode((SimpleExIndexXmlElement)node);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 通过element添加ElementNode节点,并添加到树中
        /// </summary>
        public virtual ElementNode AddElementNode(SimpleExIndexXmlElement element)
        {
            ///IsDeleted为true的,表示已经被删除,不显示
            if (element.IsDeleted)
            {
                return(null);
            }

            ElementNode elementNode = null;

            switch (element.DataType)
            {
            case DataType.Channel:
                //右侧树或选择频道才加载频道
                if (TreeView.TreeMode == TreeMode.General || TreeView.TreeMode == TreeMode.SelectChannel)
                {
                    elementNode = new ChannelNode(element as ChannelSimpleExXmlElement);
                }
                break;

            case DataType.Tmplt:
                //选择模板文件夹的树不加载模板文件
                if (TreeView.TreeMode == TreeMode.SelectTmplt || TreeView.TreeMode == TreeMode.General)
                {
                    elementNode = new TmpltNode(element as TmpltSimpleExXmlElement);
                }
                break;

            case DataType.Page:
                //只有在右侧树中才显示页面
                if (TreeView.TreeMode == TreeMode.General)
                {
                    elementNode = new PageNode(element as PageSimpleExXmlElement);
                }
                break;

            case DataType.Resources:
                //只有在右侧树中才显示资源文件夹
                if (TreeView.TreeMode == TreeMode.General)
                {
                    elementNode = new ResourceRootNode(element as ResourcesXmlElement);
                }
                break;

            case DataType.Folder:
            {
                switch (((FolderXmlElement)element).FolderType)
                {
                case FolderType.ChannelFolder:
                    //选择模板和选择模板文件夹的树不加载子频道
                    if (TreeView.TreeMode != TreeMode.SelectTmplt && TreeView.TreeMode != TreeMode.SelectTmpltFolder)
                    {
                        elementNode = new ChannelFolderNode(element as FolderXmlElement);
                    }
                    break;

                case FolderType.TmpltFolder:
                    elementNode = new TmpltFolderNode(element as FolderXmlElement);
                    break;

                case FolderType.ResourcesFolder:
                    elementNode = new ResourceFolderNode(element as FolderXmlElement);
                    break;

                default:
                    Debug.Fail("未处理的FolderType类型:" + ((FolderXmlElement)element).FolderType);
                    break;
                }

                break;
            }

            case DataType.File:
                elementNode = new ResourceFileNode(element as FileSimpleExXmlElement);
                break;

            case DataType.TmpltFolder:
                //选择频道的树不加载模板
                if (TreeView.TreeMode != TreeMode.SelectChannel)
                {
                    elementNode = new TmpltRootNode(element as TmpltFolderXmlElement);
                }
                break;

            default:
                Debug.Fail("未处理的Element的DataType:" + element.DataType);
                break;
            }

            if (elementNode == null)
            {
                return(null);
            }

            ///添加到树中
            if (elementNode is ResourceRootNode)
            {
                ///资源文件夹的根,添加到第一个
                this.AddChildNode(0, elementNode);

                ((RootChannelNode)this).ResourceRootNode = (ResourceRootNode)elementNode;
            }
            else if (elementNode is TmpltRootNode)
            {
                ///模板文件夹的根,添加到第二个
                this.AddChildNode(1, elementNode);

                ((RootChannelNode)this).TmpltRootNode = (TmpltRootNode)elementNode;
            }
            else
            {
                this.AddChildNode(elementNode);
            }

            ///调用LoadData()加载本身的数据
            elementNode.LoadData();

            ///添加到收藏夹
            if (elementNode.Element.IsFavorite)
            {
                if (TreeView.TreeMode == TreeMode.General)
                {
                    TreeView.AddLinkNodeToFavorite(elementNode);
                }
            }

            return(elementNode);
        }