コード例 #1
0
        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;
        }
コード例 #2
0
		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;
			}
		}
コード例 #3
0
		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);
				}
			}
		}
コード例 #4
0
		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;
				}
			}
		}
コード例 #5
0
        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;
                }
            }
        }
コード例 #6
0
ファイル: NativeShell.cs プロジェクト: nmoschkin/DataTools5
 public static extern uint SHChangeNotifyRegister(IntPtr windowHandle, ShellChangeNotifyEventSource sources, ShellObjectChangeTypes events, uint message, int entries, ref SHChangeNotifyEntry changeNotifyEntry);
コード例 #7
0
 internal static extern uint SHChangeNotifyRegister(
     IntPtr windowHandle,
     ShellChangeNotifyEventSource sources,
     ShellObjectChangeTypes events,
     uint message,
     int entries,
     ref SHChangeNotifyEntry changeNotifyEntry);