Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Making Font Dynamic

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

    Making Font Dynamic

    I am trying to allow the user to input a number that will change the font on a title that is placed on a chart. I have the following:

    #region Variables
    public int titleSize = 10;

    private Font titleFont = new Font("Arial", titleSize, FontStyle.Italic | FontStyle.Bold);

    When I do this, I get an error that reads:

    A field initializer cannot reference the non-static field, method, or property 'NinjaTrader.Indicator.myindicator.titleSize'

    Does the "private Font" allow for dynamic input from the parameters?

    Thanks

    #2
    You could use a font parameter. Check out http://www.ninjatrader-support2.com/...serialize+font

    Comment


      #3
      I figured that out using your link.

      THAT IS AWESOME CODE!!!

      thanks
      Last edited by velocity; 11-29-2009, 04:20 PM.

      Comment


        #4
        Adding Colors for Fonts is cool too...

        could be useful if you are into coloring your fonts...

        variables:
        Code:
        private Color upColor = Color.Lime;

        properties:
        Code:
        		[XmlIgnore()]
        		[Description("In Profit Color")]
        		[Category("Display Text")]
        		public Color UpColor
        		{
        			get { return upColor; }
        			set { upColor = value; }
        		}
        		
        		[Browsable(false)]
        		public string UpColorSerialize
        		{
        			get { return NinjaTrader.Gui.Design.SerializableColor.ToString(upColor); }
        			set { upColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
        		}

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        236 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        151 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        162 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        243 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        198 views
        0 likes
        Last Post CarlTrading  
        Working...
        X