Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Color

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

    Using Color

    Can I use System.Windows.Media.Color properties in my Properties ?

    If so in NT7 we had to serialize Color but we don't have NinjaTrader.Gui.Design anymore so do we need to serialize Color properties in NT8 ?


    Thank you

    #2
    Hello blar58,

    Thank you for your post.

    You would use Brushes in NinjaTrader 8. You can find our sample with additional information at the following link: http://ninjatrader.com/support/forum...43&postcount=2

    Comment


      #3
      Hello Patrick

      I know that we use Brush in NT8 but I need to use Color in my Properties and convert it to Brush later in my code.

      Can I use Color in my properties and if so do I need to serialize it


      Thank you

      Comment


        #4
        I would really like to know if I can use Color in my properties and turn it into Brush in my code.

        When I do that I know that now the indicator setting window is showing Brush as Hex #F0000 etc but I need to know what to do to serialize the Color property in NT 8 like we were doing in NT7 or if do I have to serialize it ?


        Thank you

        Comment


          #5
          Hi Blar58,

          I'm not sure if it helps, but if you look at the included VolumeProfile indicator code it has an example of changing colors in the parameters.

          Cheers,
          Shane

          Edit: sorry just realized that probably doesn't help much as its similiar to the other thread link already posted below.
          Last edited by ShaneAU; 04-29-2016, 07:13 AM.

          Comment


            #6
            Hello blar58,

            Thank you for your patience.

            You can serialize a Pen or a Brush in NinjaTrader 8 but not colors.

            Comment


              #7
              OK Patrick

              Thank you.
              Does that mean that if I use Color in my properties that they will not be saved when I close my indicator ?

              Comment


                #8
                blar58,

                This would mean the Colors could not be saved in a template or workspace like you would have seen in NinjaTrader 7. Any reason for using Colors over Brushes?

                Comment


                  #9
                  Originally posted by blar58 View Post
                  OK Patrick

                  Thank you.
                  Does that mean that if I use Color in my properties that they will not be saved when I close my indicator ?
                  If you must persist in doing things that way, you can use between them all, Color.ToArgb, Color.FromArgb(), Color.FromName(), Color.FromKnownColor(), Color.ToString() to serialize and deserialize colors.

                  Of course, you will still have to stop your Color property from attempting serialization by using the [XmlIgnore] attribute, and use a dummy property as the serializer, hiding said dummy property by using the [Browsable(false)] attribute.
                  Last edited by koganam; 05-03-2016, 02:04 PM.

                  Comment


                    #10
                    Originally posted by blar58 View Post
                    I know that we use Brush in NT8 but I need to use Color in my Properties and convert it to Brush later in my code.
                    Would something like this work for you?

                    Code:
                    [COLOR=#0000ff]protected[/COLOR] [COLOR=#0000ff]override[/COLOR] [COLOR=#0000ff]void[/COLOR] [COLOR=#080808]OnBarUpdate[/COLOR]()
                     {
                     [COLOR=#0000ff]     if[/COLOR]([COLOR=#080808]CurrentBar[/COLOR] == [COLOR=#ff8c00]0[/COLOR] && [COLOR=#080808]IsFirstTickOfBar[/COLOR])
                          {
                     [COLOR=#080808]          Brush[/COLOR] [COLOR=#080808]myBrush[/COLOR] = [COLOR=#080808]Brushes[/COLOR].[COLOR=#080808]Red[/COLOR];
                     [COLOR=#080808]          Color[/COLOR] [COLOR=#080808]myColor[/COLOR] = ([COLOR=#080808]myBrush[/COLOR] [COLOR=#0000ff]as[/COLOR] [COLOR=#080808]SolidColorBrush[/COLOR]).[COLOR=#080808]Color[/COLOR];
                     [COLOR=#080808]          Print[/COLOR]([COLOR=#080808]myColor[/COLOR].[COLOR=#080808]ToString[/COLOR]());
                     [COLOR=#080808]          myColor[/COLOR].[COLOR=#080808]A[/COLOR] = [COLOR=#ff8c00]50[/COLOR];
                     [COLOR=#080808]          SolidColorBrush[/COLOR] [COLOR=#080808]mySCBrush[/COLOR] = [COLOR=#0000ff]new[/COLOR] [COLOR=#080808]SolidColorBrush[/COLOR]([COLOR=#080808]myColor[/COLOR]);
                     [COLOR=#080808]          mySCBrush[/COLOR].[COLOR=#080808]Freeze[/COLOR]();
                     [COLOR=#080808]          Print[/COLOR]([COLOR=#080808]mySCBrush[/COLOR].[COLOR=#080808]Color[/COLOR].[COLOR=#080808]ToString[/COLOR]());
                          }
                     }
                    -=Edge=-
                    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                    Comment


                      #11
                      Thank you mates.

                      This is how I approached the problem.

                      I am using Color instead of Brush because I am using the WPF PropertyGrid from Xceed to change properties on the fly and if I use Brush I cannot see the color in the grid I am seeing only the Hex #FXXXXXXX ....

                      If there is a better way to do this I would love to hear it
                      Last edited by blar58; 05-04-2016, 06:45 AM.

                      Comment


                        #12
                        Koganam

                        Could you show me a small example how to serialize the Color the way you described it below

                        Thank you

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by wzgy0920, 04-20-2024, 06:09 PM
                        2 responses
                        27 views
                        0 likes
                        Last Post wzgy0920  
                        Started by wzgy0920, 02-22-2024, 01:11 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post wzgy0920  
                        Started by wzgy0920, 04-23-2024, 09:53 PM
                        2 responses
                        49 views
                        0 likes
                        Last Post wzgy0920  
                        Started by Kensonprib, 04-28-2021, 10:11 AM
                        5 responses
                        193 views
                        0 likes
                        Last Post Hasadafa  
                        Started by GussJ, 03-04-2020, 03:11 PM
                        11 responses
                        3,235 views
                        0 likes
                        Last Post xiinteractive  
                        Working...
                        X