1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using ICSharpCode.SharpDevelop.Editor;
7
namespace ICSharpCode.XmlEditor
9
public class SelectedXmlElement
11
XmlElementPath path = new XmlElementPath();
12
string selectedAttribute = String.Empty;
13
string selectedAttributeValue = String.Empty;
15
public SelectedXmlElement(ITextEditor textEditor)
16
: this(textEditor.Document.Text, textEditor.Caret.Offset)
20
public SelectedXmlElement(string xml, int index)
22
FindSelectedElement(xml, index);
23
FindSelectedAttribute(xml, index);
24
FindSelectedAttributeValue(xml, index);
27
void FindSelectedElement(string xml, int index)
29
path = XmlParser.GetActiveElementStartPathAtIndex(xml, index);
32
void FindSelectedAttribute(string xml, int index)
34
selectedAttribute = XmlParser.GetAttributeNameAtIndex(xml, index);
37
void FindSelectedAttributeValue(string xml, int index)
39
selectedAttributeValue = XmlParser.GetAttributeValueAtIndex(xml, index);
42
public XmlElementPath Path {
46
public string SelectedAttribute {
47
get { return selectedAttribute; }
50
public bool HasSelectedAttribute {
51
get { return selectedAttribute.Length > 0; }
54
public string SelectedAttributeValue {
55
get { return selectedAttributeValue; }
58
public bool HasSelectedAttributeValue {
59
get { return selectedAttributeValue.Length > 0; }