private void DisplayEmailTemplate() { XmlNode emailTemplateEditorXmlNode = siteMapDoc.DocumentElement; tvSiteMap.Nodes.Clear(); /* Add Annotation bool addAnotationsNode = true; //Add Annotation foreach (XmlNode node in emailTemplateEditorXmlNode.ChildNodes) { if(node.Name.ToLower() == "annotations") { addAnotationsNode = false; } } if(addAnotationsNode) { XmlNode annotationNode = siteMapDoc.CreateElement("Annotations"); XmlNode textAnnotation = siteMapDoc.CreateElement("TextAnnotation"); annotationNode.AppendChild(textAnnotation); emailTemplateEditorXmlNode.AppendChild(annotationNode); }*/ TreeNodeHelper.AddTreeViewNode(tvSiteMap, emailTemplateEditorXmlNode, this); // ManageMenuDisplay(); tvSiteMap.Nodes[0].Expand(); }
private void DisplayFormXml() { XmlNode formXmlEditorXmlNode = siteMapDoc.DocumentElement; tvSiteMap.Nodes.Clear(); /* Add Annotation * bool addAnotationsNode = true; * //Add Annotation * foreach (XmlNode node in formXmlEditorXmlNode.ChildNodes) * { * if(node.Name.ToLower() == "annotations") * { * addAnotationsNode = false; * } * } * * if(addAnotationsNode) * { * * XmlNode annotationNode = siteMapDoc.CreateElement("Annotations"); * XmlNode textAnnotation = siteMapDoc.CreateElement("TextAnnotation"); * annotationNode.AppendChild(textAnnotation); * * formXmlEditorXmlNode.AppendChild(annotationNode); * }*/ TreeNodeHelper.AddTreeViewNode(tvSiteMap, formXmlEditorXmlNode, this); // ManageMenuDisplay(); tvSiteMap.Nodes[0].Expand(); }
/// <summary> /// Loads the SiteMap from the extracted Xml solution files /// </summary> private void DisplaySiteMap() { XmlNode siteMapXmlNode = siteMapDoc.DocumentElement; tvSiteMap.Nodes.Clear(); TreeNodeHelper.AddTreeViewNode(tvSiteMap, siteMapXmlNode, this); ManageMenuDisplay(); tvSiteMap.Nodes[0].Expand(); }
/// <summary> /// Loads the Definition from the extracted Xml solution files /// </summary> private void DisplayDefinition(XmlDocument doc) { XmlNode definitionXmlNode = null; MethodInvoker miReadDefinition = delegate { definitionXmlNode = doc.DocumentElement; }; if (InvokeRequired) { Invoke(miReadDefinition); } else { miReadDefinition(); } MethodInvoker miFillTreeView = delegate { tvDefinition.Nodes.Clear(); TreeNodeHelper.AddTreeViewNode(tvDefinition, definitionXmlNode, this); ManageMenuDisplay(); tvDefinition.Nodes[0].Expand(); if (tvDefinition.Nodes[0].Nodes.Count > 0) { tvDefinition.Nodes[0].Nodes[0].Expand(); } UpdateLiveXML(); if (tvDefinition.Nodes.Count > 0) { tvDefinition.SelectedNode = tvDefinition.Nodes[0]; } }; if (tvDefinition.InvokeRequired) { tvDefinition.Invoke(miFillTreeView); } else { miFillTreeView(); } }
private void NodeMenuItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Name.Contains("System")) { string nodeText = e.ClickedItem.Name.Remove(0, 9); nodeText = nodeText.Substring(0, nodeText.IndexOf("ToolStripMenuItem")); string version = "2011"; switch (ConnectionDetail.OrganizationMajorVersion) { case 5: version = "2011"; break; case 6: version = "2013"; break; case 7: if (ConnectionDetail.OrganizationMinorVersion == 0) { version = "2015"; } else { version = "2015SP1"; } break; } var smcPicker = new SiteMapComponentPicker(nodeText, version); smcPicker.StartPosition = FormStartPosition.CenterParent; if (smcPicker.ShowDialog() == DialogResult.OK) { var collec = new Dictionary <string, string>(); foreach (XmlAttribute attr in smcPicker.SelectedNode.Attributes) { collec.Add(attr.Name, attr.Value); } string newNodeText = smcPicker.SelectedNode.Name + " (" + collec["Id"] + ")"; if (tvSiteMap.SelectedNode.Nodes.Find(newNodeText.Replace(" ", ""), false).Length > 0) { MessageBox.Show(this, "The selected tree node is already present!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var newNode = new TreeNode(newNodeText); newNode.Tag = collec; newNode.Name = newNodeText.Replace(" ", ""); foreach (XmlNode childNode in smcPicker.SelectedNode.ChildNodes) { TreeNodeHelper.AddTreeViewNode(newNode, childNode, this); } var e2 = new TreeNodeMouseClickEventArgs(newNode, MouseButtons.Left, 1, 0, 0); tvSiteMap.SelectedNode.Nodes.Add(newNode); TvSiteMapNodeMouseClick(tvSiteMap, e2); } } } else if (e.ClickedItem.Text == "Delete") { tvSiteMap.SelectedNode.Remove(); } else if (e.ClickedItem.Text == "Disable") { ((Dictionary <string, string>)tvSiteMap.SelectedNode.Tag).Add("_disabled", "true"); tvSiteMap.SelectedNode.ForeColor = Color.Gray; tvSiteMap.SelectedNode.Text += " - disabled"; tvSiteMap.SelectedNode.ToolTipText = "This node is disabled and won't appear in Microsoft Dynamics CRM 2011. Right click this node and enable it and make it appear on Microsoft Dynamics CRM 2011"; } else if (e.ClickedItem.Text == "Enable") { ((Dictionary <string, string>)tvSiteMap.SelectedNode.Tag).Remove("_disabled"); tvSiteMap.SelectedNode.ForeColor = Color.Black; tvSiteMap.SelectedNode.Text = tvSiteMap.SelectedNode.Text.Replace(" - disabled", ""); tvSiteMap.SelectedNode.ToolTipText = null; } else if (e.ClickedItem.Text == "Cut" || e.ClickedItem.Text == "Copy" || e.ClickedItem.Text == "Paste") { if (e.ClickedItem.Text == "Cut") { clipboard.Cut(tvSiteMap.SelectedNode); } else if (e.ClickedItem.Text == "Copy") { clipboard.Copy(tvSiteMap.SelectedNode); } else { clipboard.Paste(tvSiteMap.SelectedNode); } } else { string nodeText = e.ClickedItem.Name.Remove(0, 3); nodeText = nodeText.Substring(0, nodeText.IndexOf("ToolStripMenuItem")); var newNode = new TreeNode(nodeText); newNode.Tag = new Dictionary <string, string>(); newNode.Name = newNode.Text.Replace(" ", ""); if (newNode.Text == "Descriptions" || newNode.Text == "Titles") { var newSubNode = new TreeNode(newNode.Text.Remove(newNode.Text.Length - 1, 1)); newSubNode.Name = newSubNode.Text.Replace(" ", ""); newNode.Nodes.Add(newSubNode); var e2 = new TreeNodeMouseClickEventArgs(newSubNode, MouseButtons.Left, 1, 0, 0); tvSiteMap.SelectedNode.Nodes.Add(newNode); TvSiteMapNodeMouseClick(tvSiteMap, e2); } else { var e2 = new TreeNodeMouseClickEventArgs(newNode, MouseButtons.Left, 1, 0, 0); tvSiteMap.SelectedNode.Nodes.Add(newNode); TvSiteMapNodeMouseClick(tvSiteMap, e2); } } }
private void ToolStripButtonAddXmlClick(object sender, EventArgs e) { try { TreeNode selectedNode = tvSiteMap.SelectedNode; var axForm = new AddXmlForm(); axForm.StartPosition = FormStartPosition.CenterParent; if (axForm.ShowDialog() == DialogResult.OK) { XmlNode resultNode = axForm.AddedXmlNode; switch (resultNode.Name) { case "Area": { if (!selectedNode.Text.StartsWith("SiteMap")) { throw new Exception( "Invalid Xml content for SiteMap node!\r\n\r\n'Area' Xml content is allowed only for 'SiteMap'."); } } break; case "Group": { if (!selectedNode.Text.StartsWith("Area")) { throw new Exception( "Invalid Xml content for Area node!\r\n\r\n'Group' Xml content is allowed only for 'Area'."); } } break; case "SubArea": { if (!selectedNode.Text.StartsWith("Group")) { throw new Exception( "Invalid Xml content for Group node!\r\n\r\n'SubArea' Xml content is allowed only for 'Group'."); } } break; case "Titles": { if (!selectedNode.Text.StartsWith("Group") && !selectedNode.Text.StartsWith("SubArea") && !selectedNode.Text.StartsWith("Area")) { throw new Exception("Invalid Xml content for " + selectedNode.Text.Split(' ')[0] + " node!\r\n\r\n'Titles' Xml content is allowed only for 'Area', 'Group' and 'SubArea'."); } } break; case "Descriptions": { if (!selectedNode.Text.StartsWith("Group") && !selectedNode.Text.StartsWith("SubArea") && !selectedNode.Text.StartsWith("Area")) { throw new Exception("Invalid Xml content for " + selectedNode.Text.Split(' ')[0] + " node!\r\n\r\n'Descriptions' Xml content is allowed only for 'Area', 'Group' and 'SubArea'."); } } break; case "Title": { if (!selectedNode.Text.StartsWith("Titles")) { throw new Exception( "Invalid Xml content for Titles node!\r\n\r\n'Title' Xml content is allowed only for 'Titles'."); } } break; case "Description": { if (!selectedNode.Text.StartsWith("Descriptions")) { throw new Exception( "Invalid Xml content for Descriptions node!\r\n\r\n'Description' Xml content is allowed only for 'Descriptions'."); } } break; case "Privilege": { if (!selectedNode.Text.StartsWith("SubArea")) { throw new Exception( "Invalid Xml content for SubArea node!\r\n\r\n'Privilege' Xml content is allowed only for 'SubArea'."); } } break; default: throw new Exception("Unsupported Xml content!"); } TreeNodeHelper.AddTreeViewNode(selectedNode, resultNode, this); } } catch (Exception error) { MessageBox.Show(this, error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }