Author: aolk
Date: 2005-03-24 14:41:54 -0500 (Thu, 24 Mar 2005)
New Revision: 42234

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
Log:
2005-03-24  Alexander Olk  <[EMAIL PROTECTED]>

        * FileDialog.cs: Added Filter support (case sensitiv)



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-24 19:37:03 UTC (rev 42233)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-24 19:41:54 UTC (rev 42234)
@@ -1,3 +1,7 @@
+2005-03-24  Alexander Olk  <[EMAIL PROTECTED]>
+
+       * FileDialog.cs: Added Filter support (case sensitiv)
+
 2005-03-24  Jackson Harper  <[EMAIL PROTECTED]>
 
        * TabControl.cs: Need a couple more pixels for the lines.

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs    
2005-03-24 19:37:03 UTC (rev 42233)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs    
2005-03-24 19:41:54 UTC (rev 42234)
@@ -303,6 +303,14 @@
                        }
                }
                
+               internal ArrayList FilterArrayList
+               {
+                       get
+                       {
+                               return filterArrayList;
+                       }
+               }
+               
                public override void Reset( )
                {
                        addExtension = true;
@@ -353,9 +361,8 @@
                        if ( filter == null )
                                throw new NullReferenceException( "Filter" );
                        
-                       // FIXME: default, MS default is nothing, nada...
                        if ( filter.Length == 0 )
-                               filter = "All Files (*.*)|*.*";
+                               return;
                        
                        string[] filters = filter.Split( new Char[] {'|'} );
                        
@@ -368,9 +375,6 @@
                                
                                filterArrayList.Add( filterStruct );
                        }
-                       
-//                     if ( filterAL.Count > 1 )
-//                             filterAL.Sort();
                }
                
                internal void SendHelpRequest( EventArgs e )
@@ -445,7 +449,7 @@
                        private ComboBox fileTypeComboBox;
                        private ImageList imageListTopToolbar;
                        
-                       private FileDialog fileDialog;
+                       internal FileDialog fileDialog;
                        
                        private string currentDirectoryName;
                        
@@ -676,13 +680,7 @@
                                // Key events DONT'T work
                                fileNameComboBox.KeyUp += new KeyEventHandler( 
OnKeyUpFileNameComboBox );
                                
-                               // FIXME: Default for Filter is "", aka 
nothing, nada...
-                               // which means, show all files
-                               FilterStruct fs = new FilterStruct( "All Files 
(*.*)", "*.*" ); // set default filter;
-                               
-                               fileDialog.filterArrayList.Add( fs );
-                               
-                               UpdateFilters( fileDialog.filterArrayList );
+                               fileTypeComboBox.SelectedIndexChanged += new 
EventHandler( OnSelectedIndexChangedFileTypeComboBox );
                        }
                        
                        public ComboBox FileNameComboBox
@@ -914,6 +912,13 @@
                                }
                        }
                        
+                       void OnSelectedIndexChangedFileTypeComboBox( object 
sender, EventArgs e )
+                       {
+                               fileDialog.FilterIndex = 
fileTypeComboBox.SelectedIndex + 1;
+                               
+                               fileListView.UpdateFileListView( );
+                       }
+                       
                        public void UpdateFilters( ArrayList filters )
                        {
                                fileTypeComboBox.Items.Clear( );
@@ -929,7 +934,7 @@
                                
                                fileTypeComboBox.EndUpdate( );
                                
-                               // TODO: Update the fileListView also...
+                               fileListView.UpdateFileListView( );
                        }
                        
                        public void ChangeDirectory( string path )
@@ -1021,13 +1026,31 @@
                                        View = View.List;
                                }
                                
+                               private ArrayList GetFileInfoArrayList( 
DirectoryInfo directoryInfo )
+                               {
+                                       ArrayList arrayList = new ArrayList( );
+                                       
+                                       if ( 
fileDialogPanel.fileDialog.FilterArrayList.Count != 0 )
+                                       {
+                                               FilterStruct fs = 
(FilterStruct)fileDialogPanel.fileDialog.FilterArrayList[ 
fileDialogPanel.fileDialog.FilterIndex - 1 ];
+                                               
+                                               foreach ( string s in 
fs.filters )
+                                                       arrayList.AddRange( 
directoryInfo.GetFiles( s ) );
+                                       }
+                                       else
+                                               arrayList.AddRange( 
directoryInfo.GetFiles( ) );
+                                       
+                                       return arrayList;
+                               }
+                               
                                public void UpdateFileListView( )
                                {
                                        DirectoryInfo directoryInfo = 
fileDialogPanel.DirectoryInfo;
                                        
                                        DirectoryInfo[] directoryInfoArray = 
directoryInfo.GetDirectories( );
-                                       FileInfo[] fileInfoArray = 
directoryInfo.GetFiles( );
                                        
+                                       ArrayList fileInfoArrayList = 
GetFileInfoArrayList( directoryInfo );
+                                       
                                        fileDialogPanel.fileHashtable.Clear( );
                                        
                                        BeginUpdate( );
@@ -1055,7 +1078,7 @@
                                                Items.Add( listViewItem );
                                        }
                                        
-                                       foreach ( FileInfo fileInfo in 
fileInfoArray )
+                                       foreach ( FileInfo fileInfo in 
fileInfoArrayList )
                                        {
                                                FileStruct fileStruct = new 
FileStruct( );
                                                
@@ -1080,15 +1103,11 @@
                                                Items.Add( listViewItem );
                                        }
                                        
-                                       Console.WriteLine( "Items.Count: " + 
Items.Count );
-                                       
                                        EndUpdate( );
                                }
                                
                                protected override void OnClick( EventArgs e )
                                {
-                                       Console.WriteLine( 
"SelectedItems.Count: " + SelectedItems.Count );
-                                       
                                        if ( !MultiSelect )
                                        {
                                                if ( SelectedItems.Count > 0 )

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to