Ejemplo n.º 1
0
        private void OnSelectLocalFiles(object sender, SelectLocalFilesEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                CheckFileExists  = true,
                Multiselect      = e.SelectMultipleFiles
            };

            // Unlike WindowsForms, dialogs in WPF return a nullable boolean value.
            if ((dialog.ShowDialog(ParentWindow) ?? false) && (dialog.FileNames.Length > 0))
            {
                e.SelectedFiles = dialog.FileNames;
            }
        }
Ejemplo n.º 2
0
 private void OnSelectLocalFiles(object sender, SelectLocalFilesEventArgs e)
 {
     using (OpenFileDialog dialog = new OpenFileDialog()
     {
         InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
         CheckFileExists = true,
         Multiselect = e.SelectMultipleFiles
     })
     {
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             if (dialog.FileNames.Length > 0)
             {
                 e.SelectedFiles = dialog.FileNames;
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void webControl_SelectLocalFiles(object sender, SelectLocalFilesEventArgs e)
 {
     using (OpenFileDialog dialog = new OpenFileDialog
     {
         Title = e.Title,
         InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
         CheckFileExists = true,
         Multiselect = e.SelectMultipleFiles
     })
     {
         if ((dialog.ShowDialog(BrowserForm) == DialogResult.OK) && (dialog.FileNames.Length > 0))
         {
             e.SelectedFiles = dialog.FileNames;
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Ejemplo n.º 4
0
        private void internalRequestFileChooser( IntPtr caller, bool select_multiple_files, IntPtr title, IntPtr default_paths )
        {
            SelectLocalFilesEventArgs e = new SelectLocalFilesEventArgs(
                select_multiple_files,
                StringHelper.ConvertAweString( title ),
                StringHelper.ConvertAweString( default_paths ) );

            this.OnSelectLocalFiles( this, e );

            if ( ( e.SelectedFiles != null ) && ( e.SelectedFiles.Length > 0 ) )
            {
                foreach ( string f in e.SelectedFiles )
                    this.ChooseFile( f );
            }

            CommandManager.InvalidateRequerySuggested();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Raises the <see cref="SelectLocalFiles"/> event.
 /// </summary>
 protected virtual void OnSelectLocalFiles( object sender, SelectLocalFilesEventArgs e )
 {
     if ( SelectLocalFiles != null )
         SelectLocalFiles( sender, e );
 }