Exemple #1
0
        public static IpcWindow Create(object window)
        {
            if (null == window)
            {
                return(new IpcWindow(IntPtr.Zero));
            }

            IpcWindow ipcWindow = window as IpcWindow;

            if (null != ipcWindow)
            {
                return(ipcWindow);
            }

            WindowInteropHelper helper = window as WindowInteropHelper;

            if (null != helper)
            {
                return(new IpcWindow(helper.Handle));
            }

            System.Windows.Window wpfWindow = window as System.Windows.Window;
            if (null != wpfWindow)
            {
                return(new IpcWindow(new WindowInteropHelper(wpfWindow).Handle));
            }

            System.Windows.Forms.Form formWindow = window as System.Windows.Forms.Form;
            if (null != formWindow)
            {
                return(new IpcWindow(formWindow.Handle));
            }

            return(new IpcWindow(IntPtr.Zero));
        }
Exemple #2
0
        public static string IpcfDecryptFileStream(
            Stream inputStream,
            string inputFilePath,
            DecryptFlags flags,
            bool suppressUI,
            bool offline,
            bool hasUserConsent,
            Form parentWindow,
            ref Stream outputStream,
            WaitHandle cancelCurrentOperation = null)
        {
            SafeIpcPromptContext ipcContext =
                SafeNativeMethods.CreateIpcPromptContext(suppressUI,
                                                         offline,
                                                         hasUserConsent,
                                                         IpcWindow.Create(parentWindow).Handle,
                                                         cancelCurrentOperation);

            return(IpcfDecryptFileStream(
                       inputStream,
                       inputFilePath,
                       flags,
                       ref outputStream,
                       ipcContext));
        }
Exemple #3
0
        public static string IpcfEncryptFileStream(
            Stream inputStream,
            string inputFilePath,
            SafeInformationProtectionLicenseHandle licenseHandle,
            EncryptFlags flags,
            bool suppressUI,
            bool offline,
            bool hasUserConsent,
            Form parentWindow,
            SymmetricKeyCredential symmKey,
            ref Stream outputStream,
            WaitHandle cancelCurrentOperation = null)
        {
            SafeIpcPromptContext ipcContext =
                SafeNativeMethods.CreateIpcPromptContext(
                    suppressUI,
                    offline,
                    hasUserConsent,
                    IpcWindow.Create(parentWindow).Handle,
                    symmKey,
                    cancelCurrentOperation);

            return(IpcfEncryptFileStream(
                       inputStream,
                       inputFilePath,
                       licenseHandle,
                       flags,
                       ref outputStream,
                       ipcContext));
        }
Exemple #4
0
 public static string IpcfDecryptFileStream(
     Stream inputStream,
     string inputFilePath,
     DecryptFlags flags,
     bool suppressUI,
     bool offline,
     bool hasUserConsent,
     Form parentWindow,
     ref Stream outputStream)
 {
     return(IpcfDecryptFileStream(
                inputStream,
                inputFilePath,
                flags,
                suppressUI,
                offline,
                hasUserConsent,
                IpcWindow.Create(parentWindow).Handle,
                ref outputStream));
 }
Exemple #5
0
 public static string IpcfDecryptFile(
     string inputFile,
     DecryptFlags flags,
     bool suppressUI,
     bool offline,
     bool hasUserConsent,
     Form parentWindow,
     SymmetricKeyCredential symmKey,
     string outputDirectory = null)
 {
     return(IpcfDecryptFile(
                inputFile,
                flags,
                suppressUI,
                offline,
                hasUserConsent,
                IpcWindow.Create(parentWindow).Handle,
                symmKey,
                outputDirectory));
 }
        public static IpcWindow Create(object window)
        {
            if (null == window)
            {
                return(new IpcWindow(IntPtr.Zero));
            }

            IpcWindow ipcWindow = window as IpcWindow;

            if (null != ipcWindow)
            {
                return(ipcWindow);
            }

            WindowInteropHelper helper = window as WindowInteropHelper;

            if (null != helper)
            {
                return(new IpcWindow(helper.Handle));
            }

            System.Windows.Window wpfWindow = window as System.Windows.Window;
            if (null != wpfWindow)
            {
                return(new IpcWindow(new WindowInteropHelper(wpfWindow).Handle));
            }

            System.Windows.Forms.Form formWindow = window as System.Windows.Forms.Form;
            if (null != formWindow)
            {
                return(new IpcWindow(formWindow.Handle));
            }

            throw new ArgumentException(
                      "The passed in window must be null or of type: " +
                      "WindowInteropHelper, System.Windows.Window, or System.Windows.Forms.Form", "window");
        }
Exemple #7
0
 public static string IpcfEncryptFileStream(
     Stream inputStream,
     string inputFilePath,
     SafeInformationProtectionLicenseHandle licenseHandle,
     EncryptFlags flags,
     bool suppressUI,
     bool offline,
     bool hasUserConsent,
     Form parentWindow,
     SymmetricKeyCredential symmKey,
     ref Stream outputStream)
 {
     return(IpcfEncryptFileStream(
                inputStream,
                inputFilePath,
                licenseHandle,
                flags,
                suppressUI,
                offline,
                hasUserConsent,
                IpcWindow.Create(parentWindow).Handle,
                symmKey,
                ref outputStream));
 }
Exemple #8
0
 public static string IpcfEncryptFile(
     string inputFile,
     string templateId,
     EncryptFlags flags,
     bool suppressUI,
     bool offline,
     bool hasUserConsent,
     Form parentWindow,
     SymmetricKeyCredential symmKey    = null,
     string outputDirectory            = null,
     WaitHandle cancelCurrentOperation = null)
 {
     return(IpcfEncryptFile(
                inputFile,
                templateId,
                flags,
                suppressUI,
                offline,
                hasUserConsent,
                IpcWindow.Create(parentWindow).Handle,
                symmKey,
                outputDirectory,
                cancelCurrentOperation));
 }