public void Initialize(ISimpleKexplorerGUI newForm, FtpSite ftpSite) { this.isFtpSite = true; this.form = newForm; this.pipeline = new Pipeline(this.form); this.pipeline.StartWork(); this.drivePipelines = new Hashtable(); Pipeline drivePipeline = new Pipeline(this.form); this.drivePipelines[ftpSite.host] = drivePipeline; drivePipeline.StartWork(); KexplorerFtpNode createdNode = new KexplorerFtpNode(ftpSite); this.form.TreeView1.Nodes.Add(createdNode); drivePipeline.AddJob(new FtpLoaderWorkUnit(createdNode, ftpSite, this.form, this)); this.form.TreeView1.ContextMenu.Popup += new EventHandler(this.ContextMenu_Popup); this.form.TreeView1.AfterExpand += new TreeViewEventHandler(TreeView1_AfterExpand); this.form.TreeView1.KeyDown += new KeyEventHandler(TreeView1_KeyDown); this.form.TreeView1.AfterSelect += new TreeViewEventHandler(TreeView1_AfterFtpSelect); this.InitializeScriptManager(); }
/// <summary> /// Read the tree state of the GUI to figure out what is loaded, where it pointed, whats /// the name of the tab. /// </summary> /// <param name="kexplorerTab"></param> private void Initialize(ISimpleKexplorerGUI kexplorerTab) { if (kexplorerTab.TreeView1.Nodes[0] is KexplorerFtpNode) { var site = (KexplorerFtpNode)kexplorerTab.TreeView1.Nodes[0]; this.ftpSite = site.Site; } else { KExplorerNode selectedNode = (KExplorerNode)kexplorerTab.TreeView1.SelectedNode; if (selectedNode != null) { this.currentFolder = selectedNode.DirInfo.FullName; } else { this.currentFolder = ""; } ArrayList tdrives = new ArrayList(); foreach (KExplorerNode node in kexplorerTab.TreeView1.Nodes) { tdrives.Add(node.Text); } this.drives = (string[])tdrives.ToArray(typeof(string)); } }
/// <summary> /// Construct with the drive letter and a pointer to the main form /// </summary> /// <param name="newDriveLetter"></param> /// <param name="form1"></param> public FtpLoaderWorkUnit( KexplorerFtpNode newCreatedDriveNode, FtpSite site, ISimpleKexplorerGUI form1, IWorkGUIFlagger flagger ) { this.createdNode = newCreatedDriveNode; this.site = site; this.form = form1; this.guiFlagger = flagger; }
/// <summary> /// Construct with the drive letter and a pointer to the main form /// </summary> /// <param name="newDriveLetter"></param> /// <param name="form1"></param> public FtpLoaderWorkUnit(KexplorerFtpNode newCreatedDriveNode, FtpSite site, ISimpleKexplorerGUI form1, IWorkGUIFlagger flagger) { this.createdNode = newCreatedDriveNode; this.site = site; this.form = form1; this.guiFlagger = flagger; }
//-----------------------------------------------------------------------------// /// <summary> /// Constructor with a node that is a folder. /// </summary> /// <param name="newFolderNode"></param> /// <param name="newForm"></param> public FtpFolderWorkUnit(KexplorerFtpNode newFolderNode, ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger) { this.folderNode = newFolderNode; this.site = newFolderNode.Site; this.form = newForm; this.guiFlagger = flagger; }
//-----------------------------------------------------------------------------// /// <summary> /// Constructor with a node that is a folder. /// </summary> /// <param name="newFolderNode"></param> /// <param name="newForm"></param> public FtpFolderWorkUnit( KexplorerFtpNode newFolderNode, ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger ) { this.folderNode = newFolderNode; this.site = newFolderNode.Site; this.form = newForm; this.guiFlagger = flagger; }
public KexplorerPanel(Form newMainForm, FtpSite ftpSite) { this.mainForm = newMainForm; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // TODO: Add any initialization after the InitializeComponent call this.controller = new KExplorerControl(); this.controller.Initialize(this, ftpSite); }
private String[] GetSubDirs(string path) { string ftpfullpath = "ftp://" + site.host + path; ArrayList files = new ArrayList(); lock (FtpSite.LockInstance()) { ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential(site.username, site.pwd); //userid and password for the ftp server to given ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails; FtpWebResponse ftpResponse = (FtpWebResponse)ftp.GetResponse(); Stream responseStream = ftpResponse.GetResponseStream(); string strFile; using (StreamReader reader = new StreamReader(responseStream)) { while ((strFile = reader.ReadLine()) != null) { FtpFileInfo fInfo = new FtpFileInfo(strFile, site.type); if (fInfo.isDir && fInfo.name != "." && fInfo.name != "..") { files.Add(fInfo.name); } } } ftpResponse.Close(); } return((String[])files.ToArray(typeof(String))); }
/// <summary> /// Read the tree state of the GUI to figure out what is loaded, where it pointed, whats /// the name of the tab. /// </summary> /// <param name="kexplorerTab"></param> private void Initialize( ISimpleKexplorerGUI kexplorerTab ) { if (kexplorerTab.TreeView1.Nodes[0] is KexplorerFtpNode) { var site = (KexplorerFtpNode)kexplorerTab.TreeView1.Nodes[0]; this.ftpSite = site.Site; } else { KExplorerNode selectedNode = (KExplorerNode)kexplorerTab.TreeView1.SelectedNode; if (selectedNode != null) { this.currentFolder = selectedNode.DirInfo.FullName; } else { this.currentFolder = ""; } ArrayList tdrives = new ArrayList(); foreach (KExplorerNode node in kexplorerTab.TreeView1.Nodes) { tdrives.Add(node.Text); } this.drives = (string[])tdrives.ToArray(typeof(string)); } }
public KexplorerFtpNode(FtpSite site) { this.Text = site.targetFolder + "@" + site.host; this.ftpSite = site; this.path = site.targetFolder; }
public KexplorerFtpNode(FtpSite site, String path, String name) { this.Text = name; this.ftpSite = site; this.path = path; }
//-----------------------------------------------------------------------------// /// <summary> /// Job one is setup the ftp connection. /// /// KCS: 2/19/08 - Drive nodes are created by the main controller, because we know we always /// want them. This insures they're created in alphabetical order. etc. /// </summary> private IWorkUnit DoJobOne() { IWorkUnit nextWorkUnit = null; if (this.ftp == null && !this.stop) { try { ArrayList files = new ArrayList(); lock (FtpSite.LockInstance()) { currentPath = site.targetFolder + "/"; string ftpfullpath = "ftp://" + site.host + currentPath; ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential(site.username, site.pwd); //userid and password for the ftp server to given ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails; FtpWebResponse ftpResponse = (FtpWebResponse)ftp.GetResponse(); Stream responseStream = ftpResponse.GetResponseStream(); string strFile; using (StreamReader reader = new StreamReader(responseStream)) { while ((strFile = reader.ReadLine()) != null) { FtpFileInfo fInfo = new FtpFileInfo(strFile, site.type); if (fInfo.isDir && fInfo.name != "." && fInfo.name != "..") { files.Add(fInfo.name); } } } ftpResponse.Close(); } this.subDirs = (String[])files.ToArray(typeof(String)); if (this.subDirs != null && this.subDirs.Length > 0 && !this.stop) { try { this.guiFlagger.SignalBeginGUI(); this.form.MainForm.Invoke(new InvokeDelegate(this.AddDirectories)); } finally { this.guiFlagger.SignalEndGUI(); } // If there were sub-dirs, then, Job 3 should load each one. nextWorkUnit = this; } } catch (Exception e) { MessageBox.Show("Exception setting up FTP: " + e.Message); } finally { } } return(nextWorkUnit); }