public ActionResult Developers()
        {
            ViewBag.Message = "Your application description page.";

            IFileWorker file = new FileWorker(null);
            String dataFromFile =  file.ReadFile();

            List<String> UserList = JsonConvert.DeserializeObject<List<String>>(dataFromFile);

            return View(UserList);
        }
        public JsonResult UpdateUserList(List<String> jsonUserList)
        {
            try
            {
                var jsonString = JsonConvert.SerializeObject(jsonUserList);

                IFileWorker file = new FileWorker(null);
                file.UpdateFile(jsonString);

                return Json(new { result = "ok" });
            }
            catch
            {
                return Json(new { result = "fail" });
            }
        }
Exemple #3
0
        public static int CalcAngles(List <int[]> angles, List <MolData> list)
        {
            int types = 0;

            foreach (int[] angle in angles)
            {
                int angleType = FileWorker.GetAngleType(new double[3]
                {
                    list[angle[0] - 1].AtomType,
                    list[angle[1] - 1].AtomType,
                    list[angle[2] - 1].AtomType
                });
                if (angleType > types)
                {
                    types = angleType;
                }
            }
            return(types);
        }
        static void Download()
        {
            string path = ConfigurationManager.AppSettings.Get("DownloadHtmlPath") + FileName() + ".html";

            try
            {
                using (WebClient client = new WebClient()) client.DownloadFile(_url, path);
                FileWorker.Read(path);
            }

            catch (Exception downloadExepions) {
                FileWorker fileWorker = new FileWorker();
                fileWorker.WriteExeptions("дата:" + Convert.ToString(DateTime.Now) + "|| метод Download: " + downloadExepions.Message, ConfigurationManager.AppSettings.Get("DownloadHtmlExeptions"));
                fileWorker.Dispose();
                Console.WriteLine("Не корректная ссылка, введите повторно");
                _url = Console.ReadLine();
                Download();
            }
        }
Exemple #5
0
        void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(
                () =>
            {
                double bytesIn    = double.Parse(e.BytesReceived.ToString());
                double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
                double percentage = bytesIn / totalBytes * 100;
                R_Percentage.Text = (int)percentage + "%";
                PB_Download.Value = percentage;
                prog--;

                if (prog <= 0)
                {
                    LB_Size.Content = FileWorker.GetBytesReadableTwoDecimals((long)bytesIn) + " / " + FileWorker.GetBytesReadableTwoDecimals((long)totalBytes);
                    prog            = 20;
                }
            });
        }
    static void Main(string[] args)
    {
        var file1 = new FileInfo("file1.tmp");

        using (var writer = file1.CreateText())
        {
            writer.WriteLine("file 1");
        }
        var file2 = new FileInfo("file2.tmp");

        using (var writer = file2.CreateText())
        {
            writer.WriteLine("file 2");
        }
        var worker = new FileWorker();

        worker.Copy(new[] { file1, file2 }, @"C:\temp").Wait();
        Console.ReadLine();
    }
        private void CheckUserSecretWordAndLogin(string secret, string login)
        {
            var     list    = FileWorker.GetProfilesFromFile();
            Profile profile = list.Find(x => x.SecretWord == secret && x.Login == login);

            if (profile == null)
            {
                Console.WriteLine("Пользователя с таким секретным словом и логином нет!");
                Start();
            }
            else
            {
                Console.WriteLine("Нашли вас!");
                Console.WriteLine($"Ваш логин: {profile.Login}");
                Console.WriteLine($"Ваш пароль: {profile.Password}");
                LoginView view = new LoginView();
                view.Start();
            }
        }
        public void ReadAllFromClass_Path_ReturnsStringFromFileXML()
        {
            // Arrange
            const string FULL_PATH = @"D:\ForStudy\Components-Of-" +
                                     @"Software-Engineering\Labs\Lab2\Lab2\TempFileXML.xml";

            const string STRING_FROM_FILE = "<?xml version=\"1.0\"" +
                                            "?>\n<Text>\n      <FirstText>Some text for lab2 " +
                                            "XML</FirstText>\n      <SecondText>Second string " +
                                            "XML</SecondText>\n</Text>\n";

            string expected = FileWorker.ReadAll(FULL_PATH);

            // Act
            string actual = STRING_FROM_FILE;

            // Assert
            Assert.Equal(actual, expected);
        }
Exemple #9
0
        private void SaveResult()
        {
            var dialog = new SaveFileDialog {
                Filter = "Views (*.csv)|*.csv"
            };

            if (dialog.ShowDialog() == true)
            {
                var fileName = dialog.FileName;
                var file     = FileWorker.GetInstance(fileName, true);
                foreach (var assignment in Assignments)
                {
                    var builder = new StringBuilder();
                    builder.Append(assignment.Name);
                    builder.Append(";");
                    builder.Append(assignment.Value.Name);
                    file.WriteLine(builder.ToString());
                }
            }
        }
        private void SetLanguageClicked(object sender, EventArgs e)
        {
            var filename = Path.Combine(App.FolderPath, AppSettings.LANGUAGE_FILENAME);

            if (App.Language.Equals("Russian"))
            {
                App.Language = "English";
                LangSettings.InstanceOf.SetLanguage();
                imageLang.Source = "english_small.png";
                FileWorker.WriteTextToFile("English", filename);
            }
            else
            {
                App.Language = "Russian";
                LangSettings.InstanceOf.SetLanguage();
                imageLang.Source = "russian_small.png";
                FileWorker.WriteTextToFile("Russian", filename);
            }
            SetTextFromNewLanguage();
        }
Exemple #11
0
        /// <summary>
        /// Task 2. RSA Encryption and decryption
        /// </summary>
        /// <param name="keys">keys</param>
        /// <param name="fileName"></param>
        /// <param name="keyLength">Key length</param>
        private static void RsaCrypt(KeysHolder keys, string fileName, int keyLength)
        {
            var plainText     = FileWorker.GetBinaryFile(fileName);
            var encodedText   = new List <short>();
            var decryptedText = new List <short>();
            var rsaEncoder    = new RsaEncoder();

            // encrypting
            encodedText = Encode(keys.publicKey, keys.cypherModule, plainText, rsaEncoder, keyLength / 4, keyLength, false);
            // saving encrypted message
            FileWorker.CreateTextFileForBinaryNumber(encodedText, "crypted.txt");
            Console.WriteLine(String.Format("Encryption has finished. Check crypted.txt"));

            // decrypting
            decryptedText = Encode(keys.privateKey, keys.cypherModule, encodedText, rsaEncoder, keyLength, keyLength / 4, true);
            // saving decrypted message
            FileWorker.GetNEWFile(decryptedText, "decrypted_" + fileName);
            Console.WriteLine(String.Format("DEcryption has finished. Check decrypted{0}", fileName));
            Console.WriteLine("-------------------------------------------------------------");
        }
Exemple #12
0
        static void Main(string[] args)
        {
            DataGenerator generator  = new DataGenerator();
            FileWorker    fileWorker = new FileWorker(generator);
            DBWorker      dbWorker   = new DBWorker();

            //Generating files
            fileWorker.GenerateFiles("D:\\Files");

            //Merging files into one
            Console.WriteLine(fileWorker.MergeFiles("D:\\Files", null, "ПаШа") + " strings were deleted.");


            fileWorker.ProcessInfo += FileWorker_ProcessInfo;
            //Saving data to DB
            fileWorker.SaveData("D:\\Files\\Result.txt", dbWorker);

            Console.WriteLine("Sum is: " + dbWorker.GetSumFromIntColumn());
            Console.WriteLine("Median is: " + dbWorker.GetMedian());
        }
        public void TryCopyLatinNoRewrite_Path_ReturnsFalse()
        {
            // Arrange
            const string FULL_PATH_FROM = @"D:\ForStudy\Components-Of-" +
                                          @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                          @"\SomeRandomFile.txt";

            const string FULL_PATH_TO = @"D:\ForStudy\Components-Of-" +
                                        @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                        @"\CopyDir\SomeRandomFile.txt";

            bool expected = FileWorker.TryCopy(FULL_PATH_FROM,
                                               FULL_PATH_TO, false);

            // Act
            bool actual = false;

            // Assert
            Assert.Equal(actual, expected);
        }
        private void CheckUserSecretWordAndLogin(string secret, string login)
        {
            var     fileWorker = new FileWorker <Profile>($"{Directory.GetCurrentDirectory()}//profiles.json");
            var     list       = fileWorker.Reader.GetProfiles(true);
            Profile profile    = list.SingleOrDefault(x => x.SecretWord == secret && x.Login == login);

            if (profile == null)
            {
                Console.WriteLine("Пользователя с таким секретным словом и логином нет!");
                Start();
            }
            else
            {
                Console.WriteLine("Нашли вас!");
                Console.WriteLine($"Ваш логин: {profile.Login}");
                Console.WriteLine($"Ваш пароль: {profile.Password}");
                LoginView view = new LoginView();
                view.Start();
            }
        }
        private void WriteWordsInFile()
        {
            bool enWordInput  = CheckInputWord(EnWord);
            bool rusWordInput = CheckInputWord(RuWord);

            if (enWordInput && rusWordInput)
            {
                string     enWord = EnWord.ToLower();
                string     ruWord = RuWord.ToLower();
                FileWorker fw     = new FileWorker();
                fw.WriteInFile(filePath, enWord, ruWord);
                EnWord = "";
                RuWord = "";
            }
            else
            {
                MessageBox.Show("Ошибка");
                // потом надо исправить
            }
        }
        public void TryCopyCyrillicYesRewrite_Path_ReturnsFalse()
        {
            // Arrange
            const string FULL_PATH_FROM = @"D:\ForStudy\Components-Of-" +
                                          @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                          @"\ВипадковийФайл.txt";

            const string FULL_PATH_TO = @"D:\ForStudy\Components-Of-" +
                                        @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                        @"\CopyDir\ВипадковийФайл.txt";

            bool expected = FileWorker.TryCopy(FULL_PATH_FROM,
                                               FULL_PATH_TO, true);

            // Act
            bool actual = false;

            // Assert
            Assert.Equal(actual, expected);
        }
        public void TryCopyCyrillicYesRewrite_Path_ReturnsTrue()
        {
            // Arrange
            const string FULL_PATH_FROM = @"D:\ForStudy\Components-Of-" +
                                          @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                          @"\ФайлДляКопіюванняTestFromTrue4.txt";

            const string FULL_PATH_TO = @"D:\ForStudy\Components-Of-" +
                                        @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                        @"\CopyDir\ФайлДляКопіюванняTestToTrue4.txt";

            bool expected = FileWorker.TryCopy(FULL_PATH_FROM,
                                               FULL_PATH_TO, true);

            // Act
            bool actual = true;

            // Assert
            Assert.Equal(actual, expected);
        }
