示例#1
0
        private int h_countFiles(AbstractFolder abstractFolder)
        {
            abstractFolder.AbstractOpen();

            return abstractFolder.FilesList.Count +
              abstractFolder.DirectoriesList.Sum(innerFolder => h_countFiles(innerFolder));
        }
示例#2
0
 public override void AbstractReplace(AbstractFolder inDirectory)
 {
     // нет упрощенного перемещения для архивных файлов, оставляем только обобщенный код
     var abstractFile = inDirectory.AbstractCreateFile(AbstractName);
     AbstractCopy(abstractFile);
     AbstractRemove();
 }
示例#3
0
        public IEnumerable<ProgressInfo> AbstractCopy(AbstractFolder nodeElement)
        {
            var count = h_countFiles(this);

            var progressInfo = new ProgressInfo
            {
                All = count
            };

            Directory.CreateDirectory(nodeElement.AbstractPath);

            foreach (var item in FilesList)
            {
                var destination = nodeElement.AbstractCreateFile(item.AbstractName);
                item.AbstractCopy(destination);
                progressInfo.Current++;

                yield return progressInfo;
            }
            foreach (var item in DirectoriesList)
            {
                var createdFolder = nodeElement.AbstractCreateFolder(item.AbstractName);
                foreach (var innerItem in item.AbstractCopy(createdFolder))
                {
                    yield return innerItem;
                }
                progressInfo.Current++;

                yield return progressInfo;
            }
        }
示例#4
0
 public override void AbstractReplace(AbstractFolder inDirectory)
 {
     if (inDirectory is Folder)
         System.IO.File.Move(AbstractPath, Path.Combine(inDirectory.AbstractPath, AbstractName));
     else
     {
         var abstractFile = inDirectory.AbstractCreateFile(AbstractName);
         AbstractCopy(abstractFile);
         AbstractRemove();
     }
 }
示例#5
0
        public override void AbstractReplace(AbstractFolder nodeElement)
        {
            if (nodeElement is Folder)
                Directory.Move(AbstractPath, nodeElement.AbstractPath);
            else
            {
                foreach (var progressInfo in AbstractCopy(nodeElement))
                {

                }
                AbstractRemove();
            }
        }
示例#6
0
        public LvKontrol(IContainer container)
        {
           
            container.Add(this);

            InitializeComponent();
            toolTip1.SetToolTip(btnBack, "Назад");
            lsvPanel.View = View.Details;
            lsvPanel.Columns.Add("Имя");
            lsvPanel.Columns.Add("Размер");
            lsvPanel.Columns.Add("Дата создания");
            lsvPanel.Columns.Add("Дата изменения");
            lsvPanel.Columns.Add("Дата последнего доступа");

            cmbDrives.Items.AddRange(Environment.GetLogicalDrives());
            cmbDrives.SelectedIndex = 0;
            cmbDrives.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

            ActiveDirectory = new Folder(cmbDrives.Text);            
            
        }
示例#7
0
 public abstract void AbstractReplace(AbstractFolder nodeElement);
示例#8
0
 public abstract void AbstractReplace(AbstractFolder inDirectory);
示例#9
0
 public override void AbstractReplace(AbstractFolder inDirectory)
 {
     var abstractFolder = inDirectory.AbstractCreateFolder(AbstractName);
     AbstractCopy(abstractFolder);
     AbstractRemove();
 }
示例#10
0
        private void lsvPanel_DoubleClick(object sender, EventArgs e)
        {
            if (lsvPanel.SelectedIndices.Count != 1)
                return;

            var clickedItem = lsvPanel.Items[lsvPanel.SelectedIndices[0]].SubItems[0].Text;
           

            foreach (var item in ActiveDirectory.DirectoriesList.Where(item => item.AbstractName == clickedItem))
            {
                ActiveDirectory = item;
               
                break;
            }

            foreach (var item in ActiveDirectory.FilesList.Where(item => item.AbstractName == clickedItem))
            {
                if (item.AbstractName.EndsWith(@".zip"))
                {
                    ActiveDirectory = new ArchiveFolder(item.AbstractPath, "");
                }
                else
                {
                    item.AbstractOpen();
                    break;
                }
            }
        }
示例#11
0
 private void cmbDrives_SelectedValueChanged(object sender, EventArgs e)
 {
     ActiveDirectory = new Folder(cmbDrives.Text);
 }
示例#12
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            if (ActiveDirectory.AbstractPath.EndsWith(@".zip"))
            {
                var af = (ArchiveFolder)ActiveDirectory;                
                string backPath;

                if (af.InnerPath == "")
                {
                    backPath = af.AbstractPath.Substring(0, af.AbstractPath.LastIndexOf(@"\", StringComparison.Ordinal));

                    if (backPath.Length == 2)
                        backPath += @"\";

                    ActiveDirectory = new Folder(backPath);
                }
                else
                {
                    backPath = af.InnerPath.IndexOf(@"/", StringComparison.Ordinal) == -1 ? "" :
                    af.InnerPath.Substring(0, af.InnerPath.LastIndexOf(@"/", af.InnerPath.Length - 2, StringComparison.Ordinal) + 1);

                    ActiveDirectory = new ArchiveFolder(ActiveDirectory.AbstractPath, backPath);
                }
            }
            else
            {
                var backPath = ActiveDirectory.AbstractPath.Substring(0, ActiveDirectory.AbstractPath.LastIndexOf(@"\", StringComparison.Ordinal));

                if (backPath.Length == 2)
                    backPath += @"\";

                ActiveDirectory = new Folder(backPath);
            }
        }