OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / design / Color4Converter.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/design/Color4Converter.cpp b/SlimDXc_Jun2010(VC++2008)/source/design/Color4Converter.cpp
deleted file mode 100644 (file)
index 4fac02e..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-\r
-#include "../InternalHelpers.h"\r
-#include "../math/Color4.h"\r
-\r
-#include "Color4Converter.h"\r
-#include "FieldPropertyDescriptor.h"\r
-\r
-using namespace System;\r
-using namespace System::Collections;\r
-using namespace System::Drawing;\r
-using namespace System::ComponentModel;\r
-using namespace System::ComponentModel::Design::Serialization;\r
-using namespace System::Globalization;\r
-using namespace System::Reflection;\r
-\r
-namespace SlimDX\r
-{\r
-namespace Design\r
-{\r
-       Color4Converter::Color4Converter()\r
-       {\r
-               Type^ type = Color4::typeid;\r
-               array<PropertyDescriptor^>^ propArray =\r
-               {\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Red")),\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Green")),\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Blue")),\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Alpha")),\r
-               };\r
-\r
-               m_Properties = gcnew PropertyDescriptorCollection(propArray);\r
-       }\r
-\r
-       bool Color4Converter::CanConvertTo(ITypeDescriptorContext^ context, Type^ destinationType)\r
-       {\r
-               if( destinationType == String::typeid || destinationType == InstanceDescriptor::typeid )\r
-                       return true;\r
-               else\r
-                       return ExpandableObjectConverter::CanConvertTo(context, destinationType);\r
-       }\r
-\r
-       bool Color4Converter::CanConvertFrom(ITypeDescriptorContext^ context, Type^ sourceType)\r
-       {\r
-               if( sourceType == String::typeid )\r
-                       return true;\r
-               else\r
-                       return ExpandableObjectConverter::CanConvertFrom(context, sourceType);\r
-       }\r
-\r
-       Object^ Color4Converter::ConvertTo(ITypeDescriptorContext^ context, CultureInfo^ culture, Object^ value, Type^ destinationType)\r
-       {\r
-               if( destinationType == nullptr )\r
-                       throw gcnew ArgumentNullException( "destinationType" );\r
-\r
-               if( culture == nullptr )\r
-                       culture = CultureInfo::CurrentCulture;\r
-\r
-               Color4^ color = dynamic_cast<Color4^>( value );\r
-\r
-               if( destinationType == String::typeid && color != nullptr )\r
-               {\r
-                       String^ separator = culture->TextInfo->ListSeparator + " ";\r
-                       TypeConverter^ converter = TypeDescriptor::GetConverter(float::typeid);\r
-                       array<String^>^ stringArray = gcnew array<String^>( 4 );\r
-\r
-                       stringArray[0] = converter->ConvertToString( context, culture, color->Alpha );\r
-                       stringArray[1] = converter->ConvertToString( context, culture, color->Red );\r
-                       stringArray[2] = converter->ConvertToString( context, culture, color->Green );\r
-                       stringArray[3] = converter->ConvertToString( context, culture, color->Blue );\r
-\r
-                       return String::Join( separator, stringArray );\r
-               }\r
-               else if( destinationType == InstanceDescriptor::typeid && color != nullptr )\r
-               {\r
-                       ConstructorInfo^ info = (Color4::typeid)->GetConstructor( gcnew array<Type^> { float::typeid, float::typeid, float::typeid, float::typeid } );\r
-                       if( info != nullptr )\r
-                               return gcnew InstanceDescriptor( info, gcnew array<Object^> { color->Alpha, color->Red, color->Green, color->Blue } );\r
-               }\r
-\r
-               return ExpandableObjectConverter::ConvertTo(context, culture, value, destinationType);\r
-       }\r
-\r
-       Object^ Color4Converter::ConvertFrom(ITypeDescriptorContext^ context, CultureInfo^ culture, Object^ value)\r
-       {\r
-               if( culture == nullptr )\r
-                       culture = CultureInfo::CurrentCulture;\r
-\r
-               String^ string = dynamic_cast<String^>( value );\r
-\r
-               if( string != nullptr )\r
-               {\r
-                       string = string->Trim();\r
-                       TypeConverter^ floatConverter = TypeDescriptor::GetConverter(float::typeid);\r
-                       array<String^>^ stringArray = string->Split( culture->TextInfo->ListSeparator[0] );\r
-\r
-                       if( stringArray->Length == 1 )\r
-                       {\r
-                               int number = 0;\r
-                               if( int::TryParse( string, number ) )\r
-                                       return gcnew Color4( number );\r
-\r
-                               TypeConverter^ colorConverter = TypeDescriptor::GetConverter(Color::typeid);\r
-                               return gcnew Color4( safe_cast<Color>( colorConverter->ConvertFromString( context, culture, string ) ) );\r
-                       }\r
-                       else if( stringArray->Length == 3 )\r
-                       {\r
-                               int red;\r
-                               int green;\r
-                               int blue;\r
-                               if( int::TryParse( stringArray[0], red ) && int::TryParse( stringArray[1], green ) && int::TryParse( stringArray[2], blue ) )\r
-                                       return gcnew Color4( Color::FromArgb( red, green, blue ) );\r
-\r
-                               float r = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[0] ) );\r
-                               float g = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[1] ) );\r
-                               float b = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[2] ) );\r
-\r
-                               return gcnew Color4( r, g, b );\r
-                       }\r
-                       else if( stringArray->Length == 4 )\r
-                       {\r
-                               int red;\r
-                               int green;\r
-                               int blue;\r
-                               int alpha;\r
-                               if( int::TryParse( stringArray[0], alpha ) && int::TryParse( stringArray[1], red ) && int::TryParse( stringArray[2], green ) && int::TryParse( stringArray[3], blue ) )\r
-                                       return gcnew Color4( Color::FromArgb( alpha, red, green, blue ) );\r
-\r
-                               float a = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[0] ) );\r
-                               float r = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[1] ) );\r
-                               float g = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[2] ) );\r
-                               float b = safe_cast<float>( floatConverter->ConvertFromString( context, culture, stringArray[3] ) );\r
-\r
-                               return gcnew Color4( a, r, g, b );\r
-                       }\r
-                       else\r
-                               throw gcnew ArgumentException("Invalid color format.");\r
-               }\r
-\r
-               return ExpandableObjectConverter::ConvertFrom(context, culture, value);\r
-       }\r
-\r
-       bool Color4Converter::GetCreateInstanceSupported(ITypeDescriptorContext^ context)\r
-       {\r
-               SLIMDX_UNREFERENCED_PARAMETER(context);\r
-\r
-               return true;\r
-       }\r
-\r
-       Object^ Color4Converter::CreateInstance(ITypeDescriptorContext^ context, IDictionary^ propertyValues)\r
-       {\r
-               SLIMDX_UNREFERENCED_PARAMETER(context);\r
-\r
-               if( propertyValues == nullptr )\r
-                       throw gcnew ArgumentNullException( "propertyValues" );\r
-\r
-               return gcnew Color4( safe_cast<float>( propertyValues["Alpha"] ), safe_cast<float>( propertyValues["Red"] ),\r
-                       safe_cast<float>( propertyValues["Green"] ), safe_cast<float>( propertyValues["Blue"] ) );\r
-       }\r
-\r
-       bool Color4Converter::GetPropertiesSupported(ITypeDescriptorContext^)\r
-       {\r
-               return true;\r
-       }\r
-\r
-       PropertyDescriptorCollection^ Color4Converter::GetProperties(ITypeDescriptorContext^, Object^, array<Attribute^>^)\r
-       {\r
-               return m_Properties;\r
-       }\r
-}\r
-}
\ No newline at end of file