Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Serializing colors

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

    Serializing colors

    Hi Guys, I'd be grateful for some help on serializing colors. This is what I have so far:

    PHP Code:
    //variables
    private SolidBrush                 boxoutline            = new SolidBrush(Color.White); 
    PHP Code:
    //Properties
    [Category("2. Colors")]
           [
    Description("Colors.")]
            [
    Gui.Design.DisplayName("Box Outline color")]
            public 
    Color Boxoutline
            
    {
                
    get { return boxoutline.Color; }
                
    set this.boxoutline = new SolidBrush(value); }
            }
            
            [
    Browsable(false)]
            public 
    string BoxoutlineSerialize
            
    {
            
    get { return SerializableColor.ToString(boxoutline); }
            
    set boxoutline SerializableColor.FromString(value); }    
            } 
    The problem is for the last two lines I'm getting the "The name SerializableColor does not exist in the current context" error. I followed the example exactly.

    Any ideas on this one. Thanks in advance. DJ

    #2
    Opacity

    The other problem is being able to set the opacity in the properties section for this. For example I'd like to be able to change the 150 in properties...

    PHP Code:
    graphics.FillRectangle(new SolidBrush(Color.FromArgb(150,Color.Red.R,Color.Red.G,Color.Red.B)), bounds.+(bounds.Width/2)+1-60bounds.Top 25959); 
    I've have this from another indicator but seems to be fixed at 10 so not sure how to modify it:

    PHP Code:
    [Category("2. Colors")]
            [
    Description("Colors.")]
            [
    Gui.Design.DisplayName("Box Opacity")]
            public 
    int Opacity
            
    {
                
    get { return opacity; }
                
    set opacity Math.Min(Math.Max(0value),10); }
            } 
    Thanks in advance
    DJ

    Comment


      #3
      DJ, the max is set here to a 10 in the property -

      set { opacity = Math.Min(Math.Max(0, value),10);

      Are you saying the indicator would set the opacity of the custom Rectangle? I would expect this only to work for the NT default DrawRectangle, as it implements an opacity paramters / setting.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        For the color please try with :

        [Category("2. Colors")]
        [Description("Colors.")]
        [Gui.Design.DisplayName("Box Outline color")]
        public Color Boxoutline
        {
        get { return boxoutline.Color; }
        set { this.boxoutline = new SolidBrush(value); }
        }

        [Browsable(false)]
        public string BoxoutlineSerialize
        {
        get { return NinjaTrader.Gui.Design.SerializableColor.ToString( boxoutline); }
        set { boxoutline = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
        }
        BertrandNinjaTrader Customer Service

        Comment


          #5
          another similar question with regards to color (and opacity). When I change the background color of a panel, is there a way to apply opacity to the background colors?

          Comment


            #6
            Would not be directly supported in NnjaScript, however you can look into setting it via the Color.FromArgb like - BackColor = Color.FromArgb(100, Color.DarkBlue);
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              For the color please try with :

              [Category("2. Colors")]
              [Description("Colors.")]
              [Gui.Design.DisplayName("Box Outline color")]
              public Color Boxoutline
              {
              get { return boxoutline.Color; }
              set { this.boxoutline = new SolidBrush(value); }
              }

              [Browsable(false)]
              public string BoxoutlineSerialize
              {
              get { return NinjaTrader.Gui.Design.SerializableColor.ToString( boxoutline); }
              set { boxoutline = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
              }
              Thanks Bertrand, but that didn't work either. Here is a picture of the error. Also, this is how I'm using it so not sure if that is causing the problem as well.

              PHP Code:
              graphics.DrawRectangle(new Pen(boxoutline),  bounds.+(bounds.Width/2)+60bounds.Top+16060); 
              Also this is what I have in variables:

              PHP Code:
              private SolidBrush                 boxoutline            = new SolidBrush(Color.White); 
              Thanks. DJ
              Attached Files
              Last edited by djkiwi; 02-28-2013, 11:07 AM.

              Comment


                #8
                Ok, found the answer exactly in this post:

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Rapine Heihei, 04-23-2024, 07:51 PM
                2 responses
                30 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by Shansen, 08-30-2019, 10:18 PM
                24 responses
                943 views
                0 likes
                Last Post spwizard  
                Started by Max238, Today, 01:28 AM
                0 responses
                9 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by rocketman7, Today, 01:00 AM
                0 responses
                5 views
                0 likes
                Last Post rocketman7  
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                28 views
                0 likes
                Last Post wzgy0920  
                Working...
                X