internal void OpenTracker()
        {
            Debug.WriteLine("==== Open Tracker");
            trackers.Clear();

            var solutionFileName = GetSolutionFileName();

            if (!string.IsNullOrEmpty(solutionFileName))
            {
                monitorFolder = Path.GetDirectoryName(solutionFileName);

                GetLoadedControllableProjects().ForEach(h => AddProject(h as IVsHierarchy));

                if (monitorFolder != lastMinotorFolder)
                {
                    RemoveFolderMonitor();

                    IVsFileChangeEx fileChangeService = _sccProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
                    if (VSConstants.VSCOOKIE_NIL != _vsIVsFileChangeEventsCookie)
                    {
                        fileChangeService.UnadviseDirChange(_vsIVsFileChangeEventsCookie);
                    }
                    fileChangeService.AdviseDirChange(monitorFolder, 1, this, out _vsIVsFileChangeEventsCookie);
                    lastMinotorFolder = monitorFolder;

                    Debug.WriteLine("==== Monitoring: " + monitorFolder + " " + _vsIVsFileChangeEventsCookie);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            IVsFileChangeEx fileChangeService =
                GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;

            monitor = new CSVSMonitorFileChange();
            uint cookie;

            // Enables a client to receive notifications of changes to a directory.
            fileChangeService.AdviseDirChange(

                // String form of the moniker identifier of
                // the directory in the project system.
                Environment.GetFolderPath(
                    Environment.SpecialFolder.Desktop),

                // If true, then events should also be fired
                // for changes to sub directories. If false,
                // then events should not be fired for changes
                // to sub directories.
                Convert.ToInt32(true),

                // IVsFileChangeEvents Interface on the object
                // requesting notification of file change events.
                monitor,

                // Unique identifier for the file that is
                // associated with the event sink.
                out cookie
                );
        }
Exemple #3
0
            public DiffToolMonitor(IAnkhServiceProvider context, string monitor, bool monitorDir, int[] resolvedExitCodes)
                : base(context)
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (string.IsNullOrEmpty(monitor))
                {
                    throw new ArgumentNullException("monitor");
                }
                else if (!SvnItem.IsValidPath(monitor))
                {
                    throw new ArgumentOutOfRangeException("monitor");
                }

                _monitorDir = monitorDir;
                _toMonitor  = monitor;

                IVsFileChangeEx fx = GetService <IVsFileChangeEx>(typeof(SVsFileChangeEx));

                _cookie = 0;
                if (fx == null)
                {
                }
                else if (!_monitorDir)
                {
                    if (!VSErr.Succeeded(fx.AdviseFileChange(monitor,
                                                             (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Size
                                                                    | _VSFILECHANGEFLAGS.VSFILECHG_Add | _VSFILECHANGEFLAGS.VSFILECHG_Del
                                                                    | _VSFILECHANGEFLAGS.VSFILECHG_Attr),
                                                             this,
                                                             out _cookie)))
                    {
                        _cookie = 0;
                    }
                }
                else
                {
                    if (!VSErr.Succeeded(fx.AdviseDirChange(monitor, 1, this, out _cookie)))
                    {
                        _cookie = 0;
                    }
                }

                IAnkhOpenDocumentTracker odt = GetService <IAnkhOpenDocumentTracker>();

                if (odt != null)
                {
                    if (odt.IgnoreChanges(_toMonitor, true))
                    {
                        _odt = odt;
                    }
                }

                if (resolvedExitCodes != null)
                {
                    _resolvedExitCodes = (int[])resolvedExitCodes.Clone();
                }
            }
Exemple #4
0
        private uint Watch(string path)
        {
            if (_changeService == null)
            {
                return(0);
            }

            uint cookie;

            if (ErrorHandler.Succeeded(_changeService.AdviseDirChange(path, 1, this, out cookie)))
            {
                return(cookie);
            }
            return(0);
        }