Exemple #18
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (valid && isFileSelected && isNewsSelected && isDateSelected ||
                (!valid && isFileSelected && isNewsSelected && isDateSelected))
            {
                LoadingProcessForm processForm = new LoadingProcessForm();
                processForm.Show();
                Task.Factory.StartNew(() =>
                {
                    List <string> mails    = FileWorker.ReadFromFile(pathFile);
                    SqlCommander commander = new SqlCommander(processForm);
                    int amountCoincidences = commander.AddMails(new NpgsqlConnection(connectionString), mails, valid, SelectedDate, selectedNews);
                    conn.Close();
                    commander.DeleteAll();
                    MessageBox.Show("Импортировано " + mails.Count + " строк\n\n" + amountCoincidences.ToString() + " совпадений найдено.");
                });
            }

            else if (!valid && isFileSelected && (!isNewsSelected && !isDateSelected))
            {
                LoadingProcessForm processForm = new LoadingProcessForm();
                processForm.Show();
                Task.Factory.StartNew(() =>
                {
                    NpgsqlConnection conn  = new NpgsqlConnection(connectionString);
                    List <string> mails    = FileWorker.ReadFromFile(pathFile);
                    SqlCommander commander = new SqlCommander(processForm);
                    int amountCoincidences = commander.AddMails(conn, mails, valid);
                    conn.Close();
                    commander.DeleteAll();
                    MessageBox.Show("Импортировано " + mails.Count + " строк\n\n" + amountCoincidences.ToString() + " совпадений найдено.");
                });
            }
            else
            {
                MessageBox.Show("НЕ ВСЕ ПОЛЯ ЗАПОЛНЕНЫ!\nПОЖАЛУЙСТА, ПРОВЕРЬТЕ ПРАВИЛЬНОСТЬ ВВЕДЕННЫХ ДАННЫХ",
                                "Ошибка при вводе данных",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
        private void ButtonDecrypt_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_d.Text.Length > 0 && textBox_n.Text.Length > 0)
            {
                long          d     = Convert.ToInt64(textBox_d.Text);
                long          n     = Convert.ToInt64(textBox_n.Text);
                List <string> input = new List <string>();
                FileWorker    sr    = new FileWorker("Files\\Encrypted.txt");
                input.AddRange(sr.Read().Replace("\r\n", "\n").Split('\n'));
                string       result = RSA_Dedoce(input, d, n);
                StreamWriter sw     = new StreamWriter("Files\\Decrypted.txt");
                sw.WriteLine(result);
                sw.Close();

                Process.Start("Files\\Decrypted.txt");
            }
            else
            {
                MessageBox.Show("Введите секретный ключ!");
            }
        }
