IXRTranslateTransform (Windows Embedded CE 6.0)

1/6/2010

This class translates the location of an object in the two-dimensional x,y coordinate system.

Syntax

class IXRTranslateTransform : public IXRTransform

Methods

Method Description

IXRTranslateTransform::GetX

Retrieves the distance to translate along the x-axis.

IXRTranslateTransform::GetY

Retrieves the distance to translate along the y-axis.

IXRTranslateTransform::SetX

Sets the distance to translate along the x-axis.

IXRTranslateTransform::SetY

Sets the distance to translate along the y-axis.

Remarks

You can offset the local origin point (0,0) for a UI element on an IXRCanvas container object by setting the attached properties Canvas.Left and Canvas.Top by calling IXRDependencyObject::SetAttachedProperty(const WCHAR*, UINT). However, this is not considered a transformation; the UI object keeps its own local origin point for transformation purposes.

You can apply a group of multiple transformations, which can also include an IXRTranslateTransform, to a UI object by using an IXRTransformGroup object. You can create custom transformations by using IXRMatrixTransform.

IXRTranslateTransform defines a translation aligned along the x-axis and y-axis. The x-coordinate of an IXRTranslateTransform indicates where the x origin point shifts to, and the y-coordinate indicates where the y origin point shifts to.

To apply a location translation for a UI object, pass this object into IXRUIElement::SetRenderTransform.

You can use transformations to alter how text is displayed in your application to create a decorative effect. For example, you can create an additional IXRTextBlock object that shadows the primary IXRTextBlock and is displayed at a slight offset to create a drop shadow effect.

You can also define a location translation 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 element in the source XAML for your application, see this Microsoft Web site.

Example

The following code example creates two IXRRectangle objects of equal proportion, and then applies a translation transformation to one of them to produce a shadow effect.

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 CreateShadowedRectangle(IXRApplication* pApplication, IXRCanvas* pCanvas)
{
  // Create a rectangle, a shadow rectangle, and a transformation object
  IXRRectangle* pPrimaryRect;
  IXRRectangle* pShadowRect;
  IXRTranslateTransform* pShadowTransform;

  pApplication->CreateObject(IID_IXRRectangle, &pPrimaryRect);
  pApplication->CreateObject(IID_IXRRectangle, &pShadowRect);
  pApplication->CreateObject(IID_IXRTranslateTransform, &pShadowTransform);

  float radiusX = 5;
  float radiusY = 5;
  float offsetX = 2;
  float offsetY = 2;

  pPrimaryRect->SetRadiusX(radiusX);
  pPrimaryRect->SetRadiusY(radiusY);

  pShadowRect->SetRadiusX(radiusX);
  pShadowRect->SetRadiusY(radiusY);

  pShadowTransform->SetX(offsetX);
  pShadowTransform->SetY(offsetY);

  // Apply the translate transformation to the shadow rectangle
  pShadowRect->SetRenderTransform(&pShadowTransform);

  IXRUIElementChildren* pElementChildren;
  UINT* indexPrimary;
  UINT* indexShadow;

  // Add the two rectangles to a canvas that is in the visual tree
  pCanvas.GetChildren(&pElementChildren);
  pElementChildren.Add(&pPrimaryRect, &indexPrimary);
  pElementChildren.Add(&pShadowRect, &indexShadow);
}

To run this code example, you must already have created an IXRApplication instance, parsed the XAML and generated an object tree, and obtained the visual root. An IXRCanvas object must already exist in the visual tree.

Inheritance Hierarchy

IXRDependencyObject

    IXRGeneralTransform

        IXRTransform

            IXRTranslateTransform

.NET Framework Equivalent

System.Windows.Media.TranslateTransform

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