Question

how can I add two new properties to the sealed Arc class. I want to extend the class with a double property to hold a double value and a string property to hold the name of the object. My first try was via the Tag property but this can only hold the double value OR the object name.

The problem is that I created a new user control with 43 arc objects and when the mouse entered an arc another control shows up the value and the name of the entered segment. So every arc uses the SAME MouseEntered function and I want to get the informations via the "object sender".

I hope anyone has a nice idea.

Was it helpful?

Solution

You can't. It's sealed. Either:

  1. Create a new class that contains an Arc as a property.
  2. Store a tuple or some other object in Arc.Tag.
  3. Decorate the Arc with attributes

For your particular problem, I would suggest #2 above or to store a Dictionary<Arc, blahblahblah> or Dictionary<string, blahblahblah> (by name) and look up the info you need. #1 is a lot of overhead wrapping all the methods and properties you need for drawing, and probably more hassle than it's worth.

OTHER TIPS

You could use the composite pattern.

class SuperArc
{
   Arc Arc { get; set; }
   // other properties.
}

You can't extend sealed clases.

Try creating your own class and having Arc as a class member, and expose this member functions.

Best regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top