Tuesday
Nov212006
Removing a control’s behavior
Tuesday, November 21, 2006 at 11:49PM
In Programming .NET Components
, Juval Löwy explains the reasoning behind and how to use the EventHandlerList class (It’s used internally in the Control & derived classes to store event subscriptions).
I found that this architecture easily supports the removal of all behavior*:
For example, a security component could easily remove a control’s behavior* when the user does not have permission. Keep in mind that this is not a substitute for declarative or imperative security checks - other methods can continued to refer to the control's state or subscribe to its events in the future.
Other benefits include the ability for a security component to use a ToolTip to notify the user of access denied (ToolTips do not function on disabled controls).
* behavior as defined by event subscriptions where the event accessor implementation uses the EventHandlerList class.
I found that this architecture easily supports the removal of all behavior*:
public static void ClearEventHandlerList (Component component) {
if (component == null)
throw new ArgumentNullException ("component");
FieldInfo fieldInfo = (typeof (Component)).GetField ("events",
BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.DeclaredOnly |
BindingFlags.ExactBinding);
EventHandlerList currentList =
fieldInfo.GetValue (component) as EventHandlerList;
if (currentList != null)
currentList.Dispose ();
fieldInfo.SetValue (component, null);
}For example, a security component could easily remove a control’s behavior* when the user does not have permission. Keep in mind that this is not a substitute for declarative or imperative security checks - other methods can continued to refer to the control's state or subscribe to its events in the future.
Other benefits include the ability for a security component to use a ToolTip to notify the user of access denied (ToolTips do not function on disabled controls).
button.Click += new System.EventHandler (this.button_Click);
// the button_Click method is called when the button is clicked
...
ClearEventHandlerList (button);
// button does not have a click event subscriber anymore
// (button_Click is no longer called when the button is clicked)
* behavior as defined by event subscriptions where the event accessor implementation uses the EventHandlerList class.
Monday
Sep112006
Vista RC1 shutdown notification
Monday, September 11, 2006 at 12:06PM
The shutdown notifications need additional work in Windows Vista RC1:
Notification of an aborted system shutdown in Beta 2 had a strange title:

Luckily, Microsoft has enhanced the title in RC1, but there is still room for improvement:
- Run cmd.exe with administrative privileges
- Run the following command:
shutdown /s /t 600 - Abort the shutdown with this command:
shutdown /a
Notification of an aborted system shutdown in Beta 2 had a strange title:

Luckily, Microsoft has enhanced the title in RC1, but there is still room for improvement:
Friday
Sep012006
Network Neutrality
Friday, September 1, 2006 at 4:00AM
The Internet is not a big truck. It’s a series of tubes. - Ted Stevens
Check out this clip from The Daily Show where John Hodgman explains the technical implementation of the Internet and why we need network neutrality:
Check out this clip from The Daily Show where John Hodgman explains the technical implementation of the Internet and why we need network neutrality:
| The Daily Show With Jon Stewart | Mon - Thurs 11p / 10c | |||
| Net Neutrality Act | ||||
| www.thedailyshow.com | ||||
| ||||
Monday
Aug282006
Camera metadata
Monday, August 28, 2006 at 2:01PM
I received a lot of JPEG images taken by multiple cameras at my daughter's birthday party. My first thought was to import them in to Aperture as a birthday album. Unfortunately, these images contained incorrect capture dates preventing me from organized them in chronological order.
Digital cameras have a clock and store the capture date and time as metadata in the JPEG image. The clock must be set correctly for images from multiple sources to be organized in the order in which they were taken.
To have all of the pictures of the birthday party together in chronological order, I had to:
Digital cameras have a clock and store the capture date and time as metadata in the JPEG image. The clock must be set correctly for images from multiple sources to be organized in the order in which they were taken.
To have all of the pictures of the birthday party together in chronological order, I had to:
- Separate all pictures taken by a specific camera by folder
- Perform the following for each folder:
- Estimate the date and time of one of the pictures taken
- Use jhead, a EXIF command-line utility, David found to fix the metadata
- Use the –da switch to specify the actual and recorded date and time
- Execute for all JPEG images (*.JPG)
- Import the pictures in to Aperture.
- Compare the pictures to others with the correct date and time.
- If the images don't line up correctly, delete them, and start over again with a better estimate.
