Browse Source
TODO (for v4): 1. Auto parse -> update errors 2. Design/Undo/Redo -> update errors 3. Jump to XmlNode (position tracking required) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3441 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
28 changed files with 497 additions and 142 deletions
@ -0,0 +1,16 @@ |
|||||||
|
<ListBox x:Class="ICSharpCode.XamlDesigner.ErrorListView" |
||||||
|
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:Services="clr-namespace:ICSharpCode.WpfDesign.Designer.Services;assembly=ICSharpCode.WpfDesign.Designer"> |
||||||
|
<Control.Resources> |
||||||
|
<DataTemplate DataType="{x:Type Services:XamlError}"> |
||||||
|
<StackPanel Orientation="Horizontal"> |
||||||
|
<Image Source="Images/Error.png" |
||||||
|
Stretch="None" |
||||||
|
Margin="2"/> |
||||||
|
<TextBlock Text="{Binding Message}" |
||||||
|
VerticalAlignment="Center"/> |
||||||
|
</StackPanel> |
||||||
|
</DataTemplate> |
||||||
|
</Control.Resources> |
||||||
|
</ListBox> |
@ -0,0 +1,33 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Windows.Media.Imaging; |
||||||
|
using System.Windows.Navigation; |
||||||
|
using System.Windows.Shapes; |
||||||
|
using ICSharpCode.WpfDesign.Designer.Services; |
||||||
|
|
||||||
|
namespace ICSharpCode.XamlDesigner |
||||||
|
{ |
||||||
|
public partial class ErrorListView |
||||||
|
{ |
||||||
|
public ErrorListView() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) |
||||||
|
{ |
||||||
|
var error = e.GetDataContext() as XamlError; |
||||||
|
if (error != null) { |
||||||
|
Shell.Instance.JumpToError(error); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 701 B |
@ -0,0 +1,16 @@ |
|||||||
|
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
||||||
|
Name="root" |
||||||
|
Title="Hydralisk"> |
||||||
|
<Window.Resources> |
||||||
|
<sys:String1 x:Key="r1">Title</sys:String> |
||||||
|
<sys:String x:Key="r2">Width</sys:String> |
||||||
|
</Window.Resources> |
||||||
|
<StackPanel> |
||||||
|
<Button Name="b1" |
||||||
|
Width="100" |
||||||
|
Content="Button" /> |
||||||
|
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" /> |
||||||
|
</StackPanel> |
||||||
|
</Window> |
@ -0,0 +1,31 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using ICSharpCode.WpfDesign.XamlDom; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer.Services |
||||||
|
{ |
||||||
|
public class XamlErrorService : IXamlErrorSink |
||||||
|
{ |
||||||
|
public XamlErrorService() |
||||||
|
{ |
||||||
|
Errors = new ObservableCollection<XamlError>(); |
||||||
|
} |
||||||
|
|
||||||
|
public ObservableCollection<XamlError> Errors { get; private set; } |
||||||
|
|
||||||
|
public void ReportError(string message, int line, int column) |
||||||
|
{ |
||||||
|
Errors.Add(new XamlError() { Message = message, Line = line, Column = column }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class XamlError |
||||||
|
{ |
||||||
|
public string Message { get; set; } |
||||||
|
public int Line { get; set; } |
||||||
|
public int Column { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.XamlDom |
||||||
|
{ |
||||||
|
public interface IXamlErrorSink |
||||||
|
{ |
||||||
|
void ReportError(string message, int line, int column); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,94 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Xml; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.XamlDom |
||||||
|
{ |
||||||
|
public class PositionXmlDocument : XmlDocument |
||||||
|
{ |
||||||
|
IXmlLineInfo lineInfo; |
||||||
|
|
||||||
|
public override XmlElement CreateElement (string prefix, string localName, string namespaceURI) |
||||||
|
{ |
||||||
|
return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo); |
||||||
|
} |
||||||
|
|
||||||
|
public override XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI) |
||||||
|
{ |
||||||
|
return new PositionXmlAttribute(prefix, localName, namespaceURI, this, lineInfo); |
||||||
|
} |
||||||
|
|
||||||
|
public override void Load (XmlReader reader) |
||||||
|
{ |
||||||
|
if (reader is IXmlLineInfo) lineInfo = (IXmlLineInfo)reader; |
||||||
|
base.Load(reader); |
||||||
|
lineInfo = null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class PositionXmlElement : XmlElement, IXmlLineInfo |
||||||
|
{ |
||||||
|
public PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo) |
||||||
|
: base(prefix, localName, namespaceURI, doc) |
||||||
|
{ |
||||||
|
if (lineInfo != null) { |
||||||
|
this.lineNumber = lineInfo.LineNumber; |
||||||
|
this.linePosition = lineInfo.LinePosition; |
||||||
|
this.hasLineInfo = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int lineNumber; |
||||||
|
int linePosition; |
||||||
|
bool hasLineInfo; |
||||||
|
|
||||||
|
public bool HasLineInfo () |
||||||
|
{ |
||||||
|
return hasLineInfo; |
||||||
|
} |
||||||
|
|
||||||
|
public int LineNumber |
||||||
|
{ |
||||||
|
get { return lineNumber; } |
||||||
|
} |
||||||
|
|
||||||
|
public int LinePosition |
||||||
|
{ |
||||||
|
get { return linePosition; } |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class PositionXmlAttribute : XmlAttribute, IXmlLineInfo |
||||||
|
{ |
||||||
|
public PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo) |
||||||
|
: base(prefix, localName, namespaceURI, doc) |
||||||
|
{ |
||||||
|
if (lineInfo != null) { |
||||||
|
this.lineNumber = lineInfo.LineNumber; |
||||||
|
this.linePosition = lineInfo.LinePosition; |
||||||
|
this.hasLineInfo = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int lineNumber; |
||||||
|
int linePosition; |
||||||
|
bool hasLineInfo; |
||||||
|
|
||||||
|
public bool HasLineInfo () |
||||||
|
{ |
||||||
|
return hasLineInfo; |
||||||
|
} |
||||||
|
|
||||||
|
public int LineNumber |
||||||
|
{ |
||||||
|
get { return lineNumber; } |
||||||
|
} |
||||||
|
|
||||||
|
public int LinePosition |
||||||
|
{ |
||||||
|
get { return linePosition; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue