home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / XZipNet.msi / Data1.cab / MiniExplorer.cs < prev    next >
Encoding:
Text File  |  2002-02-04  |  41.8 KB  |  1,240 lines

  1. /*
  2.  * Xceed Zip for .NET - MiniExplorer Sample Application
  3.  * Copyright (c) 2000-2002 - Xceed Software Inc.
  4.  * 
  5.  * [MiniExplorer.cs]
  6.  * 
  7.  * This application demonstrates how to use the Xceed FileSystem object model
  8.  * in a generic way.
  9.  * 
  10.  * This file is part of Xceed Zip for .NET. The source code in this file 
  11.  * is only intended as a supplement to the documentation, and is provided 
  12.  * "as is", without warranty of any kind, either expressed or implied.
  13.  */
  14.  
  15. using System;
  16. using System.Drawing;
  17. using System.Collections;
  18. using System.ComponentModel;
  19. using System.Windows.Forms;
  20. using System.Data;
  21. using Xceed.FileSystem;
  22. using Xceed.Zip;
  23.  
  24. namespace Xceed.FileSystem.Samples.MiniExplorer
  25. {
  26.   /// <summary>
  27.   /// Summary description for MiniExplorer.
  28.   /// </summary>
  29.   public class MiniExplorer : System.Windows.Forms.Form
  30.   {
  31.     private System.Windows.Forms.TreeView FolderTree;
  32.     private System.Windows.Forms.ListView FileList;
  33.     private System.Windows.Forms.ColumnHeader FileListColName;
  34.     private System.Windows.Forms.ColumnHeader FileListColSize;
  35.     private System.Windows.Forms.ColumnHeader FileListColAttributes;
  36.     private System.Windows.Forms.ListBox ResultList;
  37.     private System.Windows.Forms.MainMenu MiniExplorerMenu;
  38.     private System.Windows.Forms.MenuItem FileMenu;
  39.     private System.Windows.Forms.MenuItem EditMenu;
  40.     private System.Windows.Forms.MenuItem HelpMenu;
  41.     private System.Windows.Forms.MenuItem HelpAboutMenu;
  42.     private System.Windows.Forms.MenuItem FileQuitMenu;
  43.     private System.Windows.Forms.MenuItem EditDeleteMenu;
  44.     private System.Windows.Forms.Splitter splitter1;
  45.     private System.Windows.Forms.Splitter splitter2;
  46.     private System.Windows.Forms.Panel ProgressPanel;
  47.     private System.Windows.Forms.MenuItem EditNewMenu;
  48.     private System.Windows.Forms.MenuItem EditNewFolderMenu;
  49.     private System.ComponentModel.IContainer components;
  50.     private System.Windows.Forms.ProgressBar CurrentProgressBar;
  51.     private System.Windows.Forms.ProgressBar AllProgressBar;
  52.     private System.Windows.Forms.ImageList FileSystemItemImages;
  53.     private System.Windows.Forms.MenuItem EditNewFileMenu;
  54.     private System.Windows.Forms.MenuItem EditCopyMenu;
  55.     private System.Windows.Forms.MenuItem EditCutMenu;
  56.     private System.Windows.Forms.MenuItem EditPasteMenu;
  57.     private System.Windows.Forms.MenuItem menuItem5;
  58.     private System.Windows.Forms.MenuItem EditRefreshMenu;
  59.     private System.Windows.Forms.MenuItem menuItem1;
  60.     private System.Windows.Forms.MenuItem EditRenameMenu;
  61.  
  62.     public MiniExplorer()
  63.     {
  64.       //
  65.       // Required for Windows Form Designer support
  66.       //
  67.       InitializeComponent();
  68.  
  69.       // Retrieve all available disk drives
  70.       string[] drives = System.IO.Directory.GetLogicalDrives();
  71.  
  72.       foreach( string drive in drives )
  73.       {
  74.         FolderTreeNode folder = new FolderTreeNode( new DiskFolder( drive ), drive );
  75.         FolderTree.Nodes.Add( folder );
  76.       }
  77.     }
  78.  
  79.     /// <summary>
  80.     /// Clean up any resources being used.
  81.     /// </summary>
  82.     protected override void Dispose( bool disposing )
  83.     {
  84.       if( disposing )
  85.       {
  86.         if (components != null) 
  87.         {
  88.           components.Dispose();
  89.         }
  90.       }
  91.       base.Dispose( disposing );
  92.     }
  93.  
  94.         #region Windows Form Designer generated code
  95.     /// <summary>
  96.     /// Required method for Designer support - do not modify
  97.     /// the contents of this method with the code editor.
  98.     /// </summary>
  99.     private void InitializeComponent()
  100.     {
  101.       this.components = new System.ComponentModel.Container();
  102.       System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MiniExplorer));
  103.       this.FolderTree = new System.Windows.Forms.TreeView();
  104.       this.FileSystemItemImages = new System.Windows.Forms.ImageList(this.components);
  105.       this.FileList = new System.Windows.Forms.ListView();
  106.       this.FileListColName = new System.Windows.Forms.ColumnHeader();
  107.       this.FileListColSize = new System.Windows.Forms.ColumnHeader();
  108.       this.FileListColAttributes = new System.Windows.Forms.ColumnHeader();
  109.       this.ResultList = new System.Windows.Forms.ListBox();
  110.       this.MiniExplorerMenu = new System.Windows.Forms.MainMenu();
  111.       this.FileMenu = new System.Windows.Forms.MenuItem();
  112.       this.FileQuitMenu = new System.Windows.Forms.MenuItem();
  113.       this.EditMenu = new System.Windows.Forms.MenuItem();
  114.       this.EditCutMenu = new System.Windows.Forms.MenuItem();
  115.       this.EditCopyMenu = new System.Windows.Forms.MenuItem();
  116.       this.EditPasteMenu = new System.Windows.Forms.MenuItem();
  117.       this.menuItem5 = new System.Windows.Forms.MenuItem();
  118.       this.EditNewMenu = new System.Windows.Forms.MenuItem();
  119.       this.EditNewFolderMenu = new System.Windows.Forms.MenuItem();
  120.       this.EditNewFileMenu = new System.Windows.Forms.MenuItem();
  121.       this.EditRenameMenu = new System.Windows.Forms.MenuItem();
  122.       this.EditDeleteMenu = new System.Windows.Forms.MenuItem();
  123.       this.menuItem1 = new System.Windows.Forms.MenuItem();
  124.       this.EditRefreshMenu = new System.Windows.Forms.MenuItem();
  125.       this.HelpMenu = new System.Windows.Forms.MenuItem();
  126.       this.HelpAboutMenu = new System.Windows.Forms.MenuItem();
  127.       this.splitter1 = new System.Windows.Forms.Splitter();
  128.       this.splitter2 = new System.Windows.Forms.Splitter();
  129.       this.ProgressPanel = new System.Windows.Forms.Panel();
  130.       this.CurrentProgressBar = new System.Windows.Forms.ProgressBar();
  131.       this.AllProgressBar = new System.Windows.Forms.ProgressBar();
  132.       this.ProgressPanel.SuspendLayout();
  133.       this.SuspendLayout();
  134.       // 
  135.       // FolderTree
  136.       // 
  137.       this.FolderTree.AllowDrop = true;
  138.       this.FolderTree.Dock = System.Windows.Forms.DockStyle.Left;
  139.       this.FolderTree.HideSelection = false;
  140.       this.FolderTree.ImageIndex = 1;
  141.       this.FolderTree.ImageList = this.FileSystemItemImages;
  142.       this.FolderTree.LabelEdit = true;
  143.       this.FolderTree.Name = "FolderTree";
  144.       this.FolderTree.Size = new System.Drawing.Size(200, 363);
  145.       this.FolderTree.TabIndex = 0;
  146.       this.FolderTree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FolderTree_KeyDown);
  147.       this.FolderTree.DragOver += new System.Windows.Forms.DragEventHandler(this.FolderTree_DragOver);
  148.       this.FolderTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.FolderTree_AfterSelect);
  149.       this.FolderTree.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.FolderTree_AfterLabelEdit);
  150.       this.FolderTree.Leave += new System.EventHandler(this.FolderTree_Leave);
  151.       this.FolderTree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.FolderTree_BeforeExpand);
  152.       this.FolderTree.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.FolderTree_ItemDrag);
  153.       this.FolderTree.DragLeave += new System.EventHandler(this.FolderTree_DragLeave);
  154.       this.FolderTree.DragDrop += new System.Windows.Forms.DragEventHandler(this.FolderTree_DragDrop);
  155.       this.FolderTree.Enter += new System.EventHandler(this.FolderTree_Enter);
  156.       // 
  157.       // FileSystemItemImages
  158.       // 
  159.       this.FileSystemItemImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  160.       this.FileSystemItemImages.ImageSize = new System.Drawing.Size(16, 16);
  161.       this.FileSystemItemImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("FileSystemItemImages.ImageStream")));
  162.       this.FileSystemItemImages.TransparentColor = System.Drawing.Color.White;
  163.       // 
  164.       // FileList
  165.       // 
  166.       this.FileList.AllowDrop = true;
  167.       this.FileList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  168.                                                                                this.FileListColName,
  169.                                                                                this.FileListColSize,
  170.                                                                                this.FileListColAttributes});
  171.       this.FileList.Dock = System.Windows.Forms.DockStyle.Fill;
  172.       this.FileList.FullRowSelect = true;
  173.       this.FileList.HideSelection = false;
  174.       this.FileList.LabelEdit = true;
  175.       this.FileList.Location = new System.Drawing.Point(203, 0);
  176.       this.FileList.Name = "FileList";
  177.       this.FileList.Size = new System.Drawing.Size(485, 363);
  178.       this.FileList.SmallImageList = this.FileSystemItemImages;
  179.       this.FileList.TabIndex = 2;
  180.       this.FileList.View = System.Windows.Forms.View.Details;
  181.       this.FileList.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FileList_KeyDown);
  182.       this.FileList.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.FileList_AfterLabelEdit);
  183.       this.FileList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.FileList_ItemDrag);
  184.       // 
  185.       // FileListColName
  186.       // 
  187.       this.FileListColName.Text = "Name";
  188.       this.FileListColName.Width = 285;
  189.       // 
  190.       // FileListColSize
  191.       // 
  192.       this.FileListColSize.Text = "Size";
  193.       // 
  194.       // FileListColAttributes
  195.       // 
  196.       this.FileListColAttributes.Text = "Attributes";
  197.       this.FileListColAttributes.Width = 85;
  198.       // 
  199.       // ResultList
  200.       // 
  201.       this.ResultList.Dock = System.Windows.Forms.DockStyle.Bottom;
  202.       this.ResultList.Location = new System.Drawing.Point(0, 366);
  203.       this.ResultList.Name = "ResultList";
  204.       this.ResultList.Size = new System.Drawing.Size(688, 69);
  205.       this.ResultList.TabIndex = 3;
  206.       // 
  207.       // MiniExplorerMenu
  208.       // 
  209.       this.MiniExplorerMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  210.                                                                                      this.FileMenu,
  211.                                                                                      this.EditMenu,
  212.                                                                                      this.HelpMenu});
  213.       // 
  214.       // FileMenu
  215.       // 
  216.       this.FileMenu.Index = 0;
  217.       this.FileMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  218.                                                                              this.FileQuitMenu});
  219.       this.FileMenu.Text = "&File";
  220.       // 
  221.       // FileQuitMenu
  222.       // 
  223.       this.FileQuitMenu.Index = 0;
  224.       this.FileQuitMenu.Text = "&Quit";
  225.       this.FileQuitMenu.Click += new System.EventHandler(this.FileQuitMenu_Click);
  226.       // 
  227.       // EditMenu
  228.       // 
  229.       this.EditMenu.Index = 1;
  230.       this.EditMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  231.                                                                              this.EditCutMenu,
  232.                                                                              this.EditCopyMenu,
  233.                                                                              this.EditPasteMenu,
  234.                                                                              this.menuItem5,
  235.                                                                              this.EditNewMenu,
  236.                                                                              this.EditRenameMenu,
  237.                                                                              this.EditDeleteMenu,
  238.                                                                              this.menuItem1,
  239.                                                                              this.EditRefreshMenu});
  240.       this.EditMenu.Text = "&Edit";
  241.       // 
  242.       // EditCutMenu
  243.       // 
  244.       this.EditCutMenu.Index = 0;
  245.       this.EditCutMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
  246.       this.EditCutMenu.Text = "C&ut";
  247.       this.EditCutMenu.Click += new System.EventHandler(this.EditCutMenu_Click);
  248.       // 
  249.       // EditCopyMenu
  250.       // 
  251.       this.EditCopyMenu.Index = 1;
  252.       this.EditCopyMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
  253.       this.EditCopyMenu.Text = "C&opy";
  254.       this.EditCopyMenu.Click += new System.EventHandler(this.EditCopyMenu_Click);
  255.       // 
  256.       // EditPasteMenu
  257.       // 
  258.       this.EditPasteMenu.Index = 2;
  259.       this.EditPasteMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
  260.       this.EditPasteMenu.Text = "&Paste";
  261.       this.EditPasteMenu.Click += new System.EventHandler(this.EditPasteMenu_Click);
  262.       // 
  263.       // menuItem5
  264.       // 
  265.       this.menuItem5.Index = 3;
  266.       this.menuItem5.Text = "-";
  267.       // 
  268.       // EditNewMenu
  269.       // 
  270.       this.EditNewMenu.Index = 4;
  271.       this.EditNewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  272.                                                                                 this.EditNewFolderMenu,
  273.                                                                                 this.EditNewFileMenu});
  274.       this.EditNewMenu.Text = "&New";
  275.       // 
  276.       // EditNewFolderMenu
  277.       // 
  278.       this.EditNewFolderMenu.Index = 0;
  279.       this.EditNewFolderMenu.Text = "&Folder...";
  280.       this.EditNewFolderMenu.Click += new System.EventHandler(this.FileNewFolderMenu_Click);
  281.       // 
  282.       // EditNewFileMenu
  283.       // 
  284.       this.EditNewFileMenu.Index = 1;
  285.       this.EditNewFileMenu.Text = "Fil&e...";
  286.       this.EditNewFileMenu.Click += new System.EventHandler(this.EditNewFileMenu_Click);
  287.       // 
  288.       // EditRenameMenu
  289.       // 
  290.       this.EditRenameMenu.Index = 5;
  291.       this.EditRenameMenu.Shortcut = System.Windows.Forms.Shortcut.F2;
  292.       this.EditRenameMenu.Text = "&Rename";
  293.       this.EditRenameMenu.Click += new System.EventHandler(this.EditRenameMenu_Click);
  294.       // 
  295.       // EditDeleteMenu
  296.       // 
  297.       this.EditDeleteMenu.Index = 6;
  298.       this.EditDeleteMenu.Shortcut = System.Windows.Forms.Shortcut.Del;
  299.       this.EditDeleteMenu.Text = "&Delete";
  300.       this.EditDeleteMenu.Click += new System.EventHandler(this.EditDeleteMenu_Click);
  301.       // 
  302.       // menuItem1
  303.       // 
  304.       this.menuItem1.Index = 7;
  305.       this.menuItem1.Text = "-";
  306.       // 
  307.       // EditRefreshMenu
  308.       // 
  309.       this.EditRefreshMenu.Index = 8;
  310.       this.EditRefreshMenu.Shortcut = System.Windows.Forms.Shortcut.F5;
  311.       this.EditRefreshMenu.Text = "R&efresh";
  312.       this.EditRefreshMenu.Click += new System.EventHandler(this.EditRefreshMenu_Click);
  313.       // 
  314.       // HelpMenu
  315.       // 
  316.       this.HelpMenu.Index = 2;
  317.       this.HelpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  318.                                                                              this.HelpAboutMenu});
  319.       this.HelpMenu.Text = "&Help";
  320.       // 
  321.       // HelpAboutMenu
  322.       // 
  323.       this.HelpAboutMenu.Index = 0;
  324.       this.HelpAboutMenu.Text = "&About MiniExplorer";
  325.       this.HelpAboutMenu.Click += new System.EventHandler(this.HelpAboutMenu_Click);
  326.       // 
  327.       // splitter1
  328.       // 
  329.       this.splitter1.Dock = System.Windows.Forms.DockStyle.Bottom;
  330.       this.splitter1.Location = new System.Drawing.Point(0, 363);
  331.       this.splitter1.Name = "splitter1";
  332.       this.splitter1.Size = new System.Drawing.Size(688, 3);
  333.       this.splitter1.TabIndex = 7;
  334.       this.splitter1.TabStop = false;
  335.       // 
  336.       // splitter2
  337.       // 
  338.       this.splitter2.Location = new System.Drawing.Point(200, 0);
  339.       this.splitter2.Name = "splitter2";
  340.       this.splitter2.Size = new System.Drawing.Size(3, 363);
  341.       this.splitter2.TabIndex = 8;
  342.       this.splitter2.TabStop = false;
  343.       // 
  344.       // ProgressPanel
  345.       // 
  346.       this.ProgressPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
  347.                                                                                 this.CurrentProgressBar,
  348.                                                                                 this.AllProgressBar});
  349.       this.ProgressPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
  350.       this.ProgressPanel.Location = new System.Drawing.Point(0, 435);
  351.       this.ProgressPanel.Name = "ProgressPanel";
  352.       this.ProgressPanel.Size = new System.Drawing.Size(688, 16);
  353.       this.ProgressPanel.TabIndex = 9;
  354.       // 
  355.       // CurrentProgressBar
  356.       // 
  357.       this.CurrentProgressBar.Dock = System.Windows.Forms.DockStyle.Left;
  358.       this.CurrentProgressBar.Name = "CurrentProgressBar";
  359.       this.CurrentProgressBar.Size = new System.Drawing.Size(192, 16);
  360.       this.CurrentProgressBar.TabIndex = 8;
  361.       // 
  362.       // AllProgressBar
  363.       // 
  364.       this.AllProgressBar.Dock = System.Windows.Forms.DockStyle.Fill;
  365.       this.AllProgressBar.Name = "AllProgressBar";
  366.       this.AllProgressBar.Size = new System.Drawing.Size(688, 16);
  367.       this.AllProgressBar.TabIndex = 7;
  368.       // 
  369.       // MiniExplorer
  370.       // 
  371.       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  372.       this.ClientSize = new System.Drawing.Size(688, 451);
  373.       this.Controls.AddRange(new System.Windows.Forms.Control[] {
  374.                                                                   this.FileList,
  375.                                                                   this.splitter2,
  376.                                                                   this.FolderTree,
  377.                                                                   this.splitter1,
  378.                                                                   this.ResultList,
  379.                                                                   this.ProgressPanel});
  380.       this.Menu = this.MiniExplorerMenu;
  381.       this.Name = "MiniExplorer";
  382.       this.Text = "Xceed MiniExplorer";
  383.       this.Load += new System.EventHandler(this.MiniExplorer_Load);
  384.       this.ProgressPanel.ResumeLayout(false);
  385.       this.ResumeLayout(false);
  386.  
  387.     }
  388.         #endregion
  389.  
  390.     /// <summary>
  391.     /// The main entry point for the application.
  392.     /// </summary>
  393.     [STAThread]
  394.     static void Main() 
  395.     {
  396.       Application.Run(new MiniExplorer());
  397.     }
  398.  
  399.     #region FOLDERTREE EVENTS
  400.  
  401.     private void FolderTree_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
  402.     {
  403.       FillFolderTree( ( FolderTreeNode )e.Node );
  404.     }
  405.  
  406.     private void FolderTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
  407.     {
  408.       FillFileList( ( FolderTreeNode ) e.Node );
  409.     }
  410.  
  411.     private void FolderTree_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
  412.     {
  413.       // We always remove the node that was used to rename this new folder.
  414.       FolderTreeNode node = ( FolderTreeNode )e.Node.Parent;
  415.  
  416.       if( !e.CancelEdit && e.Label != null )
  417.       {
  418.         try
  419.         {
  420.           if( node.Folder.GetFolder( e.Label ).Exists )
  421.           {
  422.             MessageBox.Show( "This folder already exists", "Error creating folder", 
  423.               MessageBoxButtons.OK, MessageBoxIcon.Error );
  424.             e.CancelEdit = true;
  425.             e.Node.BeginEdit();
  426.             return;
  427.           }
  428.  
  429.           if( ( ( FolderTreeNode )e.Node ).Folder == null )
  430.           {
  431.             // Create the REAL folder and the node for it.
  432.             AbstractFolder newFolder = node.Folder.CreateFolder( e.Label );
  433.             FolderTreeNode newNode = new FolderTreeNode( newFolder, e.Label );
  434.  
  435.             node.Nodes.Add( newNode );
  436.           }
  437.           else
  438.           {
  439.             // Rename
  440.             ( ( FolderTreeNode )e.Node ).Folder.Name = e.Label;
  441.           }
  442.         }
  443.         catch( Exception except )
  444.         {
  445.           ResultList.Items.Add( except.Message );
  446.         }
  447.       }
  448.  
  449.       // We remove the dummy node only at the very end
  450.       if( e.Node is FolderTreeNode )
  451.       {
  452.         if( ( ( FolderTreeNode )e.Node ).Folder == null )
  453.         {
  454.           // This was a new folder and not a rename.
  455.           e.Node.Remove();
  456.         }
  457.       }
  458.     }
  459.  
  460.     private void FolderTree_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
  461.     {
  462.       ResultList.Items.Clear();
  463.  
  464.       DataObject data = new DataObject();
  465.       data.SetData( typeof( FolderTreeNode ), e.Item );
  466.       DoDragDrop( data, DragDropEffects.Copy | DragDropEffects.Move );
  467.     }
  468.  
  469.     private void FolderTree_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
  470.     {
  471.       TreeNode node = FolderTree.GetNodeAt( this.PointToClient( new Point( e.X, e.Y ) ) );
  472.       AbstractFolder sourceFolder = null;
  473.  
  474.       e.Effect = DragDropEffects.None;
  475.  
  476.       // We don't allow to drop the file/folder in the source folder
  477.       // Check for this.
  478.       if( e.Data.GetDataPresent( typeof( FolderTreeNode ) ) )
  479.       {
  480.         // Copy/move the folder. The source folder is provided in e.Data
  481.         sourceFolder = ( ( FolderTreeNode )e.Data.GetData( typeof( FolderTreeNode ) ) ).Folder;
  482.       }
  483.       else
  484.       {
  485.         // Copy/move the file(s). The source folder is the selected one.
  486.         sourceFolder = ( ( FolderTreeNode ) FolderTree.SelectedNode ).Folder;
  487.       }
  488.  
  489.       if( node != null && !( ( FolderTreeNode )node ).Folder.Equals( sourceFolder ) )
  490.       {
  491.         if( !node.Equals( m_previousDropNode ) )
  492.         {
  493.           HighlightDropInNode( node );
  494.         }
  495.  
  496.         if( ( e.KeyState & 4 ) > 0 && ( e.AllowedEffect & DragDropEffects.Move ) > 0 )
  497.           e.Effect = DragDropEffects.Move;
  498.         else if( ( e.AllowedEffect & DragDropEffects.Copy ) > 0 )
  499.           e.Effect = DragDropEffects.Copy;
  500.       }
  501.     }
  502.  
  503.     private void FolderTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
  504.     {
  505.       FolderTreeNode node = ( FolderTreeNode )FolderTree.GetNodeAt( PointToClient( new Point( e.X, e.Y ) ) );
  506.  
  507.       HighlightDropInNode( null );
  508.  
  509.       try
  510.       {
  511.         if( e.Effect == DragDropEffects.Copy )
  512.         {
  513.           PasteFromDataObject( node, e.Data, false );
  514.         }
  515.         else if( e.Effect == DragDropEffects.Move )
  516.         {
  517.           PasteFromDataObject( node, e.Data, true );
  518.         }
  519.       }
  520.       catch( Exception except )
  521.       {
  522.         ResultList.Items.Add( except.Message );
  523.       }
  524.     }
  525.  
  526.     private void FolderTree_DragLeave(object sender, System.EventArgs e)
  527.     {
  528.       HighlightDropInNode( null );
  529.     }
  530.  
  531.     private void FolderTree_Enter(object sender, System.EventArgs e)
  532.     {
  533.       EditNewFolderMenu.Enabled = true;
  534.     }
  535.  
  536.     private void FolderTree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  537.     {
  538.       // Check if only the Ctrl key is pressed
  539.       if( e.Modifiers == Keys.Control )
  540.       {
  541.         switch( e.KeyCode )
  542.         {
  543.           case Keys.Insert:
  544.             CopyFolderInClipboard( false );
  545.             break;
  546.         }
  547.       }
  548.  
  549.       // Check if only the Shift key is pressed
  550.       if( e.Modifiers == Keys.Shift )
  551.       {
  552.         switch( e.KeyCode )
  553.         {
  554.           case Keys.Insert:
  555.             PasteFromClipboard();
  556.             break;
  557.  
  558.           case Keys.Delete:
  559.             CopyFolderInClipboard( true );
  560.             break;
  561.         }
  562.       }
  563.     }
  564.  
  565.     private void FolderTree_Leave(object sender, System.EventArgs e)
  566.     {
  567.       EditNewFolderMenu.Enabled = false;
  568.     }
  569.  
  570.     #endregion FOLDERTREE EVENTS
  571.  
  572.     #region FILELIST EVENTS
  573.  
  574.     private void FileList_AfterLabelEdit(object sender, System.Windows.Forms.LabelEditEventArgs e)
  575.     {
  576.       FolderTreeNode node = ( FolderTreeNode )FolderTree.SelectedNode;
  577.  
  578.       // Check if the file already exists
  579.       if( e.Label != null )
  580.       {
  581.         if( node.Folder.GetFile( e.Label ).Exists )
  582.         {
  583.           MessageBox.Show( "This file already exists", "Error creating file", 
  584.             MessageBoxButtons.OK, MessageBoxIcon.Error );
  585.           e.CancelEdit = true;
  586.           FileList.Items[ e.Item ].BeginEdit();
  587.           return;
  588.         }
  589.       }
  590.  
  591.       if( !e.CancelEdit && e.Label != null )
  592.       {
  593.         try
  594.         {
  595.           if( ( ( FileListItem ) FileList.Items[ e.Item ] ).File == null )
  596.           {
  597.             // We always remove the node that was used to rename this new zip file.
  598.             FileList.Items[ e.Item ].Remove();
  599.  
  600.             AbstractFile newFile = node.Folder.CreateFile( e.Label, false );
  601.             FileListItem newItem = new FileListItem( newFile );
  602.  
  603.             FileList.Items.Add( newItem );
  604.           }
  605.           else
  606.           {
  607.             // Rename
  608.             ( ( FileListItem ) FileList.Items[ e.Item ] ).File.Name = e.Label;
  609.           }
  610.  
  611.           // We must also refresh the FolderTree since this file may end by ".zip"
  612.           RefreshFolderTree( node );
  613.         }
  614.         catch( Exception except )
  615.         {
  616.           ResultList.Items.Add( except.Message );
  617.         }
  618.       }
  619.     }
  620.  
  621.     private void FileList_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
  622.     {
  623.       AbstractFile[] files = new AbstractFile[ FileList.SelectedItems.Count ];
  624.       int index = 0;
  625.  
  626.       foreach( FileListItem item in FileList.SelectedItems )
  627.       {
  628.         files[ index++ ] = item.File;
  629.         ResultList.Items.Add( "Dragging " + item.File.FullName );
  630.       }
  631.  
  632.       DataObject data = new DataObject( files );
  633.       DoDragDrop( data, DragDropEffects.Copy | DragDropEffects.Move );
  634.     }
  635.  
  636.  
  637.     private void FileList_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  638.     {
  639.       // Check if only the Ctrl key is pressed
  640.       if( e.Modifiers == Keys.Control )
  641.       {
  642.         switch( e.KeyCode )
  643.         {
  644.           case Keys.Insert:
  645.             CopyFilesInClipboard( false );
  646.             break;
  647.         }
  648.       }
  649.  
  650.       // Check if only the Shift key is pressed
  651.       if( e.Modifiers == Keys.Shift )
  652.       {
  653.         switch( e.KeyCode )
  654.         {
  655.           case Keys.Insert:
  656.             PasteFromClipboard();
  657.             break;
  658.  
  659.           case Keys.Delete:
  660.             CopyFilesInClipboard( true );
  661.             break;
  662.         }
  663.       }
  664.     }
  665.     #endregion FILELIST EVENTS
  666.  
  667.     #region MENU EVENTS
  668.  
  669.     private void EditCutMenu_Click(object sender, System.EventArgs e)
  670.     {
  671.       if( FolderTree.Focused )
  672.       {
  673.         CopyFolderInClipboard( true );
  674.       }
  675.       else
  676.       {
  677.         if( FileList.Focused )
  678.         {
  679.           CopyFilesInClipboard( true );
  680.         }
  681.       }
  682.     }
  683.  
  684.     private void EditCopyMenu_Click(object sender, System.EventArgs e)
  685.     {
  686.       if( FolderTree.Focused )
  687.       {
  688.         CopyFolderInClipboard( false );
  689.       }
  690.       else
  691.       {
  692.         if( FileList.Focused )
  693.         {
  694.           CopyFilesInClipboard( false);
  695.         }
  696.       }
  697.     }
  698.  
  699.     private void EditPasteMenu_Click(object sender, System.EventArgs e)
  700.     {
  701.       PasteFromClipboard();
  702.     }
  703.  
  704.     private void EditDeleteMenu_Click(object sender, System.EventArgs e)
  705.     {
  706.       if( FolderTree.Focused )
  707.       {
  708.         DeleteCurrentFolder();
  709.       }
  710.       else
  711.       {
  712.         if( FileList.Focused )
  713.         {
  714.           DeleteCurrentFile();
  715.         }
  716.       }
  717.     }
  718.  
  719.     private void EditNewFileMenu_Click(object sender, System.EventArgs e)
  720.     {
  721.       FolderTreeNode node = ( FolderTreeNode )FolderTree.SelectedNode;
  722.  
  723.       if( node != null )
  724.       {
  725.         FileListItem newFile = new FileListItem( "New file.zip" );
  726.         FileList.Items.Add( newFile );
  727.  
  728.         newFile.BeginEdit();
  729.       }
  730.     }
  731.  
  732.     private void EditRefreshMenu_Click(object sender, System.EventArgs e)
  733.     {
  734.       FillFileList( ( FolderTreeNode )FolderTree.SelectedNode );
  735.     }
  736.  
  737.     private void EditRenameMenu_Click(object sender, System.EventArgs e)
  738.     {
  739.       if( FolderTree.Focused )
  740.       {
  741.         RenameCurrentFolder();
  742.       }
  743.       else
  744.       {
  745.         if( FileList.Focused )
  746.         {
  747.           RenameCurrentFile();
  748.         }
  749.       }
  750.     }
  751.  
  752.     private void FileNewFolderMenu_Click(object sender, System.EventArgs e)
  753.     {
  754.       if( FolderTree.Focused )
  755.       {
  756.         FolderTreeNode node = ( FolderTreeNode )FolderTree.SelectedNode;
  757.  
  758.         if( node != null )
  759.         {
  760.           node.Expand();
  761.  
  762.           FolderTreeNode newFolder = new FolderTreeNode( "New folder" );
  763.           node.Nodes.Add( newFolder );
  764.  
  765.           // Expand again, without refreshing view, if newly added item is alone
  766.           if( node.Nodes.Count == 1 )
  767.           {
  768.             m_preventTreeUpdate = true;
  769.             node.Expand();
  770.             m_preventTreeUpdate = false;
  771.           }
  772.  
  773.           newFolder.BeginEdit();
  774.         }
  775.       }
  776.     }
  777.  
  778.     private void FileQuitMenu_Click(object sender, System.EventArgs e)
  779.     {
  780.       this.Close();
  781.     }
  782.  
  783.     private void HelpAboutMenu_Click(object sender, System.EventArgs e)
  784.     {
  785.       MessageBox.Show("Xceed Zip for .NET - MiniExplorer Sample Application\n" + 
  786.                       "Written in C#\n" +
  787.                       "Copyrights (c) 2001 - Xceed Software Inc.", 
  788.                       "About MiniExplorer...", MessageBoxButtons.OK, MessageBoxIcon.Information);
  789.     }
  790.  
  791.     #endregion MENU EVENTS
  792.  
  793.     #region FILESYSTEM EVENTS
  794.  
  795.     private void m_fileSystemEvents_ByteProgression(object sender, Xceed.FileSystem.ByteProgressionEventArgs e)
  796.     {
  797.       CurrentProgressBar.Value = e.CurrentFileBytes.Percent;
  798.       AllProgressBar.Value = e.AllFilesBytes.Percent;
  799.  
  800.       if( e.AllFilesBytes.Percent == 100 )
  801.       {
  802.         CurrentProgressBar.Value = 0;
  803.         AllProgressBar.Value = 0;
  804.       }
  805.     }
  806.  
  807.     private void m_fileSystemEvents_ItemException(object sender, Xceed.FileSystem.ItemExceptionEventArgs e)
  808.     {
  809.       if( e.Exception is InvalidDecryptionPasswordException )
  810.       {
  811.         try
  812.         {
  813.           ZipArchive rootZip = ( ZipArchive )( ( ZippedFile )e.CurrentItem ).RootFolder;
  814.           if( m_currentPassword == rootZip.DefaultDecryptionPassword )
  815.           {
  816.             PasswordForm passwordDialog = new PasswordForm();
  817.  
  818.             if( passwordDialog.ShowDialog( this, e.CurrentItem.FullName, ref m_currentPassword ) == DialogResult.OK )
  819.             {
  820.               rootZip.DefaultDecryptionPassword = m_currentPassword;
  821.               e.Action = ItemExceptionAction.Retry;
  822.             }
  823.           }
  824.           else
  825.           {
  826.             rootZip.DefaultDecryptionPassword = m_currentPassword;
  827.             e.Action = ItemExceptionAction.Retry;
  828.           }
  829.         }
  830.         catch( Exception except )
  831.         {
  832.           System.Diagnostics.Debug.WriteLine( except.Message );
  833.         }
  834.       }
  835.       else
  836.       {
  837.         DialogResult answer = MessageBox.Show( 
  838.           e.Exception.Message + "\n" + "\nWhat do you wish to do?", e.Exception.GetType().ToString() + "...", 
  839.           MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question );
  840.  
  841.         switch( answer )
  842.         {
  843.           case DialogResult.Abort:
  844.             e.Action = ItemExceptionAction.Abort;
  845.             break;
  846.  
  847.           case DialogResult.Retry:
  848.             e.Action = ItemExceptionAction.Retry;
  849.             break;
  850.  
  851.           case DialogResult.Ignore:
  852.             e.Action = ItemExceptionAction.Ignore;
  853.             break;
  854.         }
  855.       }
  856.     }
  857.  
  858.     #endregion FILESYSTEM EVENTS
  859.  
  860.     #region FORM EVENTS
  861.  
  862.     private void MiniExplorer_Load(object sender, System.EventArgs e)
  863.     {
  864.       m_fileSystemEvents = new FileSystemEvents();
  865.       m_fileSystemEvents.ByteProgression += new ByteProgressionEventHandler( m_fileSystemEvents_ByteProgression );
  866.       m_fileSystemEvents.ItemException += new ItemExceptionEventHandler( m_fileSystemEvents_ItemException );
  867.     }
  868.  
  869.     #endregion FORM EVENTS
  870.  
  871.     #region PRIVATE METHODS
  872.  
  873.     private void CopyFolderInClipboard( bool cut )
  874.     {
  875.       m_Clipboard = new DataObject();
  876.  
  877.       m_Clipboard.SetData( typeof( FolderTreeNode ), ( FolderTreeNode )FolderTree.SelectedNode );
  878.       // As a goodie, we provide a textual representation of the Folder in the Clipboard
  879.       m_Clipboard.SetData( DataFormats.Text, ( ( FolderTreeNode )FolderTree.SelectedNode ).Folder.FullName );
  880.       System.Windows.Forms.Clipboard.SetDataObject( m_Clipboard );
  881.  
  882.       m_cutClipboard = cut;
  883.     }
  884.  
  885.     private void CopyFilesInClipboard( bool cut )
  886.     {
  887.       AbstractFile[] files = new AbstractFile[ FileList.SelectedItems.Count ];
  888.       int index = 0;
  889.       System.Text.StringBuilder textContent = new System.Text.StringBuilder();
  890.  
  891.       foreach( FileListItem item in FileList.SelectedItems )
  892.       {
  893.         files[ index++ ] = item.File;
  894.         // As a goodie, we provide a textual representation of each selected file in the Clipboard
  895.         textContent.Append( item.File.FullName + "\r\n" );
  896.       }
  897.  
  898.       m_Clipboard = new DataObject();
  899.  
  900.       m_Clipboard.SetData( typeof( AbstractFile[] ), files );
  901.       m_Clipboard.SetData( DataFormats.Text, textContent );
  902.       Clipboard.SetDataObject( m_Clipboard );
  903.  
  904.       m_cutClipboard = cut;
  905.     }
  906.  
  907.     private void PasteFromClipboard()
  908.     {
  909.       if( FolderTree.Focused || FileList.Focused )
  910.       {
  911.         // We use the m_Clipboard object because of a bug in the Clipboard.GetDataObject().
  912.         PasteFromDataObject( ( FolderTreeNode )FolderTree.SelectedNode, m_Clipboard, m_cutClipboard );
  913.         
  914.         // The potential following "pastes" shall not "cut"
  915.         m_cutClipboard = false;
  916.       }
  917.     }
  918.  
  919.     private void PasteFromDataObject( FolderTreeNode destinationNode, IDataObject dataObject, bool move )
  920.     {
  921.       if( move )
  922.       {
  923.         ResultList.Items.Add( "Moving to folder " + destinationNode.Folder.FullName + "..." );
  924.       }
  925.       else
  926.       {
  927.         ResultList.Items.Add( "Copying to folder " + destinationNode.Folder.FullName + "..." );
  928.       }
  929.  
  930.       IBatchUpdateable batch = destinationNode.Folder.RootFolder as IBatchUpdateable;
  931.  
  932.       Cursor.Current = Cursors.WaitCursor;
  933.       if( batch != null )
  934.         batch.BeginUpdate();
  935.  
  936.       try
  937.       {
  938.         if( dataObject.GetDataPresent( typeof( FolderTreeNode ) ) )
  939.         {
  940.           FolderTreeNode sourceNode = ( FolderTreeNode )dataObject.GetData( typeof( FolderTreeNode ) );
  941.           AbstractFolder folder = sourceNode.Folder;
  942.  
  943.           ResultList.Items.Add( " folder " + folder.FullName );
  944.  
  945.           if( move )
  946.           {
  947.             folder.MoveTo( m_fileSystemEvents, null, destinationNode.Folder, false);
  948.             // We just moved the folder. Refresh its (previous) parent.
  949.             RefreshFolderTree( ( FolderTreeNode )sourceNode.Parent );
  950.           }
  951.           else
  952.           {
  953.             folder.CopyTo( m_fileSystemEvents, null, destinationNode.Folder, false );
  954.           }
  955.         }
  956.         else if( dataObject.GetDataPresent( typeof( AbstractFile[] ) ) )
  957.         {
  958.           foreach( AbstractFile file in ( AbstractFile[] )dataObject.GetData( typeof( AbstractFile[] ) ) )
  959.           {
  960.             ResultList.Items.Add( " file " + file.FullName );
  961.             if( move )
  962.             {
  963.               file.MoveTo( m_fileSystemEvents, null, destinationNode.Folder, true );
  964.             }
  965.             else
  966.             {
  967.               file.CopyTo( m_fileSystemEvents, null, destinationNode.Folder, true );
  968.             }
  969.           }
  970.         }
  971.         else
  972.         {
  973.           ResultList.Items.Add( "Unknown data type." );
  974.         }
  975.       }
  976.       finally
  977.       {
  978.         if( batch != null )
  979.           batch.EndUpdate();
  980.       }
  981.  
  982.       Cursor.Current = Cursors.Default;
  983.       RefreshFolderTree( destinationNode );
  984.       FillFileList( ( FolderTreeNode )FolderTree.SelectedNode );
  985.     }
  986.  
  987.     private void RefreshFolderTree( FolderTreeNode rootNode )
  988.     {
  989.       if( rootNode.IsExpanded )
  990.       {
  991.         rootNode.Collapse();
  992.         rootNode.Expand();
  993.       }
  994.     }
  995.  
  996.     private void RenameCurrentFolder()
  997.     {
  998.       if( FolderTree.SelectedNode != null )
  999.       {
  1000.         FolderTree.SelectedNode.BeginEdit();
  1001.       }
  1002.     }
  1003.  
  1004.     private void RenameCurrentFile()
  1005.     {
  1006.       if( FileList.SelectedItems.Count > 0 )
  1007.       {
  1008.         FileList.SelectedItems[ 0 ].BeginEdit();
  1009.       }
  1010.     }
  1011.  
  1012.     private void FillFolderTree( FolderTreeNode node )
  1013.     {
  1014.       if( !m_preventTreeUpdate )
  1015.       {
  1016.         Cursor.Current = Cursors.WaitCursor;
  1017.         node.Nodes.Clear();
  1018.  
  1019.         try
  1020.         {
  1021.           // We want to display zip files as folders
  1022.           foreach( AbstractFile file in node.Folder.GetFiles( false, "*.zip" ) )
  1023.           {
  1024.             try
  1025.             {
  1026.               FolderTreeNode sub = new FolderTreeNode( new ZipArchive( file ), file.Name );
  1027.               sub.ForeColor = Color.Green;
  1028.               node.Nodes.Add( sub );
  1029.             }
  1030.             catch( Exception except )
  1031.             {
  1032.               ResultList.Items.Add( except.Message );
  1033.             }
  1034.           }
  1035.         }
  1036.         catch( Exception except )
  1037.         {
  1038.           ResultList.Items.Add( except.Message );
  1039.         }
  1040.  
  1041.         try
  1042.         {
  1043.           // We must not forget normal folders  
  1044.           foreach( AbstractFolder folder in node.Folder.GetFolders( false ) )
  1045.           {
  1046.             try
  1047.             {
  1048.               FolderTreeNode sub = new FolderTreeNode( folder, folder.Name );
  1049.               node.Nodes.Add( sub );
  1050.             }
  1051.             catch( Exception except )
  1052.             {
  1053.               ResultList.Items.Add( except.Message );
  1054.             }
  1055.           }
  1056.         }
  1057.         catch( Exception except )
  1058.         {
  1059.           ResultList.Items.Add( except.Message );
  1060.         }
  1061.  
  1062.         Cursor.Current = Cursors.Default;
  1063.       }
  1064.     }
  1065.  
  1066.     private void FillFileList( FolderTreeNode node )
  1067.     {
  1068.       FileList.Items.Clear();
  1069.  
  1070.       if( node != null )
  1071.       {
  1072.         Cursor.Current = Cursors.WaitCursor;
  1073.  
  1074.         try
  1075.         {
  1076.           foreach( AbstractFile file in node.Folder.GetFiles( false ) )
  1077.           {
  1078.             try
  1079.             {
  1080.               FileListItem item = new FileListItem( file );
  1081.               FileList.Items.Add( item );
  1082.             }
  1083.             catch( Exception except )
  1084.             {
  1085.               ResultList.Items.Add( except.Message );
  1086.             }
  1087.           }
  1088.         }
  1089.         catch( Exception except )
  1090.         {
  1091.           ResultList.Items.Add( except.Message );
  1092.         }
  1093.  
  1094.         Cursor.Current = Cursors.Default;
  1095.       }
  1096.     }
  1097.  
  1098.     private void HighlightDropInNode( TreeNode node )
  1099.     {
  1100.       if( node != null )
  1101.       {
  1102.         node.BackColor = Color.FromKnownColor( KnownColor.Highlight );
  1103.         node.ForeColor = Color.FromKnownColor( KnownColor.HighlightText );
  1104.       }
  1105.  
  1106.       if( m_previousDropNode != null )
  1107.       {
  1108.         if( ( ( FolderTreeNode )m_previousDropNode ).Folder is ZipArchive )
  1109.         {
  1110.           m_previousDropNode.BackColor = Color.FromKnownColor( KnownColor.Window );
  1111.           m_previousDropNode.ForeColor = Color.Green;
  1112.         }
  1113.         else
  1114.         {
  1115.           m_previousDropNode.BackColor = Color.FromKnownColor( KnownColor.Window );
  1116.           m_previousDropNode.ForeColor = Color.FromKnownColor( KnownColor.WindowText );
  1117.         }
  1118.       }
  1119.  
  1120.       m_previousDropNode = node;
  1121.     }
  1122.  
  1123.     private void DeleteCurrentFolder()
  1124.     {
  1125.       FolderTreeNode node = ( FolderTreeNode )FolderTree.SelectedNode;
  1126.  
  1127.       if( node != null )
  1128.       {
  1129.         string folderName = string.Empty;
  1130.  
  1131.         if( node.Folder is ZipArchive )
  1132.         {
  1133.           // The name of the "folder" is the name of the zip file
  1134.           folderName = ( ( ZipArchive )node.Folder ).ZipFile.FullName;
  1135.         }
  1136.         else
  1137.         {
  1138.           folderName = node.Folder.FullName;
  1139.         }
  1140.  
  1141.         DialogResult result = MessageBox.Show(
  1142.           "Please confirm you wish to delete the following folder:\n" + folderName,
  1143.           "Deleting folder...", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
  1144.  
  1145.         if( result == DialogResult.Yes )
  1146.         {
  1147.           try
  1148.           {
  1149.             if( node.Folder is ZipArchive )
  1150.             {
  1151.               // Delete the zip file
  1152.               ( ( ZipArchive )node.Folder ).ZipFile.Delete( m_fileSystemEvents, null );
  1153.             }
  1154.             else
  1155.             {
  1156.               // Delete the folder
  1157.               node.Folder.Delete( m_fileSystemEvents, null );
  1158.             }
  1159.  
  1160.             node.Remove();
  1161.           }
  1162.           catch( Exception except )
  1163.           {
  1164.             ResultList.Items.Add( except.Message );
  1165.           }
  1166.         }
  1167.       }
  1168.     }
  1169.  
  1170.     private void DeleteCurrentFile()
  1171.     {
  1172.       DialogResult result = DialogResult.No;
  1173.  
  1174.       if( FileList.SelectedItems.Count == 1 )
  1175.       {
  1176.         FileListItem item = ( FileListItem )FileList.SelectedItems[ 0 ];
  1177.  
  1178.         result = MessageBox.Show( 
  1179.           "Please confirm you wish to delete the following file:\n" + item.File.FullName,
  1180.           "Deleting file...", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
  1181.       }
  1182.       else if( FileList.SelectedItems.Count > 1 )
  1183.       {
  1184.         result = MessageBox.Show( 
  1185.           "Please confirm you wish to delete all selected files.",
  1186.           "Deleting files...", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
  1187.       }
  1188.  
  1189.       if( result == DialogResult.Yes )
  1190.       {
  1191.         FolderTreeNode node = ( FolderTreeNode )FolderTree.SelectedNode;
  1192.  
  1193.         IBatchUpdateable batch = node.Folder.RootFolder as IBatchUpdateable;
  1194.  
  1195.         if( batch != null )
  1196.           batch.BeginUpdate();
  1197.  
  1198.         try
  1199.         {
  1200.           foreach( FileListItem item in FileList.SelectedItems )
  1201.           {
  1202.             try
  1203.             {
  1204.               item.File.Delete( m_fileSystemEvents, null );
  1205.  
  1206.               // We delete the file entry in the list view
  1207.               FileList.Items.Remove( item );
  1208.             }
  1209.             catch( Exception except )
  1210.             {
  1211.               ResultList.Items.Add( except.Message );
  1212.             }
  1213.           }
  1214.         }
  1215.         finally
  1216.         {
  1217.           if( batch != null )
  1218.             batch.EndUpdate();
  1219.  
  1220.           // We must update the FolderTree since we may have deleted zip files.
  1221.           RefreshFolderTree( node );
  1222.         }
  1223.       }
  1224.     }
  1225.  
  1226.     #endregion PRIVATE METHODS
  1227.  
  1228.     #region PRIVATE FIELDS
  1229.  
  1230.     private bool m_preventTreeUpdate = false;
  1231.     private TreeNode m_previousDropNode = null;
  1232.     private DataObject m_Clipboard = null;
  1233.     private bool m_cutClipboard = false;
  1234.     private FileSystemEvents m_fileSystemEvents = null;
  1235.     private string m_currentPassword = string.Empty;
  1236.  
  1237.     #endregion PRIVATE FIELDS
  1238.     }
  1239. }
  1240.