Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

include if statement to encapsulate classes

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

    include if statement to encapsulate classes

    Hello,

    Is it possible to create an if statement that will encapsulate classes? I am trying two different indicators and give the choice to the users between one or the other.


    For example:

    Code:
    If(indicator1)
    {
    public override void OnRenderTargetChanged()
    {
    textBrush = Brushes.Lime.ToDxBrush(RenderTarget);
    }
    
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
    
    if (IsInHitTest) return;
    if (ChartBars != null)
    {
    //get the X and Y point of the cursor and convert them to pixels
    int cursorPointX = ChartingExtensions.ConvertToHorizontalPixels(chart Control.MouseDownPoint.X, chartControl);
    int cursorPointY = ChartingExtensions.ConvertToVerticalPixels(chartCo ntrol.MouseDownPoint.Y, chartControl);
    
    blablabla
    }
    
    else(indicator2)
    {
    
    public override void OnRenderTargetChanged()
    {
    textBrush = Brushes.Red.ToDxBrush(RenderTarget);
    }
    
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
    
    if (IsInHitTest) return;
    if (ChartBars != null)
    {
    //get the X and Y point of the cursor and convert them to pixels
    int cursorPointX = ChartingExtensions.ConvertToHorizontalPixels(chart Control.MouseDownPoint.X, chartControl);
    int cursorPointY = ChartingExtensions.ConvertToVerticalPixels(chartCo ntrol.MouseDownPoint.Y, chartControl);
    
    blablabla
    }
    TY

    #2
    Hello frankduc, thanks for your post.

    Every method and property in C# needs to be within the class. If you add an IF statement outside of a class method it will not compile. Any branching that needs to take place must be done within OnRenderTargetChanged itself.

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    72 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X