Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Images and Geometry with Custom Icons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Images and Geometry with Custom Icons

    Sry, I do not how to implement the Using Images and Geometry with Custom Icons from Ninjatrader there.

    https://ninjatrader.com/support/help...orhandling.htm


    Code:
    // Add the following Using statements
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    
    BitmapImage iconBitmapImage = new BitmapImage();
    
    protected override void OnStateChange()
    {
      if (State == State.Configure)
      {
        // Set the BitmapImage's UriSource to the location of an image file
          iconBitmapImage.BeginInit();
          iconBitmapImage.UriSource = new Uri(NinjaTrader. Core.Globals.InstallDir + "icon.jpg");
          iconBitmapImage.EndInit();
      }
    }
    
    // Override Icon (read-only) to return the custom Grid and Image
    public override object Icon
    {
      get
      {
          // 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,
              Source = iconBitmapImage
          };
    
          // Add the image to the Grid
          myCanvas.Children.Add(image);
    
          return myCanvas;
      }
    }
    Can i know what is the result of this one ??
    **Is it I can have a display Icon at the Control Center there??

    And also, where i should implement this ?? (Adds On, Indicator , strategy ??)

    #2
    Hello soon123,

    Thanks for your post.

    The snippet provided would load a jpg file to make a 16x16 icon.

    This sort of code would be used in a BarsType, ChartStyle, DrawingTool or Share Service.

    It looks like you linked RealtimeErrorHandling instead of the associated documentation page for creating icons. I have linked it below.

    https://ninjatrader.com/support/help...stom_icons.htm

    For adding icons to buttons, (I.E. an AddOn button added to the Control Center) this would be more of a WPF concept. My colleague Chelsea demonstrates creating an arrow with Geometry that he adds to his added WPF menu items which may give some further direction there.

    https://ninjatrader.com/support/foru...10#post1124507

    You may also wish to reference external resources on adding images to buttons with WPF. I have linked a publicly available resource below.

    https://stackoverflow.com/questions/...n-a-wpf-button

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by b16_aln, Today, 01:48 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by fernlicht, Today, 02:38 AM
    0 responses
    6 views
    0 likes
    Last Post fernlicht  
    Started by james272, Yesterday, 10:50 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by vaz21102, Yesterday, 09:22 PM
    2 responses
    10 views
    0 likes
    Last Post vaz21102  
    Started by keepsimple, 08-17-2017, 09:18 AM
    6 responses
    1,350 views
    1 like
    Last Post gubbar924  
    Working...
    X