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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        161 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        308 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        349 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X