private string FormatEvent(ShellObjectChangeTypes changeType, ShellObjectNotificationEventArgs args) { ShellObjectChangedEventArgs changeArgs; ShellObjectRenamedEventArgs renameArgs; SystemImageUpdatedEventArgs imageArgs; string msg; if ((renameArgs = args as ShellObjectRenamedEventArgs) != null) { msg = string.Format("{0}: {1} ==> {2}", changeType, renameArgs.Path, System.IO.Path.GetFileName(renameArgs.NewPath)); } else if ((changeArgs = args as ShellObjectChangedEventArgs) != null) { msg = string.Format("{0}: {1}", changeType, changeArgs.Path); } else if ((imageArgs = args as SystemImageUpdatedEventArgs) != null) { msg = string.Format("{0}: ImageUpdated ==> {1}", changeType, imageArgs.ImageIndex); } else { msg = args.ChangeType.ToString(); } return msg; }
public void Register(ShellObjectChangeTypes changeType, Delegate handler) { Delegate del; if (!_events.TryGetValue(changeType, out del)) { _events.Add(changeType, handler); } else { del = MulticastDelegate.Combine(del, handler); _events[changeType] = del; } }
public void Invoke(object sender, ShellObjectChangeTypes changeType, EventArgs args) { // Removes FromInterrupt flag if pressent changeType = changeType & ~ShellObjectChangeTypes.FromInterrupt; Delegate del; foreach (var change in _changeOrder.Where(x => (x & changeType) != 0)) { if (_events.TryGetValue(change, out del)) { del.DynamicInvoke(sender, args); } } }
public void Unregister(ShellObjectChangeTypes changeType, Delegate handler) { Delegate del; if (_events.TryGetValue(changeType, out del)) { del = MulticastDelegate.Remove(del, handler); if (del == null) // It's a bug in .NET if del is non-null and has an empty invocation list. { _events.Remove(changeType); } else { _events[changeType] = del; } } }
public static extern uint SHChangeNotifyRegister(IntPtr windowHandle, ShellChangeNotifyEventSource sources, ShellObjectChangeTypes events, uint message, int entries, ref SHChangeNotifyEntry changeNotifyEntry);
internal static extern uint SHChangeNotifyRegister( IntPtr windowHandle, ShellChangeNotifyEventSource sources, ShellObjectChangeTypes events, uint message, int entries, ref SHChangeNotifyEntry changeNotifyEntry);