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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    669 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    378 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X