Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code Conversion

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

    Code Conversion

    How will the following Ninja Trader 7 code will convert to Ninja Trader 8?

    private void CaptureFullScreen (NinjaTrader.Gui.Chart.ChartControl chart)
    {

    if (chart.ParentForm.WindowState == FormWindowState.Minimized)
    {
    Print ("Chart form window state must be maximized or normal to capture. Chart not saved.");
    return;
    }
    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(chart.ChartPanel.Width,
    chart.ChartPanel.Height, PixelFormat.Format16bppRgb555);

    chart.ChartPanel.DrawToBitmap(bmp, chart.ChartPanel.ClientRectangle);

    string FileName =”Test.png”;

    bmp.Save(FileName, ImageFormat.Png);
    }

    Ninja Trader 8 errors are below
    How will these errors be solved in Ninja trader 8 ? Am I required to add any assembly reference here ?


    Error 1:

    ‘ NinjaTrader.Gui.Chart.ChartControl ‘ does not contain a definition for ‘ParentForm’ and no extension method ‘ParentForm’ accepting a first argument of type ‘NinjaTrader.Gui.Chart.ChartControl’ could be found (are you missing a using directive or an assembly reference?)

    Error 2:

    ‘ NinjaTrader.Gui.Chart.ChartControl ‘ does not contain a definition for ‘ChartPanel ‘ and no extension method ‘ChartPanel’ accepting a first argument of type ‘NinjaTrader.Gui.Chart.ChartControl’ could be found (are you missing a using directive or an assembly reference?)

    #2
    Hello,

    Most of this should not port over to NT8, as there have been significant changes to the chart control coming from the switch to WPF rather than WinForms. Here are a few tips for you:

    chart.ParentForm.WindowState will now be Window.GetWindow(ChartControl.Parent).WindowState

    chart.ChartPanel.Height will now be Window.GetWindow(ChartControl.Parent).Height (similar with Width)

    I'm looking into the new implementation of chart.ChartPanel.DrawToBitmap now, and I will update this thread as soon as I have some more info.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      I've got an update for you. ChartPanel.DrawToBitmap will no longer be usable, because that was from the WinForms library. You should now be able to use RenderTarget.DrawBitmap, which is the sharpdx equivalent.

      You can find more info at the link below:

      http://sharpdx.org/documentation/api...t-drawbitmap-1
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Code Conversion

        private void CaptureFullScreen (NinjaTrader.Gui.Chart.ChartControl chart)
        {

        if (System.Windows.Window.GetWindow(chart.Parent).Win dowState == System.Windows.WindowState.Minimized)
        {
        Print ("Chart form window state must be maximized or normal to capture. Chart not saved.");
        return;
        }

        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap((int)System.Windows.Window.G etWindow(chart.Parent).Width,(int) System.Windows.Window.GetWindow(chart.Parent).Heig ht, System.Drawing.Imaging.PixelFormat.Format16bppRgb5 55);



        //chart.ChartPanel.DrawToBitmap(bmp, chart.ChartPanel.ClientRectangle);

        RenderTarget.DrawBitmap(bmp,1,BitmapInterpolationM ode.Linear);

        string FileName =”Test.png”;

        bmp.Save(FileName, ImageFormat.Png);
        }

        Here bmp is System.Drawing.Bitmap object. if we use RenderTarget.DrawBitmap , then shows the following error

        cannot convert from System.Drawing.Bitmap to SharpDX.Direct2D1.Bitmap. So how we convert this bmp object to SharpDX object...?

        or is any other method for taking screenShot for the Chart Widow..?

        Comment


          #5
          Hello,

          You will need to avoid using the WinForms version entirely (System.Drawing.Bitmap), in favor of the sharpdx version of Bitmap. You can find the documentation at the link below (this website will be useful for all sharpdx documentation).

          http://sharpdx.org/documentation/api...rect2d1-bitmap
          Dave I.NinjaTrader Product Management

          Comment


            #6
            Converting NT7 scripts to work in NT8

            I would like to encourage the implementation of some kind of "macro" routine in the NT8 Editor that would do the 90%+ changes needed to go from NT7 to NT8 scripts. Then we could focus on the "non-standard" 10% of changes that prevent compiling.

            To provide a trivial example, on the transition from NT6.5 to NT7 many indicators stopped working just because the Drawing Methods added one extra input; a simple "macro" added to the NT7 editor that would have parsed the scripts and fixed them so they would compile in NT7 would have made the transition much smoother.

            I understand that the NT7 to NT8 conversion is much more complicated, but I just find myself repeating lots of routine steps that are common to all scripts. I think many users will appreciate a "smarter editor" that offers to fix the common problems instead of just "identifying" them. Items like switching from Windows Forms to WPF might probably fall in the non-standard changes area.

            Comment


              #7
              We did look into that possibility but opted not to implement since we never would be able to catch all cases and could in some cases leave the code off in a worse state then we started. The actual percentage of code we could migrate could be as high as 100% for some users and as little as 10% depending on the type of code customers would develop. In concept having a general purpose find and replace tool is a nice idea but the development time needed for the tool and the fact that the tool would never work in all scenarios we decided development time better spent implemented longer term features and functionality.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by zstheorist, Today, 07:52 PM
              0 responses
              5 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              150 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by tkaboris, Today, 05:13 PM
              0 responses
              6 views
              0 likes
              Last Post tkaboris  
              Working...
              X