Пример #1
0
        public virtual void AddElementNode(AnyXmlElement Element, TmpltTreeNodeType NodeFilterType)
        {
            TmpltBaseTreeNode tmpltBase = null;

            if (Element is SnipXmlElement)
            {
                tmpltBase = new SnipElementNode(Element as SnipXmlElement);
                if ((NodeFilterType != TmpltTreeNodeType.none) && NodeFilterType != tmpltBase.CurrentNodeType)
                {
                    return;
                }
            }
            else if (Element is SnipPartXmlElement)
            {
                tmpltBase = new PartElementNode(Element as SnipPartXmlElement);
            }
            AddChildNode(tmpltBase);
            tmpltBase.LoadData(NodeFilterType);
        }
Пример #2
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;
            }
        }