Exemple #1
0
        /// <summary>
        /// 初始化树数据
        /// </summary>
        public void LoadTreeData()
        {
            this.BeginUpdate();

            this.Nodes.Clear();
            TmpltFolderXmlElement sdsiteDoc = Service.Sdsite.CurrentDocument.TmpltFolder;

            foreach (var node in sdsiteDoc.ChildNodes)
            {
                if (node is FolderXmlElement)
                {
                    FolderElementNode FolderNode = new FolderElementNode(node as FolderXmlElement);
                    SetElementNode(FolderNode);
                    AddTmpltFolder(node as FolderXmlElement);
                }
                else if (node is TmpltSimpleExXmlElement)
                {
                    TmpltElementNode tmpltNode = new TmpltElementNode(node as TmpltSimpleExXmlElement);

                    if ((TmpltFilter == TmpltTreeNodeType.none) || TmpltFilter == tmpltNode.CurrentNodeType)
                    {
                        SetElementNode(tmpltNode);
                        AddRootNodeToTree(tmpltNode);
                    }
                }
            }
            this.EndUpdate();
            this.ContextMenuStrip = TmpltTreeContextMenuStrip.CreateForTreeView(this);
        }
Exemple #2
0
 private void TmpltTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     e.Cancel = expandCollapse;
     //展开前的判断
     if (!e.Cancel && e.Node is TmpltElementNode)
     {
         TmpltElementNode tmpltNode = e.Node as TmpltElementNode;
         TmpltXmlDocument tmpltDoc  = Service.Sdsite.CurrentDocument.GetTmpltDocumentById(tmpltNode.ID);
         if (tmpltDoc.GetSnipElementList().Count <= 0)
         {
             tmpltNode.ClearTmpltNode();
         }
     }
 }
Exemple #3
0
        private void TmpltTreeView_AfterExpand(object sender, TreeViewEventArgs e)
        {
            //生成树
            if (e.Node is TmpltElementNode)
            {
                TmpltElementNode tmpltNode = e.Node as TmpltElementNode;
                TmpltXmlDocument tmpltDoc  = Service.Sdsite.CurrentDocument.GetTmpltDocumentById(tmpltNode.ID);
                if (tmpltDoc.GetSnipElementList().Count <= 0 || tmpltNode.NodeExpand)
                {
                    return;
                }

                tmpltNode.NodeExpand = true;
                tmpltNode.LoadData(SnipFilter);
                ResetDicNodeIndexs();
            }
        }
Exemple #4
0
 private void sdsite_ElementAdded(object sender, EventArgs <SimpleExIndexXmlElement> e)
 {
     if (e.Item is TmpltSimpleExXmlElement) //如果添加的是单个模板,则直接添加
     {
         TmpltElementNode tmpltNode = new TmpltElementNode(e.Item as TmpltSimpleExXmlElement);
         if ((TmpltFilter == TmpltTreeNodeType.none) || TmpltFilter == tmpltNode.CurrentNodeType)
         {
             SetElementNode(tmpltNode);
             AddRootNodeToTree(tmpltNode);
         }
     }
     else if (e.Item is FolderXmlElement) //添加整个文件夹(里面可能包括模板)
     {
         FolderElementNode folderNode = new FolderElementNode(e.Item as FolderXmlElement);
         SetElementNode(folderNode);
         //增加了模板过滤 如果和当前过滤选择不一样,则不显示
         AddTmpltFolder(e.Item as FolderXmlElement);
     }
     //else if() 参数 SimpleExIndexXmlElement 并不能包含添加的 页面片和PART 现在只做模板
     //{
     //}
 }
