Singleton or Static class, or neither?

I'm creating a Windows Form application that is basically a recreation of paint. I have a toolstrip of various buttons, I am able to drag a copy of a bitmap onto the diagram and place it on the drawing panel. However I want to add the functionality of being able to move the bitmap around the panel and re-size it using the 9 nodes on the corners and middle of lines.

Currently my form has a

List<Diagram> theDiagrams; 

which contains a list of custom diagram objects. Each diagram represents the bitmap on the drawing panel, it has the coordinates, size, z-index, bitmap and a bit of other info. However now I want only the Diagram with the focus to be able to be editable, or to have those 9 nodes around the outside with the ability to move/re-size it. I'm thinking of creating a class that is a derivation of the Diagram class I currently have however I only want to be able to create 1 of them. Should I create a static class or possibly use a singleton design pattern to ensure only one of those objects can be created at a time. Ideally I'd like this class to be null from the start and only get set to a copy of a diagram when it's necessary.

I'm more less trying to figure out how to design the class for this particular scenario so I don't think much code is needed to get the jist of what I'm saying. However if you feel you need some examples of what I'm talking about, I'm more than happy to share the code to ensure I come up with the best solution possible.

If you didn't understand my question, should I use a singleton design pattern, a static class, or neither for what I'm trying to accomplish?

by Redditingforacure via /r/csharp

Leave a Reply