Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Centralised Events

Centralised Events

Scheduled Pinned Locked Moved The Lounge
csharpquestiondelphihelplearning
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jinwah
    wrote on last edited by
    #1

    I come from a Delphi background, (just learning the C# and .Net). In Delphi, event handlers can be centralised using an action list. In this way I can assign the same event handler to as many cotrols as I like. In addition I can manage the event handlers by iterating thru the list and enabling as I wish and also setting various other properties of the action. My question is how can this be done in C#? Thank-you for your kind help Luke :)

    M R P 3 Replies Last reply
    0
    • J Jinwah

      I come from a Delphi background, (just learning the C# and .Net). In Delphi, event handlers can be centralised using an action list. In this way I can assign the same event handler to as many cotrols as I like. In addition I can manage the event handlers by iterating thru the list and enabling as I wish and also setting various other properties of the action. My question is how can this be done in C#? Thank-you for your kind help Luke :)

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      Well, I'll take a stab at this. 1. I believe in C# you can assign the same event handler to multiple events. Just add the event function to the event handler, which, with regards to your question, can easily be done as part of the member of the control. 2. Multiple events can be assigned to the same handler. This is a nice feature, though I've never used it yet myself. 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. You said ...and also setting various other properties of the action. I'm curious--what other kinds of properties? Marc

      G J D 3 Replies Last reply
      0
      • M Marc Clifton

        Well, I'll take a stab at this. 1. I believe in C# you can assign the same event handler to multiple events. Just add the event function to the event handler, which, with regards to your question, can easily be done as part of the member of the control. 2. Multiple events can be assigned to the same handler. This is a nice feature, though I've never used it yet myself. 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. You said ...and also setting various other properties of the action. I'm curious--what other kinds of properties? Marc

        G Offline
        G Offline
        Giles
        wrote on last edited by
        #3

        Marc Clifton wrote: 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. Article please!!!!:-D

        M 1 Reply Last reply
        0
        • J Jinwah

          I come from a Delphi background, (just learning the C# and .Net). In Delphi, event handlers can be centralised using an action list. In this way I can assign the same event handler to as many cotrols as I like. In addition I can manage the event handlers by iterating thru the list and enabling as I wish and also setting various other properties of the action. My question is how can this be done in C#? Thank-you for your kind help Luke :)

          R Offline
          R Offline
          Ray Cassick
          wrote on last edited by
          #4

          Sounds like you would be interested in this... Article Clickety[^]

          1 Reply Last reply
          0
          • M Marc Clifton

            Well, I'll take a stab at this. 1. I believe in C# you can assign the same event handler to multiple events. Just add the event function to the event handler, which, with regards to your question, can easily be done as part of the member of the control. 2. Multiple events can be assigned to the same handler. This is a nice feature, though I've never used it yet myself. 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. You said ...and also setting various other properties of the action. I'm curious--what other kinds of properties? Marc

            J Offline
            J Offline
            Jinwah
            wrote on last edited by
            #5

            Delphi actions have a few properties that can be set such as Caption, Category, Checked, Enabled, Hint, ImageIndex (for fetching the Actions icon), ShortCut Keys and a Visible property. These enable some really nice code management and thru the ActionList the actions can be managed and manipulated. I have even written code to enable action events to fire over COM. A fantastic way of building application extensibility. Cheers everyone for your help glad I came to this forum, hopefully soon enough I will be able to provide some advice too.

            1 Reply Last reply
            0
            • M Marc Clifton

              Well, I'll take a stab at this. 1. I believe in C# you can assign the same event handler to multiple events. Just add the event function to the event handler, which, with regards to your question, can easily be done as part of the member of the control. 2. Multiple events can be assigned to the same handler. This is a nice feature, though I've never used it yet myself. 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. You said ...and also setting various other properties of the action. I'm curious--what other kinds of properties? Marc

              D Offline
              D Offline
              David Stone
              wrote on last edited by
              #6

              Marc Clifton wrote: . As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. Ooooh. Can we see this in action...I believe that there's an article submission wizard somewhere around here...:-D Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

              M 1 Reply Last reply
              0
              • J Jinwah

                I come from a Delphi background, (just learning the C# and .Net). In Delphi, event handlers can be centralised using an action list. In this way I can assign the same event handler to as many cotrols as I like. In addition I can manage the event handlers by iterating thru the list and enabling as I wish and also setting various other properties of the action. My question is how can this be done in C#? Thank-you for your kind help Luke :)

                P Offline
                P Offline
                Philip Fitzsimons
                wrote on last edited by
                #7

                nope, use the command pattern... see msdn http://msdn.microsoft.com/msdnmag/issues/02/10/CommandManagement/default.aspx[^]


                "When the only tool you have is a hammer, a sore thumb you will have."

                1 Reply Last reply
                0
                • G Giles

                  Marc Clifton wrote: 3. As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. Article please!!!!:-D

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #8

                  In progress! :-D

                  G 1 Reply Last reply
                  0
                  • D David Stone

                    Marc Clifton wrote: . As far as iterating through a list of event handlers and enabling/disabling them, I don't believe this can be done (I don't think C# has a master event collection, but I could be wrong). This is why I personally vector everything through an event manager class, which not only lets me trace all events, but as you said, I can enable/disable events. I can also specify whether the event is run in-line or as a separate thread, and I've recently added the ability to do run time binding of events to functions based on the function assembly, class, and name, using C#'s reflection class. Ooooh. Can we see this in action...I believe that there's an article submission wizard somewhere around here...:-D Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

                    M Offline
                    M Offline
                    Marc Clifton
                    wrote on last edited by
                    #9

                    Yup. Working on it. But I just read the link posted by Philip below, so I may have to rethink what I've done so far. :-D Marc

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      In progress! :-D

                      G Offline
                      G Offline
                      Giles
                      wrote on last edited by
                      #10

                      Cool. Good to hear it, and look forward.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups