namespace NinjaTrader.NinjaScript.Indicators
{
public class bitmapSample : Indicator
{
private object icon;
BitmapImage iconBitmapImage = new BitmapImage();
protected override void OnStateChange()
{
if (State == State.Configure)
{
Name = "bitmapSample";
IsOverlay = true;
// Set the BitmapImage's UriSource to the location of an image file
iconBitmapImage.BeginInit();
iconBitmapImage.UriSource = new Uri(NinjaTrader.Core.Globals.InstallDir + "templates/MyResources/icon.png");
iconBitmapImage.EndInit();
}
}
public override object Icon
{
get
{
try
{
// Instantiate a Grid on which to place the image
Grid myCanvas = new Grid { Height = 16, Width = 16 };
// Instantiate an Image to place on the Grid
Image image = new Image
{
Height = 16,
Width = 16,
// Height = 24, Width = 24,
Source = iconBitmapImage
};
// Add the image to the Grid
myCanvas.Children.Add(image);
icon = myCanvas;
}
catch (Exception)
{
Log("Error creating icon grid", Cbi.LogLevel.Error);
throw;
}
return icon;
}
}
}
}
Comment