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

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

@ -47,7 +47,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -47,7 +47,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
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()
@ -107,7 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -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,
// we forward all event handlers to the XamlProperty.
public override event EventHandler ValueChanged {
@ -132,21 +135,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -132,21 +135,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
public override event EventHandler ValueOnInstanceChanged {
add { _property.ValueOnIstanceChanged += value; }
remove { _property.ValueOnIstanceChanged -= value; }
add { _property.ValueOnInstanceChanged += value; }
remove { _property.ValueOnInstanceChanged -= value; }
}
public override object ValueOnInstance {
get {
return _property.ValueOnInstance;
}
get { return _property.ValueOnInstance; }
set { _property.ValueOnInstance = value; }
}
public override bool IsSet {
get { if (_property.IsSet) {
}
return _property.IsSet; }
get { return _property.IsSet; }
}
#if EventHandlerDebugging

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

@ -16,8 +16,14 @@ using System.Windows.Markup; @@ -16,8 +16,14 @@ using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
/// <summary>
/// Static class containing helper methods to work with collections (like the XamlParser does)
/// </summary>
public static class CollectionSupport
{
/// <summary>
/// Gets if the type is considered a collection in XAML.
/// </summary>
public static bool IsCollectionType(Type type)
{
return typeof(IList).IsAssignableFrom(type)
@ -26,6 +32,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -26,6 +32,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
|| 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)
{
var e = col.GetInterface("IEnumerable`1");
@ -36,6 +46,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -36,6 +46,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
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)
{
foreach (var item in items) {
@ -44,6 +57,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -44,6 +57,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
return true;
}
/// <summary>
/// Adds a value to the end of a collection.
/// </summary>
public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement)
{
IAddChild addChild = collectionInstance as IAddChild;
@ -70,6 +86,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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)
{
collectionType.InvokeMember(
@ -81,6 +100,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -81,6 +100,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
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)
{
MethodInfo m = collectionType.GetMethod("RemoveAt", RemoveAtParameters);
@ -92,6 +115,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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)
{
collectionType.InvokeMember(

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

@ -5,8 +5,14 @@ using System.Text; @@ -5,8 +5,14 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom
{
/// <summary>
/// Interface where errors during XAML loading are reported.
/// </summary>
public interface IXamlErrorSink
{
/// <summary>
/// Reports a XAML load error.
/// </summary>
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; @@ -5,13 +5,22 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom
{
/// <summary>
/// Static class that can generate XAML markup extension code ("{Binding Path=...}").
/// </summary>
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)
{
return true;
}
/// <summary>
/// Generates XAML markup extension code for the object.
/// </summary>
public static string Print(XamlObject obj)
{
StringBuilder sb = new StringBuilder();

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

@ -6,89 +6,136 @@ using System.Xml; @@ -6,89 +6,136 @@ using System.Xml;
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
{
IXmlLineInfo lineInfo;
IXmlLineInfo lineInfo; // a reference to the XmlReader, only set during load time
public override XmlElement CreateElement (string prefix, string localName, string namespaceURI)
{
return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo);
}
/// <summary>
/// Creates a PositionXmlElement.
/// </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)
{
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;
}
}
/// <summary>
/// Loads the XML document from the specified <see cref="XmlReader"/>.
/// </summary>
public override void Load(XmlReader reader)
{
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 PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
: base(prefix, localName, namespaceURI, doc)
{
internal 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;
}
/// <summary>
/// Gets whether the element has line information.
/// </summary>
public bool HasLineInfo()
{
return hasLineInfo;
}
public int LineNumber
{
get { return lineNumber; }
}
/// <summary>
/// Gets the line number.
/// </summary>
public int LineNumber {
get { return lineNumber; }
}
public int LinePosition
{
get { return linePosition; }
}
/// <summary>
/// Gets the line position (column).
/// </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 PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
: base(prefix, localName, namespaceURI, doc)
{
if (lineInfo != null) {
internal 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;
}
/// <summary>
/// Gets whether the element has line information.
/// </summary>
public bool HasLineInfo()
{
return hasLineInfo;
}
public int LineNumber
{
get { return lineNumber; }
}
/// <summary>
/// Gets the line number.
/// </summary>
public int LineNumber {
get { return lineNumber; }
}
public int LinePosition
{
get { return linePosition; }
}
/// <summary>
/// Gets the line position (column).
/// </summary>
public int LinePosition {
get { return linePosition; }
}
}
}

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

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

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

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

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

@ -6,19 +6,34 @@ using System.Windows.Markup; @@ -6,19 +6,34 @@ using System.Windows.Markup;
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
{
/// <summary>
/// Creates a new XamlObjectServiceProvider instance.
/// </summary>
public XamlObjectServiceProvider(XamlObject obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
XamlObject = 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; }
internal XamlTypeResolverProvider Resolver { get; private set; }
#region IServiceProvider Members
/// <summary>
/// Retrieves the service of the specified type.
/// </summary>
public object GetService(Type serviceType)
{
if (serviceType == typeof(IProvideValueTarget)) {
@ -34,10 +49,16 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -34,10 +49,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
#region IProvideValueTarget Members
/// <summary>
/// Gets the target object (the DependencyObject instance on which a property should be set)
/// </summary>
public object TargetObject {
get { return XamlObject.ParentProperty.ParentObject.Instance; }
}
/// <summary>
/// Gets the target dependency property.
/// </summary>
public object TargetProperty {
get { return XamlObject.ParentProperty.DependencyProperty; }
}

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

@ -80,8 +80,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -80,8 +80,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
try {
doc.Load(reader);
return Parse(doc, settings);
doc.Load(reader);
return Parse(doc, settings);
} catch (XmlException x) {
if (errorSink != null)
errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition);
@ -93,6 +93,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -93,6 +93,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary>
/// Creates a XAML document from an existing XmlDocument.
/// </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)
{
if (settings == null)
@ -121,11 +123,6 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -121,11 +123,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlParserSettings settings;
IXamlErrorSink errorSink;
Type FindType(string namespaceUri, string localName)
{
return FindType(settings.TypeFinder, namespaceUri, localName);
}
static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
{
Type elementType = typeFinder.GetType(namespaceUri, localName);
@ -159,6 +156,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -159,6 +156,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject.HasErrors = true;
}
}
// TODO: what when there's no error sink? I think we should throw exception
}
XamlObject ParseObject(XmlElement element)
@ -214,8 +212,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -214,8 +212,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject = obj;
obj.ParentObject = parentXamlObject;
if (parentXamlObject == null && obj.DependencyObject != null) {
NameScope.SetNameScope(obj.DependencyObject, new NameScope());
if (parentXamlObject == null && obj.Instance is DependencyObject) {
NameScope.SetNameScope((DependencyObject)obj.Instance, new NameScope());
}
ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize;
@ -348,6 +346,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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)
{
try {
@ -466,6 +466,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -466,6 +466,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
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)
{
try {
@ -481,7 +483,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -481,7 +483,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlPropertyValue value = null;
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);
value = xamlObject;
} else {

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

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

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

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

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

@ -85,7 +85,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -85,7 +85,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
throw new ArgumentNullException("localName");
XamlNamespace ns;
if (!namespaces.TryGetValue(xmlNamespace, out ns)) {
if (xmlNamespace.StartsWith("clr-namespace:")) {
if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.Ordinal)) {
ns = namespaces[xmlNamespace] = ParseNamespace(xmlNamespace);
} else {
return null;
@ -116,7 +116,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -116,7 +116,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlNamespace ParseNamespace(string xmlNamespace)
{
string name = xmlNamespace;
Debug.Assert(name.StartsWith("clr-namespace:"));
Debug.Assert(name.StartsWith("clr-namespace:", StringComparison.Ordinal));
name = name.Substring("clr-namespace:".Length);
string namespaceName, assembly;
int pos = name.IndexOf(';');
@ -126,7 +126,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -126,7 +126,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
} else {
namespaceName = name.Substring(0, pos);
name = name.Substring(pos + 1).Trim();
if (!name.StartsWith("assembly=")) {
if (!name.StartsWith("assembly=", StringComparison.Ordinal)) {
throw new XamlLoadException("Expected: 'assembly='");
}
assembly = name.Substring("assembly=".Length);
@ -227,7 +227,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -227,7 +227,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
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()
{
Instance = new XamlTypeFinder();

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

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

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

@ -19,6 +19,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -19,6 +19,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
// property full name => editor 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)
{
Type editorType;

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

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

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

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

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

@ -6,8 +6,15 @@ using System.Collections.ObjectModel; @@ -6,8 +6,15 @@ using System.Collections.ObjectModel;
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>
{
/// <summary>
/// Creates a new SortedObservableCollection instance.
/// </summary>
/// <param name="keySelector">The function to select the sorting key.</param>
public SortedObservableCollection(Func<T, K> keySelector)
{
this.keySelector = keySelector;
@ -17,6 +24,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -17,6 +24,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
Func<T, K> keySelector;
IComparer<K> comparer;
/// <summary>
/// Adds an item to a sorted collection.
/// </summary>
public void AddSorted(T item)
{
int i = 0;
@ -35,8 +45,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -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>
{
/// <summary>
/// Creates a new PropertyNodeCollection instance.
/// </summary>
public PropertyNodeCollection() : base(n => n.Name)
{
}

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

@ -6,8 +6,15 @@ using System.ComponentModel; @@ -6,8 +6,15 @@ using System.ComponentModel;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
/// <summary>
/// Helper class with static methods to get the list of available properties/events.
/// </summary>
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)
{
foreach (var pd1 in GetAvailableProperties(types.First())) {
@ -29,6 +36,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -29,6 +36,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
}
/// <summary>
/// Gets the available properties for the type.
/// </summary>
public static IEnumerable<PropertyDescriptor> GetAvailableProperties(Type forType)
{
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) {
@ -39,6 +49,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -39,6 +49,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
}
/// <summary>
/// Gets the available events for the type.
/// </summary>
public static IEnumerable<EventDescriptor> GetAvailableEvents(Type forType)
{
foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) {

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

@ -152,5 +152,15 @@ namespace ICSharpCode.WpfDesign @@ -152,5 +152,15 @@ namespace ICSharpCode.WpfDesign
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 @@ -57,8 +57,6 @@ namespace ICSharpCode.WpfDesign
/// Is raised when the current tool changes.
/// </summary>
event EventHandler CurrentToolChanged;
IDesignPanel DesignPanel { get; }
}
/// <summary>

2
src/Main/GlobalAssemblyInfo.template

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

Loading…
Cancel
Save