private void ShowXmlDialog(string xml) { CustomDialog dialog = new CustomDialog(); XmlViewSingleContent content = new XmlViewSingleContent(); SingleDirectionData data = new SingleDirectionData(); content.DataContext = data; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); data.Document = doc; dialog.Content = content; dialog.MaxWidth = 800; dialog.AddOkButton(); dialog.AddButton("reformat", Reformat, System.Windows.Input.Key.R, System.Windows.Input.ModifierKeys.Alt, "Reformat"); dialog.Show(); }
public bool IsValid(object owner, ICSharpCode.Core.Condition condition) { if (!condition.Properties.Contains(NodeTypeKey)) { return(false); } string nodeTypeString = condition.Properties[NodeTypeKey]; XmlEditor editor = owner as XmlEditor; if (editor == null) { return(false); } XmlViewSingleContent view = LogicalTreeHelper.FindLogicalNode(editor, "xmlView") as XmlViewSingleContent; if (view == null || view.ActiveViewer == null) { return(false); } XmlNode targetNode = view.ActiveViewer.GetCaretNode(); if (targetNode == null) { return(false); } if (nodeTypeString.Equals("LeafElement")) { if (targetNode.NodeType == XmlNodeType.Element && targetNode.ChildNodes.Count == 1 && targetNode.FirstChild.NodeType == XmlNodeType.Text) { return(true); } return(false); } else { return(targetNode.NodeType.ToString().Equals(nodeTypeString)); } }