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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    44 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    56 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    35 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    95 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    57 views
    0 likes
    Last Post PaulMohn  
    Working...
    X