예제 #1
0
        protected override void OnAfterExpand(TreeViewEventArgs e)
        {
            BaseTreeNode myNode = e.Node as BaseTreeNode;

            ///若ImageKey不等于CollapseImageKey,则认为它的图标正在表示特殊用途,那么不更换图标
            if (myNode.ImageKey == myNode.CollapseImageKey)
            {
                myNode.ImageKey         = myNode.FactImageKey;
                myNode.SelectedImageKey = myNode.ImageKey;
            }
            base.OnAfterExpand(e);
        }
예제 #2
0
        /// <summary>
        /// 移出收藏夹
        /// </summary>
        /// <param name="addTreeNodeAdvs">待移出的节点</param>
        public void RemoveFromFavorite()
        {
            this.BeginUpdate();
            SdsiteXmlDocument doc          = Service.Sdsite.CurrentDocument;
            BaseTreeNode      favoriteNode = SiteManagerNode.FavoriteRootNode;//收藏夹根节点

            BaseTreeNode[] arrSelectedNode = this.SelectedNodes.ToArray();
            foreach (BaseTreeNode node in arrSelectedNode)
            {
                doc.RemoveFavorite(((ElementNode)node).Element.Id);
            }
            this.EndUpdate();
        }
예제 #3
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);
        }
예제 #4
0
        void m_tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            BaseTreeNode myNode = e.Node as BaseTreeNode;

            if (myNode != null && (myNode.NodeType == TreeNodeType.TmpltFolder || myNode.NodeType == TreeNodeType.TmpltRootFolder))
            {
                OKBtn.Enabled    = true;
                nameTextBox.Text = XmlUtilService.CreateIncreaseTmpltTitle(((ElementNode)m_tree.CurrentNode).Element as FolderXmlElement, TranTmpltType);
            }
            else
            {
                OKBtn.Enabled = false;
            }
        }
