internal string openSaveButtonText;
internal string searchSaveLabelText;
internal bool fileDialogShowReadOnly;
+ internal bool fileDialogMultiSelect;
public bool AddExtension
{
{
get
{
- return fileNames;
+ if ( fileDialogMultiSelect )
+ return fileNames;
+
+ return null;
}
}
}
}
+ internal bool FileDialogMultiSelect
+ {
+ set
+ {
+ fileDialogMultiSelect = value;
+ fileDialogPanel.MultiSelect = value;
+ }
+
+ get
+ {
+ return fileDialogMultiSelect;
+ }
+ }
+
public override void Reset( )
{
addExtension = true;
}
}
+ internal void SetFilenames( string[] filenames )
+ {
+ fileNames = filenames;
+ }
+
internal ArrayList filterArrayList = new ArrayList();
internal class FileDialogPanel : Panel
private MenuItem previousCheckedMenuItem;
+ private bool multiSelect = false;
+
public FileDialogPanel( FileDialog fileDialog )
{
this.fileDialog = fileDialog;
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
}
}
+ 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 ( currentFileName.Length == 0 )
+ return;
+
+ if ( fileDialog.CheckFileExists )
+ {
+ 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 ( !File.Exists( currentFileName ) )
+ if ( fileListView.SelectedItems.Count > 0 )
{
- 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 );
+ // first remove all selected directories
+ ArrayList al = new ArrayList( );
+
+ foreach ( ListViewItem lvi in fileListView.SelectedItems )
+ {
+ FileStruct fileStruct = (FileStruct)fileHashtable[ lvi.Text ];
+
+ if ( fileStruct.attributes != FileAttributes.Directory )
+ {
+ al.Add( fileStruct );
+ }
+ }
- currentFileName = "";
+ fileDialog.FileName = ( (FileStruct)al[ 0 ] ).fullname;
- return;
+ string[] filenames = new string[ al.Count ];
+
+ for ( int i = 0; i < al.Count; i++ )
+ {
+ filenames[ i ] = ( (FileStruct)al[ i ] ).fullname;
+ }
+
+ fileDialog.SetFilenames( filenames );
}
}
}
}
- fileDialog.FileName = currentFileName;
-
CancelEventArgs cancelEventArgs = new CancelEventArgs( );
cancelEventArgs.Cancel = false;
fileListView.UpdateFileListView( );
}
}
+ else
+ if ( e.Button == newdirToolBarButton )
+ {
+
+ }
}
void OnClickMenuToolBarContextMenu( object sender, EventArgs e )
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;
+ }
}
}
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 );
}
}