Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     rootFolder = LoadConfig();
     if (!IsPostBack) {
       Session["CurrentPath"] = "\\";
       Refresh();
     }
     FeedLink.NavigateUrl = "RecentItemFeed.svc/feed"; // ConfigurationSettings.AppSettings["FeedURL"];
 }
Пример #2
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dialog = new OpenFileDialog()) {
            if (dialog.ShowDialog() == DialogResult.OK) {
              using (Stream stream = new DeflateStream(File.OpenRead(dialog.FileName), CompressionMode.Decompress)) {
            BinaryFormatter formatter = new BinaryFormatter();
            sourceFolder = (Metafolder)formatter.Deserialize(stream);
            destinationFolder = (Metafolder)formatter.Deserialize(stream);

            RefreshSourceTree();
            RefreshDestinationTree();
              }
            }
              }
        }
Пример #3
0
        private void ScanButton_Click(object sender, RoutedEventArgs e)
        {
            Stopwatch timer = new Stopwatch();
              ScanEngine engine = new ScanEngine();
              engine.Path = PathText.Text;

              timer.Start();
              engine.Execute();
              timer.Stop();
              StatusLabel.Content = "Scan took " + timer.Elapsed.ToString();

              sourceFolder = engine.Folder;
              destinationFolder = new Metafolder() { SourcePath = sourceFolder.SourcePath };

              FolderTree.ItemsSource = sourceFolder.Metafolders;
        }
Пример #4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Stopwatch timer = new Stopwatch();
              ScanEngine engine = new ScanEngine();
              engine.Path = pathText.Text;

              timer.Start();
              engine.Execute();
              timer.Stop();
              statusLabel.Text = "Scan took " + timer.Elapsed.ToString();

              sourceFolder.Metafolders.Add(engine.Folder);
              destinationFolder = new Metafolder() { SourcePath = sourceFolder.SourcePath };

              RefreshSourceTree();
              RefreshDestinationTree();
        }
Пример #5
0
    void Refresh()
    {
        currentFolder = rootFolder;
        string[] folderParts = ((string)Session["CurrentPath"]).Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < folderParts.Length; i++) {
          currentFolder = currentFolder.GetFolders().Find(
        folder => folder.Name == folderParts[i]
          );
        }

        List<Metafolder> folders = currentFolder.GetFolders();
        List<FileInfo> files = currentFolder.GetFiles();

        PageTitle.Text = currentFolder.Name;
        FolderInfoLabel.Text = "";
        if (folders.Count != 0) FolderInfoLabel.Text = String.Format("{0} folder{1}",
          folders.Count, folders.Count == 1 ? "" : "s");
        if (files.Count != 0) FolderInfoLabel.Text = String.Format("{0}{1}{2} file{3}",
          FolderInfoLabel.Text, FolderInfoLabel.Text == "" ? "" : ", ", files.Count,
          files.Count == 1 ? "" : "s");

        PhysicalFolderList.DataSource = currentFolder.Folders;
        PhysicalFolderList.DataBind();

        folders.Sort((a, b) => String.Compare(a.Name, b.Name));

        FolderCell.Visible = folders.Count > 0;
        FolderView.Visible = folders.Count > 0;
        FolderView.DataSource = folders;
        FolderView.DataBind();

        files.Sort((a, b) => String.Compare(a.Name, b.Name));

        FileView.DataSource = files;
        FileView.DataBind();
    }
Пример #6
0
        void Process(Metafolder folder, TreeNode node)
        {
            node.ImageIndex = 0;
              sourceMap.Add(node, folder);

              foreach (Metafolder childFolder in folder.Metafolders)
            Process(childFolder, node.Nodes.Add(childFolder.Name));
              foreach (MetaFile file in folder.Metafiles) {
            sourceMap.Add(node.Nodes.Add(file.Name, file.Name, 1, 1), file);
              }
        }
Пример #7
0
 private void RefreshTree(Metafolder folder, TreeView treeView)
 {
     treeView.BeginUpdate();
       treeView.Nodes.Clear();
       Process(folder, treeView.Nodes.Add(folder.SourcePath));
       treeView.EndUpdate();
 }
Пример #8
0
        private void Process(Metafolder folder)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(folder.SourcePath);

              try {
            foreach (DirectoryInfo childDir in dirInfo.GetDirectories()) {
              Metafolder childFolder = new Metafolder();
              childFolder.SourcePath = childDir.FullName;
              Process(childFolder);
              folder.Metafolders.Add(childFolder);
            }
            folder.Metafolders.OrderBy(x => x.Name);
              } catch (Exception ex) {
              }

              try {
            foreach (FileInfo fileInfo in dirInfo.GetFiles())
              folder.Metafiles.Add(new MetaFile() { SourcePath = fileInfo.FullName, Size = fileInfo.Length });
            folder.Metafiles.OrderBy(x => x.Name);
              } catch (Exception ex) {
              }
        }
Пример #9
0
        public List<Metafolder> GetFolders()
        {
            Dictionary<string, Metafolder> folderMerge = new Dictionary<string, Metafolder>(StringComparer.InvariantCultureIgnoreCase);

              foreach (DirectoryInfo folder in folders) {
            foreach (DirectoryInfo subfolder in folder.GetDirectories()) {
              if ((subfolder.Attributes & FileAttributes.Hidden) == 0) {
            Metafolder childFolder;
            if (folderMerge.TryGetValue(subfolder.Name, out childFolder))
              childFolder.Folders.Add(subfolder);
            else
              folderMerge.Add(subfolder.Name, childFolder = new Metafolder(subfolder));
              }
            }
              }

              foreach (Metafolder Metafolder in Metafolders) {
            Metafolder childFolder;
            if (folderMerge.TryGetValue(Metafolder.Name, out childFolder)) {
              foreach (DirectoryInfo dirInfo in Metafolder.Folders)
            if ((dirInfo.Attributes & FileAttributes.Hidden) == 0)
              childFolder.Folders.Add(dirInfo);
            } else
              folderMerge.Add(Metafolder.Name, Metafolder);
              }

              return new List<Metafolder>(folderMerge.Values);
        }
Пример #10
0
 public static Metafolder LoadFromXml(XmlElement element)
 {
     Metafolder result = new Metafolder();
       result.Name = element.GetAttribute("Name");
       foreach (XmlElement folderElement in element.SelectNodes("Folder"))
     result.Folders.Add(new System.IO.DirectoryInfo(folderElement.GetAttribute("Path")));
       foreach (XmlElement MetafolderElement in element.SelectNodes("Metafolder"))
     result.Metafolders.Add(Metafolder.LoadFromXml(MetafolderElement));
       return result;
 }