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

Add draw objects icon to a button

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

    Add draw objects icon to a button

    I have attached an image of a toolbars in the left side of the chart.

    I used this code:

    btnRuler = new System.Windows.Controls.Button();
    btnRuler.ToolTip = "Ruler";
    btnRuler.Background = Brushes.Transparent;
    btnRuler.Width = 205;
    btnRuler.Height = 30;
    btnRuler.Content = NinjaTrader.Gui.Tools.Icons.DrawRuler; //"Ruler";
    btnRuler.Click += btnRuler_Click;
    System.Windows.Controls.Grid.SetRow(btnRuler, 1);
    VerticalStackPanel.Children.Add(btnRuler);

    Now as you can see in the image the first button which is the ruler button it only draws a little box image. Now my problem is how can I add the draw objects icon successfully? I want those buttons in the image to have an draw objects icon only not a text. I will appreciate someone that could help. Thanks.
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I wanted to check, are you able to import the attached sample and see the correct icon is displayed in the Toolbar? I noted you are using a StackPanel, this could potentially be the cause. If the Toolbar icon works where your current implementation does not, could you provide an export of your script as you have it now?

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

    Comment


      #3
      I would love to send you the cs file just let me know where can I email it.

      Comment


        #4
        Hello,

        Thank you for the reply.

        After further review, a sample may not be needed. Can you try just changing the FontFamily the button is using? It is likely the base Button style does not have a specific Font set where the Toolbar button does.

        Code:
        btnRuler.FontFamily = Application.Current.TryFindResource("IconsFamily") as FontFamily
        I see this allows me to use the NT icons which are a Font, the string used from Tools.Icons then seem to work in a standard button for me.

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

        Comment


          #5
          It works :-)

          Comment


            #6
            RemoveAllDrawingObjects Icon/Button doesn't delete the drawn objects even though I have put this code:

            private void btnmnuRemoveAllDrawingObjects_Click(object sender, EventArgs e)
            {
            SendKeys.SendWait("^{Delete}");
            }

            but if it's in the main menu on the top of the chart it will work, something wrong when it's in the stack panel in the left grid. Can you help me out on this please.

            Comment


              #7
              Hello luxurious_04,

              As long as you are hitting that line of code to simulate a press of the Ctrl + Delete keys, and you have the hot key configured to Remove All Drawing Objects, you should be able to use the button press to trigger the Remove All Draw Objects prompt.

              I have attached an example of ours that will trigger this from buttons on a Stack Panel. The Remove Draw Objects hotkey will need to be assigned to Ctrl + Delete.

              If there is anything else we can do to assist, please let us know.
              Attached Files
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Today, 10:35 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by WeyldFalcon, 12-10-2020, 06:48 PM
              14 responses
              1,428 views
              0 likes
              Last Post Handclap0241  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Working...
              X