/// <summary> /// Configure option handler related stuff /// </summary> private void SetupNodePlacerOptions() { // create the EditorControl var editorFactory = new DefaultEditorFactory(); nodePlacerOptionHandler = new OptionHandler("Placer Options"); editorControl = editorFactory.CreateControl(nodePlacerOptionHandler, true, true); editorControl.Dock = DockStyle.Fill; //order is important here... placerOptionsBox.Controls.Add(editorControl); placerOptionsBox.PerformLayout(); descriptorCollection = new List <INodePlacerConfiguration>(); selectionProvider = new DefaultSelectionProvider <INodePlacerConfiguration>(descriptorCollection, delegate { return(true); }) { ContextLookup = Lookups.CreateContextLookupChainLink( (subject, type) => ((type == typeof(IPropertyMapBuilder) && (subject is INodePlacerConfiguration)) ? new AttributeBasedPropertyMapBuilderAttribute().CreateBuilder(subject.GetType()) : null)) }; //when the selection content changes, trigger this action (usually rebuild associated option handlers) selectionProvider.SelectedItemsChanged += SelectionProviderSelectionChanged; selectionProvider.PropertyItemsChanged += delegate { UpdatePreview(); SelectionProviderSelectionChanged(this, null); }; }
/// <summary> /// Update the properties when the current node placer descriptor has changed. /// </summary> private void SelectionProviderSelectionChanged(object sender, EventArgs e) { //We just rebuild the option handler from scratch editorControl.OptionHandler.BuildFromSelection(selectionProvider, Lookups.CreateContextLookupChainLink( (subject, type) => ((type == typeof(IOptionBuilder) && subject is INodePlacerConfiguration)? new SortableOptionBuilder() : null))); }
/// <summary> /// Creates a new instance using the provided domain and a filter. /// </summary> /// <param name="model">The domain to work on.</param> /// <param name="filter">A filter that works on the domain.</param> public DefaultSelectionProvider(IEnumerable <T> model, Predicate <T> filter) { eventfilter = new EventFilter <EventArgs>(); this.model = model; this.filter = filter; link = Lookups.CreateContextLookupChainLink(DescriptorContextLookupCallback); eventfilter.Event += new EventHandler <EventArgs>(eventfilter_Event); }
private void pageSetupButton_Click(object sender, EventArgs e) { OptionHandler optionHandler = new OptionHandler("PageSettings"); //We use only a subset of the available settings, since we want to filter some values //("Unknown" can be returned by some properties, but may not be set on a PrintTicket) var selectionProvider = new DefaultSelectionProvider <PrintTicketOptionsHelper>(new[] { new PrintTicketOptionsHelper(printDialog.PrintTicket) }); selectionProvider.ContextLookup = Lookups.CreateContextLookupChainLink(OptionHandlerContextLookup); selectionProvider.UpdatePropertyViewsNow(); //We populate the OptionHandler optionHandler.BuildFromSelection(selectionProvider, Lookups.CreateContextLookupChainLink(OptionHandlerContextLookup)); EditorForm form = new EditorForm() { OptionHandler = optionHandler, IsAutoAdopt = true, IsAutoCommit = false, Title = "Page Setup" }; form.ShowDialog(); }
/// <summary> /// Configure option handler related stuff /// </summary> private void SetupNodePlacerOptions() { descriptorCollection = new List <INodePlacerConfiguration>(); selectionProvider = new DefaultSelectionProvider <INodePlacerConfiguration>(descriptorCollection, delegate { return(true); }) { ContextLookup = Lookups.CreateContextLookupChainLink( (subject, type) => ((type == typeof(IPropertyMapBuilder) && (subject is INodePlacerConfiguration)) ? new AttributeBasedPropertyMapBuilderAttribute().CreateBuilder(subject.GetType()) : null)) }; //when the selection content changes, trigger this action (usually rebuild associated option handlers) selectionProvider.SelectedItemsChanged += SelectionProviderSelectionChanged; editorControl.OptionHandler = new OptionHandler("NodePlacerOptions"); editorControl.IsAutoAdopt = true; editorControl.IsAutoCommit = true; selectionProvider.PropertyItemsChanged += delegate { UpdatePreview(); SelectionProviderSelectionChanged(this, null); }; }