Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Custom share service: how to add icon

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

    Custom share service: how to add icon

    Hi,


    The following code shows an icon in the share services (e.g. Chart -> Share -> Price):

    Code:
    public override object Icon
            {
                get
                {
                    return System.Windows.Application.Current.TryFindResource("ShareIconEmail");
                }
            }

    But this one does not show an icon:

    Code:
    public override object Icon
            {         
              get 
              {
                //use a unicode character as our string which will render an arrow
                string uniCodeArrow = "\u279A";           
                return uniCodeArrow; 
              }   
            }

    How can I show a custom/unicode icon?



    Regards,

    #2
    Hello Halmix,

    Thank you for the post.

    The suggested ways to make icons would be either of the approaches listed in the help guide here: https://ninjatrader.com/support/help...=object%2BIcon

    The example that demonstrates and Image in a Grid which may be the best example to look at for this concept. Replacing the Image control for a TextBlock control in the sample could be used to display a text/Unicode icon. Because you are trying to display Unicode Text you would need a control that supports Text along with a font that supports Unicode characters.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply. But in "https://ninjatrader.com/support/helpGuides/nt8/en-us/?using_images_and_geometry_with_custom_icons.htm" it is stated that unicode icons can be used. But the example code does not show up the icon.


      • Also, how can I use a custom icon file (like a .png)?
      • Can I just copy the icon to the "C:\Users\username\Documents\NinjaTrader 8\bin\Custom\ShareServices" directory?
      • Will the icon be packages automatically when I create a zip file?

      Comment


        #4
        Hello Halmix,

        Thank you for the reply.

        Yes, Unicode characters can be used, but there is a note right after that statement in the help guide: if they exist in the icon pack for the font family used in NinjaTrader.
        An example would be using the Icons class:

        Code:
        public override object Icon
        {
        	get
        	{   
        		return Icons.LeftArrow;
        	}
        }
        Only specific Unicode characters can be used for the specific NinjaTrader icons which are part of the NinjaTrader font. For any Unicode like the one you provided, generally what I had described would be the approach to use as you can control the font.

        Code:
        public override object Icon
        {
        	get
        	{
        		System.Windows.Controls.Grid myCanvas = new System.Windows.Controls.Grid { Height = 16, Width = 16 };
        		System.Windows.Controls.TextBlock b = new System.Windows.Controls.TextBlock();
        		b.Text = "\u279A";
        		myCanvas.Children.Add(b);
        		return myCanvas;
        	}
        }

        Also, how can I use a custom icon file (like a .png)?
        The first example on the page you linked shows how to use an image.

        Can I just copy the icon to the "C:\Users\username\Documents\NinjaTrader 8\bin\Custom\ShareServices" directory?
        I would suggest to follow the sample and use the Globals object and its paths. From that you can combine to make a sub path you want. I wouldn't suggest putting random files like images inside of your script folders, but likely the user data directory root or:
        Code:
        NinjaTrader.Core.Globals.UserDataDir
        Will the icon be packages automatically when I create a zip file?
        No, you can follow the distribution guide here if you plan to export this for release:

        Specifically: https://ninjatrader.com/support/help...lyzerTemplates

        The manual step of adding your images to the zip would be needed so they can later be extracted on the end users PC into the folder structure you create in the zip. Because the Templates folder is used, going back to your previous question you likely would want to combine the UserDataDir and create a path to Templates and your subfolder.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        105 views
        0 likes
        Last Post martin70  
        Started by TraderBCL, Today, 04:38 AM
        0 responses
        4 views
        0 likes
        Last Post TraderBCL  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        470 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X