@@ -80,6 +80,7 @@ static CodeComHelper()
8080 supportedAttachedProperties . Add ( "VirtualizedCacheMaxRows" ) ;
8181 supportedAttachedProperties . Add ( "VirtualizedCacheMaxItems" ) ;
8282 supportedAttachedProperties . Add ( "EnableVirtualization" ) ;
83+ supportedAttachedProperties . Add ( "ColorOverlay" ) ;
8384
8485 ignoredProperties . Add ( "NameScope" ) ;
8586 ignoredProperties . Add ( "BaseUri" ) ;
@@ -474,7 +475,7 @@ public static CodeExpression GenerateBrushInstance(CodeMemberMethod method, Brus
474475 return brushExpr ;
475476 }
476477
477- ImageBrush image = brush as ImageBrush ;
478+ System . Windows . Media . ImageBrush image = brush as System . Windows . Media . ImageBrush ;
478479 if ( image != null )
479480 {
480481 brushExpr = GenerateImageBrush ( method , variableName , brushTypeName , brushExpr , image ) ;
@@ -486,7 +487,7 @@ public static CodeExpression GenerateBrushInstance(CodeMemberMethod method, Brus
486487 return brushExpr ;
487488 }
488489
489- private static CodeExpression GenerateImageBrush ( CodeMemberMethod method , string variableName , string brushTypeName , CodeExpression brushExpr , ImageBrush image )
490+ private static CodeExpression GenerateImageBrush ( CodeMemberMethod method , string variableName , string brushTypeName , CodeExpression brushExpr , System . Windows . Media . ImageBrush image )
490491 {
491492 CodeVariableDeclarationStatement variable = new CodeVariableDeclarationStatement (
492493 "ImageBrush" , variableName ,
@@ -497,18 +498,18 @@ private static CodeExpression GenerateImageBrush(CodeMemberMethod method, string
497498 BitmapImage bitmap = image . ImageSource as BitmapImage ;
498499 if ( bitmap != null )
499500 {
500- GenerateBitmapImageField ( method , brushExpr , image , bitmap . UriSource , variableName + "_bm" , ImageBrush . ImageSourceProperty ) ;
501+ GenerateBitmapImageField ( method , brushExpr , image , bitmap . UriSource , variableName + "_bm" , System . Windows . Media . ImageBrush . ImageSourceProperty ) ;
501502 }
502503
503- if ( BindingOperations . IsDataBound ( image , ImageBrush . ImageSourceProperty ) )
504+ if ( BindingOperations . IsDataBound ( image , System . Windows . Media . ImageBrush . ImageSourceProperty ) )
504505 {
505506 CodeComHelper . GenerateBindings ( method , brushExpr , image , variableName ) ;
506507 }
507508
508- GenerateEnumField < Stretch > ( method , brushExpr , image , ImageBrush . StretchProperty ) ;
509- GenerateEnumField < BrushMappingMode > ( method , brushExpr , image , ImageBrush . ViewboxUnitsProperty ) ;
509+ GenerateEnumField < Stretch > ( method , brushExpr , image , System . Windows . Media . ImageBrush . StretchProperty ) ;
510+ GenerateEnumField < BrushMappingMode > ( method , brushExpr , image , System . Windows . Media . ImageBrush . ViewboxUnitsProperty ) ;
510511 GenerateFieldDoubleToFloat ( method , brushExpr , image , Brush . OpacityProperty ) ;
511- GenerateRect ( method , brushExpr , image , ImageBrush . ViewboxProperty ) ;
512+ GenerateRect ( method , brushExpr , image , System . Windows . Media . ImageBrush . ViewboxProperty ) ;
512513
513514 GenerateAttachedProperties ( method , brushExpr , image ) ;
514515
@@ -835,7 +836,7 @@ private static string CreatePathFromParameters(PropertyPath propertyPath)
835836 {
836837 continue ;
837838 }
838-
839+
839840 path = path . Replace ( string . Format ( "({0})" , i ) , parameter . Name ) ;
840841 }
841842
@@ -963,6 +964,19 @@ public static void GenerateAttachedProperties(CodeMemberMethod method, CodeExpre
963964 new CodeFieldReferenceExpression ( enumType , value . ToString ( ) ) ) ;
964965 method . Statements . Add ( setValue ) ;
965966 }
967+ else if ( value is Color )
968+ {
969+ Color valueColor = ( Color ) value ;
970+
971+ CodeMethodInvokeExpression setValue = new CodeMethodInvokeExpression (
972+ typeReference , "Set" + property . Name , target ,
973+ new CodeObjectCreateExpression ( "ColorW" ,
974+ new CodePrimitiveExpression ( valueColor . R ) ,
975+ new CodePrimitiveExpression ( valueColor . G ) ,
976+ new CodePrimitiveExpression ( valueColor . B ) ,
977+ new CodePrimitiveExpression ( valueColor . A ) ) ) ;
978+ method . Statements . Add ( setValue ) ;
979+ }
966980 else
967981 {
968982 if ( value is double )
@@ -1012,7 +1026,7 @@ public static void GenerateSoundSources(CodeMemberMethod method, SoundSourceColl
10121026 public static CodeSnippetExpression GenerateSoundSource ( CodeMemberMethod method , SoundSource sound )
10131027 {
10141028 CodeSnippetExpression expression = new CodeSnippetExpression (
1015- string . Format ( "new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \" {1}\" , Volume = {2}f }}" , sound . SoundType , sound . SoundAsset , sound . Volume ) ) ;
1029+ string . Format ( "new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \" {1}\" , Volume = {2}f }}" , sound . SoundType , sound . SoundAsset , sound . Volume ) ) ;
10161030
10171031 method . Statements . Add ( new CodeMethodInvokeExpression (
10181032 new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ( "SoundManager" ) , "Instance" ) ,
@@ -1070,7 +1084,7 @@ public static void GenerateTemplateStyleField(CodeTypeDeclaration parentClass, C
10701084 CodeExpression valueExpr = GetValueExpression ( parentClass , method , value , name ) ;
10711085 method . Statements . Add ( new CodeAssignStatement ( new CodeFieldReferenceExpression ( target , property . Name ) , valueExpr ) ) ;
10721086 }
1073- }
1087+ }
10741088
10751089 /// <summary>
10761090 /// Gets the resource key expression.
@@ -1251,6 +1265,7 @@ public static void GenerateSetter(CodeTypeDeclaration parentClass, CodeMemberMet
12511265 {
12521266 setterValue = Convert . ToSingle ( setterValue ) ; // TODO maybe there is better solution for this
12531267 }
1268+
12541269 CodeExpression setterValueExpr = GetValueExpression ( parentClass , method , setterValue , setterVarName ) ;
12551270 if ( setterValueExpr != null )
12561271 {
0 commit comments