Added HhyperDescriptor, sorting backgroundsprites according to texture
This commit is contained in:
Binary file not shown.
146
Hyper.ComponentModel/ChainingPropertyDescriptor.cs
Normal file
146
Hyper.ComponentModel/ChainingPropertyDescriptor.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
namespace Hyper.ComponentModel
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
public abstract class ChainingPropertyDescriptor : PropertyDescriptor
|
||||
{
|
||||
private readonly PropertyDescriptor _root;
|
||||
|
||||
protected PropertyDescriptor Root
|
||||
{
|
||||
get { return _root; }
|
||||
}
|
||||
|
||||
protected ChainingPropertyDescriptor(PropertyDescriptor root)
|
||||
: base(root)
|
||||
{
|
||||
_root = root;
|
||||
}
|
||||
|
||||
public override void AddValueChanged(object component, EventHandler handler)
|
||||
{
|
||||
Root.AddValueChanged(component, handler);
|
||||
}
|
||||
|
||||
public override AttributeCollection Attributes
|
||||
{
|
||||
get { return Root.Attributes; }
|
||||
}
|
||||
|
||||
public override bool CanResetValue(object component)
|
||||
{
|
||||
return Root.CanResetValue(component);
|
||||
}
|
||||
|
||||
public override string Category
|
||||
{
|
||||
get { return Root.Category; }
|
||||
}
|
||||
|
||||
public override Type ComponentType
|
||||
{
|
||||
get { return Root.ComponentType; }
|
||||
}
|
||||
|
||||
public override TypeConverter Converter
|
||||
{
|
||||
get { return Root.Converter; }
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get { return Root.Description; }
|
||||
}
|
||||
|
||||
public override bool DesignTimeOnly
|
||||
{
|
||||
get { return Root.DesignTimeOnly; }
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get { return Root.DisplayName; }
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Root.Equals(obj);
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter)
|
||||
{
|
||||
return Root.GetChildProperties(instance, filter);
|
||||
}
|
||||
|
||||
public override object GetEditor(Type editorBaseType)
|
||||
{
|
||||
return Root.GetEditor(editorBaseType);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Root.GetHashCode();
|
||||
}
|
||||
|
||||
public override object GetValue(object component)
|
||||
{
|
||||
return Root.GetValue(component);
|
||||
}
|
||||
|
||||
public override bool IsBrowsable
|
||||
{
|
||||
get { return Root.IsBrowsable; }
|
||||
}
|
||||
|
||||
public override bool IsLocalizable
|
||||
{
|
||||
get { return Root.IsLocalizable; }
|
||||
}
|
||||
|
||||
public override bool IsReadOnly
|
||||
{
|
||||
get { return Root.IsReadOnly; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return Root.Name; }
|
||||
}
|
||||
|
||||
public override Type PropertyType
|
||||
{
|
||||
get { return Root.PropertyType; }
|
||||
}
|
||||
|
||||
public override void RemoveValueChanged(object component, EventHandler handler)
|
||||
{
|
||||
Root.RemoveValueChanged(component, handler);
|
||||
}
|
||||
|
||||
public override void ResetValue(object component)
|
||||
{
|
||||
Root.ResetValue(component);
|
||||
}
|
||||
|
||||
public override void SetValue(object component, object value)
|
||||
{
|
||||
Root.SetValue(component, value);
|
||||
}
|
||||
|
||||
public override bool ShouldSerializeValue(object component)
|
||||
{
|
||||
return Root.ShouldSerializeValue(component);
|
||||
}
|
||||
|
||||
public override bool SupportsChangeEvents
|
||||
{
|
||||
get { return Root.SupportsChangeEvents; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Root.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Hyper.ComponentModel/Hyper.ComponentModel.csproj
Normal file
55
Hyper.ComponentModel/Hyper.ComponentModel.csproj
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Hyper.ComponentModel</RootNamespace>
|
||||
<AssemblyName>Hyper.ComponentModel</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Hyper.ComponentModel.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChainingPropertyDescriptor.cs" />
|
||||
<Compile Include="HyperTypeDescriptionProvider.cs" />
|
||||
<Compile Include="HyperTypeDescriptor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
126
Hyper.ComponentModel/HyperTypeDescriptionProvider.cs
Normal file
126
Hyper.ComponentModel/HyperTypeDescriptionProvider.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
namespace Hyper.ComponentModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
public sealed class HyperTypeDescriptionProvider : TypeDescriptionProvider
|
||||
{
|
||||
private static readonly Dictionary<Type, ICustomTypeDescriptor> descriptors = new Dictionary<Type, ICustomTypeDescriptor>();
|
||||
private static readonly Dictionary<Type, TypeDescriptionProvider> providers = new Dictionary<Type, TypeDescriptionProvider>();
|
||||
|
||||
public static void Add(Type type)
|
||||
{
|
||||
lock (descriptors)
|
||||
{
|
||||
if (!providers.ContainsKey(type))
|
||||
{
|
||||
// determine if the base type was already added
|
||||
// if so, remove it before adding sub-type
|
||||
// (if a sub-type is added after its base type, infinite recursion occurs in GetTypeDescriptor())
|
||||
var baseFound = false;
|
||||
if (type.BaseType != null && providers.ContainsKey(type.BaseType))
|
||||
{
|
||||
baseFound = true;
|
||||
Remove(type.BaseType);
|
||||
}
|
||||
|
||||
// add the provider for the type
|
||||
var provider = new HyperTypeDescriptionProvider(TypeDescriptor.GetProvider(type));
|
||||
|
||||
TypeDescriptor.AddProvider(provider, type);
|
||||
providers.Add(type, provider);
|
||||
|
||||
// initialize descriptor
|
||||
provider.GetTypeDescriptor(type);
|
||||
|
||||
// if base type was removed, we can now add it back after building the sub-type descriptor
|
||||
if (baseFound)
|
||||
Add(type.BaseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Remove(Type type)
|
||||
{
|
||||
lock (descriptors)
|
||||
{
|
||||
TypeDescriptor.RemoveProvider(providers[type], type);
|
||||
providers.Remove(type);
|
||||
descriptors.Remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
lock (descriptors)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
TypeDescriptor.RemoveProvider(provider.Value, provider.Key);
|
||||
providers.Clear();
|
||||
descriptors.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private HyperTypeDescriptionProvider()
|
||||
: this(typeof(object))
|
||||
{ }
|
||||
|
||||
private HyperTypeDescriptionProvider(Type type)
|
||||
: this(TypeDescriptor.GetProvider(type))
|
||||
{ }
|
||||
|
||||
private HyperTypeDescriptionProvider(TypeDescriptionProvider parent)
|
||||
: base(parent)
|
||||
{ }
|
||||
|
||||
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
|
||||
{
|
||||
lock (descriptors)
|
||||
{
|
||||
ICustomTypeDescriptor descriptor;
|
||||
if (!descriptors.TryGetValue(objectType, out descriptor))
|
||||
{
|
||||
try
|
||||
{
|
||||
descriptor = BuildDescriptor(objectType);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return base.GetTypeDescriptor(objectType, instance);
|
||||
}
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
[SecuritySafeCritical]
|
||||
[ReflectionPermission(SecurityAction.Assert, Unrestricted = true)]
|
||||
private ICustomTypeDescriptor BuildDescriptor(Type objectType)
|
||||
{
|
||||
// NOTE: "descriptors" already locked here
|
||||
|
||||
// get the parent descriptor and add to the dictionary so that
|
||||
// building the new descriptor will use the base rather than recursing
|
||||
var descriptor = base.GetTypeDescriptor(objectType, null);
|
||||
descriptors.Add(objectType, descriptor);
|
||||
try
|
||||
{
|
||||
// build a new descriptor from this, and replace the lookup
|
||||
descriptor = new HyperTypeDescriptor(descriptor);
|
||||
descriptors[objectType] = descriptor;
|
||||
return descriptor;
|
||||
}
|
||||
catch
|
||||
{ // rollback and throw
|
||||
// (perhaps because the specific caller lacked permissions;
|
||||
// another caller may be successful)
|
||||
descriptors.Remove(objectType);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
265
Hyper.ComponentModel/HyperTypeDescriptor.cs
Normal file
265
Hyper.ComponentModel/HyperTypeDescriptor.cs
Normal file
@@ -0,0 +1,265 @@
|
||||
namespace Hyper.ComponentModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Threading;
|
||||
|
||||
public sealed class HyperTypeDescriptor : CustomTypeDescriptor
|
||||
{
|
||||
private readonly PropertyDescriptorCollection propertyCollections;
|
||||
|
||||
private static readonly Dictionary<PropertyInfo, PropertyDescriptor> properties =
|
||||
new Dictionary<PropertyInfo, PropertyDescriptor>();
|
||||
|
||||
internal HyperTypeDescriptor(ICustomTypeDescriptor parent)
|
||||
: base(parent)
|
||||
{
|
||||
propertyCollections = WrapProperties(parent.GetProperties());
|
||||
}
|
||||
|
||||
public override sealed PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
||||
{
|
||||
return propertyCollections;
|
||||
}
|
||||
|
||||
public override sealed PropertyDescriptorCollection GetProperties()
|
||||
{
|
||||
return propertyCollections;
|
||||
}
|
||||
|
||||
private static PropertyDescriptorCollection WrapProperties(PropertyDescriptorCollection oldProps)
|
||||
{
|
||||
PropertyDescriptor[] newProps = new PropertyDescriptor[oldProps.Count];
|
||||
int index = 0;
|
||||
bool changed = false;
|
||||
// HACK: how to identify reflection, given that the class is internal...
|
||||
Type wrapMe =
|
||||
Assembly.GetAssembly(typeof (PropertyDescriptor))
|
||||
.GetType("System.ComponentModel.ReflectPropertyDescriptor");
|
||||
foreach (PropertyDescriptor oldProp in oldProps)
|
||||
{
|
||||
PropertyDescriptor pd = oldProp;
|
||||
// if it looks like reflection, try to create a bespoke descriptor
|
||||
if (ReferenceEquals(wrapMe, pd.GetType()) && TryCreatePropertyDescriptor(ref pd))
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
newProps[index++] = pd;
|
||||
}
|
||||
|
||||
return changed ? new PropertyDescriptorCollection(newProps, true) : oldProps;
|
||||
}
|
||||
|
||||
private static readonly ModuleBuilder moduleBuilder;
|
||||
private static int counter;
|
||||
|
||||
static HyperTypeDescriptor()
|
||||
{
|
||||
AssemblyName an = new AssemblyName("Hyper.ComponentModel.dynamic");
|
||||
AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run);
|
||||
moduleBuilder = ab.DefineDynamicModule("Hyper.ComponentModel.dynamic.dll");
|
||||
|
||||
}
|
||||
|
||||
private static bool TryCreatePropertyDescriptor(ref PropertyDescriptor descriptor)
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyInfo property = descriptor.ComponentType.GetProperty(descriptor.Name);
|
||||
if (property == null) return false;
|
||||
|
||||
lock (properties)
|
||||
{
|
||||
PropertyDescriptor foundBuiltAlready;
|
||||
if (properties.TryGetValue(property, out foundBuiltAlready))
|
||||
{
|
||||
descriptor = foundBuiltAlready;
|
||||
return true;
|
||||
}
|
||||
|
||||
string name = "_c" + Interlocked.Increment(ref counter).ToString();
|
||||
TypeBuilder tb = moduleBuilder.DefineType(name,
|
||||
TypeAttributes.Sealed | TypeAttributes.NotPublic | TypeAttributes.Class |
|
||||
TypeAttributes.BeforeFieldInit | TypeAttributes.AutoClass | TypeAttributes.Public,
|
||||
typeof (ChainingPropertyDescriptor));
|
||||
|
||||
// ctor calls base
|
||||
ConstructorBuilder cb =
|
||||
tb.DefineConstructor(
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.SpecialName |
|
||||
MethodAttributes.RTSpecialName, CallingConventions.Standard,
|
||||
new Type[] {typeof (PropertyDescriptor)});
|
||||
ILGenerator il = cb.GetILGenerator();
|
||||
il.Emit(OpCodes.Ldarg_0);
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Call,
|
||||
typeof (ChainingPropertyDescriptor).GetConstructor(
|
||||
BindingFlags.NonPublic | BindingFlags.Instance, null,
|
||||
new Type[] {typeof (PropertyDescriptor)}, null));
|
||||
il.Emit(OpCodes.Ret);
|
||||
|
||||
MethodBuilder mb;
|
||||
MethodInfo baseMethod;
|
||||
if (property.CanRead)
|
||||
{
|
||||
// obtain the implementation that we want to override
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetMethod("GetValue");
|
||||
// create a new method that accepts an object and returns an object (as per the base)
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final,
|
||||
baseMethod.CallingConvention, baseMethod.ReturnType, new Type[] {typeof (object)});
|
||||
// start writing IL into the method
|
||||
il = mb.GetILGenerator();
|
||||
if (property.DeclaringType.IsValueType)
|
||||
{
|
||||
// upbox the object argument into our known (instance) struct type
|
||||
LocalBuilder lb = il.DeclareLocal(property.DeclaringType);
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Unbox_Any, property.DeclaringType);
|
||||
il.Emit(OpCodes.Stloc_0);
|
||||
il.Emit(OpCodes.Ldloca_S, lb);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cast the object argument into our known class type
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Castclass, property.DeclaringType);
|
||||
}
|
||||
// call the "get" method
|
||||
il.Emit(OpCodes.Callvirt, property.GetGetMethod());
|
||||
|
||||
if (property.PropertyType.IsValueType)
|
||||
{
|
||||
// box it from the known (value) struct type
|
||||
il.Emit(OpCodes.Box, property.PropertyType);
|
||||
}
|
||||
// return the value
|
||||
il.Emit(OpCodes.Ret);
|
||||
// signal that this method should override the base
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
}
|
||||
|
||||
bool supportsChangeEvents = descriptor.SupportsChangeEvents, isReadOnly = descriptor.IsReadOnly;
|
||||
|
||||
// override SupportsChangeEvents
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetProperty("SupportsChangeEvents").GetGetMethod();
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final | MethodAttributes.SpecialName, baseMethod.CallingConvention,
|
||||
baseMethod.ReturnType, Type.EmptyTypes);
|
||||
il = mb.GetILGenerator();
|
||||
if (supportsChangeEvents)
|
||||
{
|
||||
il.Emit(OpCodes.Ldc_I4_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
il.Emit(OpCodes.Ldc_I4_0);
|
||||
}
|
||||
il.Emit(OpCodes.Ret);
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
|
||||
// override IsReadOnly
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetProperty("IsReadOnly").GetGetMethod();
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final | MethodAttributes.SpecialName, baseMethod.CallingConvention,
|
||||
baseMethod.ReturnType, Type.EmptyTypes);
|
||||
il = mb.GetILGenerator();
|
||||
if (isReadOnly)
|
||||
{
|
||||
il.Emit(OpCodes.Ldc_I4_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
il.Emit(OpCodes.Ldc_I4_0);
|
||||
}
|
||||
il.Emit(OpCodes.Ret);
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
|
||||
// for classes, implement write (would be lost in unbox for structs)
|
||||
if (!property.DeclaringType.IsValueType)
|
||||
{
|
||||
if (!isReadOnly && property.CanWrite)
|
||||
{
|
||||
// override set method
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetMethod("SetValue");
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final, baseMethod.CallingConvention, baseMethod.ReturnType,
|
||||
new Type[] {typeof (object), typeof (object)});
|
||||
il = mb.GetILGenerator();
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Castclass, property.DeclaringType);
|
||||
il.Emit(OpCodes.Ldarg_2);
|
||||
if (property.PropertyType.IsValueType)
|
||||
{
|
||||
il.Emit(OpCodes.Unbox_Any, property.PropertyType);
|
||||
}
|
||||
else
|
||||
{
|
||||
il.Emit(OpCodes.Castclass, property.PropertyType);
|
||||
}
|
||||
il.Emit(OpCodes.Callvirt, property.GetSetMethod());
|
||||
il.Emit(OpCodes.Ret);
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
}
|
||||
|
||||
if (supportsChangeEvents)
|
||||
{
|
||||
EventInfo ei = property.DeclaringType.GetEvent(property.Name + "Changed");
|
||||
if (ei != null)
|
||||
{
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetMethod("AddValueChanged");
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final | MethodAttributes.SpecialName, baseMethod.CallingConvention,
|
||||
baseMethod.ReturnType, new Type[] {typeof (object), typeof (EventHandler)});
|
||||
il = mb.GetILGenerator();
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Castclass, property.DeclaringType);
|
||||
il.Emit(OpCodes.Ldarg_2);
|
||||
il.Emit(OpCodes.Callvirt, ei.GetAddMethod());
|
||||
il.Emit(OpCodes.Ret);
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
|
||||
baseMethod = typeof (ChainingPropertyDescriptor).GetMethod("RemoveValueChanged");
|
||||
mb = tb.DefineMethod(baseMethod.Name,
|
||||
MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Virtual |
|
||||
MethodAttributes.Final | MethodAttributes.SpecialName, baseMethod.CallingConvention,
|
||||
baseMethod.ReturnType, new Type[] {typeof (object), typeof (EventHandler)});
|
||||
il = mb.GetILGenerator();
|
||||
il.Emit(OpCodes.Ldarg_1);
|
||||
il.Emit(OpCodes.Castclass, property.DeclaringType);
|
||||
il.Emit(OpCodes.Ldarg_2);
|
||||
il.Emit(OpCodes.Callvirt, ei.GetRemoveMethod());
|
||||
il.Emit(OpCodes.Ret);
|
||||
tb.DefineMethodOverride(mb, baseMethod);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
PropertyDescriptor newDesc =
|
||||
tb.CreateType()
|
||||
.GetConstructor(new Type[] {typeof (PropertyDescriptor)})
|
||||
.Invoke(new object[] {descriptor}) as PropertyDescriptor;
|
||||
if (newDesc == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
descriptor = newDesc;
|
||||
properties.Add(property, descriptor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Hyper.ComponentModel/Properties/AssemblyInfo.cs
Normal file
36
Hyper.ComponentModel/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Hyper.ComponentModel")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Hyper.ComponentModel")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("aa867666-4c7a-489b-98ac-ce79048bddfa")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1155,6 +1155,10 @@
|
||||
<Project>{0aad36e3-51a5-4a07-ab60-5c8a66bd38b7}</Project>
|
||||
<Name>Farseer Physics MonoGame</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Hyper.ComponentModel\Hyper.ComponentModel.csproj">
|
||||
<Project>{3b8f9edb-6e5e-450c-abc2-ec49075d0b50}</Project>
|
||||
<Name>Hyper.ComponentModel</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj">
|
||||
<Project>{49ba1c69-6104-41ac-a5d8-b54fa9f696e8}</Project>
|
||||
<Name>Lidgren.Network</Name>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ReferencePath>
|
||||
|
||||
@@ -49,7 +49,20 @@ namespace Barotrauma
|
||||
BackgroundSpritePrefab prefab = GetRandomPrefab();
|
||||
Vector2 pos = FindSpritePosition(level, prefab);
|
||||
|
||||
sprites.Add(new BackgroundSprite(prefab, pos));
|
||||
var newSprite = new BackgroundSprite(prefab, pos);
|
||||
|
||||
int n = 0;
|
||||
|
||||
while (n < sprites.Count)
|
||||
{
|
||||
n++;
|
||||
|
||||
Sprite existingSprite = sprites[n - 1].Prefab.Sprite;
|
||||
if (existingSprite == null) continue;
|
||||
if (existingSprite.Texture == newSprite.Prefab.Sprite.Texture) break;
|
||||
}
|
||||
|
||||
sprites.Insert(i, newSprite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace Barotrauma
|
||||
|
||||
CurrGraphicsDevice = GraphicsDevice;
|
||||
|
||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
|
||||
|
||||
//Event.Init("Content/randomevents.xml");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma", "Subsurface\Barotrauma.csproj", "{008C0F83-E914-4966-9135-EA885059EDD8}"
|
||||
EndProject
|
||||
@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter", "CrashRepor
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyper.ComponentModel", "Hyper.ComponentModel\Hyper.ComponentModel.csproj", "{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Android|Any CPU = Android|Any CPU
|
||||
@@ -347,6 +349,60 @@ Global
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.Build.0 = Release|x86
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.iOS|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Linux|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.OSX|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.PSM|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Release|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows|x86.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|x86.ActiveCfg = Release|Any CPU
|
||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Windows8|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user