IXRSolidColorBrush (Windows Embedded CE 6.0)

1/6/2010

This class paints an area with a solid color.

Syntax

class IXRSolidColorBrush : public IXRBrush

Parameters

Method Description

IXRSolidColorBrush::GetColor

Retrieves the color of this brush.

IXRSolidColorBrush::SetColor

Sets the color of this brush.

Remarks

When you set a solid color to paint with, you can use the RGB macro or the RGBA macro to create a color value for this brush. For more information about identifying the correct BYTE values to use in the RGB or RGBA macro for red, green, and blue, see this Web site.

For guidance on creating RGB colors, color complements, and themes, see the EasyRGB.

You can animate an IXRSolidColorBrush by using either IXRColorAnimation or IXRColorAnimationUsingKeyFrames. Usually, you animate the brush by indirectly targeting a property of a target object, such as Fill or Color. To do this, set the attached property "Storyboard.TargetProperty" on an IXRColorAnimation object by using its inherited method IXRDependencyObject::SetAttachedProperty.

You can also define a solid-color brush as an attribute in Microsoft Silverlight 2 XAML. For information about the differences between XAML in Silverlight for Windows Embedded and Silverlight 2, see Differences Between Silverlight for the Web and Silverlight for Windows Embedded. For more information about how to define this brush in the source XAML for your application, see this Microsoft Web site.

Example

The following code example creates a solid color brush, uses it to fill a rectangle object, and then creates an animation storyboard that will animate the color of the brush at run-time.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include "XamlRuntime.h"

Void CreateBrushAnimation(IXRApplication* pApplication, IXRRectangle* pRect, IXRStoryboard* pStoryboard)
{
  // create a solid color brush
  IXRSolidColorBrush* myPaintBrush;
  COLORREF oldBrushColor = RGB(0,0,255);

  pApplication->CreateObject(IID_IXRSolidColorBrush, &myPaintBrush);
  myPaintBrush->SetColor(oldBrushColor);

  // paint an existing shape with that brush
  pRect->SetFill(&myPaintBrush);
  pRect->SetName(L"PaintedRectangle");

  // now create an animation that will change it to a new color when 
  // triggered
  COLORREF newBrushColor = RGB(0,0,128);
  XRTimeSpan ColoringTime = { 50000 };

  IXRColorAnimation* myColorAnimation;
  CreateObject(IID_IXRColorAnimation, &myColorAnimation);
  IXRColorAnimation->SetAttachedProperty(L"Storyboard.TargetName", L"PaintedRectangle");
  IXRColorAnimation->SetAttachedProperty(L"Storyboard.TargetProperty", L"Fill");
  IXRColorAnimation->SetTo(newBrushColor);
  IXRColorAnimation->SetBeginTime(ColoringTime);

  // add it to a storyboard's collection of animations
  IXRTimelineCollection* pChildren;
  UINT index;
  pStoryboard->GetChildren(&pChildren);
  pChildren->Add(myColorAnimation, &index);
}

To run this code example, the visual tree must already be generated, the visual tree must contain shape and storyboard elements, and IXRShape and IXRStoryboard instances must already be created. Notice that the target name of the IXRRectangle object is set in C++ code by calling the inherited method IXRDependencyObject::SetName. This named object has the target property to animate.

Inheritance Hierarchy

IXRDependencyObject

    IXRBrush

        IXRSolidColorBrush

.NET Framework Equivalent

System.Windows.Media.SolidColorBrush

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

Classes for Visual Appearance and Behavior

Other Resources

Working with Colors