bool TrySelectType(TypeBrowserDialog typeBrowserDialog, DataGridViewCell cell)
        {
            typeBrowserDialog.ShowDialog();
            if (typeBrowserDialog.SelectedType != null)
            {
                if (!ParameterTypeFilterProvider.IsValidType(typeBrowserDialog.SelectedType))
                {
                    DesignerHelpers.ShowMessage(this.ServiceProvider, SR2.GetString(SR2.InvalidParameterType,
                                                                                    typeBrowserDialog.SelectedType), DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return(false);
                }
                AddToTypeList(typeBrowserDialog.SelectedType);
            }
            typeChooserCellItem.ChosenType = typeBrowserDialog.SelectedType;
            cell.Value = typeBrowserDialog.SelectedType;

            return(true);
        }
Example #2
0
            public bool? ShowDialog( IntPtr owner )
            {
                // create view model based on picker properties, then
                // create and show the view
                var model = new TypeBrowserViewModel()
                {
                    NameConvention = NameConvention,
                    FilterByConvention = !string.IsNullOrEmpty( NameConvention ),
                    LocalAssembly = localAssembly
                };

                model.RestrictedBaseTypeNames.AddRange( RestrictedBaseTypeNames ?? Enumerable.Empty<string>() );
                model.LocalAssemblyReferences.AddRange( localAssemblyReferences );

                using ( var view = new TypeBrowserDialog( model ) )
                {
                    var helper = new WindowInteropHelper( view )
                    {
                        Owner = owner
                    };

                    // change title from default value only if an alternate title is provided
                    if ( !string.IsNullOrEmpty( Title ) )
                        model.Title = Title;

                    var result = view.ShowDialog();

                    // if a type is selected, set it. wrap the type so that it is
                    // serialized across appdomain boundaries
                    if ( ( result ?? false ) )
                        SelectedType = new SimpleType( model.SelectedType );

                    helper.Owner = IntPtr.Zero;

                    return result;
                }
            }
        void ImportContractButtonClicked(object sender, EventArgs e)
        {
            using (TypeBrowserDialog typeBrowserDialog = new TypeBrowserDialog(serviceProvider as IServiceProvider, new ServiceContractsTypeFilterProvider(), "System.String"))
            {
                typeBrowserDialog.ShowDialog();
                if (typeBrowserDialog.SelectedType != null)
                {
                    ServiceContractListItem contractItem = new ServiceContractListItem(this.operationsListBox);
                    contractItem.Validating      += new CancelEventHandler(ServiceContractValidating);
                    contractItem.Name             = typeBrowserDialog.SelectedType.FullName;
                    contractItem.ContractType     = typeBrowserDialog.SelectedType;
                    contractItem.IsCustomContract = false;
                    CancelEventArgs cancelEventArgs = new CancelEventArgs();
                    contractItem.Validating.Invoke(contractItem, cancelEventArgs);
                    if (cancelEventArgs.Cancel)
                    {
                        return;
                    }
                    AddServiceContract(contractItem);

                    ImportContract(typeBrowserDialog.SelectedType);
                }
            }
        }