예제 #5
0
 /// <summary>
 /// 检验是否已经加入收藏夹
 /// </summary>
 /// <param name="addNode"></param>
 /// <param name="favoriteNodeList"></param>
 /// <returns></returns>
 public bool IsInFavorite(BaseTreeNode addNode)
 {
     foreach (BaseTreeNode node in SiteManagerNode.FavoriteRootNode.Nodes)
     {
         if (((ElementNode)node).Element.Id != ((ElementNode)addNode).Element.Id)
         {
             continue;
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
예제 #6
0
        /// <summary>
        /// 与RemoveChildNodeTemp成对出现
        /// </summary>
        public int AddChildNodeTemp(int index, BaseTreeNode node)
        {
            int result = index;

            ///先添加到节点中
            if (index == -1)
            {
                result = this.Nodes.Add(node);
            }
            else
            {
                this.Nodes.Insert(index, node);
            }

            return(result);
        }
예제 #7
0
        /// <summary>
        /// 添加文件元素后对应树节点变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void sdsite_ElementAdded(object sender, EventArgs <SimpleExIndexXmlElement> e)
        {
            ElementNode newNode = AddElementNode(e.Item);

            if (newNode != null)
            {
                this.CurrentNode = newNode;

                switch (newNode.Element.DataType)
                {
                case DataType.Channel:
                case DataType.Folder:
                    this.RenameNode();
                    break;
                }
            }
            //CurrentNode = newNode;
            //if (newNode is BaseFileElementNode)
            //{
            //    if (newNode.NodeType == TreeNodeType.Page)
            //    {
            //        switch (((PageNode)newNode).Element.PageType)
            //        {
            //            case PageType.General:
            //                Service.Workbench.OpenWorkDocument(WorkDocumentType.HtmlDesigner, newNode.Element.Id);
            //                break;
            //            case PageType.Product:
            //            case PageType.Project:
            //            case PageType.InviteBidding:
            //            case PageType.Knowledge:
            //            case PageType.Hr:
            //                Service.Workbench.OpenWorkDocument(WorkDocumentType.Edit,e.Item.Id);// Service.Sdsite.CurrentDocument.RootChannel.Id);
            //                break;
            //            case PageType.Home:
            //                Service.Workbench.OpenWorkDocument(WorkDocumentType.HomePage, newNode.Element.Id);
            //                break;
            //        }
            //    }
            //    //todo:新增的页面,模板,资源文件后执行对应操作
            //}
            //else
            //{
            //    this.LabelEdit = true;
            //    RenameNode();
            //}
        }
예제 #8
0
        protected override void OnAfterCollapse(TreeViewEventArgs e)
        {
            BaseTreeNode myNode = e.Node as BaseTreeNode;

            ///若是SiteManagerNode(即根节点)折叠,则再次展开,即不允许其折叠
            if (myNode == SiteManagerNode)
            {
                SiteManagerNode.Expand();
                return;
            }

            ///若ImageKey不等于ExpandImageKey,则认为它的图标正在表示特殊用途,那么不更换图标
            if (myNode.ImageKey == myNode.ExpandImageKey)
            {
                myNode.ImageKey         = myNode.FactImageKey;
                myNode.SelectedImageKey = myNode.ImageKey;
            }
            base.OnAfterCollapse(e);
        }
예제 #9
0
        public override void MenuOpening()
        {
            ///先判断选择的数量,不等于1则不显示
            if (TreeView.SelectedNodes.Count == 1)
            {
                BaseTreeNode node = TreeView.CurrentNode;
                if (node.NodeType == TreeNodeType.Link)
                {
                    node = ((LinkNode)node).TargetNode;
                }

                if (node.NodeType == TreeNodeType.Link ||
                    node.NodeType == TreeNodeType.Page ||
                    node.NodeType == TreeNodeType.ResourceFile ||
                    node.NodeType == TreeNodeType.Tmplt)
                {
                    this.Visible = true;
                    return;
                }
            }
            this.Visible = false;
        }
예제 #10
0
        /// <summary>
        /// 通过此方法判定是否允许将srcNode放入targetNode节点,作为targetNode的子节点
        /// </summary>
        public override bool CanInto(BaseTreeNode srcNode, BaseTreeNode targetNode)
        {
            if (this.TreeMode != TreeMode.General)
            {
                return(false);
            }

            if ((srcNode.NodeType == TreeNodeType.Tmplt || srcNode.NodeType == TreeNodeType.TmpltFolder) &&
                (targetNode.NodeType == TreeNodeType.ChannelFolder || targetNode.NodeType == TreeNodeType.Channel) ||
                (srcNode.NodeType == TreeNodeType.TmpltFolder && targetNode.NodeType == TreeNodeType.RootChannel) ||
                (srcNode.NodeType == TreeNodeType.ResourceFolder && targetNode.NodeType == TreeNodeType.RootChannel))
            {
                return(false);
            }

            /* if (!((baseSrcNode.NodeType == TreeNodeType.ResourceFolder || baseSrcNode.NodeType == TreeNodeType.ResourceFile)
             *   && (baseTargetNode.NodeType == TreeNodeType.ResourceFolder || baseTargetNode.NodeType == TreeNodeType.ResourceRoot)))
             * {
             *   return false;
             * }*/

            return(base.CanInto(srcNode, targetNode));
        }
예제 #11
0
        /// <summary>
        /// 节点排除出项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void sdsite_ElementExclude(object sender, EventArgs <SimpleExIndexXmlElement> e)
        {
            ElementNode eleNode  = GetElementNode(e.Item.Id);
            int         eleIndex = eleNode.Index;

            BaseTreeNode parentNode = eleNode.Parent;

            parentNode.RemoveChildNode(eleNode);
            if (ShowAllFiles)
            {
                OutsideNode outSideNode = null;
                if (e.Item is FolderXmlElement)
                {
                    outSideNode = new FileOutsideNode(e.Item.AbsoluteFilePath);
                }
                else
                {
                    outSideNode = new FolderOutsideNode(e.Item.AbsoluteFilePath);
                }
                outSideNode.Text = e.Item.FileName;
                parentNode.Nodes.Insert(eleIndex, outSideNode);
            }
        }
예제 #12
0
        public void DeleteSelectNodes()
        {
            if (SelectedNodes.Count > 0)
            {
                ///先判断是否所有节点可以删除.有任何不可以删除的节点则不执行任何删除操作
                foreach (BaseTreeNode node in this.SelectedNodes)
                {
                    if (!node.CanDelete)
                    {
                        return;
                    }
                }

                ///所有节点都可以删除,那么真正执行删除命令
                if (MessageService.Show("${res:Tree.msg.delete}", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    BaseTreeNode[] treeNodes      = this.SelectedNodes.ToArray();
                    BaseTreeNode   nextSelectNode = (BaseTreeNode)treeNodes[0].PrevNode;

                    foreach (ElementNode node in treeNodes)
                    {
                        bool result = Service.Sdsite.CurrentDocument.DeleteItem(node.Element);

                        ///为false则表示删除失败。
                        if (!result)
                        {
                            nextSelectNode = node;
                            break;
                        }
                    }
                    this.CurrentNode = (BaseTreeNode)nextSelectNode;
                    this.Select();
                    this.Focus();
                }
            }
        }
예제 #13
0
        public virtual int AddChildNode(int index, BaseTreeNode node)
        {
            int result = index;

            ///先添加到节点中
            if (index == -1)
            {
                result = this.Nodes.Add(node);
            }
            else
            {
                this.Nodes.Insert(index, node);
            }

            ///设置图标
            node.SelectedImageKey = node.ImageKey = node.FactImageKey;

            ///初始化节点状态
            TreeView.InitNode(node);

            ///检查文件是否正常
            if (node is ElementNode)
            {
                ElementNode elementNode = (ElementNode)node;

                ///添加到TreeNode的dic容器里去
                if (TreeView.TreeMode == TreeMode.General && elementNode.NodeType != TreeNodeType.Link)
                {
                    TreeView.SetElementNode(elementNode);
                }

                ///检查文件是否存在:不存在,则在图标上画一个感叹号
                if (!Utility.File.Exists(elementNode.Element.AbsoluteFilePath))
                {
                    string signKey = Service.Draw.GetSignKey(node.FactImageKey, SignType.ExcalmatoryPoint);
                    if (!this.TreeView.ImageList.Images.ContainsKey(signKey))
                    {
                        ///若是资源文件节点,则先确定图标已经存在
                        if (elementNode is ResourceFileNode)
                        {
                            ResourceFileNode fileNode = (ResourceFileNode)elementNode;
                            fileNode.InsureIcon();
                        }

                        ///画标记
                        Image signImage = this.TreeView.ImageList.Images[node.FactImageKey];
                        Service.Draw.DrawSign(signImage, SignType.ExcalmatoryPoint);
                        this.TreeView.ImageList.Images.Add(signKey, signImage);
                    }

                    node.SelectedImageKey = node.ImageKey = signKey;

                    if (elementNode.IsFolder)
                    {
                        node.ToolTipText = "此文件夹不存在!";
                    }
                    else
                    {
                        node.ToolTipText = "此文件不存在!";
                    }
                }
                else
                {
                    bool isHealthy = true;
                    switch (elementNode.Element.DataType)
                    {
                    ///检查非首页型模板是否有正文型页面片
                    case DataType.Tmplt:
                    {
                        TmpltSimpleExXmlElement tmpltEle = elementNode.Element as TmpltSimpleExXmlElement;
                        if (tmpltEle.TmpltType != TmpltType.Home && !tmpltEle.HasContentSnip)
                        {
                            isHealthy = false;
                            elementNode.ToolTipText = "此模板没有正文型页面片。属于不完整模板。\r\n请为此模板创建正文型页面片,否则关联到它的页面无法正常生成。";
                        }
                        break;
                    }

                    ///检查页面是否正确关联了模板
                    case DataType.Page:
                    {
                        PageSimpleExXmlElement pageEle = elementNode.Element as PageSimpleExXmlElement;
                        if (string.IsNullOrEmpty(pageEle.TmpltId))
                        {
                            isHealthy = false;
                            elementNode.ToolTipText = "此页面没有设置关联模板,属于不完整页面。\r\n请重新选择关联模板,否则将无法生成最终页面。";
                        }
                        else
                        {
                            TmpltSimpleExXmlElement tmpltEle = Service.Sdsite.CurrentDocument.GetTmpltElementById(pageEle.TmpltId);
                            if (tmpltEle == null ||
                                !File.Exists(tmpltEle.AbsoluteFilePath))
                            {
                                isHealthy = false;
                                elementNode.ToolTipText = "此页面关联的模板未能找到,属于不完整页面。\r\n请重新选择关联模板,否则无法生成最终页面。";
                            }
                            else
                            {
                                isHealthy = true;
                                //ElementNode tmpltNode = TreeView.GetElementNode(tmpltEle.Id);
                                //if (tmpltNode != null)
                                //{
                                //    elementNode.ToolTipText = "此页面完整,关联的模板是:" + tmpltNode.FullPath + "。\r\n可生成最终页面。";
                                //}
                            }
                        }
                        break;
                    }
                    }

                    ///不健康节点,在图标上添加标记
                    if (!isHealthy)
                    {
                        string signKey = Service.Draw.GetSignKey(node.FactImageKey, SignType.QuestionPoint);
                        if (!this.TreeView.ImageList.Images.ContainsKey(signKey))
                        {
                            Image signImage = this.TreeView.ImageList.Images[node.FactImageKey];
                            Service.Draw.DrawSign(signImage, SignType.QuestionPoint);
                            this.TreeView.ImageList.Images.Add(signKey, signImage);
                        }

                        node.SelectedImageKey = node.ImageKey = signKey;
                    }
                }
            }

            return(result);
        }
예제 #14
0
 public override void SetElementNode(BaseTreeNode elementNode)
 {
     _dicNodeIndexs[((ElementNode)elementNode).Element.Id] = (ElementNode)elementNode;
 }
예제 #15
0
 /// <summary>
 /// 临时删除,一般供移动时使用
 /// </summary>
 public void RemoveChildNodeTemp(BaseTreeNode node)
 {
     ((TreeNode)node).Remove();
 }
예제 #16
0
        /// <summary>
        /// 此方法最终调用RemoveChildNode方法
        /// </summary>
        public void RemoveChildNodeAt(int index)
        {
            BaseTreeNode node = (BaseTreeNode)this.Nodes[index];

            RemoveChildNode(node);
        }
예제 #17
0
        /// <summary>
        /// 拖拽结束,将要移动节点的预处理。返回值:是否取消拖拽
        /// </summary>
        /// <param name="srcNode"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        void ProcessDragDropedNode(BaseTreeNode srcNode, DragDropNodeEventArgs e)
        {
            BaseTreeNode            putNode   = e.DragDropResult.DropPutNode as BaseTreeNode;
            SdsiteXmlDocument       doc       = Service.Sdsite.CurrentDocument;
            SimpleExIndexXmlElement dragEle   = ((ElementNode)srcNode).Element;
            SimpleExIndexXmlElement targetEle = null;

            if (e.DragDropResult.DropPutNode is DataNode)
            {
                targetEle = ((ElementNode)e.DragDropResult.DropPutNode).Element;
            }

            ///将要拖放到此节点内
            BaseTreeNode parentNode = null;

            if (e.DragDropResult.DropResultType == DragDropResultType.Into)
            {
                parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode;
            }
            else
            {
                parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode.Parent;
            }

            ///收藏夹的处理方式
            if (parentNode.NodeType == TreeNodeType.Favorite)
            {
                doc.AddFavorite(dragEle);
            }
            ///
            else
            {
                ///移动
                if ((e.DrgEvent.Effect & DragDropEffects.Move) != 0)
                {
                    ///处理XmlElement
                    bool result = doc.MoveNode(dragEle, targetEle, e.DragDropResult.DropResultType);

                    if (result)
                    {
                        ///处理树节点
                        srcNode.Parent.RemoveChildNodeTemp(srcNode);
                        switch (e.DragDropResult.DropResultType)
                        {
                        case DragDropResultType.Before:
                            putNode.Parent.AddChildNodeTemp(putNode.Index, srcNode);
                            break;

                        case DragDropResultType.After:
                            putNode.Parent.AddChildNodeTemp(putNode.Index + 1, srcNode);
                            break;

                        case DragDropResultType.Into:
                            putNode.AddChildNodeTemp(srcNode);
                            break;

                        default:
                            Debug.Assert(false);
                            break;
                        }
                    }
                }
                ///拷贝
                else if ((e.DrgEvent.Effect & DragDropEffects.Copy) != 0)
                {
                    doc.CopyNode(dragEle.Id, ((ElementNode)parentNode).Element.Id);
                }
            }
        }
예제 #18
0
 /// <summary>
 /// 与RemoveChildNodeTemp成对出现
 /// </summary>
 public int AddChildNodeTemp(BaseTreeNode node)
 {
     return(AddChildNodeTemp(-1, node));
 }