Form Class Hierarchy

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Sun Mar 30, 2008 2:10 am

Form Class Hierarchy

So we have two (that I can see) classes of Form:
1. ControllerHostForm
2. AbstractControllerImpl

Why doesn't #1 implement #2?

Also I propose we do this in AbstractControllerImpl:
  Code:
private static AbstractControllerImpl theInstance;

abstract static AbstractControllerImpl getControllerInstance();

public static AbstractControllerImpl create(Form parent) {
    create();
    theInstance.MdiParent = parent;
    theInstance.Hide();
    return theInstance;
}

public static AbstractControllerImpl create() {
    if (theInstance==null) theInstance = getControllerInstance();
    return theInstance;
}

public static AbastractControllerImpl activate() {
    create();
    theInstance.Show();
    theInstance.Activate();
    return theInstance;
}


Then in classes that implemented it:
  Code:
public class MyForm : AbstractControllerImpl {
    ....
    override static AbstractControllerImpl getControllerInstance() {
        return new MyForm();
    }
    ....
}

Please excuse the lack of C# correctness (and the usage of a static variable in an abstract class). I'm trying more to convey the idea than the code.

Also all controllers should really implement the same interface so that we can put the maximum amount of handling code in that interface and subsequently only have to really modify that if/when we make changes to the way controller dialogs get handled.
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Mon Mar 31, 2008 12:39 pm

Re: Form Class Hierarchy

I did just have a quick go at this but I lack the understanding of both C# and the controller/form hierarchy to be able to do it.

One of the things I was looking at doing was, instead of using static identifiers in each class, was to use the class as a key in a hashmap (something you can do in Java) but didn't know how to access a class like that in C#.
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

jendave

Sticking around

Posts: 32

Joined: Fri Mar 14, 2008 7:53 pm

Post Mon Mar 31, 2008 2:57 pm

Re: Form Class Hierarchy

I have been looking at this. I should have something in the next few days.

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Mon Mar 31, 2008 3:08 pm

Re: Form Class Hierarchy

Cool, I'll wait for that. I hope my tampering was some form of help! :ugeek:
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

Return to Core Development

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.