• 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 gfx not (always) copied during importing addon

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

    Custom gfx not (always) copied during importing addon

    Hi Ninja

    I've made a custom drawing tool package which has a few custom gfx.
    During installation these gfx should be copied automatically into the C:\Users\[USERNAME]\Documents\NinjaTrader 8\templates folder
    Strange thing is.. this works fine when i import it on some machines.. but on other pcs, the tools itself get installed but the gfx are not copied..

    Here's how my addon-zip file looks internally. As you can see i added a templates folder

    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	45.3 KB
ID:	1040108

    And within the templates folder is a subfolder called TDU in which all the gfx are placed.
    After zipping, i can import the addon fine in ninja and the drawing tool gets installed fine.
    However the gfx in the templates\TDU dont get copied into C:\Users\[USERNAME]\Documents\NinjaTrader 8\templates\TDU


    Click image for larger version

Name:	Capture2.JPG
Views:	1
Size:	73.9 KB
ID:	1040109

    #2
    Hello Erwin Beckers,

    Thanks for your inquiry.

    When I test on my end with NinjaTrader 8 Release 16.3, I'm able to place png files in a "templates" folder of the export as well as within a sub folder of the templates folder and I am not encountering any issue.

    Could you confirm if you are hitting the issue with the test package I have attached and you are on the latest version of NinjaTrader 8?

    Is there any other detail that you could provide on the machines where this does not work? If we can identify some specific differences that create this behavior we could use the information to report the issue for a fix.

    I look forward to being of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Yes you zip file works fine. But mine doesnt,, In my case the gfx files are not copied , and my folder structure inside the zip looks the same as yours

      Could it be that it fails since my package

      1) is a drawing tool, not an indicator
      2) the gfx is used for the Icon.. (see below) and not for drawing something on the chart


      Code:
         public abstract class MeasuredMove: DrawingTool
          {
              protected BitmapImage _iconBitmapImage = new BitmapImage();
              protected override void OnStateChange()
              {
                  ...
                  if (State == State.Configure)
                  {
                      _iconBitmapImage.BeginInit();
                      var folder = Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "templates");
                      folder = Path.Combine(folder, "TDU");
                      folder = Path.Combine(folder, "wolf.png");
                      _iconBitmapImage.UriSource = new Uri(folder);
                      _iconBitmapImage.EndInit();
                 }
            }
      
            public override object Icon
              {
                  get
                  {
                      // Instantiate a Grid on which to place the image
                      var myCanvas = new Grid { Height = 16, Width = 16 };
      
                      // Instantiate an Image to place on the Grid
                      var image = new Image
                      {
                          Height = 16,
                          Width = 16,
                          Source = _iconBitmapImage
                      };
      
                      // Add the image to the Grid
                      myCanvas.Children.Add(image);
      
                      return myCanvas;
                  }
              }

      Comment


        #4
        Hello Erwin,

        I would not expect how the resource is used in code to effect how that resource is imported when it is added in the templates folder of an export.

        When I test using a blank drawing tool that does not use the file at all and then add the resources to an export of that drawing tool, I can import both png files from "templates" and the subfolder.

        There still seems to be some unknown which is causing the difference in behavior for your export.

        If you create a blank drawing tool similar to the dummy scripts attached, are you able to import both resource files for both source code exports and compiled assembly exports?

        If you swap resources between using the SampleDrawBitmap.png and wolf.png does your script or the test script import differently?

        I look forward to being of further assistance.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Finally figured it out.. Ninja locks the icon files on disk when the drawingtool is loaded.
          This means that if you want to install a newer version of the drawing tool then the installation fails since it cannot overwrite the icons.

          To fix this i had to rewrite the part which loads the icon from disk.
          Basicly it now loads the icon from a stream instead of directly from the file. That way Ninjatrader cannot lock the file anymore;

          Code:
                  public override object Icon
                  {
                      get
                      {
                          var grid= new Grid { Height = 16, Width = 16 };
                          var image = new Image
                          {
                              Height = 16,
                              Width = 16,
                              Source = GetImageSource("myicon.png")
                          };
          
                          grid.Children.Add(image);
                          return grid;
                      }
                  }
          
                  private BitmapImage GetImageSource(string fileName)
                  {
                      var folder = Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "templates");
                      folder = Path.Combine(folder, "mysubfolder");
                      folder = Path.Combine(folder, fileName);
                      if (!File.Exists(folder)) return null;
          
                      using (var stream = File.OpenRead(folder))
                      {
                          var bitmap = new BitmapImage();
                          bitmap.BeginInit();
                          bitmap.CacheOption = BitmapCacheOption.OnLoad;
                          bitmap.StreamSource = stream;
                          bitmap.EndInit();
                          bitmap.Freeze();
          
                          return bitmap;
                      }
                  }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ajsdnyyrr1234DDf, Today, 09:39 AM
          0 responses
          5 views
          0 likes
          Last Post ajsdnyyrr1234DDf  
          Started by afoschini, Today, 09:18 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by rexsole, Today, 08:02 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by johnnybegoode, Yesterday, 07:06 PM
          1 response
          18 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by johnnybegoode, Yesterday, 10:06 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X