Example #1
0
        /// <summary>
        /// Called when a project item is removed.
        /// </summary>
        /// <param name="item">The item.</param>
        public virtual void OnProjectItemRemoved(ProjectItem item)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "OnProjectItemRemoved fired for: {0}", this.ToString()));
            _dispProjectItemsEvents_ItemRemovedEventHandler projectitemRemovedHandler = this.ProjectItemRemoved;

            if (projectitemRemovedHandler != null)
            {
                projectitemRemovedHandler(item);
            }
        }
Example #2
0
        private bool RemoveFilesHandlersInstalled => _itemRemovedEventHandler != null || _projectRemovedEventHandler != null; // second conditional is useless but kept for clarity

        private void RegisterEvents(object sender = null, EventArgs e = null)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            if (((Config)m_plugin.Options).AutoAdd)
            {
                if (!AddFilesHandlersInstalled)
                {
                    Log.Info("Adding handlers to automatically add files to perforce as you add them to the project");
                    _itemAddedEventHandler     = new _dispProjectItemsEvents_ItemAddedEventHandler(OnItemAdded);
                    m_projectEvents.ItemAdded += _itemAddedEventHandler;

                    _projectAddedEventHandler      = new _dispSolutionEvents_ProjectAddedEventHandler(OnProjectAdded);
                    m_solutionEvents.ProjectAdded += _projectAddedEventHandler;
                }
            }
            else if (AddFilesHandlersInstalled)
            {
                Log.Info("Removing handlers to automatically add files to perforce as you add them to the project");
                m_projectEvents.ItemAdded -= _itemAddedEventHandler;
                _itemAddedEventHandler     = null;

                m_solutionEvents.ProjectAdded -= _projectAddedEventHandler;
                _projectAddedEventHandler      = null;
            }

            if (((Config)m_plugin.Options).AutoDelete)
            {
                if (!RemoveFilesHandlersInstalled)
                {
                    Log.Info("Adding handlers to automatically delete files from perforce as you remove them from the project");
                    _itemRemovedEventHandler     = new _dispProjectItemsEvents_ItemRemovedEventHandler(OnItemRemoved);
                    m_projectEvents.ItemRemoved += _itemRemovedEventHandler;

                    _projectRemovedEventHandler      = new _dispSolutionEvents_ProjectRemovedEventHandler(OnProjectRemoved);
                    m_solutionEvents.ProjectRemoved += _projectRemovedEventHandler;
                }
            }
            else if (RemoveFilesHandlersInstalled)
            {
                Log.Info("Removing handlers to automatically deleting files from perforce as you remove them from the project");
                m_projectEvents.ItemRemoved -= _itemRemovedEventHandler;
                _itemRemovedEventHandler     = null;

                m_solutionEvents.ProjectRemoved -= _projectRemovedEventHandler;
                _projectRemovedEventHandler      = null;
            }
        }
        public static void BindEvents(DTE2 application)
        {
            if (_events != null)
                return;

            _application = application;
            var letsDoTheMSCastBoogie = (Events2)_application.Events;
            _events = letsDoTheMSCastBoogie.ProjectItemsEvents;
            _solutionEvents = _application.Events.SolutionItemsEvents;
            _added = new _dispProjectItemsEvents_ItemAddedEventHandler(_events_ItemAdded);
            _deleted = new _dispProjectItemsEvents_ItemRemovedEventHandler(_events_ItemRemoved);
            _renamed = new _dispProjectItemsEvents_ItemRenamedEventHandler(_events_ItemRenamed);
            _events.ItemAdded += _added;
            _events.ItemRemoved += _deleted;
            _events.ItemRenamed += _renamed;
            //_solutionEvents.ItemAdded += _added;
            //_solutionEvents.ItemRemoved += _deleted;
            //_solutionEvents.ItemRenamed += _renamed;
        }
Example #4
0
        public static void BindEvents(DTE2 application)
        {
            if (_events != null)
            {
                return;
            }

            _application = application;
            var letsDoTheMSCastBoogie = (Events2)_application.Events;

            _events              = letsDoTheMSCastBoogie.ProjectItemsEvents;
            _solutionEvents      = _application.Events.SolutionItemsEvents;
            _added               = new _dispProjectItemsEvents_ItemAddedEventHandler(_events_ItemAdded);
            _deleted             = new _dispProjectItemsEvents_ItemRemovedEventHandler(_events_ItemRemoved);
            _renamed             = new _dispProjectItemsEvents_ItemRenamedEventHandler(_events_ItemRenamed);
            _events.ItemAdded   += _added;
            _events.ItemRemoved += _deleted;
            _events.ItemRenamed += _renamed;
            //_solutionEvents.ItemAdded += _added;
            //_solutionEvents.ItemRemoved += _deleted;
            //_solutionEvents.ItemRenamed += _renamed;
        }