Пример #1
0
 public void FileCopy(string path, string destDirName)
 {
     try
     {
         FileInfo file        = new FileInfo(path);
         string   destination = destDirName;
         file.CopyTo(destination, true);
         if (isCut)
         {
             File.Delete(path);
         }
     }
     catch
     {
         ModuleWindow.ErrorMessage("File copied from this directory!");
     }
 }
        private void Update(ConsoleKeyInfo key, ref int item)
        {
            try
            {
                if (key.Key == ConsoleKey.RightArrow)
                {
                    item++;
                    RenderItems();
                }

                else if (key.Key == ConsoleKey.LeftArrow)
                {
                    item--;
                    RenderItems();
                }

                if (item >= windows.Length)
                {
                    item = 0;
                    RenderItems();
                }

                else if (item < 0)
                {
                    item = windows.Length - 1;
                    RenderItems();
                }

                if (key.Key == ConsoleKey.F1)
                {
                    windows[onFocusedElement].CutItem(false);
                }

                else if (key.Key == ConsoleKey.F2)
                {
                    windows[onFocusedElement].CutItem(true);
                }

                else if (key.Key == ConsoleKey.F3)
                {
                    windows[onFocusedElement].PasteItem();
                }

                else if (key.Key == ConsoleKey.F4)
                {
                    windows[onFocusedElement].GetRoot();
                }

                else if (key.Key == ConsoleKey.F5)
                {
                    windows[onFocusedElement].GetDirectories();
                }

                else if (key.Key == ConsoleKey.F6)
                {
                    windows[onFocusedElement].Properties();
                    RenderItems();
                }

                else if (key.Key == ConsoleKey.F7)
                {
                    if (windows[onFocusedElement].Items.Count == 0)
                    {
                        throw new InvalidOperationException("There is no items");
                    }
                    var newName = ModuleWindow.ReadMessage("Enter new Name:");
                    windows[onFocusedElement].Rename(newName);
                    RenderItems();
                }

                else if (key.Key == ConsoleKey.F8)
                {
                    if (windows[onFocusedElement].Items.Count == 0)
                    {
                        throw new InvalidOperationException("There is no items in this directory");
                    }
                    var name = ModuleWindow.ReadMessage("Enter file name:");
                    windows[onFocusedElement].Find(name);
                    if (windows[onFocusedElement].Items.Count == 0)
                    {
                        throw new InvalidOperationException("File not found(");
                    }
                    RenderItems();
                }

                else if (key.Key == ConsoleKey.F9)
                {
                    var name = ModuleWindow.ReadMessage("Enter new direction name:");
                    windows[onFocusedElement].CreateDirectory(name);
                    RenderItems();
                }

                else if (key.Key == ConsoleKey.Enter)
                {
                    windows[onFocusedElement].Enter();
                }
            }
            catch (Exception ex)
            {
                ModuleWindow.ErrorMessage(ex.Message);
                RenderItems();
            }
        }