예제 #1
0
        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);
        }
예제 #2
0
 public bool goUp()
 {
     if (rootItem.getParent != null)
     {
         rootItem = rootItem.getParent;
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }
예제 #5
0
 public bool goUp()
 {
     if (rootItem.getParent != null)
     {
         rootItem = rootItem.getParent;
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #6
0
 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();
     }
 }
예제 #7
0
 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;
 }
예제 #8
0
        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);
        }
예제 #9
0
 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();
     }
 }
예제 #10
0
        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);
        }
예제 #11
0
 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;
 }
예제 #12
0
        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;
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
        }
예제 #16
0
 public void cut(FSItem item)
 {
     Console.WriteLine(String.Format("FMC cut '{0}'", item.getName));
     buffer  = item;
     cutFlag = true;
 }
예제 #17
0
        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();
        }
예제 #18
0
 public void copy(FSItem item)
 {
     Console.WriteLine(String.Format("FMC copy '{0}'", item.getName));
     buffer  = item;
     cutFlag = false;
 }
예제 #19
0
 public History(FSItem rootItem)
 {
     this.rootItem = rootItem;
 }
예제 #20
0
 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;
 }
예제 #21
0
 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;
 }
예제 #22
0
 public bool unExecute(FSItem item)
 {
     return(history.enter(item.getParent));
 }
예제 #23
0
 public bool execute(FSItem item)
 {
     return(history.goUp());
 }
예제 #24
0
 public bool unExecute(FSItem item)
 {
     return history.enter(item);
 }
예제 #25
0
 public bool unExecute(FSItem item)
 {
     throw new Exception("Trying to unPaste");
 }
예제 #26
0
 public void copy(FSItem item)
 {
     Console.WriteLine(String.Format("FMC copy '{0}'", item.getName));
     buffer = item;
     cutFlag = false;
 }
예제 #27
0
 public void cut(FSItem item)
 {
     Console.WriteLine(String.Format("FMC cut '{0}'", item.getName));
     buffer = item;
     cutFlag = true;
 }
예제 #28
0
 public History(FSItem rootItem)
 {
     this.rootItem = rootItem;
 }
예제 #29
0
 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();
     }
 }
예제 #30
0
 public bool unExecute(FSItem item)
 {
     throw new Exception("Trying to unDelete");
 }
예제 #31
0
 public bool execute(FSItem item)
 {
     return history.goUp();
 }
예제 #32
0
 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();
     }
 }
예제 #33
0
 public bool execute(FSItem item)
 {
     return history.paste(item);
 }
예제 #34
0
        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;
        }
예제 #35
0
 public bool execute(FSItem item)
 {
     return(history.enter(item));
 }
예제 #36
0
 public void addItem(FSItem item)
 {
     items.Add(item);
 }
예제 #37
0
 public void addItem(FSItem item)
 {
     items.Add(item);
 }
예제 #38
0
 public bool execute(FSItem item)
 {
     return(history.delete(item));
 }