static void OnEditedTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { ActivityTypeResolver resolver = (ActivityTypeResolver)sender; resolver.OnEditTypeAssigned(); }
public ActivityTypeResolverAutomationPeer(ActivityTypeResolver owner) : base(owner) { }
// return true if KeyDownEvent should be set to handled bool HandleBrowseType() { bool retval = false; TypeWrapper wrapper = (TypeWrapper)this.typeComboBox.SelectedItem; if ((wrapper != null && !wrapper.IsTypeDefinition) || this.BrowseTypeDirectly) { Type result = null; bool?dialogResult = true; bool typeIsArray = true; bool fireEvent = false; //handle choosing an array of T if (wrapper != null && typeof(ArrayOf <>) == wrapper.Type) { fireEvent = true; this.RaiseEvent(new RoutedEventArgs(TypePresenter.TypeBrowserOpenedEvent, this)); result = wrapper.Type; } else if (wrapper != null && wrapper.DisplayName == NullString) { this.Type = null; return(false); } else { retval = true; fireEvent = true; this.RaiseEvent(new RoutedEventArgs(TypePresenter.TypeBrowserOpenedEvent, this)); TypeBrowser browser = new TypeBrowser(AssemblyContext, this.Context, this.Filter); SetWindowOwner(browser); if (this.CenterTypeBrowserDialog) { browser.WindowStartupLocation = WindowStartupLocation.CenterScreen; } dialogResult = browser.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { result = browser.ConcreteType; } typeIsArray = false; } if (dialogResult.HasValue && dialogResult.Value) { //user may have chosen generic type (IList) if (result.IsGenericTypeDefinition) { retval = true; ActivityTypeResolver wnd = new ActivityTypeResolver(); SetWindowOwner(wnd); wnd.Context = this.Context; wnd.EditedType = result; if (this.CenterActivityTypeResolverDialog) { wnd.WindowStartupLocation = WindowStartupLocation.CenterScreen; } result = (true == wnd.ShowDialog() ? wnd.ConcreteType : null); } //if we have a type if (null != result) { //if we have a ArrayOf<some type here>, create actual array type if (typeIsArray) { result = result.GetGenericArguments()[0].MakeArrayType(); } //add it to the cache if (!MostRecentlyUsedTypes.Any <Type>(p => Type.Equals(p, result))) { MostRecentlyUsedTypes.Add(result); } //and return updated result this.Type = result; } else { this.Type = this.lastSelection; } BindingExpression binding = this.typeComboBox.GetBindingExpression(ComboBox.SelectedItemProperty); binding.UpdateTarget(); } else { SetComboBoxToLastSelection(); } if (fireEvent) { this.RaiseEvent(new RoutedEventArgs(TypePresenter.TypeBrowserClosedEvent, this)); } } return(retval); }