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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        637 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X