Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartStyle Remove Stroke Item

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

    ChartStyle Remove Stroke Item

    Hi,

    I am trying to remove the CandleOutlineColor Item from ChartStyle Properties and want to leave the rest of the Items (Width and DashStyle) untouched. How can I do that?

    Regards and thanks

    #2
    Are you trying to fully remove if from the code or just hide it from the UI?

    Comment


      #3
      I want it removed from the data series menu, so that its not available there.

      Comment


        #4
        In the OnStateChange() where State == State.Configure do this -
        Code:
        Properties.Remove(Properties.Find("Stroke", true));

        Comment


          #5
          Thanks Calonious,

          this removes as far as I know the complete stroke section, perhaps I wasnt precise enough, but i only want the color option of the stroke section to be removed.

          Comment


            #6
            Hello,

            I believe the problem is the object the PropertyGrid is using would be the Stroke property its self which has all of these sub properties in the Stroke object.

            One solution would be to hide the existing Stroke property and create a custom property that only displays what you want. by using the "new" and "base" keywords we could do this.

            A Type converter is required for this as you would need to create a class that inherits from Stroke.

            Here is an example, please note this is only the specific parts of logic outlined in the below sample, the needed overrides have been removed to shorten the sample. See the attached .cs for a full script example:

            Code:
            public class TestStyle : ChartStyle
            {
            	private MyCustomObject myCustomStroke;
            
            	[TypeConverter(typeof(ExpandableObjectConverter))]
            	public class MyCustomObject : Stroke
            	{
            		public new float Width { get { return base.Width; } set { base.Width = value; } }
            		public new DashStyleHelper DashStyleHelper { get { return base.DashStyleHelper; } set { base.DashStyleHelper = value; } }
            
            		[Browsable(false)]
            		public new System.Windows.Media.Brush Brush { get { return base.Brush; } set { base.Brush = value; } }
            	}
            
            	[Display(Name = "Stroke", Order = 0)]
            	public MyCustomObject MyCustomStroke
            	{
            		get
            		{
            			Stroke.Brush = myCustomStroke.Brush;
            			Stroke.Width = myCustomStroke.Width;
            			Stroke.DashStyleHelper = myCustomStroke.DashStyleHelper;
            			return myCustomStroke;
            
            		}
            		set
            		{
            			myCustomStroke = value;
            			Stroke.Brush = myCustomStroke.Brush;
            			Stroke.Width = myCustomStroke.Width;
            			Stroke.DashStyleHelper = myCustomStroke.DashStyleHelper;
            		}
            	}
            
            
            
            	protected override void OnStateChange()
            	{
            		if (State == State.SetDefaults)
            		{
            			MyCustomStroke = new MyCustomObject
            			{
            				Width = 1.0f,
            				Brush = Brushes.Red,
            				DashStyleHelper = DashStyleHelper.Solid
            			};
            		}
            		else if (State == State.Configure)
            		{
            			Properties.Remove(Properties.Find("Stroke", true));
            		}
            	}
            }
            The bold areas are meant to show the difference from how you would declare a normal property, because I specify that the Name of the variable is the same as the inherited, the new keyword can be used to say this is a new variable that is the same name, then base and this would come into play to determine which property you are actually setting.

            Edit: There is an issue with directly setting the Stroke property to a Custom class as you will get an error in the log because of this. Instead, setting the Name of the property and Removing the existing seems to be more correct or does not produce an error.
            I look forward to being of further assistance.
            Attached Files
            Last edited by NinjaTrader_Jesse; 02-10-2016, 01:50 PM. Reason: Edited sample
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks Jesse,

              will work with that.

              Regards

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by PaulMohn, Today, 12:36 PM
              0 responses
              2 views
              0 likes
              Last Post PaulMohn  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              38 views
              0 likes
              Last Post love2code2trade  
              Started by alifarahani, Today, 09:40 AM
              2 responses
              14 views
              0 likes
              Last Post alifarahani  
              Started by junkone, Today, 11:37 AM
              3 responses
              20 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by frankthearm, Yesterday, 09:08 AM
              12 responses
              44 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X