public bool ValidateX509Certificate(X509Certificate certificate, string message)
        {
            var certificate2 = certificate as X509Certificate2;

            Debug.Assert(certificate2 != null);

            if (certificate2.Verify())
            {
                return(true);
            }

            // Use native message box here since Win32 can show it from any thread.
            // Parent window must be NULL since otherwise the call hangs since VS
            // is in modal state due to the progress dialog. Note that native message
            // box appearance is a bit different from VS dialogs and matches OS theme
            // rather than VS fonts and colors.
            var platform = _services.GetService <IPlatformServices>();

            if (Win32MessageBox.Show(platform.ApplicationWindowHandle, message,
                                     Win32MessageBox.Flags.YesNo | Win32MessageBox.Flags.IconWarning) == Win32MessageBox.Result.Yes)
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
 public static void Show()
 {
     if (Interlocked.Exchange(ref LowMemoryMessage.shown, 1) != 0)
     {
         return;
     }
     int num = (int)Win32MessageBox.Show(LowMemoryMessage.errorMessage, LowMemoryMessage.messageTitle, MessageBoxButton.OK, MessageBoxImage.Hand);
 }
Beispiel #3
0
        internal static CredentialHandle ReadFromCredentialManager(string authority)
        {
            if (NativeMethods.CredRead(authority, NativeMethods.CRED_TYPE.GENERIC, 0, out IntPtr creds))
            {
                return(new CredentialHandle(creds));
            }
            var error = Marshal.GetLastWin32Error();

            // if credentials were not found then continue to prompt user for credentials.
            // otherwise there was an error while reading credentials.
            if (error != NativeMethods.ERROR_NOT_FOUND)
            {
                Win32MessageBox.Show(IntPtr.Zero, Invariant($"{Resources.Error_CredReadFailed} {ErrorCodeConverter.MessageFromErrorCode(error)}"),
                                     Win32MessageBox.Flags.OkOnly | Win32MessageBox.Flags.Topmost | Win32MessageBox.Flags.TaskModal);
            }
            return(null);
        }
Beispiel #4
0
 private static void Phase2InitializationUIStage(object arg)
 {
     _initializationFailsafe.Initialize(delegate
     {
         _appInitializationSequencer.UIReady();
     });
     ProcessAppArgs();
     Download.Instance.Phase2Init();
     if (!ZuneShell.DefaultInstance.NavigationsPending && ZuneShell.DefaultInstance.CurrentPage is StartupPage)
     {
         ZuneUI.Shell.NavigateToHomePage();
     }
     if (_dbRebuilt)
     {
         string caption = ZuneLibrary.LoadStringFromResource(109U);
         string text    = ZuneLibrary.LoadStringFromResource(110U);
         if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(text))
         {
             Win32MessageBox.Show(text, caption, Win32MessageBoxType.MB_ICONHAND, null);
         }
     }
     _phase2InitComplete = true;
 }