/// <summary>
        /// Notifies all of the listeners that the specified node and all of its children need to be invalidated.
        /// </summary>
        /// <param name="parent">The parent node that needs to be invalidated.</param>
        public void OnInvalidateItems(Node parent)
        {
            Tracer.VerifyNonNullArgument(parent, "parent");

            // Let all of our listeners know that the hierarchy needs to be refreshed.
            Tracer.WriteLine(classType, "OnInvalidateItems", Tracer.Level.Information, "Notifying all of our listeners that the hierarchy needs to be refreshed from '{0}'.", parent.Caption);

            // There are some cases where the collection is changed while we're iterating it.
            // To be safe, we'll create a copy of the collection and iterate over that.
            // We just want a shallow copy, though, and not a deep (Clone) copy.
            ArrayList clone = new ArrayList(this.Values);
            foreach (IVsHierarchyEvents eventItem in clone)
            {
                try
                {
                    eventItem.OnInvalidateItems(parent.HierarchyId);
                }
                catch (Exception e)
                {
                    Tracer.WriteLine(classType, "OnInvalidateItems", Tracer.Level.Warning, "There was an exception in one of the listener's event handling code: {0}", e.ToString());
                }
            }
        }
示例#2
0
        private int QuerySingleStatusCommand(Node node, Guid commandGroup, uint command, out uint commandFlags)
        {
            int hr = NativeMethods.S_OK;
            CommandStatus commandStatus = CommandStatus.NotSupportedOrEnabled;

            if (commandGroup == VsMenus.StandardCommandSet97)
            {
                VsCommand vsCommand = (VsCommand)command;
                if (node != null)
                {
                    commandStatus = node.QueryStandard97CommandStatus(vsCommand);
                }
                Tracer.WriteLine(classType, "QuerySingleStatusCommand", Tracer.Level.Verbose, "Command '{0}' is {1} on item {2}", vsCommand, commandStatus, node);
            }
            else if (commandGroup == VsMenus.StandardCommandSet2K)
            {
                VsCommand2K command2K = (VsCommand2K)command;
                if (node != null)
                {
                    commandStatus = node.QueryStandard2KCommandStatus(command2K);
                }
                Tracer.WriteLine(classType, "QuerySingleStatusCommand", Tracer.Level.Verbose, "Command '{0}' is {1} on item {2}", command2K, commandStatus, node);
            }
            else
            {
                hr = NativeMethods.OLECMDERR_E_UNKNOWNGROUP;
                Tracer.WriteLine(classType, "QuerySingleStatusCommand", Tracer.Level.Verbose, "Command group {0} is not supported on item {1}.", commandGroup.ToString("B"), node);
            }

            if (commandStatus == CommandStatus.Unhandled)
            {
                commandStatus = CommandStatus.NotSupportedOrEnabled;
                hr = NativeMethods.OLECMDERR_E_NOTSUPPORTED;
            }
            commandFlags = unchecked((uint)commandStatus);
            return hr;
        }
示例#3
0
        protected virtual bool ExecuteStandard97Command(Node node, VsCommand command)
        {
            Tracer.VerifyNonNullArgument(node, "node");

            // Give the node first dibs on executing the command.
            bool supported = node.ExecuteStandard97Command(command);
            Tracer.WriteLineIf(classType, "ExecuteStandard97Command", Tracer.Level.Verbose, !supported, "Not executing the command '{0}'", command);
            return supported;
        }
示例#4
0
 public void OnPropertyChanged(Node node, __VSHPROPID propertyId)
 {
     // Let all of our listeners know that an item was changed.
     this.eventListeners.OnPropertyChanged(node, propertyId);
 }
示例#5
0
 public void OnItemDeleted(Node node)
 {
     // Let all of our listeners know that an item was deleted.
     this.eventListeners.OnItemDeleted(node);
     // Refresh the hierarchy display.
     this.OnInvalidateItems(node.Parent);
 }
