Пример #1
0
        internal virtual void SetDialogProperties(IFileDialog dialog)
        {
            uint cookie;

            dialog.Advise(new VistaFileDialogEvents(this), out cookie);

            // Set the default file name
            if (!(_fileNames == null || _fileNames.Length == 0 || string.IsNullOrEmpty(_fileNames[0])))
            {
                string parent = Path.GetDirectoryName(_fileNames[0]);
                if (parent == null || !Directory.Exists(parent))
                {
                    dialog.SetFileName(_fileNames[0]);
                }
                else
                {
                    string folder = Path.GetFileName(_fileNames[0]);
                    dialog.SetFolder(NativeMethods.CreateItemFromParsingName(parent));
                    dialog.SetFileName(folder);
                }
            }

            // Set the filter
            if (!string.IsNullOrEmpty(_filter))
            {
                string[] filterElements = _filter.Split(new char[] { '|' });
                NativeMethods.COMDLG_FILTERSPEC[] filter = new NativeMethods.COMDLG_FILTERSPEC[filterElements.Length / 2];
                for (int x = 0; x < filterElements.Length; x += 2)
                {
                    filter[x / 2].pszName = filterElements[x];
                    filter[x / 2].pszSpec = filterElements[x + 1];
                }
                dialog.SetFileTypes((uint)filter.Length, filter);

                if (_filterIndex > 0 && _filterIndex <= filter.Length)
                {
                    dialog.SetFileTypeIndex((uint)_filterIndex);
                }
            }

            // Default extension
            if (_addExtension && !string.IsNullOrEmpty(_defaultExt))
            {
                dialog.SetDefaultExtension(_defaultExt);
            }

            // Initial directory
            if (!string.IsNullOrEmpty(_initialDirectory))
            {
                IShellItem item = NativeMethods.CreateItemFromParsingName(_initialDirectory);
                dialog.SetDefaultFolder(item);
            }

            if (!string.IsNullOrEmpty(_title))
            {
                dialog.SetTitle(_title);
            }

            dialog.SetOptions((_options | NativeMethods.FOS.FOS_FORCEFILESYSTEM));
        }
Пример #2
0
 private void InitializeEventSink(IFileDialog nativeDlg)
 {
     // Check if we even need to have a sink.
     if (FileOk != null ||
         FolderChanging != null ||
         FolderChanged != null ||
         SelectionChanged != null ||
         FileTypeChanged != null ||
         DialogOpening != null ||
         (controls != null && controls.Count > 0))
     {
         uint cookie;
         nativeEventSink = new NativeDialogEventSink(this);
         nativeDlg.Advise(nativeEventSink, out cookie);
         nativeEventSink.Cookie = cookie;
     }
 }
Пример #3
0
        internal override void SetDialogProperties(IFileDialog dialog)
        {
            base.SetDialogProperties(dialog);

            uint cookie;
            var  events = new TraceLabSaveAsDialogEvents(this);

            dialog.Advise(events, out cookie);

            Ookii.Dialogs.Wpf.Interop.IFileDialogCustomize customize = (Ookii.Dialogs.Wpf.Interop.IFileDialogCustomize)dialog;

            customize.StartVisualGroup(_configVisualGroupId, "Referenced files:");
            customize.AddComboBox(_comboBoxId);
            customize.AddControlItem(_comboBoxId, _ignoreId, ignoreLabel);
            customize.AddControlItem(_comboBoxId, _copyId, copyLabel);
            customize.AddControlItem(_comboBoxId, _copyOverwriteId, copyOverwriteLabel);
            customize.AddControlItem(_comboBoxId, _keepReferenceId, determinePathsLabel);
            customize.SetSelectedControlItem(_comboBoxId, _ignoreId); //select default
            customize.EndVisualGroup();

            customize.AddText(_helpTextId, ignoreDescription);
        }
Пример #4
0
 private void InitializeEventSink(IFileDialog nativeDialog)
 {
     // Check if we even need to have a sink
     if (FileOk != null
         || FolderChanging != null
         || FolderChanged != null
         || SelectionChanged != null
         || FileTypeChanged != null
         || Opening != null
         || (controls != null && controls.Count > 0))
     {
         uint cookie;
         nativeEventSink = new NativeDialogEventSink(this);
         nativeDialog.Advise(nativeEventSink, out cookie);
         nativeEventSink.Cookie = cookie;
     }
 }
