/// <summary>
 /// Launch the user interface for developer to pick a contract type.
 /// </summary>
 /// <param name="localAssemblyName">The local assembly name.</param>
 /// <param name="referencedAssemblies">The list of referenced assembly names.</param>
 /// <param name="editingContext">The editing context.</param>
 /// <returns>The contract type selected by user or null if user cancels.</returns>
 public static Type SelectContractType(AssemblyName localAssemblyName, IList<AssemblyName> referencedAssemblies, EditingContext editingContext)
 {
     AssemblyContextControlItem assemblyContextControlItem = new AssemblyContextControlItem { LocalAssemblyName = localAssemblyName, ReferencedAssemblyNames = referencedAssemblies };
     TypeBrowser typeBrowser = new TypeBrowser(assemblyContextControlItem, editingContext, FilterFunction);
     bool? dialogResult = typeBrowser.ShowDialog(/* owner = */ null);
     if (dialogResult.HasValue && dialogResult.Value)
     {
         return typeBrowser.ConcreteType;
     }
     else
     {
         return null;
     }
 }
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            var source = (ILocalAssemblySource) value;
            var item = new AssemblyContextControlItem()
            {
                LocalAssemblyName = source.LocalAssemblyName,
                ReferencedAssemblyNames = source.LocalAssemblyReferences.ToList()
            };
            var context = new EditingContext();

            context.Services.Publish( () => new WindowHelperService( IntPtr.Zero ) );
            context.Services.Publish( () => (IMultiTargetingSupportService) new MultiTargetingSupportService( source ) );
            context.Items.SetValue( item );

            return context;
        }
        public TypeBrowser(AssemblyContextControlItem assemblyContext, EditingContext context, Func<Type, bool> filter)
        {
            this.assemblyContext = assemblyContext;
            this.Context = context;
            this.filter = filter;
            SetValue(GenericTypeMappingProperty, new ObservableCollection<TypeKeyValue>());
            GenericTypeMapping.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(GenericTypeMappingCollectionChanged);
            InitializeComponent();
            this.typeEntryTextBox.Focus();

            if (!size.IsEmpty)
            {
                this.Height = size.Height;
                this.Width = size.Width;
            }

            this.SizeChanged += new SizeChangedEventHandler(TypeBrowser_SizeChanged);

            this.HelpKeyword = HelpKeywords.TypeBrowser;
            this.perfEventProvider = new DesignerPerfEventProvider();
        }
 /// <summary>
 /// Get an instance of IExpressionEditorInstance
 /// </summary>
 /// <param name="assemblies"></param>
 /// <param name="importedNamespaces"></param>
 /// <param name="variables"></param>
 /// <param name="text"></param>
 /// <param name="expressionType"></param>
 /// <param name="initialSize"></param>
 /// <returns></returns>
 public IExpressionEditorInstance CreateExpressionEditor(AssemblyContextControlItem assemblies, ImportedNamespaceContextItem importedNamespaces, List<System.Activities.Presentation.Model.ModelItem> variables, string text, Type expressionType, System.Windows.Size initialSize)
 {
     return CreateExpressionEditorPrivate(assemblies, importedNamespaces, variables, text, expressionType,
                                          initialSize);
 }
 /// <summary>
 /// Get an instance of IExpressionEditorInstance
 /// </summary>
 /// <param name="assemblies"></param>
 /// <param name="importedNamespaces"></param>
 /// <param name="variables"></param>
 /// <param name="text"></param>
 /// <returns></returns>
 public IExpressionEditorInstance CreateExpressionEditor(AssemblyContextControlItem assemblies, ImportedNamespaceContextItem importedNamespaces, List<System.Activities.Presentation.Model.ModelItem> variables, string text)
 {
     return CreateExpressionEditorPrivate(assemblies, importedNamespaces, variables, text, null, Size.Empty);
 }
        private IExpressionEditorInstance CreateExpressionEditorPrivate(AssemblyContextControlItem assemblies, ImportedNamespaceContextItem importedNamespaces, List<ModelItem> modelItems, string text, Type expressionType, Size initialSize)
        {
            var instance = new ExpressionEditorInstance();
            instance.Guid = Guid.NewGuid();
            instance.Text = text;
            instance.HighlightWords = EditorKeyWord;
            instance.ExpressionType = expressionType;
            instance.IntellisenseNodeList = CreateUpdatedIntellisense(modelItems);
            instance.LostAggregateFocus += LostFocus;

            editorInstances.Add(instance.Guid.ToString(), instance);
            return instance;
        }
 /// <summary>
 /// Update context
 /// </summary>
 /// <param name="assemblies"></param>
 /// <param name="importedNamespaces"></param>
 public void UpdateContext(AssemblyContextControlItem assemblies, ImportedNamespaceContextItem importedNamespaces)
 {
 }