• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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:
        https://ninjatrader.com/support/help...stribution.htm
        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 Sadat, Today, 09:09 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_JoshG  
        Started by login_dejavu, Today, 07:57 AM
        4 responses
        17 views
        0 likes
        Last Post login_dejavu  
        Started by Lender, Yesterday, 05:15 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by rcmcd, Today, 07:52 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by rcmcd, Today, 07:49 AM
        2 responses
        13 views
        0 likes
        Last Post rcmcd
        by rcmcd
         
        Working...
        X