Author: aolk Date: 2005-03-19 08:44:31 -0500 (Sat, 19 Mar 2005) New Revision: 42031
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
Log:
2005-03-19 Alexander Olk <[EMAIL PROTECTED]>
* FileDialog.cs, OpenFileDialog.cs: OpenFileDialog Multiselect now works
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-03-19 04:55:52 UTC (rev 42030)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-03-19 13:44:31 UTC (rev 42031)
@@ -1,3 +1,7 @@
+2005-03-19 Alexander Olk <[EMAIL PROTECTED]>
+
+ * FileDialog.cs, OpenFileDialog.cs: OpenFileDialog Multiselect now works
+
2005-03-18 Peter Bartok <[EMAIL PROTECTED]>
* ThemeWin32Classic.cs: Moved listview column headers a bit, to avoid
@@ -9,9 +13,9 @@
2005-03-18 Peter Bartok <[EMAIL PROTECTED]>
- * ControlPaint.cs:
- - Don't throw NotImplemented exceptions, just print a notice once
- instead (requested by Miguel). This makes running existing SWF
+ * ControlPaint.cs:
+ - Don't throw NotImplemented exceptions, just print a notice once
+ instead (requested by Miguel). This makes running existing SWF
apps a bit easier
* Control.cs:
- Commented out Drag'N'Drop XplatUI call (no driver support yet)
@@ -23,7 +27,7 @@
* ListView.cs:
- Removed debug output
* ThemeWin32Classic.cs:
- - Fixed drawing of status bar, now draws Text property if there
+ - Fixed drawing of status bar, now draws Text property if there
are no defined panels
2005-03-18 Jackson Harper <[EMAIL PROTECTED]>
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-19 04:55:52 UTC (rev 42030)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs
2005-03-19 13:44:31 UTC (rev 42031)
@@ -58,6 +58,7 @@
internal string openSaveButtonText;
internal string searchSaveLabelText;
internal bool fileDialogShowReadOnly;
+ internal bool fileDialogMultiSelect;
public bool AddExtension
{
@@ -141,7 +142,10 @@
{
get
{
- return fileNames;
+ if ( fileDialogMultiSelect )
+ return fileNames;
+
+ return null;
}
}
@@ -285,6 +289,20 @@
}
}
+ internal bool FileDialogMultiSelect
+ {
+ set
+ {
+ fileDialogMultiSelect = value;
+ fileDialogPanel.MultiSelect = value;
+ }
+
+ get
+ {
+ return fileDialogMultiSelect;
+ }
+ }
+
public override void Reset( )
{
addExtension = true;
@@ -382,6 +400,11 @@
}
}
+ internal void SetFilenames( string[] filenames )
+ {
+ fileNames = filenames;
+ }
+
internal ArrayList filterArrayList = new ArrayList();
internal class FileDialogPanel : Panel
@@ -441,6 +464,8 @@
private MenuItem previousCheckedMenuItem;
+ private bool multiSelect = false;
+
public FileDialogPanel( FileDialog fileDialog )
{
this.fileDialog = fileDialog;
@@ -518,6 +543,7 @@
fileListView.Columns.Add( " Type", 100,
HorizontalAlignment.Left );
fileListView.Columns.Add( " Last Access", 150,
HorizontalAlignment.Left );
fileListView.AllowColumnReorder = true;
+ fileListView.MultiSelect = false;
fileListView.TabIndex = 2;
// fileNameLabel
@@ -756,24 +782,72 @@
}
}
+ public bool MultiSelect
+ {
+ set
+ {
+ multiSelect = value;
+ fileListView.MultiSelect = value;
+ }
+
+ get
+ {
+ return multiSelect;
+ }
+ }
+
void OnClickOpenButton( object sender, EventArgs e )
{
- currentFileName =
Path.Combine(currentDirectoryName, fileNameComboBox.Text.Trim());
+ currentFileName = Path.Combine(
currentDirectoryName, fileNameComboBox.Text.Trim( ) );
Console.WriteLine( "OnClickOpenButton
currentFileName: " + currentFileName );
- if ( currentFileName.Length == 0 )
- return;
-
- if ( fileDialog.CheckFileExists )
+ if ( !multiSelect )
{
- if ( !File.Exists( currentFileName ) )
+ if ( currentFileName.Length == 0 )
+ return;
+
+ if ( fileDialog.CheckFileExists )
{
- string message =
currentFileName + " doesn't exist. Please verify that you have entered the
correct file name.";
- MessageBox.Show( message,
fileDialog.OpenSaveButtonText, MessageBoxButtons.OK, MessageBoxIcon.Warning );
+ if ( !File.Exists(
currentFileName ) )
+ {
+ string message =
currentFileName + " doesn't exist. Please verify that you have entered the
correct file name.";
+ MessageBox.Show(
message, fileDialog.OpenSaveButtonText, MessageBoxButtons.OK,
MessageBoxIcon.Warning );
+
+ currentFileName = "";
+
+ return;
+ }
+ }
+
+ fileDialog.FileName = currentFileName;
+ }
+ else // multiSelect = true
+ {
+ if ( fileListView.SelectedItems.Count >
0 )
+ {
+ // first remove all selected
directories
+ ArrayList al = new ArrayList( );
- currentFileName = "";
+ foreach ( ListViewItem lvi in
fileListView.SelectedItems )
+ {
+ FileStruct fileStruct =
(FileStruct)fileHashtable[ lvi.Text ];
+
+ if (
fileStruct.attributes != FileAttributes.Directory )
+ {
+ al.Add(
fileStruct );
+ }
+ }
- return;
+ fileDialog.FileName = (
(FileStruct)al[ 0 ] ).fullname;
+
+ string[] filenames = new
string[ al.Count ];
+
+ for ( int i = 0; i < al.Count;
i++ )
+ {
+ filenames[ i ] = (
(FileStruct)al[ i ] ).fullname;
+ }
+
+ fileDialog.SetFilenames(
filenames );
}
}
@@ -790,8 +864,6 @@
}
}
- fileDialog.FileName = currentFileName;
-
CancelEventArgs cancelEventArgs = new
CancelEventArgs( );
cancelEventArgs.Cancel = false;
@@ -844,6 +916,11 @@
fileListView.UpdateFileListView( );
}
}
+ else
+ if ( e.Button == newdirToolBarButton )
+ {
+
+ }
}
void OnClickMenuToolBarContextMenu( object sender,
EventArgs e )
@@ -1064,17 +1141,21 @@
protected override void OnClick( EventArgs e )
{
- ListViewItem listViewItem;
-
- if (SelectedItems.Count > 0) {
- listViewItem = SelectedItems[ 0
];
-
- FileStruct fileStruct =
(FileStruct)fileDialogPanel.fileHashtable[ listViewItem.Text ];
+ Console.WriteLine(
"SelectedItems.Count: " + SelectedItems.Count );
- if ( fileStruct.attributes !=
FileAttributes.Directory )
+ if ( !MultiSelect )
+ {
+ if ( SelectedItems.Count > 0 )
{
-
fileDialogPanel.FileNameComboBox.Text = listViewItem.Text;
-
fileDialogPanel.CurrentFileName = fileStruct.fullname;
+ ListViewItem
listViewItem = SelectedItems[ 0 ];
+
+ FileStruct fileStruct =
(FileStruct)fileDialogPanel.fileHashtable[ listViewItem.Text ];
+
+ if (
fileStruct.attributes != FileAttributes.Directory )
+ {
+
fileDialogPanel.FileNameComboBox.Text = listViewItem.Text;
+
fileDialogPanel.CurrentFileName = fileStruct.fullname;
+ }
}
}
@@ -1083,23 +1164,59 @@
protected override void OnDoubleClick(
EventArgs e )
{
- ListViewItem listViewItem =
SelectedItems[ 0 ];
-
- FileStruct fileStruct =
(FileStruct)fileDialogPanel.fileHashtable[ listViewItem.Text ];
-
- if ( fileStruct.attributes ==
FileAttributes.Directory )
+ if ( SelectedItems.Count > 0 )
{
-
fileDialogPanel.ChangeDirectory( fileStruct.fullname );
+ ListViewItem listViewItem =
SelectedItems[ 0 ];
+
+ FileStruct fileStruct =
(FileStruct)fileDialogPanel.fileHashtable[ listViewItem.Text ];
+
+ if ( fileStruct.attributes ==
FileAttributes.Directory )
+ {
+
fileDialogPanel.ChangeDirectory( fileStruct.fullname );
+ }
+ else
+ {
+
fileDialogPanel.FileNameComboBox.Text = listViewItem.Text;
+
fileDialogPanel.CurrentFileName = fileStruct.fullname;
+
fileDialogPanel.ForceDialogEnd( );
+ return;
+ }
}
- else
+
+ base.OnDoubleClick( e );
+ }
+
+ protected override void OnSelectedIndexChanged(
EventArgs e )
+ {
+ if ( MultiSelect )
{
-
fileDialogPanel.FileNameComboBox.Text = listViewItem.Text;
- fileDialogPanel.CurrentFileName
= fileStruct.fullname;
- fileDialogPanel.ForceDialogEnd(
);
- return;
+ if ( SelectedItems.Count > 0 )
+ {
+ string combotext = "";
+
+ if (
SelectedItems.Count == 1 )
+ {
+ FileStruct
fileStruct = (FileStruct)fileDialogPanel.fileHashtable[ SelectedItems[ 0 ].Text
];
+
+ if (
fileStruct.attributes != FileAttributes.Directory )
+
combotext = SelectedItems[ 0 ].Text;
+ }
+ else
+ {
+ foreach (
ListViewItem lvi in SelectedItems )
+ {
+
FileStruct fileStruct = (FileStruct)fileDialogPanel.fileHashtable[ lvi.Text ];
+
+ if (
fileStruct.attributes != FileAttributes.Directory )
+
combotext += "\"" + lvi.Text + "\" ";
+ }
+ }
+
+
fileDialogPanel.FileNameComboBox.Text = combotext;
+ }
}
- base.OnDoubleClick( e );
+ base.OnSelectedIndexChanged( e );
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
2005-03-19 04:55:52 UTC (rev 42030)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/OpenFileDialog.cs
2005-03-19 13:44:31 UTC (rev 42031)
@@ -66,6 +66,7 @@
set
{
multiSelect = value;
+ FileDialogMultiSelect = value;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
