Пример #1
0
        public void listBox1_DoubleClick(object sender, EventArgs e)
        {
            deviceInfo = devices.ElementAt(listBox1.SelectedIndex);
            updateUI(deviceInfo.DeviceName + "  was selected.");

            data[0] = deviceInfo.DeviceAddress.ToString();
            // data[1] = zipFolderPath;
            // data[2] = password_result;
            //  data[3] = deviceInfo.DeviceName;
            client = new FireSharp.FirebaseClient(ifc);
            if (client == null)
            {
                MessageBox.Show("there was some internet error");
            }

            var res = client.Get(@"fileData/" + data[0]);
            // var set = client.Set(@"fileData/" + data[key, 0], fd);

            fileData fd = res.ResultAs<fileData>();

            if(fd == null)
            {
                MessageBox.Show("Selected Device is not registered!");
            }
            else
            {
                data[1] = fd.FolderPath;
                data[2] = fd.Password;
                data[3] = fd.DeviceName;
               // button1.Enabled = true;
                using (Form_password f_password = new Form_password())
                {
                    f_password.ShowDialog();

                    password_result = f_password.returnValue();
                    if (password_result.Trim() == string.Empty)
                    {
                        MessageBox.Show("This Field cannot left empty!");
                        return; // return because we don't want to run normal code of buton click
                    }
                    // MessageBox.Show(password_result);

                }

                if(password_result == data[2])
                {
                    updateUI2("Device Address : "+data[0]);
                    updateUI2("Encrypted Folder : " + data[1].Remove(data[1].Length - 4, 4));
                    updateUI2("Password : "******"Device Name : "+ data[3]);
                    button1.Enabled = true;
                    updateUI("Press OK to decrypt folder.");
                }
                else
                {
                    MessageBox.Show("Please Enter Correct password!");
                    return;
                }

            }   

        }
Пример #2
0
        public void listBox1_DoubleClick(object sender, EventArgs e)
        {
            deviceInfo = devices.ElementAt(listBox1.SelectedIndex);
            updateUI(deviceInfo.DeviceName + "  was selected.");

            client = new FireSharp.FirebaseClient(ifc);
            if (client == null)
            {
                MessageBox.Show("there was some internet error");
            }
            var res = client.Get(@"fileData/" + deviceInfo.DeviceAddress.ToString());


            fileData fd = res.ResultAs <fileData>();

            if (fd != null)
            {
                MessageBox.Show("You have already resisterd one folder for this device!\n\nplease " +
                                "decrypt first then use this device for encryption of another folder.");
                return;
            }

            //OpenFileDialog ofd = new OpenFileDialog();
            FolderBrowserDialog ofd = new FolderBrowserDialog();

            ofd.Description = "Select your folder";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                updateUI(ofd.SelectedPath + "  Folder selected.");

                FolderPathToZip = ofd.SelectedPath.Trim();
                //to store the value of folderapth
            }
            //String path = ofd.SelectedPath;

            /*String path = @"C:\Users\Nikunj\Desktop\test1";
             * Thread thread = new Thread(t =>
             * {
             *  using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
             *  {
             *      zip.AddDirectory(path);
             *      System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
             *      // zip.SaveProgress += Zip_SaveProgress;
             *      zip.Save(string.Format("{0}{1}.zip", di.Parent.FullName, di.Name));
             *
             *  }
             * })
             * { IsBackground = true };
             * thread.Start();
             */


            /* f_password.ShowDialog();
             *
             * string deviceName = deviceInfo.DeviceName;
             * string folderName =ofd.SelectedPath ;
             *
             *
             * Form_password f_p = new Form_password();
             * string Final_password = null;
             * Final_password= f_p.returnValue();
             * updateUI(Final_password + " Set Sucessfully");
             * textBox1.Text = folderName;
             *   MessageBox.Show(Final_password);
             */
            using (Form_password f_password = new Form_password())
            {
                f_password.ShowDialog();

                password_result = f_password.returnValue();
                if (password_result.Trim() == string.Empty)
                {
                    MessageBox.Show("This Field cannot left empty!");
                    return; // return because we don't want to run normal code of buton click
                }
                // MessageBox.Show(password_result);

                updateUI(password_result + " Set Sucessfully");
            }

            for (int j = 0; j < 4; j++)
            {
                data[j] = null;
            }

            data[0] = deviceInfo.DeviceAddress.ToString();
            // data[1, key] = ofd.SelectedPath;
            //data[1] = ofd.SelectedPath;
            data[1] = FolderPathToZip + ".zip";
            data[2] = password_result;
            data[3] = deviceInfo.DeviceName;

            updateUI2("Device Address : " + data[0]);
            updateUI2("Folder path : " + data[1].Remove(data[1].Length - 4, 4));
            updateUI2("Password : "******"Device name : " + data[3]);

            button1.Enabled = true;
            updateUI("Press OK to Encrypt Selected folder.");
        }