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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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 schmidtbc16, Today, 03:36 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by RT001, Today, 03:25 PM
              2 responses
              14 views
              0 likes
              Last Post RT001
              by RT001
               
              Started by mbrandau, Today, 01:58 PM
              5 responses
              37 views
              0 likes
              Last Post mbrandau  
              Started by remcovdmeulen, Today, 02:15 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by gbrad, Today, 09:57 AM
              7 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X