예제 #1
0
        int IDebugPortPicker.DisplayPortPicker(IntPtr hwndParentDialog, out string pbstrPortId)
        {
            // If this is null, then the PortPicker handler shows an error. Set to empty by default
            pbstrPortId = "";
            ContainerPickerDialogWindow dialog = new ContainerPickerDialogWindow();

            // Register parent
            WindowInteropHelper helper = new WindowInteropHelper(dialog);

            helper.Owner = hwndParentDialog;

            bool?dialogResult = dialog.ShowModal();

            if (dialogResult.GetValueOrDefault(false))
            {
                pbstrPortId = dialog.SelectedContainerConnectionString;
                return(VSConstants.S_OK);
            }

            return(VSConstants.S_FALSE);
        }
예제 #2
0
        /// <summary>
        /// Open the ContainerPickerDialog
        /// </summary>
        /// <param name="hwnd">Parent hwnd or IntPtr.Zero</param>
        /// <param name="connectionString">[out] connection string obtained by the dialog</param>
        /// <returns></returns>
        public static bool ShowContainerPickerWindow(IntPtr hwnd, out string connectionString)
        {
            ThreadHelper.ThrowIfNotOnUIThread("Microsoft.SSHDebugPS.ShowContainerPickerWindow");
            ContainerPickerDialogWindow dialog = new ContainerPickerDialogWindow();

            if (hwnd == IntPtr.Zero) // get the VS main window hwnd
            {
                try
                {
                    // parent to the global VS window
                    DTE dte = (DTE)Package.GetGlobalService(typeof(SDTE));
                    hwnd = new IntPtr(dte?.MainWindow?.HWnd ?? 0);
                }
                catch // No DTE?
                {
                    Debug.Fail("No DTE?");
                }
            }

            if (hwnd != IntPtr.Zero)
            {
                WindowInteropHelper helper = new WindowInteropHelper(dialog);
                helper.Owner = hwnd;
            }

            bool?dialogResult = dialog.ShowModal();

            if (dialogResult.GetValueOrDefault(false))
            {
                connectionString = dialog.SelectedContainerConnectionString;
                return(true);
            }

            connectionString = string.Empty;
            return(false);
        }