Пример #5
0
 public VistaDialogEvents(IFileDialog dialog, OnOkCallback okCallback)
 { 
     _dialog = dialog;
     _eventCookie = dialog.Advise(this);
     _okCallback = okCallback;
 }
Пример #6
0
        internal virtual void SetDialogProperties(IFileDialog dialog)
        {
            uint cookie;
            dialog.Advise(new VistaFileDialogEvents(this), out cookie);

            // Set the default file name
            if( !(_fileNames == null || _fileNames.Length == 0 || string.IsNullOrEmpty(_fileNames[0])) )
            {
                string parent = Path.GetDirectoryName(_fileNames[0]);
                if( parent == null || !Directory.Exists(parent) )
                {
                    dialog.SetFileName(_fileNames[0]);
                }
                else
                {
                    string folder = Path.GetFileName(_fileNames[0]);
                    dialog.SetFolder(NativeMethods.CreateItemFromParsingName(parent));
                    dialog.SetFileName(folder);
                }
            }

            // Set the filter
            if( !string.IsNullOrEmpty(_filter) )
            {
                string[] filterElements = _filter.Split(new char[] { '|' });
                NativeMethods.COMDLG_FILTERSPEC[] filter = new NativeMethods.COMDLG_FILTERSPEC[filterElements.Length / 2];
                for( int x = 0; x < filterElements.Length; x += 2 )
                {
                    filter[x / 2].pszName = filterElements[x];
                    filter[x / 2].pszSpec = filterElements[x + 1];
                }
                dialog.SetFileTypes((uint)filter.Length, filter);

                if( _filterIndex > 0 && _filterIndex <= filter.Length )
                    dialog.SetFileTypeIndex((uint)_filterIndex);
            }

            // Default extension
            if( _addExtension && !string.IsNullOrEmpty(_defaultExt) )
            {
                dialog.SetDefaultExtension(_defaultExt);
            }

            // Initial directory
            if( !string.IsNullOrEmpty(_initialDirectory) )
            {
                IShellItem item = NativeMethods.CreateItemFromParsingName(_initialDirectory);
                dialog.SetDefaultFolder(item);
            }

            // ShowHelp
            if( _showHelp )
            {
                IFileDialogCustomize customize = (IFileDialogCustomize)dialog;
                customize.AddPushButton(HelpButtonId, "&Help");
            }

            if( !string.IsNullOrEmpty(_title) )
            {
                dialog.SetTitle(_title);
            }

            dialog.SetOptions((_options | NativeMethods.FOS.FOS_FORCEFILESYSTEM));
        }
        internal override void SetDialogProperties(IFileDialog dialog)
        {
            base.SetDialogProperties(dialog);

            uint cookie;
            var events = new TraceLabSaveAsDialogEvents(this);
            dialog.Advise(events, out cookie);
            
            Ookii.Dialogs.Wpf.Interop.IFileDialogCustomize customize = (Ookii.Dialogs.Wpf.Interop.IFileDialogCustomize)dialog;
            
            customize.StartVisualGroup(_configVisualGroupId, "Referenced files:");
            customize.AddComboBox(_comboBoxId);
            customize.AddControlItem(_comboBoxId, _ignoreId, ignoreLabel);
            customize.AddControlItem(_comboBoxId, _copyId, copyLabel);
            customize.AddControlItem(_comboBoxId, _copyOverwriteId, copyOverwriteLabel);
            customize.AddControlItem(_comboBoxId, _keepReferenceId, determinePathsLabel);
            customize.SetSelectedControlItem(_comboBoxId, _ignoreId); //select default
            customize.EndVisualGroup();

            customize.AddText(_helpTextId, ignoreDescription);
        }
Пример #8
0
 public VistaDialogEvents(IFileDialog dialog, FileDialog.VistaDialogEvents.OnOkCallback okCallback)
 {
     this._dialog      = dialog;
     this._eventCookie = dialog.Advise(this);
     this._okCallback  = okCallback;
 }