Example #1
0
        private void OnChangeNotifierNotify(object sender, ChangeNotifyEventArgs e)
        {
            // get our equivalent item
            if (e.FileSystemPath1 != null)
            {
                // is it really about us?
                if (e.FileSystemPath1.StartsWith(RootPath, StringComparison.OrdinalIgnoreCase))
                {
                    // get relative path and normalize a bit
                    var relPath = IOUtilities.PathRemoveStartSlash(e.FileSystemPath1.Substring(RootPath.Length));
                    switch (e.Event)
                    {
                    case SHCNE.SHCNE_DELETE:
                    case SHCNE.SHCNE_CREATE:
                    case SHCNE.SHCNE_RMDIR:
                    case SHCNE.SHCNE_MKDIR:
                        // we need to get the path's parent, because the path points to an item that doesn't exist or was deleted
                        relPath = Path.GetDirectoryName(relPath);
                        break;
                    }

                    var item = RootPhysical.ParseItem(relPath);
                    if (item != null)
                    {
                        // note we could be smarter and handle event one by one
                        item.NotifyUpdate();
                    }
                }
            }
        }
Example #2
0
		void Params_ObjectChanged(object sender, ChangeNotifyEventArgs e)
		{
			OnObjectChanged(new ObjectChangeNotifyEventArgs(this, ChangeNotifyAction.ObjectChange, e.SourceArgs ?? e,
																																																					"Params", sender, null));
		}
Example #3
0
		//-------------------------------------------------------------------------------------
		void Object_ObjectChanging(object sender, ChangeNotifyEventArgs e)
		{
			OnObjectChanging(new ObjectChangeNotifyEventArgs(this,	ChangeNotifyAction.ObjectChange,	e.SourceArgs ?? e,
				 																																															"Object",		sender,	null));
		}
Example #4
0
		void Binder_ObjectChanged(object sender, ChangeNotifyEventArgs args)
		{
			if(isBindOff == false && args.Action == ChangeNotifyAction.ObjectReset)
			{
				RefreshInternal();
				OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0));
			}
		}
Example #5
0
		//-------------------------------------------------------------------------------------
		void Binder_ObjectChanging(object sender, ChangeNotifyEventArgs args)
		{
			//if(isBindOff == false)
			// BindOff();
		}
        private void OnChangeNotifierNotify(object sender, ChangeNotifyEventArgs e)
        {
            // get our equivalent item
            if (e.FileSystemPath1 != null)
            {
                // is it really about us?
                if (e.FileSystemPath1.StartsWith(RootPath, StringComparison.OrdinalIgnoreCase))
                {
                    // get relative path and normalize a bit
                    var relPath1 = IOUtilities.PathRemoveStartSlash(e.FileSystemPath1.Substring(RootPath.Length));

                    // build a PIDL corresponding to our namespace from a file system path (not in our namespace)
                    // and get/update the corresponding ShellItem from the cache, if it exists.
                    ShellItem       item;
                    ShellItemIdList idl;
                    switch (e.Event)
                    {
                    case SHCNE.SHCNE_DELETE:
                    case SHCNE.SHCNE_RMDIR:
                        idl  = ShellItemIdList.FromFileSystem(RootPhysical.IdList, relPath1, e.Event == SHCNE.SHCNE_RMDIR ? FileAttributes.Directory : FileAttributes.Normal);
                        item = Server.GetFromCache(idl);
                        if (item != null)
                        {
                            item.NotifyDelete();
                            Server.RemoveFromCache(item.IdList);
                        }
                        break;

                    case SHCNE.SHCNE_RENAMEFOLDER:
                    case SHCNE.SHCNE_RENAMEITEM:
                        idl  = ShellItemIdList.FromFileSystem(RootPhysical.IdList, relPath1, e.Event == SHCNE.SHCNE_RENAMEFOLDER ? FileAttributes.Directory : FileAttributes.Normal);
                        item = Server.GetFromCache(idl);
                        if (item != null)
                        {
                            Server.RemoveFromCache(item.IdList);
                        }

                        // 1 is previous, 2 is new
                        var relPath2 = IOUtilities.PathRemoveStartSlash(e.FileSystemPath2.Substring(RootPath.Length));
                        var idl2     = ShellItemIdList.FromFileSystem(RootPhysical.IdList, relPath2, e.Event == SHCNE.SHCNE_RENAMEFOLDER ? FileAttributes.Directory : FileAttributes.Normal);
                        ShellUtilities.ChangeNotify(e.Event, 0, idl, idl2);
                        break;

                    case SHCNE.SHCNE_UPDATEITEM:
                    case SHCNE.SHCNE_UPDATEDIR:
                        idl  = ShellItemIdList.FromFileSystem(RootPhysical.IdList, relPath1, e.Event == SHCNE.SHCNE_UPDATEDIR ? FileAttributes.Directory : FileAttributes.Normal);
                        item = Server.GetFromCache(idl);
                        if (item != null)
                        {
                            item.NotifyUpdate();
                        }
                        break;

                    case SHCNE.SHCNE_CREATE:
                    case SHCNE.SHCNE_MKDIR:
                        idl  = ShellItemIdList.FromFileSystem(RootPhysical.IdList, relPath1, e.Event == SHCNE.SHCNE_MKDIR ? FileAttributes.Directory : FileAttributes.Normal);
                        item = Server.GetFromCache(idl);
                        if (item != null)     // item should in general be null (creation)
                        {
                            item.NotifyCreate();
                        }
                        else
                        {
                            ShellUtilities.ChangeNotify(e.Event, 0, idl);
                        }
                        break;
                    }
                }
            }
        }