[Gtk-sharp-list] Child windows in a seperate dll file.
oldspiceap at gmail.com
Tue Apr 29 13:42:18 EDT 2008
Greetings, I'm new to programming and thus to C#. In fact I'm only a few
weeks into my learning process. I've written an app for work and now am
rewriting it so that its not so hideous and ugly. At the moment its at like
8000 lines and all in one class with just a ton of methods.
Anyways I've started rewriting it and decided to split the eventhandlers
into their own dll file so that it would be easier to maintain and cleaner.
This worked to a degree but I'd like to create dialogs that come up and
unfortunately I cannot seem to make that happen as it cannot compile due to
being unable to locate the parent window. I have the program split up into
three files now:
First is a simple file for the exe:
// We'll be using these later I think.
// using Gtk;
// using GtkSharp;
static void Main()
sowInterface drawSow = new sowInterface();
Simple enough even for someone as slow as me. Now onto the code to draw the
interface (almost nothing yet but its a rewrite ;) don't make fun!
public class sowInterface
public void MainInterface ()
Window window = new Window ("Statement of Work Generator");
/* Set a handler for delete_event that immediately
* exits GTK. */
window.DeleteEvent += OnDelete;
// sets windows size by default. We'll see if we need this later on.
// window.SetDefaultSize (200,200);
/* Set the border width of the window and show the window itself.*/
/* Create a big ass table and place it inside the main window.*/
Table table = new Table (26, 4, false);
/// Create Label for Customer Name
Label customer_name = new Label("Customer Name: ");
table.Attach(customer_name, 0, 1, 0, 1);
/// Create Label for Company Name
Label company_name = new Label("Company Name: ");
table.Attach(company_name, 0, 1, 1, 2);
/// Create Label for fuel surcharge percentage
Label fuel_surcharge_label = new Label("Fuel Surcharge (%): ");
table.Attach(fuel_surcharge_label, 0, 1, 2, 3);
/// Create Label for discount percentage
Label discount_percent_label = new Label("Discount (%): ");
table.Attach(discount_percent_label, 0, 1, 3, 4);
/// Create Label for discount reason
Label discount_reason_label = new Label("Reason for Discount: ");
table.Attach(discount_reason_label, 0, 1, 4, 5);
/// Create Label for service options.
Label service_options_label = new Label("Full Service? ");
table.Attach(service_options_label, 0, 1, 5, 6);
OnDelete2 OnDelete = new OnDelete2();
// Handles exiting when you click the X button - temp disabled as trying
to split into dll
static void OnDelete (object obj, DeleteEventArgs e)
and now the file I'm using for the event handler:
public class event_handlers
public static void OnDelete2 (object obj, DeleteEventArgs e)
MessageDialog md = new MessageDialog (window,
ButtonsType.YesNo, "Are you sure you want to quit?");
ResponseType result = (ResponseType)md.Run ();
if (result == ResponseType.Yes)
As you can see I've commented out the confirmation dialog box. I had though
instancing it in my main drawinterface would make it work but it doesn't.
Can anyone point me in the right direction?
Also eventually part of the code will eventually have certain events calling
methods that change the values and labels of other widgets so I need to
figure out how to do that across libraries as well.
Many thanks and kind regards. Hopefully someone can point me in the right
P.S. I've also attached an archive that includes my old (horrible) source
code as well as the beginnings that are listed above and the makefile to
compile the new version. Eventually I'd like to add a preferences dialog as
well and make that its own library so that it can be worked on
independently. So I'll need to be passing things back and fourth like a
View this message in context: http://www.nabble.com/Child-windows-in-a-seperate-dll-file.-tp16966107p16966107.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
More information about the Gtk-sharp-list