public bool paste(FSItem item) { string destinationPath = getFullPath(rootItem) + "\\" + item.getName; string sourcePath = getFullPath(item); if (item.getFolder() == null) { File.Copy(sourcePath, destinationPath); } else { Directory.CreateDirectory(destinationPath); //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePath, destinationPath)); } //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(sourcePath, destinationPath), true); } } return(true); }
public bool goUp() { if (rootItem.getParent != null) { rootItem = rootItem.getParent; return(true); } else { return(false); } }
public void paste(FSItem item) { Console.WriteLine(String.Format("FMC paste '{0}'", item.getName)); buffer = null; cutFlag = false; if (browserControll.execute(pasteID, item, true)) { history.getRootItem.getFolder().addItem(item); } drawInView(); }
private string getFullPath(FSItem item) { string fullPath = item.getName; FSItem tempItem = item; while (tempItem.getParent != null) { fullPath = tempItem.getParent.getName.Trim('\\') + "\\" + fullPath; tempItem = tempItem.getParent; } return(fullPath); }
public bool goUp() { if (rootItem.getParent != null) { rootItem = rootItem.getParent; return true; } else { return false; } }
public void enter(FSItem item) { if (browserControll.execute(enterID, item)) { FSItem newItem = FSScan.inDirectory(item.getParent, address + "\\" + item.getName); item.getFolder().clearChildren(); foreach (FSItem it in newItem.getFolder().getChildren) { item.getFolder().addItem(it); } drawInView(); } }
public bool execute(int commandNumber, FSItem item = null, bool ignoreHistory = false) { bool result = commandList.ElementAt(commandNumber).execute(item); if (result && !ignoreHistory) { executedCommandList.Push(new KeyValuePair<int, FSItem>(commandNumber, item)); return true; } else if (ignoreHistory && result) return true; return false; }
public long size(FSItem item) { Measured measured; if (item.getFolder() == null) { measured = item as Measured; } else { measured = new MDirectoryAdapter(item as MDirectory); } return(measured.getSize); }
public void delete(FSItem item) { if (browserControll.execute(deleteID, item, true)) { FSItem rootItem = FSScan.inDirectory(history.getRootItem.getParent, address); FSItem[] children = rootItem.getFolder().getChildren; history.getRootItem.getFolder().clearChildren(); foreach (FSItem it in children) { history.getRootItem.getFolder().addItem(it); } drawInView(); } }
public bool execute(int commandNumber, FSItem item = null, bool ignoreHistory = false) { bool result = commandList.ElementAt(commandNumber).execute(item); if (result && !ignoreHistory) { executedCommandList.Push(new KeyValuePair <int, FSItem>(commandNumber, item)); return(true); } else if (ignoreHistory && result) { return(true); } return(false); }
public bool delete(FSItem item) { string fullPath = getFullPath(item); if (item.getFolder() != null) { if (!Directory.Exists(fullPath)) throw new DirectoryNotFoundException("Указанная папка не существует: " + item.getName); Directory.Delete(fullPath, true); } else { if (!File.Exists(fullPath)) throw new FileNotFoundException("Указанный файл не существует: " + item.getName , item.getName); File.Delete(fullPath); } return true; }
public bool enter(FSItem item) { if (item.getFolder() != null) { rootItem = item; return true; } else { FSItem tmp = item; string path = tmp.getName; while (tmp.getParent != null) { path = tmp.getParent.getName.Trim('\\') + "\\" + path; tmp = tmp.getParent; } Process.Start(path); return false; } }
public bool enter(FSItem item) { if (item.getFolder() != null) { rootItem = item; return(true); } else { FSItem tmp = item; string path = tmp.getName; while (tmp.getParent != null) { path = tmp.getParent.getName.Trim('\\') + "\\" + path; tmp = tmp.getParent; } Process.Start(path); return(false); } }
private void drawInView() //отрисовка папок и файлов { if (history.getRootItem.getFolder() == null) { throw new Exception("File cannot be a root item"); } FSItem tmp = history.getRootItem; address = tmp.getName; while (tmp.getParent != null) { address = tmp.getParent.getName.Trim('\\') + "\\" + address; tmp = tmp.getParent; } tb.Text = address; lb.Items.Clear(); foreach (FSItem fsItem in history.getRootItem.getFolder().getChildren) { lb.Items.Add(fsItem); } }
public bool delete(FSItem item) { string fullPath = getFullPath(item); if (item.getFolder() != null) { if (!Directory.Exists(fullPath)) { throw new DirectoryNotFoundException("Указанная папка не существует: " + item.getName); } Directory.Delete(fullPath, true); } else { if (!File.Exists(fullPath)) { throw new FileNotFoundException("Указанный файл не существует: " + item.getName, item.getName); } File.Delete(fullPath); } return(true); }
public void cut(FSItem item) { Console.WriteLine(String.Format("FMC cut '{0}'", item.getName)); buffer = item; cutFlag = true; }
public void paste(FSItem item) { Console.WriteLine(String.Format("FMC paste '{0}'", item.getName)); buffer = null; cutFlag = false; if (browserControll.execute(pasteID, item, true)) history.getRootItem.getFolder().addItem(item); drawInView(); }
public void copy(FSItem item) { Console.WriteLine(String.Format("FMC copy '{0}'", item.getName)); buffer = item; cutFlag = false; }
public History(FSItem rootItem) { this.rootItem = rootItem; }
private string getFullPath(FSItem item) { string fullPath = item.getName; FSItem tempItem = item; while (tempItem.getParent != null) { fullPath = tempItem.getParent.getName.Trim('\\') + "\\" + fullPath; tempItem = tempItem.getParent; } return fullPath; }
public long size(FSItem item) { Measured measured; if (item.getFolder() == null) measured = item as Measured; else measured = new MDirectoryAdapter(item as MDirectory); return measured.getSize; }
public bool unExecute(FSItem item) { return(history.enter(item.getParent)); }
public bool execute(FSItem item) { return(history.goUp()); }
public bool unExecute(FSItem item) { return history.enter(item); }
public bool unExecute(FSItem item) { throw new Exception("Trying to unPaste"); }
public void enter(FSItem item) { if (browserControll.execute(enterID, item)) { FSItem newItem = FSScan.inDirectory(item.getParent, address + "\\" + item.getName); item.getFolder().clearChildren(); foreach (FSItem it in newItem.getFolder().getChildren) item.getFolder().addItem(it); drawInView(); } }
public bool unExecute(FSItem item) { throw new Exception("Trying to unDelete"); }
public bool execute(FSItem item) { return history.goUp(); }
public void delete(FSItem item) { if (browserControll.execute(deleteID, item, true)) { FSItem rootItem = FSScan.inDirectory(history.getRootItem.getParent, address); FSItem[] children = rootItem.getFolder().getChildren; history.getRootItem.getFolder().clearChildren(); foreach (FSItem it in children) history.getRootItem.getFolder().addItem(it); drawInView(); } }
public bool execute(FSItem item) { return history.paste(item); }
public bool paste(FSItem item) { string destinationPath = getFullPath(rootItem) + "\\" + item.getName; string sourcePath = getFullPath(item); if(item.getFolder() == null) File.Copy(sourcePath, destinationPath); else { Directory.CreateDirectory(destinationPath); //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) Directory.CreateDirectory(dirPath.Replace(sourcePath, destinationPath)); //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) File.Copy(newPath, newPath.Replace(sourcePath, destinationPath), true); } return true; }
public bool execute(FSItem item) { return(history.enter(item)); }
public void addItem(FSItem item) { items.Add(item); }
public bool execute(FSItem item) { return(history.delete(item)); }