Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Get a Object to basicly work as a polygon? RSS

6 replies

Last post Feb 09, 2009 01:00 PM by ArneHB

(0)
  • ArneHB

    ArneHB

    Member

    18 Points

    20 Posts

    Get a Object to basicly work as a polygon?

    Feb 02, 2009 08:43 AM | LINK

    I need some help with a problem I got. I want a class to extend/inherit/derive polygon, but this is not posible since Polygon is sealed. I have some properties I need to have in the Polygon like ID, Name and Parent Polygon (Would contain the same class). What I need is a class that basicly work as a polygon class, but has the extra properties. I also need it to be a UIElement so I can add it into a Canvas and other uses. The question is, how should I make this class, should it extend from Shape as Polygon does? How will I be able to "paint" the class? Is there anything like in Windows form where you can override paint, in silverlight?

     Any answer and code example would be very much appriciated!

     Cheers
    Arne

    Polygon Class Inherit UIElement

  • ArneHB

    ArneHB

    Member

    18 Points

    20 Posts

    Re: Get a Object to basicly work as a polygon?

    Feb 03, 2009 01:12 PM | LINK

    *bump* Can anyone lead me into the right direction atleast? :)

  • Amanda Wang - MSFT

    Amanda Wang...

    All-Star

    17236 Points

    1466 Posts

    Re: Get a Object to basicly work as a polygon?

    Feb 06, 2009 03:16 AM | LINK

     Hi Arne,

    ArneHB

    What I need is a class that basicly work as a polygon class, but has the extra properties. I also need it to be a UIElement so I can add it into a Canvas and other uses

    When creating managed classes, we had to decide whether or not to make them sealed or not. Discussing this subject can lead to a religious debate.

    But What extra properties do you want to add?  Can you post your requirment here, so we can discuss if there is other way can help you instead of inherit the polygon?

     

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • ArneHB

    ArneHB

    Member

    18 Points

    20 Posts

    Re: Get a Object to basicly work as a polygon?

    Feb 06, 2009 06:49 AM | LINK

    Thanks for answering :)

     I'm experimenting with silverlight, and I'm making a little application where you can draw polygons that will be considered a "region" or a "area". I havn't implemented it yet but the plan is that you will be able to have a map in the background and draw the polygon over it.

     I want this polygon added in a combobox, which will be easy enough, since the combobox is doing a to string on the object can I override tostrong and return the property I want. This is so you'll be able to choose parent polygon from the combobox, if you want a polygon inside another in a three structur. Like say you draw a area/region over a map and you want in that region/area several sub regions.

    Let's say we call the class RegionPolygon. I'd like these properties:
    Int ID
    String Name
    RegionPolygon ParentRegionPoly

    override String ToString(){ return Name; }

    I also want to set a few properties to polygon in the class, like border and background so I don't have to do that everytime I declear and initiate the class.

  • ArneHB

    ArneHB

    Member

    18 Points

    20 Posts

    Re: Re: Get a Object to basicly work as a polygon?

    Feb 09, 2009 07:15 AM | LINK

    Sorry for bumping but is there something that i unclear that I need to explain futher? English isn't my main lanuage so I understand that what I write can be unclear and poorly explained.

  • RonaldEekelder

    RonaldEekelder

    Member

    28 Points

    14 Posts

    Re: Re: Get a Object to basicly work as a polygon?

    Feb 09, 2009 08:01 AM | LINK

    Maybe you should consider 'containment' instead of 'inheritance'.

    Ronald Eekelder
    www.OakReFactory.com
  • ArneHB

    ArneHB

    Member

    18 Points

    20 Posts

    Re: Re: Re: Get a Object to basicly work as a polygon?

    Feb 09, 2009 01:00 PM | LINK

    Yes that works, and that is how I'm doing it now. However it results in much extra and unnececary code, as I can't just simply override the paint metode and paint the polygon from the class it contains within. I'm also adding it to a combobox and such so it looks really like a spaghetti code now.