Using Images and Geometry with Custom Icons
<< Click to Display Table of Contents >> Using Images and Geometry with Custom Icons |
When overriding the Icon method in a Share Service, Drawing Object, or Chart Style, you can use a variety of inputs to specify what will be displayed on the icon, including UniCode characters (if they exist in the icon pack for the font family used in NinjaTrader), custom Geometry Paths from the System.Windows.Shapes namespace, or image files. Using an image file for a custom icon can allow the flexibility of creating your icon's visuals outside of your code via image editing software. For more information about adding custom Icons, see the "Icon" page under the topics for each of the NinjaScript object types listed above.
Using an Image as an IconThe process for using an image as an icon is fairly straightforward using WPF objects, and is the same for different NinjaScript objects.
1.Instantiate a new BitmapImage object 2.Assign a Uri to the BitmapImage, pointing to an image file 3.Instantiate a Grid of the same dimensions as the icon 4.Instantiate an Image object 5.Assign the BitmapImage as the Image's Source 6.Add the Image to the Grid 7.Return the Grid by overriding the Icon property
|
Using Geometry on an IconCustom geometry Paths can be used to draw and fill custom shapes, which can then be applied directly to a Canvas returned for use in an Icon. The process for using a Path is similar to that for using an Image:
1.Instantiate a new Path object 2.Instantiate a Grid of the same dimensions as the icon 3.Define the visual properties of the Path 4.Add the Path to the Grid 5.Return the Grid by overriding the Icon property
|