Everything displays normally in the chart bar type selection list and in the toolbar after changing to my style BUT my icon is missing from the toolbar when Ninja Trader starts -- it shows a blank space.
EXPECTED: You should see the icon between "4 Minute" and to the pencil, not just when selecting but on start-up too.
I saw samples with multiple ways to load the icon and I even tried making it static so that it would always be there but that doesn't seem to fix this.
Some code...
namespace NinjaTrader.NinjaScript.ChartStyles { public class MyCustomStyle : ChartStyle { private BitmapImage iconBitmapImage = null ; private object icon = null; protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "* Custom *"; ChartStyleType = (ChartStyleType)99; } else if (State == State.Configure) { .............. // Set the BitmapImage's UriSource to the location o f an image file - see https://ninjatrader.com/support/helpGuides/nt8/?cs0103.htm try { if (icon == null && iconBitmap Image == null) { string fname = NinjaTrader.Core.Globals.UserDataDir + "bin\\Custom\\MyMedia\\icon_bk16x16.png"; if (!File.Exists(fname)) { icon = Gui.Tools.Icons.ChartEquivolume; } else { iconBitmapImage = new BitmapImage(); iconBitmapImage.BeginI nit(); iconBitmapImage.UriSou rce = new Uri(fname); iconBitmapImage.EndIni t(); } } } catch (Exception exIcon) { Print("☰☰☰☰ ERROR - exception.\n" + exIcon.ToString()); icon = Gui.Tools.Icons.ChartEq uivolume; } } } ........ public override object Icon { get { if (icon != null) return icon; 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 ex) { Print("☰☰☰☰ ERROR - exception getting icon canvas, reverting to normal icon.\n" + ex.ToString()); icon = Gui.Tools.Icons.ChartEq uivolume; } return icon; } }
* Am I doing something wrong? Or do I need to hook something else up?
* Is there a problem with using a PNG image as my icon?
I can find no examples where someone used their own icon.
Comment