I'm trying to wrap my head around the best way to code this form using object-orientation in VB.NET (2005). Basically, I am responding to the three main mouse events (down, move, up) in different ways based on a flag that is set (essentially, what button is pressed). And right now, it looks something like this inside the form:

VB Code:
  1. Private flag as Flags
  2.  
  3. Private Enum Flags As Integer
  4. Flag1
  5. Flag2
  6. End Enum
  7.  
  8. Private Sub Button1_Click(...) Handles Button1.Click
  9.    flag = Flags.Flag1
  10. End Sub
  11.  
  12. Private Sub Button2_Click(...) Handles Button2.Click
  13.    flag = Flags.Flag2
  14. End Sub
  15.  
  16. Private Sub MyViewWindow_MouseDown(...) Handles MyViewWindow.MouseDown
  17.    Select Case flag
  18.       Case Flag1
  19.          ' do something
  20.       Case Flag2
  21.          ' do something else
  22. End Sub
  23.  
  24. Private Sub MyViewWindow_MouseMove(...) Handles MyViewWindow.MouseDown
  25.    Select Case flag
  26.       Case Flag1
  27.          ' do something
  28.       Case Flag2
  29.          ' do something else
  30. End Sub
  31.  
  32. Private Sub MyViewWindow_MouseUp(...) Handles MyViewWindow.MouseDown
  33.    Select Case flag
  34.       Case Flag1
  35.          ' do something
  36.       Case Flag2
  37.          ' do something else
  38. End Sub

It seems like there must be a better way to do this using OOP. When you consider that I actually have 10-15 flags, those event handlers become these enormous subroutines. It also seems way too procedural, that there must be a way to use delegates or other classes or something to clean this up a bit. Is there a better way?