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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        87 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        106 views
        0 likes
        Last Post CarlTrading  
        Working...
        X