private void OnCreateWall(CreateWall_AddPanelEventArgs e) { EventHandler <CreateWall_AddPanelEventArgs> handler = CreateWallEventHandler; if (handler != null) { handler(this, e); } }
public void CreateWall(int X, int Y) { // Create a panel called "WallPanel" WallPanel.Location = new System.Drawing.Point(300, 50); WallPanel.Name = "pnl_ClimbingWall"; // Assigns the size the dimentions passed to the subroutine... //...from WallWidth and Wall Height in the WallSubmit click event WallPanel.Size = new System.Drawing.Size(X, Y); WallPanel.BackColor = Color.LightGreen; ////Dynamically Creates a click event for "WallPanel" to dectect when its been clicked Form1 form = new Form1(); WallPanel.MouseClick += BuildWallScreen.Instance.WallPanel_Click; //Creates a new instance of the event handler CreateWall_AddPanelEventArgs args = new CreateWall_AddPanelEventArgs(); //Adds the wallpanel to the event args.WallPanel = WallPanel; //activates the event sender with the event 'args' OnCreateWall(args); }
//Event Handler for adding the control to the wall private void WallBuild_CreateWallEventHandler(object sender, CreateWall_AddPanelEventArgs e) { //adds the controll panel passed through the event handler to the form Controls.Add(e.WallPanel); }