コード例 #1
0
ファイル: Decrypt.xaml.cs プロジェクト: imjihun/EglobalStudy
        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);
        }