Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is the converter and editor for brushes?

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

    What is the converter and editor for brushes?

    Hello,

    If I want to manually apply a converter/editor to a property in order to get the color picker used for a Brush property, what should I use?

    Thanks,
    Wil

    #2
    Hello wbennettjr,

    There are no attributes needed, you would just need a public brush property. We have a sample that shows the property plus serialization in the following link: https://ninjatrader.com/support/help...definedbrushes

    Using the brush editor in other ways would not be supported so I would have no suggestions if the question was "how can i use the brush editor with a non Brush type property".



    Please let me know if I may be of further assistance.

    Comment


      #3
      Thanks for the reply Jesse,

      I understand what you are saying. It is using a converter and color picker property editor though. What are those classes?

      Thanks,
      Wil

      Comment


        #4
        Hello wbennettjr,

        Can you provide more context on what you are trying to do or as to why a Brush property wouldn't work?

        There are no examples that I am aware of which uses a different types or converter/editor attribute to display the list of brushes. The property grid does not require using an attribute for brushes because it is looking for Brush type specifically to display the menu. If you can provide more context perhaps there is a solution such as using a Brush property and customize the get/set of the property to convert the type.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thanks Jesse,

          I have the following class that I would like to use the converter for. The idea is to remove the need to create an xxxBrushSerialize property everytime as it needlessly clutters the class. I can use the ExpandableObjectConverter but I do not want to add the extra layer of nesting.

          Code:
          public class BrushProperty
          {
              [Display(Name = "Brush")]
              [XmlIgnore]
              public Brush Brush { get; set; }
          
              [Browsable(false)]
              public string BrushSerialize
              {
                  get { return Serialize.BrushToString(Brush); }
                  set { Brush = Serialize.StringToBrush(value); }
              }
          
              public static implicit operator Brush(BrushProperty instance) => instance.Brush;
              public static implicit operator BrushProperty(Brush brush) => new BrushProperty { Brush = brush };
          }
          Thanks,
          Wil

          Comment


            #6
            Hello Wil,

            This kind of custom class work is getting outside of what is documented in the help guide and supported by NinjaTrader support.

            With an ExpandableObjectConverter class this does kind of achieve that, but does nest the brush in an expandable class.
            https://ninjatrader.com/support/foru...552#post790552

            Unfortunately, we are not aware of any supported ways to not have to serialize objects, and our development and support directs NinjaScript developers to serializing objects.
            There may be a way, but this may take some unsupported code to achieve.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks ChelseaB.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              77 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              45 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              27 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              32 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              64 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X