private int h_countFiles(AbstractFolder abstractFolder) { abstractFolder.AbstractOpen(); return abstractFolder.FilesList.Count + abstractFolder.DirectoriesList.Sum(innerFolder => h_countFiles(innerFolder)); }
public override void AbstractReplace(AbstractFolder inDirectory) { // нет упрощенного перемещения для архивных файлов, оставляем только обобщенный код var abstractFile = inDirectory.AbstractCreateFile(AbstractName); AbstractCopy(abstractFile); AbstractRemove(); }
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; } }
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(); } }
public override void AbstractReplace(AbstractFolder nodeElement) { if (nodeElement is Folder) Directory.Move(AbstractPath, nodeElement.AbstractPath); else { foreach (var progressInfo in AbstractCopy(nodeElement)) { } AbstractRemove(); } }
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); }
public abstract void AbstractReplace(AbstractFolder nodeElement);
public abstract void AbstractReplace(AbstractFolder inDirectory);
public override void AbstractReplace(AbstractFolder inDirectory) { var abstractFolder = inDirectory.AbstractCreateFolder(AbstractName); AbstractCopy(abstractFolder); AbstractRemove(); }
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; } } }
private void cmbDrives_SelectedValueChanged(object sender, EventArgs e) { ActiveDirectory = new Folder(cmbDrives.Text); }
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); } }