Exemple #5
0
 private void AddTmpltFolder(FolderXmlElement Folder)
 {
     foreach (var node in Folder.ChildNodes)
     {
         if (node is FolderXmlElement)
         {
             //有可能要加其ID  如果该文件夹有模板,并且删除该文件夹,要根据这个删模板树的内容
             FolderElementNode FolderNode = new FolderElementNode(node as FolderXmlElement);
             SetElementNode(FolderNode);
             AddTmpltFolder(node as FolderXmlElement);
         }
         else if (node is TmpltSimpleExXmlElement)
         {
             TmpltElementNode tmpltNode = new TmpltElementNode(node as TmpltSimpleExXmlElement);
             if ((TmpltFilter == TmpltTreeNodeType.none) || TmpltFilter == tmpltNode.CurrentNodeType)
             {
                 SetElementNode(tmpltNode);
                 AddRootNodeToTree(tmpltNode);
             }
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// 定位到模板/页面片/PART
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TmpltTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TmpltBaseTreeNode tmpltBaseNode = e.Node as TmpltBaseTreeNode;

            if (tmpltBaseNode == null)
            {
                return;
            }

            switch (tmpltBaseNode.NodeType)
            {
            case TreeNodeType.Tmplt:
                //打开(或激活)模板
                Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, ((TmpltSimpleExXmlElement)tmpltBaseNode.Element).Id);
                break;

            case TreeNodeType.Snip:
            {        //打开页面片
                //得到对应的页面片
                SnipElementNode snipElementNode = tmpltBaseNode as SnipElementNode;
                SnipXmlElement  snipElement     = snipElementNode.Element as SnipXmlElement;

                //得到页面片所属的模板文件
                TmpltElementNode        tmpltElementNode = snipElementNode.Parent as TmpltElementNode;
                TmpltSimpleExXmlElement tmpltElement     = tmpltElementNode.Element as TmpltSimpleExXmlElement;

                //先打开(或激活)对应的模板 如果该模板已经打开,不用打开也不用激活她,因为目的是为了打开页面片
                //如果打开的话回出现令人烦的闪烁现象
                if (!Service.Workbench.GetResultKeyID(WorkDocumentType.TmpltDesigner, tmpltElement.Id))
                {
                    Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, tmpltElement.Id);
                }
                //打开(激活)页面片
                Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, snipElement.Id, tmpltElement.Id);


                //因为如果添加一个页面片且没有保存,再重命名,新的名不能保存,模板里没有对应的内容
                //所以的通知页面片设计器,将FORM的TEXT进行修改
                snipElementNode.ChangeNodeText(e.Node.Text);
            }

            break;

            case TreeNodeType.SnipPart:
            {         //找到PART对应的页面片
                PartElementNode    partElemetNode  = tmpltBaseNode as PartElementNode;
                SnipPartXmlElement snipPartElement = partElemetNode.Element as SnipPartXmlElement;

                TmpltBaseTreeNode tmpltNode = (TmpltBaseTreeNode)partElemetNode;
                while (!(tmpltNode is SnipElementNode))
                {
                    tmpltNode = (TmpltBaseTreeNode)(tmpltNode.Parent);
                }

                //得到对应的页面片
                SnipElementNode snipElementNode = tmpltNode as SnipElementNode;
                SnipXmlElement  snipElement     = snipElementNode.Element as SnipXmlElement;


                ////得到页面片所属的模板文件
                TmpltElementNode        tmpltElementNode = snipElementNode.Parent as TmpltElementNode;
                TmpltSimpleExXmlElement tmpltElement     = tmpltElementNode.Element as TmpltSimpleExXmlElement;

                //先打开(或激活)对应的模板
                if (!Service.Workbench.GetResultKeyID(WorkDocumentType.TmpltDesigner, tmpltElement.Id))
                {
                    Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, tmpltElement.Id);
                }

                //打开页面片!
                Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, snipElement.Id, tmpltElement.Id);
                string [] strArray = new string[2];
                strArray[0] = snipElement.Id;
                strArray[1] = snipPartElement.SnipPartId;

                SdsiteXmlDocument.OnOrientationPart(new EventArgs <string[]>(strArray));
            }
            break;
            }
        }
Exemple #7
0
 /// <summary>
 /// 添加根节点的内部方法
 /// </summary>
 private void AddRootNodeToTree(TmpltElementNode node)
 {
     ///添加到树中
     this.Nodes.Add(node);
 }