Beispiel #1
0
 private static void FillerCallback(CDirectoryEntry rootEntry)
 {
     m_bFillFinished = true;
     m_filledEntry   = rootEntry;
     //m_timer.Start();
     // This is where tree gets filled
 }
Beispiel #2
0
        private static void TraverseInternal(DirectoryInfo dir, ref List <CDirectoryEntry> entry)
        {
            DirectoryInfo[] subDirs  = dir.GetDirectories();
            FileInfo[]      subFiles = dir.GetFiles();

            foreach (DirectoryInfo directory in subDirs)
            {
                var item = new CDirectoryEntry();

                item.Header      = directory.Name;
                item.FullPath    = directory.FullName;
                item.IsDirectory = true;

                TraverseInternal(directory, ref item.SubEntries);


                entry.Add(item);
            }

            foreach (FileInfo file in subFiles)
            {
                var item = new CDirectoryEntry();

                item.Header      = file.Name;
                item.FullPath    = file.FullName;
                item.IsDirectory = false;


                entry.Add(item);
            }
        }
Beispiel #3
0
        private static void TraverseDirectory(object fillOut)
        {
            lock (fillOut)
            {
                CFillerThreadParam param = fillOut as CFillerThreadParam;

                CDirectoryEntry fill = param.rootEntry;

                if (fill != null)
                {
                    DirectoryInfo info = new DirectoryInfo(fill.FullPath);

                    TraverseInternal(info, ref fill.SubEntries);
                }

                param.callBack(fill);
            }
        }
Beispiel #4
0
        static void FillTreeItem(CDirectoryEntry entry, ref DirectoryTreeItem item)
        {
            var newDir = new DirectoryTreeItem();

            newDir.Header      = entry.Header;
            newDir.IsDirectory = entry.IsDirectory;
            newDir.FullPath    = entry.FullPath;
            if (!newDir.IsDirectory)
            {
                if (CSourceTracker.Instance.IsFileTracked(newDir.FullPath))
                {
                    // TODO: Load some fancy icon here!
                    // Also see revisits
                    newDir.Header += " [Tracked]";
                }
            }

            if (entry.IsDirectory)
            {
                foreach (CDirectoryEntry subEntry in entry.SubEntries)
                {
                    FillTreeItem(subEntry, ref newDir);
                }
            }
            else
            {
                newDir.MouseDoubleClick += delegate
                {
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();

                    System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(newDir.FullPath);

                    proc.StartInfo = info;

                    proc.Start();
                };
            }

            item.ToolTip = item.FullPath;
            item.Items.Add(newDir);
            item.ContextMenu = m_viewItemContextMenu;
        }
Beispiel #5
0
        public static void PopulateTreeView(string sRootPath)
        {
            if (!Directory.Exists(sRootPath))
            {
                var empty = new DirectoryTreeItem();
                empty.Header = "Specified path doesn't exist!";                 // LOCALIZE

                m_targetTreeView.Items.Clear();
                m_targetTreeView.Items.Add(empty);
                return;
            }

            DirectoryInfo     dirInfo = new DirectoryInfo(sRootPath);
            DirectoryTreeItem item    = new DirectoryTreeItem();



            /*item.SetName(dirInfo.Name);
             * item.FullPath = dirInfo.FullName;
             * item.IsDirectory = true;
             *
             * item.ContextMenu = m_viewItemContextMenu;
             *
             * //item.MouseRightButtonDown += delegate { item.IsSelected = true; };
             *
             *
             * TraverseDirectory(dirInfo, ref item);
             *
             * m_targetTreeView.Items.Add(item);*/

            if (sRootPath == m_sDirectoryToWatch)
            {
                m_lastSelectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;
            }
            else
            {
                m_lastSelectedItem = null;
            }

            m_bFillFinished = false;

            CDirectoryEntry rootEntry = new CDirectoryEntry();

            rootEntry.Header      = dirInfo.Name;
            rootEntry.FullPath    = dirInfo.FullName;
            rootEntry.IsDirectory = true;

            CFillerThreadParam param = new CFillerThreadParam();

            param.rootEntry = rootEntry;
            param.callBack  = FillerCallback;
            m_timer.Start();

            m_targetTreeView.Items.Clear();

            item.Header = "Loading";
            m_targetTreeView.Items.Add(item);

            Thread filler = new Thread(TraverseDirectory);

            filler.Start(param as object);
        }