Пример #1
0
        private int OpenEncryptFile()
        {
            if (listView_linux_files.SelectedItems.Count < 1)
            {
                return(-1);
            }

            LinuxListViewItem llvi = listView_linux_files.SelectedItems[0] as LinuxListViewItem;

            if (llvi == null)
            {
                return(-2);
            }

            string remote_path = llvi.LinuxTVI.Path;

            string local_filename       = "temp" + Idx_Encrypt_File_Open++;
            string remote_path_dec_file = FindDecryptFile(remote_path);

            if (remote_path_dec_file == null)
            {
                return(-3);
            }

            if (SSHController.SendNRecvCofileCommandPreview(listView_linux_files.SelectedItems.Cast <Object>(), false))
            {
                StartCoRoutine(10000,
                               delegate
                {
                    if (SSHController.MoveFileToLocal(root_path, remote_path_dec_file, local_filename, 0))
                    {
                        llvi.LinuxTVI.RefreshChildFromParent();
                        Cofile.current.RefreshListView(Cofile.cur_LinuxTreeViewItem);

                        string url_localfile = root_path + local_filename;
                        string[] split       = remote_path.Split('.');
                        string expansion     = split[split.Length - 2];
                        if (expansion == "png" ||
                            expansion == "dib" ||
                            expansion == "bmp" ||
                            expansion == "jpg" ||
                            expansion == "jpeg" ||
                            expansion == "jpe" ||
                            expansion == "jfif" ||
                            expansion == "gif" ||
                            expansion == "tif" ||
                            expansion == "tiff"
                            )
                        {
                            Window_ViewImage wvi = new Window_ViewImage(LoadImage(url_localfile), llvi.LinuxTVI.FileInfo.Name);
                            FileContoller.DeleteFile(url_localfile);

                            Point pt = this.PointToScreen(new Point(0, 0));
                            wvi.Left = pt.X;
                            wvi.Top  = pt.Y;
                            wvi.ShowDialog();
                        }
                        else
                        {
                            string str = FileContoller.Read(url_localfile);
                            FileContoller.DeleteFile(url_localfile);

                            Window_ViewFile wvf = new Window_ViewFile(str, llvi.LinuxTVI.FileInfo.Name);

                            Point pt = this.PointToScreen(new Point(0, 0));
                            wvf.Left = pt.X;
                            wvf.Top  = pt.Y;
                            wvf.ShowDialog();
                        }
                        return(0);
                    }
                    else
                    {
                        //Log.ErrorIntoUI("Check the Cofile Config File or Check File To Decrypt", "Decrypt Failed", Status.current.richTextBox_status);
                        //Log.PrintError("Cant Download Decrypt File", "UserControls.Cofile.OpenEncryptFile");
                        return(-1);
                    }
                }, "Check the Cofile Config File or Check File To Decrypt", "Decrypt Failed");
            }
            return(-4);
        }
Пример #2
0
        void EncryptFileOpen()
        {
            if (listView_linux_files.SelectedItems.Count < 1)
            {
                return;
            }

            LinuxListViewItem llvi = listView_linux_files.SelectedItems[0] as LinuxListViewItem;

            if (llvi == null)
            {
                return;
            }

            if (SSHController.SendNRecvCofileCommand(listView_linux_files.SelectedItems.Cast <Object>(), false))
            {
                string remote_path = llvi.LinuxTVI.Path;
                JToken jtok        = JsonController.parseJson(FileContoller.Read(current.Selected_config_file_path));
                if (jtok == null)
                {
                    return;
                }

                JValue jval_input_extansion  = jtok["dec_option"]["input_extension"] as JValue;
                JValue jval_output_extension = jtok["dec_option"]["output_extension"] as JValue;

                if (remote_path.Length > jval_input_extansion.Value.ToString().Length + 1 &&
                    remote_path.Substring(remote_path.Length - jval_input_extansion.Value.ToString().Length) == jval_input_extansion.Value.ToString())
                {
                    remote_path = remote_path.Substring(0, remote_path.Length - jval_input_extansion.Value.ToString().Length - 1);
                }

                string   remote_dec_path   = remote_path + "." + jval_output_extension.Value.ToString();
                string[] split_remote_path = remote_path.Split('/');
                string   local_filename    = split_remote_path[split_remote_path.Length - 1] + Idx_Encrypt_File_Open++;

                if (SSHController.moveFileToLocal(root_path, remote_dec_path, local_filename))
                {
                    llvi.LinuxTVI.RefreshChildFromParent();
                    Cofile.current.RefreshListView(Cofile.cur_LinuxTreeViewItem);

                    string   url_localfile = root_path + local_filename;
                    string[] split         = remote_path.Split('.');
                    if (split[split.Length - 1] == "gif" ||
                        split[split.Length - 1] == "bmp" ||
                        split[split.Length - 1] == "jpg" ||
                        split[split.Length - 1] == "png"
                        )
                    {
                        Window_ViewImage wvi = new Window_ViewImage(LoadImage(url_localfile), llvi.LinuxTVI.FileInfo.Name);
                        File.Delete(url_localfile);

                        wvi.ShowDialog();
                    }
                    else
                    {
                        string str = FileContoller.Read(url_localfile);
                        File.Delete(url_localfile);

                        Window_ViewFile wvf = new Window_ViewFile(str, llvi.LinuxTVI.FileInfo.Name);
                        wvf.ShowDialog();
                    }
                }
                else
                {
                    Log.PrintError("Decryption Failed\r\tCheck the config file", "ListView_linux_files_MouseDoubleClick", Status.current.richTextBox_status);
                }
            }
        }