private void OnMouseDoubleClickLinuxFile(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ListView lv = sender as ListView; if (lv == null) { return; } LinuxListViewItem selected = lv.SelectedItem as LinuxListViewItem; if (selected == null) { return; } if (selected.IsDirectory) { OpenDirectory(selected); } else { OpenEncryptFile(); } } }
int FocusListView(ListView lv, string find) { int idx_start = lv.SelectedIndex; // find.Length == 1 일때는 lv.SelectedIndex == -1 일때도 포함. // 처음 키보드찾기를 할 때, find.Length 는 1부터 시작할 수 밖에 없음. if (find.Length == 1 || idx_start == -1) { idx_start++; if (idx_start >= lv.Items.Count) { idx_start = 0; } } int idx = idx_start; for (int cnt = 0; cnt < lv.Items.Count; cnt++) { LinuxListViewItem llvi = lv.Items[idx] as LinuxListViewItem; if (llvi == null) { continue; } string name = llvi.BindingName.ToLower(); int j; for (j = 0; j < name.Length && j < find.Length; j++) { if (name[j] != find[j]) { break; } } if (j == find.Length) { ((UIElement)lv.ItemContainerGenerator.ContainerFromItem(lv.Items[idx])).Focus(); break; } idx++; if (idx >= lv.Items.Count) { idx = 0; } } return(0); }
private int OpenDirectory(LinuxListViewItem llvi) { if (llvi.IsDirectory) { if (llvi.LinuxTVI == null) { return(-1); } llvi.LinuxTVI.RefreshChild(); //RefreshListView(selected.LinuxTVI); //llvi.LinuxTVI.IsExpanded = false; //llvi.LinuxTVI.IsExpanded = true; llvi.LinuxTVI.Focus(); } return(0); }
public void RefreshListView(LinuxTreeViewItem cur) { if (cur == null) { return; } cur_LinuxTreeViewItem = cur; comboBox_listView_linuxpath.Text = cur.Path; list_LinuxListViewItem.Clear(); LinuxListViewItem llvi = new LinuxListViewItem() { BindingName = "..", IsDirectory = true, LinuxTVI = cur.Parent as LinuxTreeViewItem }; list_LinuxListViewItem.Add(llvi); for (int i = 0; i < cur.Items.Count; i++) { LinuxTreeViewItem ltvi = cur.Items[i] as LinuxTreeViewItem; if (ltvi == null) { continue; } llvi = new LinuxListViewItem() { BindingName = ltvi.Header.Text, IsDirectory = ltvi.IsDirectory, LinuxTVI = ltvi }; list_LinuxListViewItem.Add(llvi); } listView_linux_files.Items.Clear(); for (int i = 0; i < list_LinuxListViewItem.Count; i++) { if (list_LinuxListViewItem[i].LinuxTVI != null && list_LinuxListViewItem[i].LinuxTVI.Visibility == Visibility.Visible) { listView_linux_files.Items.Add(list_LinuxListViewItem[i]); } } }
private void OnMouseDoubleClickLinuxListView(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ListView lv = sender as ListView; if (lv == null) { return; } LinuxListViewItem selected = lv.SelectedItem as LinuxListViewItem; if (selected == null) { return; } if (selected.IsDirectory) { if (selected.LinuxTVI == null) { return; } selected.LinuxTVI.RefreshChild(); //RefreshListView(selected.LinuxTVI); //llvi.LinuxTVI.IsExpanded = false; //llvi.LinuxTVI.IsExpanded = true; selected.LinuxTVI.Focus(); } else { FileDoubleClick?.Invoke(); } } }
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); }
private void OnDropWorkFile(object sender, DragEventArgs e) { // If the DataObject contains string data, extract it. if (e.Data.GetDataPresent("Object")) { Object data_obj = (Object)e.Data.GetData("Object"); ObservableCollection <object> list_llvi = data_obj as ObservableCollection <object>; List <LinuxTreeViewItem> list_ltvi = data_obj as List <LinuxTreeViewItem>; if (list_ltvi != null) { for (int i = 0; i < list_ltvi.Count; i++) { // 중복 체크 int idx_dup; for (idx_dup = 0; idx_dup < listView_work_files.Items.Count; idx_dup++) { LinuxListViewItem llvi = listView_work_files.Items[idx_dup] as LinuxListViewItem; if (llvi.LinuxTVI.Path == list_ltvi[i].Path) { break; } } if (listView_work_files.Items.Count > 0 && idx_dup != listView_work_files.Items.Count) { continue; } listView_work_files.Items.Add(new LinuxListViewItem() { BindingName = list_ltvi[i].Header.Text, IsDirectory = list_ltvi[i].IsDirectory, LinuxTVI = list_ltvi[i] }); } } else if (list_llvi != null) { for (int i = 0; i < list_llvi.Count; i++) { LinuxListViewItem llvi = list_llvi[i] as LinuxListViewItem; // 중복 체크 int idx_dup; for (idx_dup = 0; idx_dup < listView_work_files.Items.Count; idx_dup++) { LinuxListViewItem llvi_for_dup_check = listView_work_files.Items[idx_dup] as LinuxListViewItem; if (llvi_for_dup_check.LinuxTVI.Path == llvi.LinuxTVI.Path) { break; } } if (listView_work_files.Items.Count > 0 && idx_dup != listView_work_files.Items.Count) { continue; } // 상위폴더 체크 if (llvi.BindingName == "..") { llvi = new LinuxListViewItem() { BindingName = llvi.LinuxTVI.Header.Text, IsDirectory = llvi.IsDirectory, LinuxTVI = llvi.LinuxTVI }; } listView_work_files.Items.Add(llvi); } } } }
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); } } }