Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
using System;
namespace System.Windows {
public abstract class AttachedPropertyBrowsableAttribute : Attribute
{
protected AttachedPropertyBrowsableAttribute ()
{
}
}
}

View File

@@ -0,0 +1,59 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
using System;
namespace System.Windows {
[AttributeUsage (AttributeTargets.Method, AllowMultiple = true)]
public sealed class AttachedPropertyBrowsableForTypeAttribute : AttachedPropertyBrowsableAttribute
{
Type targetType;
public AttachedPropertyBrowsableForTypeAttribute (Type targetType)
{
this.targetType = targetType;
}
public Type TargetType {
get { return targetType; }
}
public override object TypeId {
get { throw new NotImplementedException (); }
}
public override bool Equals (object obj)
{
throw new NotImplementedException ();
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,54 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
using System;
namespace System.Windows {
[AttributeUsage (AttributeTargets.Method, AllowMultiple = false)]
public sealed class AttachedPropertyBrowsableWhenAttributePresentAttribute : AttachedPropertyBrowsableAttribute
{
Type attributeType;
public AttachedPropertyBrowsableWhenAttributePresentAttribute (Type attributeType)
{
this.attributeType = attributeType;
}
public Type AttributeType {
get { return attributeType; }
}
public override bool Equals (object obj)
{
throw new NotImplementedException ();
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,29 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
namespace System.Windows {
public delegate object CoerceValueCallback (DependencyObject d, object baseValue);
}

View File

@@ -0,0 +1,145 @@
//
// DependencyObject.cs
//
// Author:
// Iain McCoy (iain@mccoy.id.au)
// Chris Toshok (toshok@ximian.com)
//
// (C) 2005 Iain McCoy
// (C) 2007 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.Windows.Threading;
namespace System.Windows {
public class DependencyObject : DispatcherObject {
private static Dictionary<Type,Dictionary<string,DependencyProperty>> propertyDeclarations = new Dictionary<Type,Dictionary<string,DependencyProperty>>();
private Dictionary<DependencyProperty,object> properties = new Dictionary<DependencyProperty,object>();
[MonoTODO]
public bool IsSealed {
get { return false; }
}
public DependencyObjectType DependencyObjectType {
get { return DependencyObjectType.FromSystemType (GetType()); }
}
public void ClearValue(DependencyProperty dp)
{
if (IsSealed)
throw new InvalidOperationException ("Cannot manipulate property values on a sealed DependencyObject");
properties[dp] = null;
}
public void ClearValue(DependencyPropertyKey key)
{
ClearValue (key.DependencyProperty);
}
public void CoerceValue (DependencyProperty dp)
{
PropertyMetadata pm = dp.GetMetadata (this);
if (pm.CoerceValueCallback != null)
pm.CoerceValueCallback (this, GetValue (dp));
}
public sealed override bool Equals (object obj)
{
throw new NotImplementedException("Equals");
}
public sealed override int GetHashCode ()
{
throw new NotImplementedException("GetHashCode");
}
[MonoTODO]
public LocalValueEnumerator GetLocalValueEnumerator()
{
return new LocalValueEnumerator(properties);
}
public object GetValue(DependencyProperty dp)
{
object val = properties.ContainsKey (dp) ? properties [dp] : null;
return val == null ? dp.DefaultMetadata.DefaultValue : val;
}
[MonoTODO]
public void InvalidateProperty(DependencyProperty dp)
{
throw new NotImplementedException("InvalidateProperty(DependencyProperty dp)");
}
protected virtual void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
PropertyMetadata pm = e.Property.GetMetadata (this);
if (pm.PropertyChangedCallback != null)
pm.PropertyChangedCallback (this, e);
}
public object ReadLocalValue(DependencyProperty dp)
{
object val = properties.ContainsKey (dp) ? properties [dp] : null;
return val == null ? DependencyProperty.UnsetValue : val;
}
public void SetValue(DependencyProperty dp, object value)
{
if (IsSealed)
throw new InvalidOperationException ("Cannot manipulate property values on a sealed DependencyObject");
if (!dp.IsValidType (value))
throw new ArgumentException ("value not of the correct type for this DependencyProperty");
ValidateValueCallback validate = dp.ValidateValueCallback;
if (validate != null && !validate(value))
throw new Exception("Value does not validate");
else
properties[dp] = value;
}
public void SetValue(DependencyPropertyKey key, object value)
{
SetValue (key.DependencyProperty, value);
}
protected virtual bool ShouldSerializeProperty (DependencyProperty dp)
{
throw new NotImplementedException ();
}
internal static void register(Type t, DependencyProperty dp)
{
if (!propertyDeclarations.ContainsKey (t))
propertyDeclarations[t] = new Dictionary<string,DependencyProperty>();
Dictionary<string,DependencyProperty> typeDeclarations = propertyDeclarations[t];
if (!typeDeclarations.ContainsKey(dp.Name))
typeDeclarations[dp.Name] = dp;
else
throw new ArgumentException("A property named " + dp.Name + " already exists on " + t.Name);
}
}
}

View File

@@ -0,0 +1,89 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// (C) 2005 Iain McCoy
// (C) 2007 Novell, Inc.
//
// Authors:
// Iain McCoy (iain@mccoy.id.au)
// Chris Toshok (toshok@ximian.com)
//
//
using System.Collections.Generic;
namespace System.Windows {
public class DependencyObjectType {
private static Dictionary<Type,DependencyObjectType> typeMap = new Dictionary<Type,DependencyObjectType>();
private static int current_id;
private int id;
private Type systemType;
private DependencyObjectType (int id, Type systemType)
{
this.id = id;
this.systemType = systemType;
}
public DependencyObjectType BaseType {
get { return DependencyObjectType.FromSystemType (systemType.BaseType); }
}
public int Id {
get { return id; }
}
public string Name {
get { return systemType.Name; }
}
public Type SystemType {
get { return systemType; }
}
public static DependencyObjectType FromSystemType(Type systemType)
{
if (typeMap.ContainsKey (systemType))
return typeMap[systemType];
DependencyObjectType dot;
typeMap[systemType] = dot = new DependencyObjectType (current_id++, systemType);
return dot;
}
public bool IsInstanceOfType(DependencyObject dependencyObject)
{
return systemType.IsInstanceOfType (dependencyObject);
}
public bool IsSubclassOf(DependencyObjectType dependencyObjectType)
{
return systemType.IsSubclassOf (dependencyObjectType.SystemType);
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,229 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// (C) 2005 Iain McCoy
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Iain McCoy (iain@mccoy.id.au)
// Chris Toshok (toshok@ximian.com)
//
using System.Collections.Generic;
namespace System.Windows {
public sealed class DependencyProperty {
private Dictionary<Type,PropertyMetadata> metadataByType = new Dictionary<Type,PropertyMetadata>();
public static readonly object UnsetValue = new object ();
private DependencyProperty (bool isAttached, string name, Type propertyType, Type ownerType,
PropertyMetadata defaultMetadata,
ValidateValueCallback validateValueCallback)
{
IsAttached = isAttached;
DefaultMetadata = (defaultMetadata == null ? new PropertyMetadata() : defaultMetadata);
Name = name;
OwnerType = ownerType;
PropertyType = propertyType;
ValidateValueCallback = validateValueCallback;
}
internal bool IsAttached { get; set; }
public bool ReadOnly { get; private set; }
public PropertyMetadata DefaultMetadata { get; private set; }
public string Name { get; private set; }
public Type OwnerType { get; private set; }
public Type PropertyType { get; private set; }
public ValidateValueCallback ValidateValueCallback { get; private set; }
public int GlobalIndex {
get { throw new NotImplementedException (); }
}
public DependencyProperty AddOwner(Type ownerType)
{
return AddOwner (ownerType, null);
}
public DependencyProperty AddOwner(Type ownerType, PropertyMetadata typeMetadata)
{
if (typeMetadata == null) typeMetadata = new PropertyMetadata ();
OverrideMetadata (ownerType, typeMetadata);
// MS seems to always return the same DependencyProperty
return this;
}
public PropertyMetadata GetMetadata(Type forType)
{
if (metadataByType.ContainsKey (forType))
return metadataByType[forType];
return null;
}
public PropertyMetadata GetMetadata(DependencyObject dependencyObject)
{
if (metadataByType.ContainsKey (dependencyObject.GetType()))
return metadataByType[dependencyObject.GetType()];
return null;
}
public PropertyMetadata GetMetadata(DependencyObjectType dependencyObjectType)
{
if (metadataByType.ContainsKey (dependencyObjectType.SystemType))
return metadataByType[dependencyObjectType.SystemType];
return null;
}
public bool IsValidType(object value)
{
return PropertyType.IsInstanceOfType (value);
}
public bool IsValidValue(object value)
{
if (!IsValidType (value))
return false;
if (ValidateValueCallback == null)
return true;
return ValidateValueCallback (value);
}
public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
{
if (forType == null)
throw new ArgumentNullException ("forType");
if (typeMetadata == null)
throw new ArgumentNullException ("typeMetadata");
if (ReadOnly)
throw new InvalidOperationException (String.Format ("Cannot override metadata on readonly property '{0}' without using a DependencyPropertyKey", Name));
typeMetadata.DoMerge (DefaultMetadata, this, forType);
metadataByType.Add (forType, typeMetadata);
}
public void OverrideMetadata (Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key)
{
if (forType == null)
throw new ArgumentNullException ("forType");
if (typeMetadata == null)
throw new ArgumentNullException ("typeMetadata");
// further checking? should we check
// key.DependencyProperty == this?
typeMetadata.DoMerge (DefaultMetadata, this, forType);
metadataByType.Add (forType, typeMetadata);
}
public override string ToString ()
{
return Name;
}
public override int GetHashCode ()
{
return Name.GetHashCode() ^ PropertyType.GetHashCode() ^ OwnerType.GetHashCode();
}
public static DependencyProperty Register(string name, Type propertyType, Type ownerType)
{
return Register(name, propertyType, ownerType, null, null);
}
public static DependencyProperty Register(string name, Type propertyType, Type ownerType,
PropertyMetadata typeMetadata)
{
return Register(name, propertyType, ownerType, typeMetadata, null);
}
public static DependencyProperty Register(string name, Type propertyType, Type ownerType,
PropertyMetadata typeMetadata,
ValidateValueCallback validateValueCallback)
{
if (typeMetadata == null)
typeMetadata = new PropertyMetadata();
DependencyProperty dp = new DependencyProperty(false, name, propertyType, ownerType,
typeMetadata, validateValueCallback);
DependencyObject.register(ownerType, dp);
dp.OverrideMetadata (ownerType, typeMetadata);
return dp;
}
public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType)
{
return RegisterAttached(name, propertyType, ownerType, null, null);
}
public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType,
PropertyMetadata defaultMetadata)
{
return RegisterAttached(name, propertyType, ownerType, defaultMetadata, null);
}
public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType,
PropertyMetadata defaultMetadata,
ValidateValueCallback validateValueCallback)
{
DependencyProperty dp = new DependencyProperty(true, name, propertyType, ownerType,
defaultMetadata, validateValueCallback);
DependencyObject.register(ownerType, dp);
return dp;
}
public static DependencyPropertyKey RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType,
PropertyMetadata defaultMetadata)
{
throw new NotImplementedException("RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata)");
}
public static DependencyPropertyKey RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType,
PropertyMetadata defaultMetadata,
ValidateValueCallback validateValueCallback)
{
throw new NotImplementedException("RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback)");
}
public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType,
PropertyMetadata typeMetadata)
{
return RegisterReadOnly (name, propertyType, ownerType, typeMetadata, null);
}
public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType,
PropertyMetadata typeMetadata,
ValidateValueCallback validateValueCallback)
{
DependencyProperty prop = Register (name, propertyType, ownerType, typeMetadata, validateValueCallback);
prop.ReadOnly = true;
return new DependencyPropertyKey (prop);
}
}
}

View File

@@ -0,0 +1,83 @@
//
// DependencyPropertyChangedEventArgs.cs
//
// Author:
// Chris Toshok (toshok@ximian.com)
//
// (C) 2007 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Windows {
public struct DependencyPropertyChangedEventArgs {
public DependencyPropertyChangedEventArgs (DependencyProperty property, object oldValue, object newValue)
: this ()
{
this.Property = property;
this.OldValue = oldValue;
this.NewValue = newValue;
}
public object NewValue {
get; private set;
}
public object OldValue {
get; private set;
}
public DependencyProperty Property {
get; private set;
}
public override bool Equals (object obj)
{
if (!(obj is DependencyPropertyChangedEventArgs))
return false;
return Equals ((DependencyPropertyChangedEventArgs)obj);
}
public bool Equals (DependencyPropertyChangedEventArgs args)
{
return (Property == args.Property &&
NewValue == args.NewValue &&
OldValue == args.OldValue);
}
public static bool operator != (DependencyPropertyChangedEventArgs left, DependencyPropertyChangedEventArgs right)
{
throw new NotImplementedException ();
}
public static bool operator == (DependencyPropertyChangedEventArgs left, DependencyPropertyChangedEventArgs right)
{
throw new NotImplementedException ();
}
public override int GetHashCode()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,31 @@
//
// DependencyPropertyChangedEventHandler.cs
//
// Author:
// Chris Toshok (toshok@ximian.com)
//
// (C) 2007 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Windows {
public delegate void DependencyPropertyChangedEventHandler (object sender, DependencyPropertyChangedEventArgs e);
}

View File

@@ -0,0 +1,46 @@
//
// DependencyPropertyKey.cs
//
// Author:
// Iain McCoy (iain@mccoy.id.au)
//
// (C) 2005 Iain McCoy
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Windows {
public sealed class DependencyPropertyKey {
internal DependencyPropertyKey (DependencyProperty dependencyProperty)
{
this.dependencyProperty = dependencyProperty;
}
private DependencyProperty dependencyProperty;
public DependencyProperty DependencyProperty {
get { return dependencyProperty; }
}
public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
{
dependencyProperty.OverrideMetadata (forType, typeMetadata, this);
}
}
}

View File

@@ -0,0 +1,39 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
using System;
using System.ComponentModel;
namespace System.Windows {
[TypeConverter (typeof (ExpressionConverter))]
public class Expression
{
internal Expression ()
{
}
}
}

View File

@@ -0,0 +1,60 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Windows {
public class ExpressionConverter : TypeConverter
{
public ExpressionConverter ()
{
}
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
{
throw new NotImplementedException ();
}
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
throw new NotImplementedException ();
}
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
{
throw new NotImplementedException ();
}
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,148 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
namespace System.Windows {
public abstract class Freezable : DependencyObject {
protected Freezable () {
}
public Freezable Clone ()
{
throw new NotImplementedException ();
}
protected virtual void CloneCore (Freezable sourceFreezable)
{
throw new NotImplementedException ();
}
public Freezable CloneCurrentValue ()
{
throw new NotImplementedException ();
}
protected virtual void CloneCurrentValueCore (Freezable sourceFreezable)
{
throw new NotImplementedException ();
}
protected Freezable CreateInstance ()
{
throw new NotImplementedException ();
}
protected abstract Freezable CreateInstanceCore ();
public void Freeze ()
{
throw new NotImplementedException ();
}
protected static bool Freeze (Freezable freezable,
bool isChecking)
{
throw new NotImplementedException ();
}
protected virtual bool FreezeCore (bool isChecking)
{
throw new NotImplementedException ();
}
public Freezable GetAsFrozen ()
{
throw new NotImplementedException ();
}
protected virtual void GetAsFrozenCore (Freezable sourceFreezable)
{
throw new NotImplementedException ();
}
public Freezable GetCurrentValueAsFrozen ()
{
throw new NotImplementedException ();
}
protected virtual void GetCurrentValueAsFrozenCore (Freezable sourceFreezable)
{
throw new NotImplementedException ();
}
protected virtual void OnChanged ()
{
throw new NotImplementedException ();
}
protected void OnFreezablePropertyChanged (DependencyObject oldValue,
DependencyObject newValue)
{
throw new NotImplementedException ();
}
protected void OnFreezablePropertyChanged (DependencyObject oldValue,
DependencyObject newValue,
DependencyProperty property)
{
throw new NotImplementedException ();
}
protected override void OnPropertyChanged (DependencyPropertyChangedEventArgs e)
{
throw new NotImplementedException ();
}
protected void ReadPreamble ()
{
throw new NotImplementedException ();
}
protected void WritePostscript ()
{
throw new NotImplementedException ();
}
protected void WritePreamble ()
{
throw new NotImplementedException ();
}
public bool CanFreeze {
get { return FreezeCore (true); }
}
public bool IsFrozen {
get {
throw new NotImplementedException ();
}
}
public event EventHandler Changed;
}
}

View File

@@ -0,0 +1,32 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok <toshok@novell.com>
//
using System;
namespace System.Windows {
public interface IWeakEventListener {
bool ReceiveWeakEvent (Type managerType, object sender, EventArgs e);
}
}

View File

@@ -0,0 +1,138 @@
//
// DependencyPropertyChangedEventArgs.cs
//
// Author:
// Chris Toshok (toshok@ximian.com)
//
// (C) 2007 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
using System.Windows.Converters;
using System.Windows.Markup;
namespace System.Windows {
[Serializable]
[TypeConverter (typeof(Int32RectConverter))]
[ValueSerializer (typeof(Int32RectValueSerializer))]
public struct Int32Rect : IFormattable
{
int x, y, width, height;
public Int32Rect (int x, int y, int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public static bool operator != (Int32Rect int32Rect1, Int32Rect int32Rect2)
{
return !int32Rect1.Equals(int32Rect2);
}
public static bool operator == (Int32Rect int32Rect1, Int32Rect int32Rect2)
{
return int32Rect1.Equals(int32Rect2);
}
public static Int32Rect Empty {
get { return new Int32Rect (0, 0, 0, 0); }
}
public int Height {
get { return height; }
set { height = value; }
}
public bool IsEmpty {
get { return width == 0 && height == 0; }
}
public int Width {
get { return width; }
set { width = value; }
}
public int X {
get { return x; }
set { x = value; }
}
public int Y {
get { return y; }
set { y = value; }
}
public bool Equals (Int32Rect value)
{
return (x == value.x &&
y == value.y &&
width == value.width &&
height == value.height);
}
public override bool Equals (object o)
{
if (!(o is Int32Rect))
return false;
return Equals ((Int32Rect)o);
}
public static bool Equals (Int32Rect int32Rect1, Int32Rect int32Rect2)
{
return int32Rect1.Equals (int32Rect2);
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
public static Int32Rect Parse (string source)
{
throw new NotImplementedException ();
}
public override string ToString ()
{
if (IsEmpty)
return "Empty";
return String.Format ("{0},{1},{2},{3}", x, y, width, height);
}
public string ToString (IFormatProvider provider)
{
throw new NotImplementedException ();
}
string IFormattable.ToString (string format, IFormatProvider provider)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,57 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok <toshok@novell.com>
//
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Windows {
public sealed class Int32RectConverter : TypeConverter
{
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof (string);
}
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof (string);
}
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (!(value is string))
throw new NotSupportedException ("Int32RectConvert only supports converting from strings");
return Int32Rect.Parse ((string)value);
}
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return ((Int32Rect)value).ToString (culture);
}
}
}

View File

@@ -0,0 +1,68 @@
//
// LocalValueEntry.cs
//
// Author:
// Iain McCoy (iain@mccoy.id.au)
//
// (C) 2005 Iain McCoy
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Windows {
public struct LocalValueEntry {
private DependencyProperty property;
private object value;
internal LocalValueEntry(DependencyProperty property, object value)
{
this.property = property;
this.value = value;
}
public DependencyProperty Property {
get { return property; }
}
public object Value {
get { return value; }
}
public static bool operator != (LocalValueEntry obj1, LocalValueEntry obj2)
{
throw new NotImplementedException ();
}
public static bool operator == (LocalValueEntry obj1, LocalValueEntry obj2)
{
throw new NotImplementedException ();
}
public override bool Equals (object obj)
{
throw new NotImplementedException ();
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,88 @@
//
// LocalValueEnumerator.cs
//
// Author:
// Iain McCoy (iain@mccoy.id.au)
//
// (C) 2005 Iain McCoy
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Collections.Generic;
namespace System.Windows {
public struct LocalValueEnumerator : IEnumerator {
private IDictionaryEnumerator propertyEnumerator;
private Dictionary<DependencyProperty,object> properties;
private int count;
internal LocalValueEnumerator(Dictionary<DependencyProperty,object> properties)
{
this.count = properties.Count;
this.properties = properties;
this.propertyEnumerator = properties.GetEnumerator();
}
public int Count {
get { return count; }
}
public LocalValueEntry Current {
get { return new LocalValueEntry((DependencyProperty)propertyEnumerator.Key,
propertyEnumerator.Value); }
}
object IEnumerator.Current {
get { return this.Current; }
}
public bool MoveNext()
{
return propertyEnumerator.MoveNext();
}
public void Reset()
{
propertyEnumerator.Reset();
}
public static bool operator != (LocalValueEnumerator obj1, LocalValueEnumerator obj2)
{
throw new NotImplementedException ();
}
public static bool operator == (LocalValueEnumerator obj1, LocalValueEnumerator obj2)
{
throw new NotImplementedException ();
}
public override bool Equals (object obj)
{
throw new NotImplementedException ();
}
public override int GetHashCode ()
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,195 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok (toshok@novell.com)
//
using System;
using System.ComponentModel;
using System.Windows.Converters;
using System.Windows.Markup;
using System.Windows.Media;
using System.Globalization;
namespace System.Windows {
[Serializable]
[TypeConverter (typeof (PointConverter))]
[ValueSerializer (typeof (PointValueSerializer))]
public struct Point : IFormattable
{
public Point (double x, double y)
{
this.x = x;
this.y = y;
}
public double X {
get { return x; }
set { x = value; }
}
public double Y {
get { return y; }
set { y = value; }
}
public override bool Equals (object o)
{
if (!(o is Point))
return false;
return Equals ((Point)o);
}
public bool Equals (Point value)
{
return x == value.X && y == value.Y;
}
public override int GetHashCode ()
{
return (x.GetHashCode() ^ y.GetHashCode());
}
public void Offset (double offsetX, double offsetY)
{
x += offsetX;
y += offsetY;
}
public static Point Add (Point point, Vector vector)
{
return new Point (point.X + vector.X, point.Y + vector.Y);
}
public static bool Equals (Point point1, Point point2)
{
return point1.Equals (point2);
}
public static Point Multiply (Point point, Matrix matrix)
{
return new Point (point.X * matrix.M11 + point.Y * matrix.M21 + matrix.OffsetX,
point.X * matrix.M12 + point.Y * matrix.M22 + matrix.OffsetY);
}
public static Vector Subtract (Point point1, Point point2)
{
return new Vector (point1.X - point2.X, point1.Y - point2.Y);
}
public static Point Subtract (Point point, Vector vector)
{
return new Point (point.X - vector.X, point.Y - vector.Y);
}
/* operators */
public static Vector operator -(Point point1, Point point2)
{
return Subtract (point1, point2);
}
public static Point operator -(Point point, Vector vector)
{
return Subtract (point, vector);
}
public static Point operator + (Point point, Vector vector)
{
return Add (point, vector);
}
public static Point operator * (Point point, Matrix matrix)
{
return Multiply (point, matrix);
}
public static bool operator != (Point point1, Point point2)
{
return !point1.Equals(point2);
}
public static bool operator == (Point point1, Point point2)
{
return point1.Equals(point2);
}
public static explicit operator Size (Point point)
{
return new Size (point.X, point.Y);
}
public static explicit operator Vector (Point point)
{
return new Vector (point.X, point.Y);
}
public static Point Parse (string source)
{
string[] points = source.Split(',');
if (points.Length<2)
throw new InvalidOperationException ("source does not contain two numbers");
if (points.Length > 2)
throw new InvalidOperationException ("source contains too many delimiters");
CultureInfo ci = CultureInfo.InvariantCulture;
return new Point (Convert.ToDouble(points[0],ci), Convert.ToDouble(points[1],ci));
}
public override string ToString ()
{
return this.ToString(null, null);
}
public string ToString (IFormatProvider provider)
{
return this.ToString(null, provider);
}
private string ToString(string format,IFormatProvider formatProvider)
{
CultureInfo ci = (CultureInfo)formatProvider;
if (ci == null)
ci = CultureInfo.CurrentCulture;
string seperator = ci.NumberFormat.NumberDecimalSeparator;
if (seperator.Equals(","))
seperator = ";";
else
seperator = ",";
object[] ob = { this.x, seperator, this.y };
return string.Format(formatProvider, "{0:" + format + "}{1}{2:" + format + "}", ob);
}
string IFormattable.ToString (string format, IFormatProvider formatProvider)
{
return this.ToString(format, formatProvider);
}
double x;
double y;
}
}

View File

@@ -0,0 +1,57 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Chris Toshok <toshok@novell.com>
//
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Windows {
public sealed class PointConverter : TypeConverter
{
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof (string);
}
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof (string);
}
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (!(value is string))
throw new NotSupportedException ("PointConverter only supports converting from strings");
return Point.Parse ((string)value);
}
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return ((Point)value).ToString (culture);
}
}
}

Some files were not shown because too many files have changed in this diff Show More