示例#6
0
 public void OnInvalidateItems(Node parent)
 {
     if (parent == null)
     {
         parent = this.RootNode;
     }
     this.eventListeners.OnInvalidateItems(parent);
 }
        /// <summary>
        /// Notifies all of our event listeners that an item in the hierarchy has changed.
        /// </summary>
        /// <param name="node">The <see cref="Node"/> that has changed.</param>
        /// <param name="propertyId">The property that has changed.</param>
        public void OnPropertyChanged(Node node, __VSHPROPID propertyId)
        {
            Tracer.VerifyNonNullArgument(node, "node");

            object newValue;
            node.GetProperty(propertyId, out newValue);

            // There are some cases where the collection is changed while we're iterating it.
            // To be safe, we'll create a copy of the collection and iterate over that.
            // We just want a shallow copy, though, and not a deep (Clone) copy.
            ArrayList clone = new ArrayList(this.Values);
            for (int i = 0; i < clone.Count; i++)
            {
                IVsHierarchyEvents eventItem = (IVsHierarchyEvents)clone[i];
                Tracer.WriteLineVerbose(classType, "OnPropertyChanged", "Notifying event listener {0} that '{1}' has changed its {2} property to '{3}'.", this.CookieOf(i), node.Caption, propertyId, newValue);
                try
                {
                    eventItem.OnPropertyChanged(node.HierarchyId, (int)propertyId, 0);
                }
                catch (Exception e)
                {
                    Tracer.WriteLineWarning(classType, "OnPropertyChanged", "There was an exception in the event listener {0} event handling code: {1}", this.CookieOf(i), e.ToString());
                }
            }
        }
        /// <summary>
        /// Notifies all of the registered listeners that a node was removed from the hierarchy.
        /// </summary>
        /// <param name="node">The node that was removed.</param>
        public void OnItemDeleted(Node node)
        {
            Tracer.VerifyNonNullArgument(node, "node");

            // Let all of our listeners know that an item was deleted.
            Tracer.WriteLine(classType, "OnItemDeleted", Tracer.Level.Information, "Notifying all of our listeners that '{0}' was removed from the hierarchy.", node.Caption);

            // There are some cases where the collection is changed while we're iterating it,
            // for example when the project node is removed. To be safe, we'll create a copy
            // of the collection and iterate over that. We just want a shallow copy, though,
            // and not a deep (Clone) copy.
            ArrayList clone = new ArrayList(this.Values);
            foreach (IVsHierarchyEvents eventItem in clone)
            {
                try
                {
                    eventItem.OnItemDeleted(node.HierarchyId);
                }
                catch (Exception e)
                {
                    Tracer.WriteLine(classType, "OnItemDeleted", Tracer.Level.Warning, "There was an exception in one of the listener's event handling code: {0}", e.ToString());
                }
            }
        }
        /// <summary>
        /// Notifies all of the registered listeners that a node was added to the hierarchy.
        /// </summary>
        /// <param name="node">The node that was added.</param>
        public void OnItemAdded(Node node)
        {
            Tracer.VerifyNonNullArgument(node, "node");

            // Let all of our listeners know that an item was added.
            Tracer.WriteLine(classType, "OnItemAdded", Tracer.Level.Information, "Notifying all of our listeners that '{0}' was added to the hierarchy.", node.Caption);

            // There are some cases where the collection is changed while we're iterating it.
            // To be safe, we'll create a copy of the collection and iterate over that.
            // We just want a shallow copy, though, and not a deep (Clone) copy.
            ArrayList clone = new ArrayList(this.Values);
            foreach (IVsHierarchyEvents eventItem in clone)
            {
                uint parentId = (node.Parent != null ? node.Parent.HierarchyId : NativeMethods.VSITEMID_NIL);
                uint previousSiblingId = (node.PreviousSibling != null ? node.PreviousSibling.HierarchyId : NativeMethods.VSITEMID_NIL);
                uint nodeId = node.HierarchyId;
                try
                {
                    eventItem.OnItemAdded(parentId, previousSiblingId, nodeId);
                }
                catch (Exception e)
                {
                    Tracer.WriteLine(classType, "OnItemAdded", Tracer.Level.Warning, "There was an exception in one of the listener's event handling code: {0}", e.ToString());
                }
            }
        }
示例#10
0
 //==========================================================================================
 // Constructors
 //==========================================================================================
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeProperties"/> class.
 /// </summary>
 protected NodeProperties(Node node)
 {
     Tracer.VerifyNonNullArgument(node, "node");
     this.node = node;
 }