private void OKBtn_Click(object sender, EventArgs e) { if ((m_tree.CurrentNode is DataNode) && ((DataNode)m_tree.CurrentNode).NodeType == TreeNodeType.Tmplt) { this.TmpltId = ((TmpltNode)m_tree.CurrentNode).Element.Id; //如果传入的父元素为空,则父频道为网站根节点 if (_parentEle == null) { _parentEle = ((ElementNode)m_tree.SelectTreeRootChanNode).Element as FolderXmlElement; PageType = (PageType)((int)((TmpltNode)m_tree.CurrentNode).Element.TmpltType); } ///检查是否有重名 //if (File.Exists(Path.Combine(_parentEle.AbsoluteFilePath, NameTextBox.Text + Utility.Const.PageFileExt))) //{ // MessageService.Show("此文件已存在,请重新命名。"); // NameTextBox.SelectAll(); // NameTextBox.Focus(); // return; //} SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; PageSimpleExXmlElement pageEle = doc.CreatePage(_parentEle.Id, PageType, NameTextBox.Text, TmpltId); this.NewPageId = pageEle.Id; this.DialogResult = DialogResult.OK; Close(); } else { MessageService.Show("请选择模板!"); } }
private void OKBtn_Click(object sender, EventArgs e) { SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; ///不创建模板 if (!newTmpltCheckBox.Checked) { if ((m_tree.CurrentNode is DataNode) && ((DataNode)m_tree.CurrentNode).NodeType == TreeNodeType.Tmplt) { if (_parentEle == null)//如果传入的父元素为空,则父频道为网站根节点 { _parentEle = ((ElementNode)m_tree.SelectTreeRootChanNode).Element as FolderXmlElement; } PageSimpleExXmlElement pageEle = doc.CreatePage(_parentEle, PageType.Home, NameTextBox.Text, ((TmpltNode)m_tree.CurrentNode).Element.Id); NewPageId = pageEle.Id; } else { MessageService.Show("请选择模板!"); return; } } ///创建页面同时创建模板 else { KeyValuePair <string, string> keyvalue = doc.CreateHome(_parentEle, NameTextBox.Text); NewPageId = keyvalue.Value; } this.DialogResult = DialogResult.OK; Close(); }