IXRPath (Windows Embedded CE 6.0)
1/6/2010
This class draws a series of connected lines and curves. The line and curve dimensions are declared through the IXRPath::SetData method, and can be specified either with an IXRPath-specific mini-language, or with an object model.
Syntax
class IXRPath : public IXRShape
Methods
Method | Description |
---|---|
Retrieves a geometry object that specifies the shape to be drawn with this path. |
|
Sets a geometry object that specifies the shape to be drawn with this path. |
Remarks
Fundamentally, a path is a shape and it inherits from IXRShape. However, IXRPath can be used to create much more complex two-dimensional graphics than the other shapes can create. The IXRPath object can draw closed or open shapes, lines, and curves. For a description of the shapes that the IXRPath object supports, see the IXRPath::SetData method.
IXRPath supports two parallel techniques for declaring its contents: as an object model that uses discrete geometries declared in markup or code, or as mini-language declared in markup. The geometry object model can use the IXRGeometryGroup object as data in order to specify a composite of multiple geometries. The mini-language is comparable to a pathing-language output used in some graphics tools.
You can also define a path element in 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 Path Class on MSDN. For more information about how to use the mini-language definition format for a path element in XAML markup, see Path Markup Syntax on MSDN.
Note
For best performance avoid explicitly setting the Width and Height of an IXRPath. Calling the inherited methods IXRFrameworkElement::SetWidth or IXRFrameworkElement::SetHeight will result in additional stretching, which slows performance. Instead, you should rely on the explicitly set coordinates of the IXRPath object and its contained data to control its shape and position. In effect, the IXRPath object will have a natural height/width, although those values are not reported to the object model. For more information, see IXRShape::SetStretch.
Example
The following code example uses an IXRPath to create an ellipse object by using predefined Brush objects and ellipse geometry, and then adds it to an IXRCanvas that is currently in the visual tree. If the window is already displayed on-screen, the path will be drawn automatically when Silverlight detects the change and refreshes the visual-host window. It uses smart pointers and method overloads that help ensure type-safety. For more information, see Type-Safety in Silverlight for Windows Embedded.
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 <windows.h>
#include <XamlRuntime.h>
#include <XRPtr.h>
void CreatePathOnCanvas(IXRApplication* pApplication, IXRCanvas* pCanvas,
IXRSolidColorBrush* myGoldBrush, IXRSolidColorBrush* myBlackBrush)
{
XRPoint myEllipsePoint;
myEllipsePoint.x = 50;
myEllipsePoint.y = 50;
float RadX = 50;
float RadY = 50;
float width = 1;
// Note: This code uses smart pointers to ensure that all interfaces are released
// (see Type-Safety in Silverlight for Windows Embedded topic)
IXREllipseGeometryPtr myEllipseGeometry;
IXRPathPtr circularPath;
IXRUIElementCollectionPtr pCanvasChildren;
//
// Create an ellipse geometry for the path object.
//
// Note: CreateObject is a Helper Template Overload Method
// (see Type-Safety in Silverlight for Windows Embedded topic)
pApplication->CreateObject(IID_IXREllipseGeometry, &myEllipseGeometry);
myEllipseGeometry->SetCenter(&myEllipsePoint);
myEllipseGeometry->SetRadiusX(RadX);
myEllipseGeometry->SetRadiusY(RadY);
//
// Create a path object
//
pApplication->CreateObject(IID_IXRPath, &circularPath);
circularPath->SetFill(myGoldBrush);
circularPath->SetStroke(myBlackBrush);
circularPath->SetStrokeThickness(width);
circularPath->SetData(myEllipseGeometry);
//
// Add the path object to the collection of child elements for an
// existing canvas object
//
int index;
pCanvas->GetChildren(&pCanvasChildren);
pCanvasChildren->Add(circularPath, &index);
}
The previous code example assumes that two IXRSolidColorBrush objects have already been created that each represents the colors gold and black, respectively. For more information on the objects used in this code example, see IXRApplication, IXRSolidColorBrush, IXRCanvas, XRPtr<Interface>, IXREllipseGeometry, and IXRApplication::CreateObject(IID,Object). The following illustration depicts the visual result of the previous code example:
Inheritance Hierarchy
IXRPath
.NET Framework Equivalent
System.Windows.Shapes.Path
Requirements
Header | XamlRuntime.h |
sysgen | SYSGEN_XAML_RUNTIME |
Windows Embedded CE | Windows Embedded CE 6.0 R3 |
See Also
Reference
Classes for UI Element Management