Пример #1
0
        //private void ProjectService_FileRenaming(object sender, SledProjectServiceFileEventArgs e)
        //{
        //    ISledDocument sd = e.File.SledDocument;
        //    if (sd == null)
        //        return;

        //    if (!IsValidDocument(sd))
        //        return;

        //    Remove(sd);
        //}

        //private void ProjectService_FileRenamed(object sender, SledProjectServiceFileEventArgs e)
        //{
        //    ISledDocument sd = e.File.SledDocument;
        //    if (sd == null)
        //        return;

        //    if (!IsValidDocument(sd))
        //        return;

        //    Add(sd);
        //}

        #endregion

        #region Member Methods

        private void Add(ISledDocument sd)
        {
            if (!IsValidDocument(sd))
                return;

            sd.UriChanged += SledDocumentUriChanged;

            if (m_dict.ContainsKey(sd))
                return;

            var watcher =
                new SledFileSystemWatcher
                    {
                        Tag = sd,
                        Path = Path.GetDirectoryName(sd.Uri.LocalPath),
                        Filter = Path.GetFileName(sd.Uri.LocalPath),
                        NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Attributes,
                        SynchronizingObject = m_mainForm
                    };
            watcher.Changed += WatcherChanged;
            watcher.EnableRaisingEvents = true;

            // Add to dictionary
            m_dict[sd] = watcher;
            m_dictFileStats[sd] = SledFileSystemFileStats.GetStats(sd.Uri.LocalPath);
        }
Пример #2
0
        private void Create(SledProjectFilesType project)
        {
            Cleanup();

            var absPath = project.AbsolutePath;

            // Create new file watcher for the project
            m_watcher =
                new SledFileSystemWatcher
                    {
                        Tag = project,
                        Path = Path.GetDirectoryName(absPath),
                        Filter = Path.GetFileName(absPath),
                        NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Attributes,
                        SynchronizingObject = m_mainForm
                    };
            m_watcher.Changed += WatcherChanged;
            m_watcher.EnableRaisingEvents = true;

            // Get initial stats
            m_fileStats = SledFileSystemFileStats.GetStats(absPath);
        }