示例#1
0
        private bool HandleVistaFileOk(FileDialogNative.IFileDialog dialog)
        {
            int options     = this.options;
            int filterIndex = this.filterIndex;

            string[] fileNames = this.fileNames;
            bool     securityCheckFileNames = this.securityCheckFileNames;
            bool     flag2 = false;

            try
            {
                uint num3;
                this.securityCheckFileNames = true;
                Thread.MemoryBarrier();
                dialog.GetFileTypeIndex(out num3);
                this.filterIndex = (int)num3;
                this.fileNames   = this.ProcessVistaFiles(dialog);
                if (!this.ProcessFileNames())
                {
                    return(flag2);
                }
                CancelEventArgs e = new CancelEventArgs();
                if (NativeWindow.WndProcShouldBeDebuggable)
                {
                    this.OnFileOk(e);
                    return(!e.Cancel);
                }
                try
                {
                    this.OnFileOk(e);
                    flag2 = !e.Cancel;
                }
                catch (Exception exception)
                {
                    Application.OnThreadException(exception);
                }
            }
            finally
            {
                if (!flag2)
                {
                    this.securityCheckFileNames = securityCheckFileNames;
                    Thread.MemoryBarrier();
                    this.fileNames   = fileNames;
                    this.options     = options;
                    this.filterIndex = filterIndex;
                }
                else if ((this.options & 4) != 0)
                {
                    this.options &= -2;
                }
            }
            return(flag2);
        }
示例#2
0
        private bool HandleVistaFileOk(FileDialogNative.IFileDialog dialog)
        {
            int saveOptions     = options;
            int saveFilterIndex = filterIndex;

            string[] saveFileNames = fileNames;
            bool     ok            = false;

            try
            {
                Thread.MemoryBarrier();
                uint filterIndexTemp;
                dialog.GetFileTypeIndex(out filterIndexTemp);
                filterIndex = unchecked ((int)filterIndexTemp);
                fileNames   = ProcessVistaFiles(dialog);
                if (ProcessFileNames())
                {
                    CancelEventArgs ceevent = new CancelEventArgs();
                    if (NativeWindow.WndProcShouldBeDebuggable)
                    {
                        OnFileOk(ceevent);
                        ok = !ceevent.Cancel;
                    }
                    else
                    {
                        try
                        {
                            OnFileOk(ceevent);
                            ok = !ceevent.Cancel;
                        }
                        catch (Exception e)
                        {
                            Application.OnThreadException(e);
                        }
                    }
                }
            }
            finally
            {
                if (!ok)
                {
                    Thread.MemoryBarrier();
                    fileNames = saveFileNames;

                    options     = saveOptions;
                    filterIndex = saveFilterIndex;
                }
                else
                {
                    if (0 != (options & NativeMethods.OFN_HIDEREADONLY))
                    {
                        //When the dialog is dismissed OK, the Readonly bit can't
                        // be left on if ShowReadOnly was false
                        // Downlevel this happens automatically, on Vista mode, we need to watch out for it.

                        options &= ~NativeMethods.OFN_READONLY;
                    }
                }
            }
            return(ok);
        }