CSharpProblem
CSharpProblem

Reputation: 3

Calling a Class or Method in C# using Mono

I'm having some problems calling a class or method in C# using Mono, can anyone give some help on what I'm doing wrong?

I want this piece of code:

public static void Execute(ScriptHost host)
{
    try
    {
        TesteGUI teste = new TesteGUI(); //?
        TesteGUI(); // ?
    }
    catch(Exception e)
    {
    }
    finally
    {
    }
}       

To call this piece of code:

public TesteGUI(Gtk.Window parentWindow) : base(Gtk.WindowType.Toplevel)
{
    base.Modal = false;
    base.TransientFor = parentWindow;
    base.Decorated = false;
    base.WindowPosition = WindowPosition.CenterAlways;

    this.MyBuild();

    base.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args)
                        {
                                if (args.Event.Key == Gdk.Key.Escape)
                                {
                                    this.Destroy();
                                }
                            };
}

What is my doing wrong and how can I make it work?

Thank you

Upvotes: 0

Views: 347

Answers (1)

Ahmed Salman Tahir
Ahmed Salman Tahir

Reputation: 1779

You should do it like this:

public static void Execute(ScriptHost host)
{
    try
    {
        TesteGUI teste = new TesteGUI(parentWindow); //where parentWindow is defined somewhere earlier and is of type Gtk.Window
    }
    catch(Exception e)
    {
    }
    finally
    {

    }
}   

Upvotes: 1

Related Questions