コード例 #1
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);
                }
            }
        }