Browse Source

Add missing documentation for WpfDesign.XamlDom.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3509 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
4333bf1d26
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
  2. 19
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
  3. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
  4. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
  5. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
  6. 137
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
  7. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
  8. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  9. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
  10. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
  11. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
  12. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
  13. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
  14. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
  15. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
  16. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
  17. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
  18. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
  19. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
  20. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
  21. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
  22. 2
      src/Main/GlobalAssemblyInfo.template

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void CreateSurface(PlacementOperation operation) void CreateSurface(PlacementOperation operation)
{ {
if (ExtendedItem.Services.Tool.DesignPanel != null) { if (ExtendedItem.Services.DesignPanel != null) {
surface = new Canvas(); surface = new Canvas();
adornerPanel = new AdornerPanel(); adornerPanel = new AdornerPanel();

19
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs

@ -47,7 +47,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public bool Equals(XamlModelProperty other) public bool Equals(XamlModelProperty other)
{ {
return this._designItem == other._designItem && this._property == other._property; if (other == null)
return false;
else
return this._designItem == other._designItem && this._property == other._property;
} }
public override int GetHashCode() public override int GetHashCode()
@ -107,7 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
} }
// There may be multipley XamlModelProperty instances for the same property, // There may be multiple XamlModelProperty instances for the same property,
// so this class may not have any mutable fields / events - instead, // so this class may not have any mutable fields / events - instead,
// we forward all event handlers to the XamlProperty. // we forward all event handlers to the XamlProperty.
public override event EventHandler ValueChanged { public override event EventHandler ValueChanged {
@ -132,21 +135,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
public override event EventHandler ValueOnInstanceChanged { public override event EventHandler ValueOnInstanceChanged {
add { _property.ValueOnIstanceChanged += value; } add { _property.ValueOnInstanceChanged += value; }
remove { _property.ValueOnIstanceChanged -= value; } remove { _property.ValueOnInstanceChanged -= value; }
} }
public override object ValueOnInstance { public override object ValueOnInstance {
get { get { return _property.ValueOnInstance; }
return _property.ValueOnInstance;
}
set { _property.ValueOnInstance = value; } set { _property.ValueOnInstance = value; }
} }
public override bool IsSet { public override bool IsSet {
get { if (_property.IsSet) { get { return _property.IsSet; }
}
return _property.IsSet; }
} }
#if EventHandlerDebugging #if EventHandlerDebugging

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs

@ -16,8 +16,14 @@ using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
/// <summary>
/// Static class containing helper methods to work with collections (like the XamlParser does)
/// </summary>
public static class CollectionSupport public static class CollectionSupport
{ {
/// <summary>
/// Gets if the type is considered a collection in XAML.
/// </summary>
public static bool IsCollectionType(Type type) public static bool IsCollectionType(Type type)
{ {
return typeof(IList).IsAssignableFrom(type) return typeof(IList).IsAssignableFrom(type)
@ -26,6 +32,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
|| typeof(ResourceDictionary).IsAssignableFrom(type); || typeof(ResourceDictionary).IsAssignableFrom(type);
} }
/// <summary>
/// Gets if the collection type <paramref name="col"/> can accepts items of type
/// <paramref name="item"/>.
/// </summary>
public static bool CanCollectionAdd(Type col, Type item) public static bool CanCollectionAdd(Type col, Type item)
{ {
var e = col.GetInterface("IEnumerable`1"); var e = col.GetInterface("IEnumerable`1");
@ -36,6 +46,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
return true; return true;
} }
/// <summary>
/// Gets if the collection type <paramref name="col"/> can accept the specified items.
/// </summary>
public static bool CanCollectionAdd(Type col, IEnumerable items) public static bool CanCollectionAdd(Type col, IEnumerable items)
{ {
foreach (var item in items) { foreach (var item in items) {
@ -44,6 +57,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
return true; return true;
} }
/// <summary>
/// Adds a value to the end of a collection.
/// </summary>
public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement) public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement)
{ {
IAddChild addChild = collectionInstance as IAddChild; IAddChild addChild = collectionInstance as IAddChild;
@ -70,6 +86,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
/// <summary>
/// Adds a value at the specified index in the collection.
/// </summary>
public static void Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index) public static void Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
{ {
collectionType.InvokeMember( collectionType.InvokeMember(
@ -81,6 +100,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
static readonly Type[] RemoveAtParameters = { typeof(int) }; static readonly Type[] RemoveAtParameters = { typeof(int) };
/// <summary>
/// Removes the item at the specified index of the collection.
/// </summary>
/// <returns>True if the removal succeeded, false if the collection type does not support RemoveAt.</returns>
public static bool RemoveItemAt(Type collectionType, object collectionInstance, int index) public static bool RemoveItemAt(Type collectionType, object collectionInstance, int index)
{ {
MethodInfo m = collectionType.GetMethod("RemoveAt", RemoveAtParameters); MethodInfo m = collectionType.GetMethod("RemoveAt", RemoveAtParameters);
@ -92,6 +115,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
/// <summary>
/// Removes an item instance from the specified collection.
/// </summary>
public static void RemoveItem(Type collectionType, object collectionInstance, object item) public static void RemoveItem(Type collectionType, object collectionInstance, object item)
{ {
collectionType.InvokeMember( collectionType.InvokeMember(

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs

@ -5,8 +5,14 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
/// <summary>
/// Interface where errors during XAML loading are reported.
/// </summary>
public interface IXamlErrorSink public interface IXamlErrorSink
{ {
/// <summary>
/// Reports a XAML load error.
/// </summary>
void ReportError(string message, int line, int column); void ReportError(string message, int line, int column);
} }
} }

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs

@ -5,13 +5,22 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
/// <summary>
/// Static class that can generate XAML markup extension code ("{Binding Path=...}").
/// </summary>
public static class MarkupExtensionPrinter public static class MarkupExtensionPrinter
{ {
/// <summary>
/// Gets whether shorthand XAML markup extension code can be generated for the object.
/// </summary>
public static bool CanPrint(XamlObject obj) public static bool CanPrint(XamlObject obj)
{ {
return true; return true;
} }
/// <summary>
/// Generates XAML markup extension code for the object.
/// </summary>
public static string Print(XamlObject obj) public static string Print(XamlObject obj)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

137
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs

@ -6,89 +6,136 @@ using System.Xml;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
// SuppressMessage justification: we're just adding position info to XmlDocument and don't want to fix
// any of it's other issues.
/// <summary>
/// Class derived from System.Xml.XmlDocument that remembers line/column information for elements and attributes
/// when loading from a <see cref="XmlTextReader"/> or other <see cref="IXmlLineInfo"/>-implementing reader.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1058:TypesShouldNotExtendCertainBaseTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class PositionXmlDocument : XmlDocument public class PositionXmlDocument : XmlDocument
{ {
IXmlLineInfo lineInfo; IXmlLineInfo lineInfo; // a reference to the XmlReader, only set during load time
public override XmlElement CreateElement (string prefix, string localName, string namespaceURI) /// <summary>
{ /// Creates a PositionXmlElement.
return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo); /// </summary>
} public override XmlElement CreateElement(string prefix, string localName, string namespaceURI)
{
return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo);
}
/// <summary>
/// Creates a PositionXmlAttribute.
/// </summary>
public override XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI) public override XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI)
{ {
return new PositionXmlAttribute(prefix, localName, namespaceURI, this, lineInfo); return new PositionXmlAttribute(prefix, localName, namespaceURI, this, lineInfo);
} }
public override void Load (XmlReader reader) /// <summary>
{ /// Loads the XML document from the specified <see cref="XmlReader"/>.
if (reader is IXmlLineInfo) lineInfo = (IXmlLineInfo)reader; /// </summary>
base.Load(reader); public override void Load(XmlReader reader)
lineInfo = null; {
} lineInfo = reader as IXmlLineInfo;
} try {
base.Load(reader);
} finally {
lineInfo = null;
}
}
}
/// <summary>
/// XML Element with line/column information.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class PositionXmlElement : XmlElement, IXmlLineInfo public class PositionXmlElement : XmlElement, IXmlLineInfo
{ {
public PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo) internal PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
: base(prefix, localName, namespaceURI, doc) : base(prefix, localName, namespaceURI, doc)
{ {
if (lineInfo != null) { if (lineInfo != null) {
this.lineNumber = lineInfo.LineNumber; this.lineNumber = lineInfo.LineNumber;
this.linePosition = lineInfo.LinePosition; this.linePosition = lineInfo.LinePosition;
this.hasLineInfo = true; this.hasLineInfo = true;
} }
} }
int lineNumber; int lineNumber;
int linePosition; int linePosition;
bool hasLineInfo; bool hasLineInfo;
public bool HasLineInfo () /// <summary>
{ /// Gets whether the element has line information.
return hasLineInfo; /// </summary>
} public bool HasLineInfo()
{
return hasLineInfo;
}
public int LineNumber /// <summary>
{ /// Gets the line number.
get { return lineNumber; } /// </summary>
} public int LineNumber {
get { return lineNumber; }
}
public int LinePosition /// <summary>
{ /// Gets the line position (column).
get { return linePosition; } /// </summary>
} public int LinePosition {
get { return linePosition; }
}
} }
/// <summary>
/// XML Attribute with line/column information.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
public class PositionXmlAttribute : XmlAttribute, IXmlLineInfo public class PositionXmlAttribute : XmlAttribute, IXmlLineInfo
{ {
public PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo) internal PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
: base(prefix, localName, namespaceURI, doc) : base(prefix, localName, namespaceURI, doc)
{ {
if (lineInfo != null) { if (lineInfo != null) {
this.lineNumber = lineInfo.LineNumber; this.lineNumber = lineInfo.LineNumber;
this.linePosition = lineInfo.LinePosition; this.linePosition = lineInfo.LinePosition;
this.hasLineInfo = true; this.hasLineInfo = true;
} }
} }
int lineNumber; int lineNumber;
int linePosition; int linePosition;
bool hasLineInfo; bool hasLineInfo;
public bool HasLineInfo () /// <summary>
{ /// Gets whether the element has line information.
return hasLineInfo; /// </summary>
} public bool HasLineInfo()
{
return hasLineInfo;
}
public int LineNumber /// <summary>
{ /// Gets the line number.
get { return lineNumber; } /// </summary>
} public int LineNumber {
get { return lineNumber; }
}
public int LinePosition /// <summary>
{ /// Gets the line position (column).
get { return linePosition; } /// </summary>
} public int LinePosition {
get { return linePosition; }
}
} }
} }

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj

@ -15,10 +15,11 @@
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis> <RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Globalization#CA1303</CodeAnalysisRules> <CodeAnalysisRules>-Microsoft.Performance#CA1800</CodeAnalysisRules>
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath> <OutputPath>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile> <DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -112,6 +112,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
/// <summary>
/// Gets whether this XamlObject represents a markup extension in short form ("{Binding}" syntax)
/// </summary>
public bool IsMarkupExtensionRoot { public bool IsMarkupExtensionRoot {
get { return XmlAttribute != null; } get { return XmlAttribute != null; }
} }
@ -122,7 +125,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XmlElement newElement = e.OwnerDocument.CreateElement(prefix, e.Name, e.NamespaceURI); XmlElement newElement = e.OwnerDocument.CreateElement(prefix, e.Name, e.NamespaceURI);
foreach (XmlAttribute a in target.Attributes) { foreach (XmlAttribute a in target.Attributes) {
if (a.Name.StartsWith("xmlns")) { if (a.Prefix == "xmlns") {
newElement.Attributes.Append(a.Clone() as XmlAttribute); newElement.Attributes.Append(a.Clone() as XmlAttribute);
} }
} }
@ -197,16 +200,18 @@ namespace ICSharpCode.WpfDesign.XamlDom
get { return instance; } get { return instance; }
} }
/// <summary>
/// Gets whether this instance represents a MarkupExtension.
/// </summary>
public bool IsMarkupExtension { public bool IsMarkupExtension {
get { return instance is MarkupExtension; } get { return instance is MarkupExtension; }
} }
/// <summary>
/// Gets whether there were load errors for this object.
/// </summary>
public bool HasErrors { get; internal set; } public bool HasErrors { get; internal set; }
public DependencyObject DependencyObject {
get { return instance as DependencyObject; }
}
/// <summary> /// <summary>
/// Gets the type of this object element. /// Gets the type of this object element.
/// </summary> /// </summary>
@ -226,6 +231,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
string contentPropertyName; string contentPropertyName;
/// <summary>
/// Gets the name of the content property.
/// </summary>
public string ContentPropertyName { public string ContentPropertyName {
get { get {
return contentPropertyName; return contentPropertyName;
@ -304,6 +312,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
element.SetAttribute(name, XamlConstants.XamlNamespace, value); element.SetAttribute(name, XamlConstants.XamlNamespace, value);
} }
/// <summary>
/// Gets/Sets the <see cref="XamlObjectServiceProvider"/> associated with this XamlObject.
/// </summary>
public XamlObjectServiceProvider ServiceProvider { get; set; } public XamlObjectServiceProvider ServiceProvider { get; set; }
MarkupExtensionWrapper wrapper; MarkupExtensionWrapper wrapper;

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs

@ -6,19 +6,34 @@ using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
/// <summary>
/// A service provider that provides the IProvideValueTarget and IXamlTypeResolver services.
/// No other services (e.g. from the document's service provider) are offered.
/// </summary>
public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget
{ {
/// <summary>
/// Creates a new XamlObjectServiceProvider instance.
/// </summary>
public XamlObjectServiceProvider(XamlObject obj) public XamlObjectServiceProvider(XamlObject obj)
{ {
if (obj == null)
throw new ArgumentNullException("obj");
XamlObject = obj; XamlObject = obj;
Resolver = new XamlTypeResolverProvider(obj); Resolver = new XamlTypeResolverProvider(obj);
} }
/// <summary>
/// Gets the XamlObject that owns this service provider (e.g. the XamlObject that represents a markup extension).
/// </summary>
public XamlObject XamlObject { get; private set; } public XamlObject XamlObject { get; private set; }
internal XamlTypeResolverProvider Resolver { get; private set; } internal XamlTypeResolverProvider Resolver { get; private set; }
#region IServiceProvider Members #region IServiceProvider Members
/// <summary>
/// Retrieves the service of the specified type.
/// </summary>
public object GetService(Type serviceType) public object GetService(Type serviceType)
{ {
if (serviceType == typeof(IProvideValueTarget)) { if (serviceType == typeof(IProvideValueTarget)) {
@ -34,10 +49,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
#region IProvideValueTarget Members #region IProvideValueTarget Members
/// <summary>
/// Gets the target object (the DependencyObject instance on which a property should be set)
/// </summary>
public object TargetObject { public object TargetObject {
get { return XamlObject.ParentProperty.ParentObject.Instance; } get { return XamlObject.ParentProperty.ParentObject.Instance; }
} }
/// <summary>
/// Gets the target dependency property.
/// </summary>
public object TargetProperty { public object TargetProperty {
get { return XamlObject.ParentProperty.DependencyProperty; } get { return XamlObject.ParentProperty.DependencyProperty; }
} }

22
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -80,8 +80,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink)); var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
try { try {
doc.Load(reader); doc.Load(reader);
return Parse(doc, settings); return Parse(doc, settings);
} catch (XmlException x) { } catch (XmlException x) {
if (errorSink != null) if (errorSink != null)
errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition); errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition);
@ -93,6 +93,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary> /// <summary>
/// Creates a XAML document from an existing XmlDocument. /// Creates a XAML document from an existing XmlDocument.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification="We need to continue parsing, and the error is reported to the user.")]
internal static XamlDocument Parse(XmlDocument document, XamlParserSettings settings) internal static XamlDocument Parse(XmlDocument document, XamlParserSettings settings)
{ {
if (settings == null) if (settings == null)
@ -121,11 +123,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlParserSettings settings; XamlParserSettings settings;
IXamlErrorSink errorSink; IXamlErrorSink errorSink;
Type FindType(string namespaceUri, string localName)
{
return FindType(settings.TypeFinder, namespaceUri, localName);
}
static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName) static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
{ {
Type elementType = typeFinder.GetType(namespaceUri, localName); Type elementType = typeFinder.GetType(namespaceUri, localName);
@ -159,6 +156,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject.HasErrors = true; currentXamlObject.HasErrors = true;
} }
} }
// TODO: what when there's no error sink? I think we should throw exception
} }
XamlObject ParseObject(XmlElement element) XamlObject ParseObject(XmlElement element)
@ -214,8 +212,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject = obj; currentXamlObject = obj;
obj.ParentObject = parentXamlObject; obj.ParentObject = parentXamlObject;
if (parentXamlObject == null && obj.DependencyObject != null) { if (parentXamlObject == null && obj.Instance is DependencyObject) {
NameScope.SetNameScope(obj.DependencyObject, new NameScope()); NameScope.SetNameScope((DependencyObject)obj.Instance, new NameScope());
} }
ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize; ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize;
@ -348,6 +346,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification="We need to continue parsing, and the error is reported to the user.")]
XamlPropertyValue ParseValue(XmlNode childNode) XamlPropertyValue ParseValue(XmlNode childNode)
{ {
try { try {
@ -466,6 +466,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
propertyName = qualifiedName.Substring(pos + 1); propertyName = qualifiedName.Substring(pos + 1);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification="We need to continue parsing, and the error is reported to the user.")]
void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute) void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute)
{ {
try { try {
@ -481,7 +483,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlPropertyValue value = null; XamlPropertyValue value = null;
var valueText = attribute.Value; var valueText = attribute.Value;
if (valueText.StartsWith("{") && !valueText.StartsWith("{}")) { if (valueText.StartsWith("{", StringComparison.Ordinal) && !valueText.StartsWith("{}", StringComparison.Ordinal)) {
var xamlObject = MarkupExtensionParser.Parse(valueText, obj, real ? attribute : null); var xamlObject = MarkupExtensionParser.Parse(valueText, obj, real ? attribute : null);
value = xamlObject; value = xamlObject;
} else { } else {

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary> /// </summary>
public bool IsSet { public bool IsSet {
get { return propertyValue != null || get { return propertyValue != null ||
_propertyElement != null; // collection _propertyElement != null; // collection
} }
} }
@ -153,8 +153,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary> /// </summary>
public event EventHandler ValueChanged; public event EventHandler ValueChanged;
//When ME evaluated PropertyValue dosn't changed but ValueOnIstance does. /// <summary>
public event EventHandler ValueOnIstanceChanged; /// Occurs when MarkupExtension evaluated PropertyValue dosn't changed but ValueOnInstance does.
/// </summary>
public event EventHandler ValueOnInstanceChanged;
void SetPropertyValue(XamlPropertyValue value) void SetPropertyValue(XamlPropertyValue value)
{ {
@ -314,7 +316,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
name = PropertyName; name = PropertyName;
var element = ParentObject.XmlElement; var element = ParentObject.XmlElement;
if (element.GetPrefixOfNamespace(ns) == "") { if (string.IsNullOrEmpty(element.GetPrefixOfNamespace(ns))) {
element.SetAttribute(name, value); element.SetAttribute(name, value);
return element.GetAttributeNode(name); return element.GetAttributeNode(name);
} else { } else {
@ -334,8 +336,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
var element = ParentObject.XmlElement; var element = ParentObject.XmlElement;
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
var prefix = element.GetPrefixOfNamespace(ns); var prefix = element.GetPrefixOfNamespace(ns);
if (prefix == "") return name; if (string.IsNullOrEmpty(prefix))
return prefix + ":" + name; return name;
else
return prefix + ":" + name;
} }
/// <summary> /// <summary>
@ -371,15 +375,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
set { set {
propertyInfo.SetValue(parentObject.Instance, value); propertyInfo.SetValue(parentObject.Instance, value);
if (ValueOnIstanceChanged != null) if (ValueOnInstanceChanged != null)
ValueOnIstanceChanged(this, EventArgs.Empty); ValueOnInstanceChanged(this, EventArgs.Empty);
} }
} }
/// <summary>
/// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
/// </summary>
public bool IsAdvanced { public bool IsAdvanced {
get { return propertyInfo.IsAdvanced; } get { return propertyInfo.IsAdvanced; }
} }
/// <summary>
/// Gets the dependency property.
/// </summary>
public DependencyProperty DependencyProperty { public DependencyProperty DependencyProperty {
get { get {
return propertyInfo.DependencyProperty; return propertyInfo.DependencyProperty;
@ -403,8 +413,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
while (obj != null) { while (obj != null) {
var nameScope = obj.Instance as INameScope; var nameScope = obj.Instance as INameScope;
if (nameScope == null) { if (nameScope == null) {
if (obj.DependencyObject != null) if (obj.Instance is DependencyObject)
nameScope = NameScope.GetNameScope(obj.DependencyObject); nameScope = NameScope.GetNameScope((DependencyObject)obj.Instance);
} }
if (nameScope != null) { if (nameScope != null) {
if (oldName != null) { if (oldName != null) {
@ -420,10 +430,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
void PossiblyMarkupExtensionChanged(XamlPropertyValue part)
{
}
/*public bool IsAttributeSyntax { /*public bool IsAttributeSyntax {
get { get {
return attribute != null; return attribute != null;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
public string Text { public string Text {
get { get {
if (attribute != null) { if (attribute != null) {
if (attribute.Value.StartsWith("{}")) if (attribute.Value.StartsWith("{}", StringComparison.Ordinal))
return attribute.Value.Substring(2); return attribute.Value.Substring(2);
else else
return attribute.Value; return attribute.Value;

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs

@ -85,7 +85,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
throw new ArgumentNullException("localName"); throw new ArgumentNullException("localName");
XamlNamespace ns; XamlNamespace ns;
if (!namespaces.TryGetValue(xmlNamespace, out ns)) { if (!namespaces.TryGetValue(xmlNamespace, out ns)) {
if (xmlNamespace.StartsWith("clr-namespace:")) { if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.Ordinal)) {
ns = namespaces[xmlNamespace] = ParseNamespace(xmlNamespace); ns = namespaces[xmlNamespace] = ParseNamespace(xmlNamespace);
} else { } else {
return null; return null;
@ -116,7 +116,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlNamespace ParseNamespace(string xmlNamespace) XamlNamespace ParseNamespace(string xmlNamespace)
{ {
string name = xmlNamespace; string name = xmlNamespace;
Debug.Assert(name.StartsWith("clr-namespace:")); Debug.Assert(name.StartsWith("clr-namespace:", StringComparison.Ordinal));
name = name.Substring("clr-namespace:".Length); name = name.Substring("clr-namespace:".Length);
string namespaceName, assembly; string namespaceName, assembly;
int pos = name.IndexOf(';'); int pos = name.IndexOf(';');
@ -126,7 +126,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
} else { } else {
namespaceName = name.Substring(0, pos); namespaceName = name.Substring(0, pos);
name = name.Substring(pos + 1).Trim(); name = name.Substring(pos + 1).Trim();
if (!name.StartsWith("assembly=")) { if (!name.StartsWith("assembly=", StringComparison.Ordinal)) {
throw new XamlLoadException("Expected: 'assembly='"); throw new XamlLoadException("Expected: 'assembly='");
} }
assembly = name.Substring("assembly=".Length); assembly = name.Substring("assembly=".Length);
@ -227,7 +227,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
{ {
internal static readonly XamlTypeFinder Instance; internal static readonly XamlTypeFinder Instance;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",
Justification = "We're using an explicit constructor to get it's lazy-loading semantics.")]
static WpfTypeFinder() static WpfTypeFinder()
{ {
Instance = new XamlTypeFinder(); Instance = new XamlTypeFinder();

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs

@ -42,6 +42,9 @@ namespace ICSharpCode.WpfDesign
get; get;
} }
/// <summary>
/// Gets whether the design context can be saved.
/// </summary>
public abstract bool CanSave { get; } public abstract bool CanSave { get; }
/// <summary> /// <summary>

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs

@ -19,6 +19,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
// property full name => editor type // property full name => editor type
static Dictionary<string, Type> propertyEditors = new Dictionary<string, Type>(); static Dictionary<string, Type> propertyEditors = new Dictionary<string, Type>();
/// <summary>
/// Creates a property editor for the specified <paramref name="property"/>
/// </summary>
public static FrameworkElement CreateEditor(DesignItemProperty property) public static FrameworkElement CreateEditor(DesignItemProperty property)
{ {
Type editorType; Type editorType;

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs

@ -19,11 +19,15 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
[TypeEditor(typeof(Enum))] [TypeEditor(typeof(Enum))]
public partial class ComboBoxEditor public partial class ComboBoxEditor
{ {
/// <summary>
/// Create a new ComboBoxEditor instance.
/// </summary>
public ComboBoxEditor() public ComboBoxEditor()
{ {
InitializeComponent(); InitializeComponent();
} }
/// <inheritdoc/>
public override void OnApplyTemplate() public override void OnApplyTemplate()
{ {
base.OnApplyTemplate(); base.OnApplyTemplate();

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs

@ -16,18 +16,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
{ {
public partial class TextBoxEditor public partial class TextBoxEditor
{ {
/// <summary>
/// Creates a new TextBoxEditor instance.
/// </summary>
public TextBoxEditor() public TextBoxEditor()
{ {
InitializeComponent(); InitializeComponent();
} }
/// <inheritdoc/>
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
if (e.Key == Key.Enter) { if (e.Key == Key.Enter) {
BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource(); BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource();
SelectAll(); SelectAll();
} } else if (e.Key == Key.Escape) {
else if (e.Key == Key.Escape) {
BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget(); BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
} }
} }

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs

@ -6,8 +6,15 @@ using System.Collections.ObjectModel;
namespace ICSharpCode.WpfDesign.PropertyGrid namespace ICSharpCode.WpfDesign.PropertyGrid
{ {
/// <summary>
/// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection.
/// </summary>
public class SortedObservableCollection<T, K> : ObservableCollection<T> public class SortedObservableCollection<T, K> : ObservableCollection<T>
{ {
/// <summary>
/// Creates a new SortedObservableCollection instance.
/// </summary>
/// <param name="keySelector">The function to select the sorting key.</param>
public SortedObservableCollection(Func<T, K> keySelector) public SortedObservableCollection(Func<T, K> keySelector)
{ {
this.keySelector = keySelector; this.keySelector = keySelector;
@ -17,6 +24,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
Func<T, K> keySelector; Func<T, K> keySelector;
IComparer<K> comparer; IComparer<K> comparer;
/// <summary>
/// Adds an item to a sorted collection.
/// </summary>
public void AddSorted(T item) public void AddSorted(T item)
{ {
int i = 0; int i = 0;
@ -35,8 +45,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
} }
} }
/// <summary>
/// A SortedObservableCollection{PropertyNode, string} that sorts by the PropertyNode's Name.
/// </summary>
public class PropertyNodeCollection : SortedObservableCollection<PropertyNode, string> public class PropertyNodeCollection : SortedObservableCollection<PropertyNode, string>
{ {
/// <summary>
/// Creates a new PropertyNodeCollection instance.
/// </summary>
public PropertyNodeCollection() : base(n => n.Name) public PropertyNodeCollection() : base(n => n.Name)
{ {
} }

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

@ -6,8 +6,15 @@ using System.ComponentModel;
namespace ICSharpCode.WpfDesign.PropertyGrid namespace ICSharpCode.WpfDesign.PropertyGrid
{ {
/// <summary>
/// Helper class with static methods to get the list of available properties/events.
/// </summary>
public static class TypeHelper public static class TypeHelper
{ {
/// <summary>
/// Gets the available properties common to all input types.
/// </summary>
/// <param name="types">List of input types. The list must have at least one element.</param>
public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<Type> types) public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<Type> types)
{ {
foreach (var pd1 in GetAvailableProperties(types.First())) { foreach (var pd1 in GetAvailableProperties(types.First())) {
@ -29,6 +36,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
} }
} }
/// <summary>
/// Gets the available properties for the type.
/// </summary>
public static IEnumerable<PropertyDescriptor> GetAvailableProperties(Type forType) public static IEnumerable<PropertyDescriptor> GetAvailableProperties(Type forType)
{ {
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) { foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) {
@ -39,6 +49,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
} }
} }
/// <summary>
/// Gets the available events for the type.
/// </summary>
public static IEnumerable<EventDescriptor> GetAvailableEvents(Type forType) public static IEnumerable<EventDescriptor> GetAvailableEvents(Type forType)
{ {
foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) { foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) {

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs

@ -152,5 +152,15 @@ namespace ICSharpCode.WpfDesign
return GetServiceOrThrowException<Extensions.ExtensionManager>(); return GetServiceOrThrowException<Extensions.ExtensionManager>();
} }
} }
/// <summary>
/// Gets the <see cref="IDesignPanel"/>.
/// Throws an exception if the service is not found.
/// </summary>
public IDesignPanel DesignPanel {
get {
return GetServiceOrThrowException<IDesignPanel>();
}
}
} }
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs

@ -57,8 +57,6 @@ namespace ICSharpCode.WpfDesign
/// Is raised when the current tool changes. /// Is raised when the current tool changes.
/// </summary> /// </summary>
event EventHandler CurrentToolChanged; event EventHandler CurrentToolChanged;
IDesignPanel DesignPanel { get; }
} }
/// <summary> /// <summary>

2
src/Main/GlobalAssemblyInfo.template

@ -14,6 +14,7 @@
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
using System.Resources;
using System.Reflection; using System.Reflection;
[assembly: System.Runtime.InteropServices.ComVisible(false)] [assembly: System.Runtime.InteropServices.ComVisible(false)]
@ -21,6 +22,7 @@ using System.Reflection;
[assembly: AssemblyProduct("SharpDevelop")] [assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2008 AlphaSierraPapa")] [assembly: AssemblyCopyright("2000-2008 AlphaSierraPapa")]
[assembly: AssemblyVersion(RevisionClass.FullVersion)] [assembly: AssemblyVersion(RevisionClass.FullVersion)]
[assembly: NeutralResourcesLanguage("en-US")]
internal static class RevisionClass internal static class RevisionClass
{ {

Loading…
Cancel
Save