public static void OnPlinqStatistics(object sender, MainFormEventArgs e)
        {
            TextStatistics           TS            = new TextStatistics(e.Index, e.Item, e.CurrentDir);
            ModelPresenterStatistics mp_statistics = new ModelPresenterStatistics(TS);

            TS.ShowDialog();
        }
 public void OnMouseDoubleClick(object sender, MainFormEventArgs e)
 {
     if (e.Item.Contains(".sys"))
     {
     }
     if (e.Item != "..")
     {
         IEntry selectedEntry = FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item);
         if (selectedEntry is IDirectory)
         {
             currentDirectory = (IDirectory)selectedEntry;
             navigationView.RefreshCurrentDirectoryEntries();
         }
         else // if (selectedEntry is IFile)
         {
             Process.Start(selectedEntry.FullName);
         }
     }
     else
     {
         IEntry selectedEntry = FileFactory.CreateEntry(e.CurrentDir);
         if (selectedEntry is IDirectory)
         {
             currentDirectory = (IDirectory)selectedEntry;
             navigationView.RefreshCurrentDirectoryEntries();
         }
         else // if (selectedEntry is IFile)
         {
             Process.Start(selectedEntry.FullName);
         }
     }
     navigationView.OnDeleted = false;
 }
        public void OnFileInsert(object sender, MainFormEventArgs e)
        {
            try
            {
                if (copySource is MyDirectory)
                {
                    InsertDirectory(new MyDirectory(copySource.FullName), currentDirectory.FullName + @"\" + e.Item + @"\" + copiedEntryName + @"\");
                }
                else
                {
                    InsertFile(new MyFile(copySource.FullName), currentDirectory.FullName + @"\" + e.Item + @"\" + copiedEntryName);
                }
                navigationView.RefreshCurrentDirectoryEntries();
            }
            catch (Exception ex)
            {
                throw new MyException("Ошибка в Insert", new Exception());
            }


            /*
             * if (MyDirectory.Exists(Copied))
             *  InsertFolder(new MyDirectory(Copied), e.CurrentDir + CopyName + @"\");
             * else
             *  InsertFile(new MyFile(Copied), e.CurrentDir + CopyName);
             *
             * OpenedDirectory(e.CurrentDir);*/
        }
        public void OnFileRename(object sender, MainFormEventArgs e)
        {
            View.RenameDeleteForm rd = new View.RenameDeleteForm();
            if (rd.ShowDialog() == DialogResult.OK)
            {
                string newEntry = currentDirectory.FullName + @"\" + rd.txtBoxNewName.Text;
                IEntry oldEntry = FileFactory.CreateEntry(currentDirectory.FullName + @"\");
                if (oldEntry is IDirectory)
                {
                    InsertDirectory((IDirectory)oldEntry, newEntry);
                    MyDirectory.Delete(oldEntry.FullName);
                }
                else
                {
                    InsertFile((IFile)oldEntry, newEntry);
                    MyFile.Delete(oldEntry.FullName);
                }
                navigationView.RefreshCurrentDirectoryEntries();
            }



            /*       string target = e.CurrentDir + e.Item;
             *    if (MyDirectory.Exists(target))
             *         Directory.Move(target, e.CurrentDir + rd.txtBoxNewName.Text);
             *     else
             *         File.Move(target, e.CurrentDir + rd.txtBoxNewName.Text);
             *
             *     rd.Close();
             *     rd = null;
             *     OpenedDirectory(e.CurrentDir);
             *
             */
        }
        public void OnFileDelete(object sender, MainFormEventArgs e)
        {
            View.RenameDeleteForm rd = new View.RenameDeleteForm();
            rd.lblAreUSure.Visible   = true;
            rd.txtBoxNewName.Visible = false;
            rd.LblNewName.Visible    = false;
            rd.lblAreUSure.Font      = new Font("SanSerif", 12, FontStyle.Underline);

            if (rd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    IEntry entry = FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item);
                    if (entry is IDirectory)
                    {
                        MyDirectory.Delete(entry.FullName);
                    }
                    else
                    {
                        MyFile.Delete(entry.FullName);
                    }

                    navigationView.OnDeleted = true;
                    navigationView.RefreshCurrentDirectoryEntries_1();
                }
                catch (Exception ex)
                {
                    throw new MyException("Отказано в доступе", ex);
                }
            }
        }
        public void OnFileCopy(object sender, MainFormEventArgs e)
        {
            copySource      = FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item);
            copiedEntryName = "CopyOf" + MyFile.GetFileNameWithoutExtension(FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item).Name) +
                              MyFile.GetExtension(FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item).Name);

            /*Copied = e.CurrentDir + e.Item;
             * CopyName = "CopyOf" + e.Item;
             * OpenedDirectory(e.CurrentDir);*/
        }
 public void OnArchiveThread(object sender, MainFormEventArgs e)
 {
     try
     {
         navigationView.IArchivationLength = "";
         Archive_Thread TH = new Archive_Thread(e.CurrentDir, e.Item, Convert.ToInt16(e.Index));
         TH.try_archivation();
         navigationView.IArchivationLength = TH.watch.Elapsed.ToString();
         navigationView.RefreshCurrentDirectoryEntries_1();
     }
     catch (UnauthorizedAccessException) { MessageBox.Show("Отказано в доступе!"); }
     catch (Exception ex) { MessageBox.Show("Ошибка!\n" + ex.Message); }
 }
        public void OnZipFindInfo(object sender, MainFormEventArgs e)
        {
            try
            {
                ZipFindInfo ZFI = new ZipFindInfo(e.CurrentDir, e.Item, Convert.ToInt16(e.Index));
                ZFI.try_findinfo();
                MessageBox.Show("Поиск завершён!\nВся найденная информация сохранена в файле:\n");
                navigationView.RefreshCurrentDirectoryEntries_1();

                //  txtThreadTimer.Text = TH.watch.Elapsed.ToString();
            }
            catch (UnauthorizedAccessException) { MessageBox.Show("Отказано в доступе!"); }
            catch (Exception ex) { MessageBox.Show("Ошибка!\n" + ex.Message); }
        }
        public void OnFindInfoThread(object sender, MainFormEventArgs e)
        {
            try
            {
                FindInfoThread FITHR = new FindInfoThread(e.CurrentDir, e.Item, Convert.ToInt16(e.Index));
                FITHR.try_findinfo();
                MessageBox.Show("Поиск завершён!\nВся найденная информация сохранена в файле:\n");
                OpenedDirectory(e.CurrentDir);

                //  txtThreadTimer.Text = TH.watch.Elapsed.ToString();
            }
            catch (UnauthorizedAccessException) { MessageBox.Show("Отказано в доступе!"); }
            catch (Exception ex) { MessageBox.Show("Ошибка!\n" + ex.Message); }
        }
        public void OnStartClick(object sender, MainFormEventArgs e)
        {
            List <string> allWords = new List <string>(MyFile.ReadAllText(e.CurrentDir + @"\" + e.Item).ToLower().Split(new[] { " ", "\r" }, StringSplitOptions.None));

            int words   = allWords.AsParallel().Where(word => !string.IsNullOrWhiteSpace(word) && !string.IsNullOrEmpty(word)).Count();
            int strings = allWords.AsParallel().Where(word => word.Contains('\r') || word.Contains('\n')).Count();

            allWords = allWords.AsParallel().Select(word => word.Replace("\n", "").Replace("\r", ""))
                       .Where(word => !string.IsNullOrEmpty(word) && !string.IsNullOrWhiteSpace(word)).ToList();



            int n = 0;

            List <int> counts = new List <int>();
            //if (progressBar.BInvoke())
            List <string> ordered = allWords.AsParallel().AsOrdered().OrderByDescending(
                word =>
            {
                int count = allWords.AsParallel().AsOrdered().Where(w => w == word).Count();
                counts.Add(count);
                n++;


                //progressBar.PerformStep();
                return(count);
            }).Distinct().ToList();


            counts = counts.AsParallel().AsOrdered().OrderByDescending(q => q).Distinct().ToList();

            int i = 0;

            while (i < ordered.Count)
            {
                StatisticsForm.TopTenList.Add("    " + "\n" + ordered[i] + "  ");
                i++;
            }



            StatisticsForm.totalWords   = "Total words" + words.ToString();
            StatisticsForm.totalStrings = "Total strings" + strings.ToString();

            StatisticsForm.ImproveChanges();
        }
 public void OnCloseClick(object sender, MainFormEventArgs e)
 {
     StatisticsForm.End();
 }