Exemple #20
0
 public void AddFileTest()
 {
     Assert.True(storageDatabaseUtils.AddFile("testfile.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testfile.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("db.accdb", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\db.accdb"))));
     Assert.True(storageDatabaseUtils.AddFile("docfile.docx", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\docfile.docx"))));
     Assert.True(storageDatabaseUtils.AddFile("pdftest.pdf", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\pdftest.pdf"))));
     Assert.True(storageDatabaseUtils.AddFile("archive.zip", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\archive.zip"))));
     Assert.True(storageDatabaseUtils.AddFile("picture.jpg", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\picture.jpg"))));
     Assert.True(storageDatabaseUtils.AddFile("present.pptx", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\present.pptx"))));
     Assert.True(storageDatabaseUtils.AddFile("✔️✔️✔️.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\✔️✔️✔️.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("ґєїъэё.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\ґєїъэё.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("mathcad.xmcd", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\mathcad.xmcd"))));
     Assert.True(storageDatabaseUtils.AddFile("somepng.png", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\somepng.png"))));
     Assert.True(storageDatabaseUtils.AddFile("Відео-файл.mp4", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\Відео-файл.mp4"))));
     Assert.True(storageDatabaseUtils.AddFile("music.mp3", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\music.mp3"))));
     Assert.True(storageDatabaseUtils.AddFile("apktest.apk", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\apktest.apk"))));
     Assert.True(storageDatabaseUtils.AddFile("someexe.exe", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\someexe.exe"))));
     Assert.True(storageDatabaseUtils.AddFile("HUH", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\HUH"))));
     Assert.True(storageDatabaseUtils.AddFile("oops.torrent", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\oops.torrent"))));
     Assert.True(storageDatabaseUtils.AddFile(".txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\.txt"))));
 }
Exemple #21
0
        public static void DeserializeCurrencies()
        {
            string json = "";

            try
            {
                json = FileWorker.Read("cache.json");   //reading the local attached file
                var data = NbuAccess.SetCurrencies();   // if error occures here, local file data will be used
                FileWorker.Write("cache.json", data);   // overwriting(or creating) local file copy with new data from server

                json = FileWorker.Read("cache.json");
            }
            catch (Exception e) when(e is AggregateException || e is HttpRequestException)
            {
                Console.WriteLine("----------------------------------------------");
                Console.WriteLine("Program was uable to refresh currencies!");
                Console.WriteLine("Latest succesfull request results will be used");
                Console.WriteLine("----------------------------------------------");
            }

            Currencies = JsonConvert.DeserializeObject <List <Currency> >(json);
        }
        public void TryCopyLatinNoRewrite_Path_ReturnsTrue()
        {
            // Arrange
            const string FULL_PATH_FROM = @"D:\ForStudy\Components-Of-" +
                                          @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                          @"\CopyFileTestFromTrue1.txt";

            const string FULL_PATH_TO = @"D:\ForStudy\Components-Of-" +
                                        @"Software-Engineering\Labs\Lab2\Lab2\TestFiles" +
                                        @"\CopyDir\CopyFileTestToTrue1.txt";

            bool expected = FileWorker.TryCopy(FULL_PATH_FROM,
                                               FULL_PATH_TO, false);

            // Act
            bool actual = true;

            File.Delete(FULL_PATH_TO);

            // Assert
            Assert.Equal(actual, expected);
        }
Exemple #23
0
        public void Start()
        {
            var login = TypeLogin();
            var pass  = TypePassword();

            if (CheckLoginAndPass(login, pass))
            {
                var list = FileWorker.GetProfilesFromFile();
                Console.WriteLine("Пользователь успешно вошел в ЧАТ");
                var newpass = PasswordWorker.GenerateNewPassword();
                Console.WriteLine($"Ваш пароль для следующего вашего входа: {newpass}");
                var profile = list.Single(x => x.Login == login);
                profile.Password = PasswordWorker.Encrypt(newpass, login);
                FileWorker.RefreshAll(list);
            }

            else
            {
                //Console.WriteLine("Некорректные данные! Даю еще одну попытку..");
                //Start();
            }
        }
        public void NextGenTest()
        {
            var game = new Game();

            Cell[,] test = new Cell[5, 5];
            Game.SetBlank(ref test);
            test[1, 2] = new Cell(true);
            test[2, 2] = new Cell(true);
            test[3, 2] = new Cell(true);

            game.SetEnvironment(test);
            test = game.NextGen();


            Cell[,] expected = new Cell[5, 5];
            Game.SetBlank(ref expected);

            expected[2, 1] = new Cell(true);
            expected[2, 2] = new Cell(true);
            expected[2, 3] = new Cell(true);

            Assert.AreEqual(FileWorker.GetState(test), FileWorker.GetState(expected));
        }
Exemple #25
0
        public Model()
        {
            AccsBlocked                 = 0;
            ProxyBlocked                = 0;
            AccsSwitched                = 0;
            ProxySwitched               = 0;
            IsMailsReady                = false;
            IsProxyInited               = false;
            IsObjectsReady              = false;
            IsAgentsInited              = false;
            IsAccountInited             = false;
            IsProgramComplitlyEnded     = false;
            AccountInfoDataSet_Success  = new List <string>();
            AccountInfoDataSet_Required = new List <string>();

            _noMoreProxy = true;
            //_deleteProxy = new List<Dictionary<string, object>>();

            _proxy      = new Proxy();
            _account    = new Accounts();
            _accMails   = new AccountsMail();
            _fileWorker = new FileWorker();
            _agents     = new UserAgents();
        }
        private void ButtonCrypt_Click(object sender, RoutedEventArgs e)
        {
            if ((textBox_p.Text.Length > 0) && (textBox_q.Text.Length > 0))
            {
                long p = Convert.ToInt64(textBox_p.Text);
                long q = Convert.ToInt64(textBox_q.Text);

                if (IsTheNumberSimple(p) && IsTheNumberSimple(q))
                {
                    FileWorker sr = new FileWorker("Files\\TextToEncrypt.txt");
                    var        s  = sr.Read();
                    sr.Path = $"Files\\OpenKey.txt";
                    sr.Write($"{p} {q}");
                    s = s.ToUpper();
                    long          n      = p * q;
                    long          m      = (p - 1) * (q - 1);
                    long          d      = Calculate_d(m);
                    long          e_     = Calculate_e(d, m);
                    List <string> result = RSA_Endoce(s, e_, n);
                    string        wr     = String.Join(Environment.NewLine, result);
                    textBox_d.Text = d.ToString();
                    textBox_n.Text = n.ToString();
                    sr.Path        = "Files\\CloseKey.txt";
                    sr.Write($"{d} {n}");
                    Process.Start("Files\\Encrypted.txt");
                }
                else
                {
                    MessageBox.Show("p или q - не простые числа!");
                }
            }
            else
            {
                MessageBox.Show("Введите p и q!");
            }
        }
Exemple #27
0
 public void WriteData(TGUpl a)
 {
     FileWorker.WriteData(this);
     a.SendMessage("Успешно сохранено.", MainModer.UId);
 }
Exemple #28
0
 public void WriteNonexistentPath()
 {
     Assert.True(FileWorker.Write("last christmas", "lights"));
 }
Exemple #29
0
 public void WriteExistingFile()
 {
     Assert.True(FileWorker.Write("ho-ho-ho", @"C:\FilesTests\ho-ho-ho.txt"));
 }
Exemple #30
0
 public void WriteEmptyLine()
 {
     Assert.True(FileWorker.Write("", @"C:\FilesTests\NEW1.txt"));
 }
Exemple #31
0
 public void TryWriteText()
 {
     Assert.True(FileWorker.Write("Home alone", @"C:\FilesTests\American christmas movies.txt"));
 }
        private static List<string> GetEnabledDevs()
        {
            IFileWorker file = new FileWorker(null);
            String dataFromFile = file.ReadFile();

            List<string> Devs = JsonConvert.DeserializeObject<List<string>>(dataFromFile);
            return Devs;
        }
Exemple #33
0
        public void SetConnection()
        {
            isRunning = true;
            // Creating local end point
            IPHostEntry ipHost     = Dns.GetHostEntry("localhost");
            IPEndPoint  ipEndPoint = new IPEndPoint(ipAddress, port);

            socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            try
            {
                // Binding
                socket.Bind(ipEndPoint);
                // Listening Mode
                socket.Listen(1);

                while (true)
                {
                    // Waiting for connection
                    Socket handler = socket.Accept();
                    // Getting data
                    byte[] recBytes = new byte[1024];
                    int    nBytes   = handler.Receive(recBytes);

                    bool isSendingMust = recBytes[0] > 0 ? true : false;

                    switch ((Buttons)recBytes[1])
                    {
                    case Buttons.SymbolRecieved:
                    {
                        string symbol = DataBinary.GetNormalRepresentation <string>(recBytes, 1, recBytes.Length - 2);
                        if (symbol == " ")
                        {
                            System.Windows.Forms.SendKeys.SendWait(" ");
                        }
                        else
                        {
                            System.Windows.Forms.SendKeys.SendWait(String.Concat("{", symbol, "}"));
                        }
                        break;
                    }

                    case Buttons.leftbutton:
                        Mouse.Click(Buttons.leftbutton);
                        break;

                    case Buttons.rightbutton:
                        Mouse.Click(Buttons.rightbutton);
                        break;

                    case Buttons.StartPresentation:
                        System.Windows.Forms.SendKeys.SendWait("{F5}");
                        break;

                    case Buttons.NextSlide:
                        System.Windows.Forms.SendKeys.SendWait("{RIGHT}");
                        break;

                    case Buttons.PreviousSlide:
                        System.Windows.Forms.SendKeys.SendWait("{LEFT}");
                        break;

                    case Buttons.EndPresentation:
                        System.Windows.Forms.SendKeys.SendWait("{ESC}");
                        break;

                    case Buttons.MoveMouse:
                        byte[] firstFloat = new byte[4];
                        for (int i = 2, j = 0; i < 6; i++, j++)
                        {
                            firstFloat[j] = recBytes[i];
                        }

                        byte[] secondFloat = new byte[4];
                        for (int i = 6, j = 0; i < 10; i++, j++)
                        {
                            secondFloat[j] = recBytes[i];
                        }

                        MessageBox.Show(Math.Round(System.BitConverter.ToSingle(firstFloat, 0), 1).ToString() + "; " + Math.Round(System.BitConverter.ToSingle(secondFloat, 0), 1).ToString());

                        break;

                    case Buttons.GetDrives:
                    {
                        handler.Send(DataBinary.GetBinaryRepresentationWX(FileWorker.GetDrives()));
                        break;
                    }

                    case Buttons.GetPresentations:
                    {
                        int  chosenDrive = DataBinary.GetNormalRepresentation <int>(recBytes, 1, recBytes.Length - 2);
                        bool isFile      = false;
                        var  answer      = FileWorker.GetListOfContainingFiles(chosenDrive, ".pptx", ref isFile);

                        if (isFile)
                        {
                            Process.Start(answer[0]);
                        }
                        else
                        {
                            handler.Send(DataBinary.GetBinaryRepresentationWX(answer));
                        }

                        break;
                    }

                    case Buttons.IsFileExists:
                    {
                        if (FileWorker.IsFileExists(DataBinary.GetNormalRepresentation <string>(recBytes, 1, recBytes.Length - 2)))
                        {
                            handler.Send(new byte[] { 1 });
                        }
                        else
                        {
                            handler.Send(new byte[] { 0 });
                        }

                        break;
                    }

                    case Buttons.RunFile:
                    {
                        string pathToFile = DataBinary.GetNormalRepresentation <string>(recBytes, 1, recBytes.Length - 2);
                        Process.Start(pathToFile);
                        break;
                    }

                    case Buttons.RunPresentation:
                    {
                        string pathToFile = DataBinary.GetNormalRepresentation <string>(recBytes, 1, recBytes.Length - 2);
                        Process.Start(FileWorker.GetFilePath(pathToFile, FileWorker.driveName));
                        break;
                    }

                    case Buttons.PreviousDirectory:
                    {
                        if (FileWorker.driveName == null)
                        {
                            handler.Send(DataBinary.GetBinaryRepresentationWX(FileWorker.GetDrives()));
                            break;
                        }
                        bool isFile = false;

                        if (FileWorker.GetParentPath() == null)
                        {
                            FileWorker.driveName = null;
                            handler.Send(DataBinary.GetBinaryRepresentationWX(FileWorker.GetDrives()));
                        }
                        else
                        {
                            handler.Send(DataBinary.GetBinaryRepresentationWX(FileWorker.GetListOfContainingFiles(1, ".pptx", ref isFile)));
                        }
                        break;
                    }
                    }

                    if (isSendingMust)
                    {
                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            ScreenShot.GetScreenShot().Save(memoryStream, ImageFormat.Jpeg);
                            byte[] bytess = memoryStream.GetBuffer();

                            int sendedBytes = 0;
                            int bufSize     = 8;

                            handler.Send(Encoding.Default.GetBytes(bytess.Length.ToString() + "\n"));
                            while (sendedBytes < bytess.Length)
                            {
                                sendedBytes += handler.Send(bytess, sendedBytes, bytess.Length - sendedBytes > bufSize ? bufSize : bytess.Length - sendedBytes, SocketFlags.None);
                            }

                            handler.Send(bytess);
                        }
                    }

                    // Socket release
                    handler.Shutdown(SocketShutdown.Both);
                    handler.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }