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

NT7 Conversion -- pop up window in WPF, how to?

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

    NT7 Conversion -- pop up window in WPF, how to?

    Hello,

    I have an Indicator in NT7 that pops up an alert when there is a pending news event ....but am not sure how to do this in NT8....

    Here is how I get the WinForm into the compile image:in NT7

    namespace NinjaTrader.Indicator
    {

    public partial class NewsAlertForm : Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private System.ComponentModel.IContainer components = null;


    public NewsAlertForm()
    {
    InitializeComponent();
    }​​

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    (by the way, is there a way in this forum to preserve tabs on cut/paste?)

    And, then this form can be launched from an Indicator Script...

    Anyone?

    Any code examples?

    I can make a project in Visual Studio to get the base code but am not sure how to integrate it into NT8....also not sure how to use the XAML to define the Windows in NT8....???

    Thx...

    #2
    I don't want to use MessageBox for this because it is modal...

    Comment


      #3
      Hello llanqui,

      Windows forms is no longer used in NT8 so you would need to make a WPF window if you wanted to make a popup window of your own. NinjaTrader does not compile XAML so any type of windows you make will need to be done in code rather than xaml.

      You can find an example of creating a NTWindow which is a styled WPF window in the following link. The addon sample basic would be the correct way to launch a window in addition to how to make your own window class that has content.



      See line 83 for an example of the code needed to start a new instance of a window.

      See line 106 or the class AddOnFrameworkWindow for an example of making a custom window, this is the class that line 83 opens when making a new window.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thank you Jesse :-)

        Comment


          #5
          Looking at the code now....I don't want the new window to be in a Tab ... just want it to be a stand alone window...like a pop up....and escape closes the window.....

          are there examples of that?

          Thx...

          Comment


            #6
            It would be like a MessageBox but could have a bunch of text rows, and non-modal

            not to be attached to any NT Object, Command Center, NT Tab, etc...

            Comment


              #7
              Hello llanqui,

              You don't have to use tabs if you don't want to, you are in control of creating the content for the window. The sample from the help guide demonstrates all the available concepts that are possible, if you don't want to use part of that just don't include that. A windows content is set by setting its Content property. In that sample the content is the tab control, if you wanted to make something else you need to design the controls you wanted and then assign that to the windows Content.


              JesseNinjaTrader Customer Service

              Comment


                #8
                Ok, thank you.

                Comment


                  #9
                  Hello llanqui,

                  One other item is that you can still reference the code in the AddOnFrameworkTab class which is parsing the xaml file. If you wanted to design an interface using xaml instead of C# you can see how the tabs Content is set by parsing xaml from file and setting it as the content. You can do the same process to generate the Content in the window class without using the tab class.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Ok, good, because I'll probably use Visual Studio to set up the UI. Thx

                    Comment


                      #11
                      Actually I would much prefer to make the pop up window with C# code and not XAML, but if I do a web search, all the examples are in XAML....

                      It is only a windows with a text box, nothing more...

                      Comment


                        #12
                        well, it is really this simple...works well...only a few lines of code

                        var window = new Window ();
                        window.Title = "News Alert";
                        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        window.ResizeMode = ResizeMode.CanResize;
                        window.SizeToContent = SizeToContent.WidthAndHeight;

                        var stackPanel = new StackPanel { Orientation = Orientation.Vertical };

                        TextBox textBox = new TextBox();

                        textBox.FontSize = 16;
                        textBox.Margin = new Thickness (30);
                        textBox.FontFamily = new FontFamily("Arial");
                        // textBox.FontWeight = FontWeights.Bold;

                        textBox.Text = MultiAlertText;

                        stackPanel.Children.Add(textBox);
                        window.Content = stackPanel;

                        window.Show();​

                        Comment


                          #13
                          llanqui You may want to consider using an NTWindow (NinjaTrader.Gui.Tools.NTWindow). It will be styled the same as other NT windows, and can be used in much the same way. There are a few differences worthy of note, including that the NTWindow uses .Caption instead of .Title. Perhaps try it to see if it works as you want? The AddOnFramework example contains useful representative usage.

                          Thanks.
                          Multi-Dimensional Managed Trading
                          jeronymite
                          NinjaTrader Ecosystem Vendor - Mizpah Software

                          Comment


                            #14
                            this is only for a pup up news alert....and is very simple, just what I need...I'm still on a learning curve, porting to NT8, and need to use my time efficiently to get the application working at the base level...later can come the "nicer" features...thx

                            will add a feature to close the windows with ESC...then this one is finished

                            I like that it resizes itself to the content, I don't need the NT8 skins...

                            Comment


                              #15
                              Originally posted by llanqui View Post
                              well, it is really this simple...works well...only a few lines of code

                              var window = new Window ();
                              window.Title = "News Alert";
                              window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                              window.ResizeMode = ResizeMode.CanResize;
                              window.SizeToContent = SizeToContent.WidthAndHeight;

                              var stackPanel = new StackPanel { Orientation = Orientation.Vertical };

                              TextBox textBox = new TextBox();

                              textBox.FontSize = 16;
                              textBox.Margin = new Thickness (30);
                              textBox.FontFamily = new FontFamily("Arial");
                              // textBox.FontWeight = FontWeights.Bold;

                              textBox.Text = MultiAlertText;

                              stackPanel.Children.Add(textBox);
                              window.Content = stackPanel;

                              window.Show();​
                              IIanqui,

                              Thanks for those code snipets.

                              Please, could you post a working and complete code snipets to show which section of the NT8 indicator (i.e State.Configure, State.DataLoaded, OnBarUpdate()) these codes should be placed.

                              omololu

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by PhillT, Today, 02:16 PM
                              2 responses
                              6 views
                              0 likes
                              Last Post PhillT
                              by PhillT
                               
                              Started by Kaledus, Today, 01:29 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Yesterday, 09:08 AM
                              14 responses
                              47 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by gentlebenthebear, Today, 01:30 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gentlebenthebear  
                              Started by PaulMohn, Today, 12:36 PM
                              2 responses
                              17 views
                              0 likes
                              Last Post PaulMohn  
                              Working...
                              X