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> /// When a node is selected. Start the job to load the datagrid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeView1_AfterFtpSelect(object sender, TreeViewEventArgs e) { KexplorerFtpNode kNode = (KexplorerFtpNode)e.Node; if (kNode.Stale) { if (kNode.Path == null) { Pipeline drivePipeline = (Pipeline)this.drivePipelines[kNode.Site.host]; if (drivePipeline == null) { drivePipeline = new Pipeline(this.form); this.drivePipelines[kNode.Site.host] = drivePipeline; drivePipeline.StartWork(); } drivePipeline.AddJob(new FtpLoaderWorkUnit(kNode, kNode.Site, this.form, this)); } else { Pipeline drivePipeline = (Pipeline)this.drivePipelines[kNode.Site.host]; if (drivePipeline == null) { drivePipeline = new Pipeline(this.form); this.drivePipelines[kNode.Site.host] = drivePipeline; drivePipeline.StartWork(); } drivePipeline.AddJob(new FtpFolderWorkUnit(kNode, this.form, this)); } //this.pipeline.AddJob( new FolderWorkUnit( kNode, this.form, this ) ); } // File List always gets done in the main pipeline. this.pipeline.AddPriorityJob(new FtpFileListWorkUnit(kNode, this.form, this)); }
//-----------------------------------------------------------------------------// /// <summary> /// When a node is selected. Start the job to load the datagrid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeView1_AfterSelect(object sender, TreeViewEventArgs e) { KExplorerNode kNode = (KExplorerNode)e.Node; if ( kNode.Stale ) { if ( kNode.DirInfo == null ) { string emptyDrive = kNode.Text.Substring(0,1); Pipeline drivePipeline = (Pipeline)this.drivePipelines[ emptyDrive ]; if ( drivePipeline == null ) { drivePipeline = new Pipeline( this.form ); this.drivePipelines[ emptyDrive ] = drivePipeline; drivePipeline.StartWork(); } drivePipeline.AddJob( new DriveLoaderWorkUnit( kNode, emptyDrive, this.form, this )); } else { // Refresh the node if it's stale... string drive = kNode.DirInfo.FullName.Substring(0,1); Pipeline drivePipeline = (Pipeline)this.drivePipelines[ drive ]; if ( drivePipeline == null ) { drivePipeline = new Pipeline( this.form ); this.drivePipelines[ drive ] = drivePipeline; drivePipeline.StartWork(); } drivePipeline.AddJob( new FolderWorkUnit( kNode , this.form, this )); } //this.pipeline.AddJob( new FolderWorkUnit( kNode, this.form, this ) ); } // File List always gets done in the main pipeline. this.pipeline.AddPriorityJob( new FileListWorkUnit( kNode, this.form, this )); }
//-----------------------------------------------------------------------------// /// <summary> /// Initialize with a Form1 /// </summary> /// <param name="newForm"></param> public void Initialize(ISimpleKexplorerGUI newForm, string currentFolderName, ArrayList onlyTheseDrives ) { this.form = newForm; this.pipeline = new Pipeline( this.form); this.pipeline.StartWork(); this.drivePipelines = new Hashtable(); newForm.WatchingForFolder = currentFolderName; string[] drives = null; if ( onlyTheseDrives != null && onlyTheseDrives.Count > 0 ) { drives = (string[])onlyTheseDrives.ToArray(typeof(string)); } else { drives = System.IO.Directory.GetLogicalDrives(); } foreach( string drive in drives ) { //this.pipeline.AddJob( // new DriveLoaderWorkUnit( drive.Substring( 0, 1), this.form, this ) ); Pipeline drivePipeline = new Pipeline( this.form ); this.drivePipelines[ drive.Substring(0,1) ] = drivePipeline; drivePipeline.StartWork(); KExplorerNode createdNode = new KExplorerNode( drive.Substring( 0, 1) ); this.form.TreeView1.Nodes.Add( createdNode ); drivePipeline.AddJob(new DriveLoaderWorkUnit( createdNode, drive.Substring( 0, 1), this.form, this ) ); } this.launcher = new Launcher(); this.launcher.Initialize(); this.form.TreeView1.AfterExpand += new TreeViewEventHandler(TreeView1_AfterExpand); this.form.TreeView1.KeyDown += new KeyEventHandler(TreeView1_KeyDown); this.form.TreeView1.AfterSelect += new TreeViewEventHandler(TreeView1_AfterSelect); this.form.DataGridView1.KeyDown += new KeyEventHandler(DataGrid1_KeyDown); this.form.TreeView1.DoubleClick += new EventHandler(TreeView1_DoubleClick); this.form.DataGridView1.DoubleClick += new EventHandler(DataGrid1_DoubleClick); this.form.TreeView1.MouseDown += new MouseEventHandler(TreeView1_MouseDown); this.InitializeScriptManager(); this.form.TreeView1.ContextMenu.Popup +=new EventHandler(ContextMenu_Popup ); this.form.DataGridView1.ContextMenuStrip = this.form.FileGridMenuStrip; this.form.DataGridView1.ContextMenuStrip.Opening +=new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening); if ( currentFolderName != null && currentFolderName.Length > 0 ) { KExplorerNode driveNode = null; foreach ( KExplorerNode node in this.form.TreeView1.Nodes ) { if ( currentFolderName.StartsWith( node.Text )) { driveNode = node; break; } } Pipeline drivePipeline = (Pipeline)this.drivePipelines[currentFolderName.Substring(0,1)]; drivePipeline.AddJob( new FolderFinderWorkUnit( currentFolderName, new KExplorerNode[]{driveNode} , this.form , this )); } }