public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { if (!GetItemIsContainer(index)) { use_new = false; return; } //returns DirectoryList of parent folder var target_dir = Path.GetDirectoryName(file_name_full); new_collection = new DirectoryList(0, false, target_dir); var err = false; try { new_collection.Refill(); } catch (Exception ex) { err = true; Messages.ShowException(ex); } if (err) { use_new = false; } else { use_new = true; preferred_focused_text = Path.GetFileName(file_name_full); } }
public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focus) { internal_list.Keys[index].Update(); if (!internal_list.Keys[index].DeviceReady) { Messages.ShowMessage(string.Format("Device {0} not ready.", internal_list.Keys[index].RootPathName)); use_new = false; return; } preferred_focus = string.Empty; new_collection = new DirectoryList(0, false, internal_list.Keys[index].RootPathName); try { new_collection.Refill(); new_collection.MainWindow = this.MainWindow; use_new = true; } catch (Exception ex) { Messages.ShowException(ex); } }
private void jump_to(mFilePanel target_panel) { var dial = new JumpToDialog(); dial.Text = Options.GetLiteral(Options.LANG_WHERE_TO_JUMP); if (dial.ShowDialog() != DialogResult.OK) { return; } var path = dial.textBoxPath.Text; FileCollectionBase new_source = null; try { //parse path if (path.StartsWith(@"\\")) { //assume smb path var target_res = WinApiWNETwrapper.GetResourceInfo(path); if (target_res.dwDisplayType == netCommander.WNet.ResourceDisplayType.SHARE) { //it is network share - show directory list new_source = new DirectoryList(0, false, path); } else if ((target_res.dwUsage & ResourceUsage.CONTAINER) != ResourceUsage.CONTAINER) { //target_res is not container - try show parent target_res = WinApiWNETwrapper.GetParentResource(target_res); new_source = new WnetResourceList(0, false, target_res); } else { //show target_resource new_source = new WnetResourceList(0, false, target_res); } }//end of stratsWith("\\") brunch else { new_source = new DirectoryList(0, false, path); } //now refill source new_source.MainWindow = this; new_source.Refill(); target_panel.Source = new_source; target_panel.Refresh(); } catch (Exception ex) { Messages.ShowException(ex, string.Format(Options.GetLiteral(Options.LANG_CANNOT_SHOW_0), path)); } }
public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { if (index == 0) { //return container from wnet try { NETRESOURCE container = WinApiWNETwrapper.GetParentResource(server_ref); WnetResourceList wnet_list = new WnetResourceList(SortCriteria, SortReverse, container); preferred_focused_text = server_ref.lpRemoteName; wnet_list.Refill(); use_new = true; new_collection = wnet_list; } catch (Exception ex) { Messages.ShowException(ex); } return; } //else return DirectoryList try { string target_dir = string.Format ("{0}\\{1}", server_ref.lpRemoteName, internal_list.Keys[index - 1].shi1_netname); DirectoryList dir_list = new DirectoryList(SortCriteria, SortReverse, target_dir); dir_list.Refill(); use_new = true; new_collection = dir_list; } catch (Exception ex) { Messages.ShowException(ex); } return; }
public override void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { //throw new NotImplementedException(); // there is not child collection }
/// <summary> /// create child collection. will be invoke on <enter> on container items /// </summary> /// <param name="index">target item index</param> /// <param name="new_collection">set if new FileCollectionBase needed</param> /// <param name="use_new">must use new_collection, else use current collection</param> /// <param name="preferred_focused_text">text to set caret</param> public abstract void GetChildCollection(int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text);
public override void GetChildCollection (int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { string old_dir = internal_directory_path; string new_dir = string.Empty; if (index == 0) { //go up if (internal_directory_path == string.Empty) { //already root, return return; } //need parent dir // // first // first/second // first/second/third... preferred_focused_text = FtpPath.GetFile(internal_directory_path); new_dir = FtpPath.GetDirectory(internal_directory_path); internal_directory_path = new_dir; use_new = false; try { Refill(); } catch (Exception ex) { internal_directory_path = old_dir; Messages.ShowException(ex); } return; } else { //go down if (internal_directory_path == string.Empty) { new_dir = internal_list.Keys[index - 1].EntryName; } else { new_dir = FtpPath.Combine(internal_directory_path, internal_list.Keys[index - 1].EntryName); } use_new = false; internal_directory_path = new_dir; try { Refill(); } catch (Exception ex) { internal_directory_path = old_dir; Messages.ShowException(ex); } return; } }
public override void GetChildCollection (int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { if (!GetItemIsContainer(index)) { use_new = false; return; } NETRESOURCE target_container = new NETRESOURCE(); if (index == 0) { //go up to container of resourse_root //cache valid? if (parent_cache != null) { //fill from cache internal_list.Clear(); foreach (NETRESOURCE res in parent_cache.ResourceList) { internal_list.Add(res, null); } preferred_focused_text = resource_root.lpRemoteName; resource_root = parent_cache.ResourceRoot; parent_cache = parent_cache.ParentCache; OnAfterRefill(); use_new = false; return; } //workaround. //Wnet throws exception while getting parent of resource like 'Microsoft Windows Network' if ((resource_root.lpRemoteName == null) || (resource_root.dwDisplayType == ResourceDisplayType.NETWORK)) { target_container = WinApiWNETwrapper.RootNetresource; } else { target_container = WinApiWNETwrapper.GetParentResource(resource_root); } preferred_focused_text = resource_root.lpRemoteName; //set new resource_root resource_root = target_container; //and fill Refill(); //and return use_new = false; return; }//end of UP brunch //else go to down target_container = internal_list.Keys[index - 1]; //case disk share - switch to DirectoryList if (target_container.dwType == ResourceType.DISK) { //switch to DirectoryList DirectoryList new_source = new DirectoryList (SortCriteria, SortReverse, target_container.lpRemoteName); new_source.MainWindow = MainWindow; try { new_source.Refill(); use_new = true; new_collection = new_source; } catch (Win32Exception win5_ex) { if (win5_ex.NativeErrorCode == 5) //access denied { //try to establish connection with creds if (establish_connection(target_container)) { try { //and retry new_source.Refill(); use_new = true; new_collection = new_source; } catch (Exception ex) { Messages.ShowException(ex); } } } else { Messages.ShowException(win5_ex); } } catch (Exception ex) { Messages.ShowException(ex); } return; } //prepare parent cache InternalCache new_cache = new InternalCache(target_container); new_cache.ParentCache = parent_cache; new_cache.ResourceList.AddRange(internal_list.Keys); new_cache.ResourceRoot = resource_root; try { resource_root = target_container; use_new = false; Refill(); parent_cache = new_cache; } catch (Exception ex) { Messages.ShowException(ex); } return; }
public override void GetChildCollection (int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focused_text) { if (LockSafe) { Messages.ShowMessage("Cannot change directory now."); return; } if (!GetItemIsContainer(index)) { use_new = false; return; } //directory to go to.. var target_dir = internal_list.Keys[index]; var old_virt_dir = string.Empty; if (target_dir == "..") { //up if (zip_virtual_dir == string.Empty) { //go to directory list try { new_collection = new DirectoryList(0, false, Path.GetDirectoryName(zip_file_name)); preferred_focused_text = Path.GetFileName(zip_file_name); use_new = true; new_collection.MainWindow = (mainForm)Program.MainWindow; new_collection.Refill(); } catch (Exception ex) { Messages.ShowException(ex); } return; } else { //up old_virt_dir = zip_virtual_dir; zip_virtual_dir = FtpPath.GetDirectory(zip_virtual_dir); preferred_focused_text = old_virt_dir; try { Refill(); } catch (Exception ex) { zip_virtual_dir = old_virt_dir; Messages.ShowException(ex); } return; } } else { //go to down old_virt_dir = zip_virtual_dir; //down zip_virtual_dir = target_dir; try { Refill(); } catch (Exception ex) { zip_virtual_dir = old_virt_dir; Messages.ShowException(ex); } return; } }
public override void GetChildCollection (int index, ref FileCollectionBase new_collection, ref bool use_new, ref string preferred_focus) { if (!GetItemIsContainer(index)) { use_new = false; return; } //directory to go to.. string target_dir = Path.Combine(directory_path, internal_list.Keys[index].cFileName); target_dir = Path.GetFullPath(target_dir); //case for smb network paths if ((target_dir == directory_path) && (target_dir.StartsWith(@"\\"))) { //go to share list try { netCommander.WNet.NETRESOURCE target_res = netCommander.WNet.WinApiWNETwrapper.GetParentResource (netCommander.WNet.WinApiWNETwrapper.GetResourceInfo(directory_path)); WnetResourceList netsh_list = new WnetResourceList(0, false, target_res); netsh_list.MainWindow = MainWindow; netsh_list.Refill(); new_collection = netsh_list; use_new = true; preferred_focus = directory_path; } catch (Exception ex) { Messages.ShowException(ex); } return; } //preferred focus text if (internal_list.Keys[index].cFileName == "..") { //go up string old_dir = Path.GetFileName(directory_path); preferred_focus = old_dir; } else { //go down - focus on 0 preferred_focus = string.Empty; } //use current DirectoryList use_new = false; //save current directory path //needed if exception occur while filling string dir_old = directory_path; directory_path = target_dir; try { Refill(); } catch (Exception ex) { //directory path not change directory_path = dir_old; Messages.ShowException(ex); } }