Featured post
Initializing objected created in .NET CollectionEditor with a specific reference -
i need initialize new objects created collectioneditor specific reference.
more specifically, have object, pipeline, can edited in propertygrid. object contains collection of markers. markers need reference pipeline in order calculations.
currently, propertygrid pipeline has entry markers. clicking on ellipse button brings collectioneditor. editing properties fine, need set current pipeline new markers created. i'm not sure of best way that. there events can monitor? need create custom collectioneditor (but how know specific pipeline?)?
you need create custom collectioneditor , custom propertydescriptor class. propertydescriptor can store pipeline object gets passed collection editor overriding propertydescriptor.geteditor. let pipeline create new markers objects , required initialization.
here code started:
public class mycollectioneditor : system.componentmodel.design.collectioneditor { private pipeline _pipeline; public mycollectioneditor(type type) : base(type) {} public mycollectioneditor(type type, pipeline pipeline) : base(type) { _pipeline = pipeline; } protected override object createinstance(type itemtype) { return _pipeline.createnewmarker(); } } public class mypropertydescriptor : propertydescriptor { private pipeline _pipeline; public mypropertydescriptor(pipeline pipeline) : base(name, null) { _pipeline = pipeline; } public override object geteditor(type editorbasetype) { return new mycollectioneditor(typeof(markercollection), _pipeline); } // ... other overrides ... } // ... // implement system.componentmodel.icustomtypedescriptor.getproperties public system.componentmodel.propertydescriptorcollection getproperties() { propertydescriptorcollection pdc = new propertydescriptorcollection(null); foreach (marker m in markers) { mypropertydescriptor pd = new mypropertydescriptor(m); pdc.add(pd); } return pdc; }
- Get link
- X
- Other Apps
Comments
Post a Comment