private void _cmb_algorithm_SelectedIndexChanged(object sender, EventArgs e) { if (_cmb_algorithm.SelectedIndex >= 0) { // Instance a new object from selected type Core.Addins.AddinInfo info = _cmb_algorithm.SelectedItem as Core.Addins.AddinInfo; if (info != null) { _algorithm = Core.Addins.AddinStore.CreateInstance(info) as Core.IImageAlgorithm; _property_grid.SelectedObject = _algorithm; } } }
private void _cmb_patterns_SelectedIndexChanged(object sender, EventArgs e) { if (_cmb_patterns.SelectedIndex >= 0) { // Instance a new object from selected type Core.Addins.AddinInfo info = _cmb_patterns.SelectedItem as Core.Addins.AddinInfo; if (info != null) { _pattern = Core.Addins.AddinStore.CreateInstance(info) as Core.CalibrationPattern; _pg.SelectedObject = _pattern; if (Context.Setup.Camera.HasIntrinsics) { _pattern.IntrinsicParameters = Context.Setup.Camera.Intrinsics; } } } }
void _pg_config_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) { if (_current != null) { _current.ReleaseInteraction(); _current = null; } Type r = e.NewSelection.PropertyDescriptor.PropertyType; Core.Addins.AddinInfo suitable = _interactors.FirstOrDefault( ai => ai.Attribute <UI.InteractionResultTypeAttribute>().ResultType == r); if (suitable != null) { _current = Core.Addins.AddinStore.CreateInstance(suitable) as UI.I2DInteractor; _current.InteractionCompleted += new EventHandler <Parsley.UI.InteractionEventArgs>(_current_InteractionCompleted); _current.UnscaledSize = _context.Setup.Camera.FrameSize; _current.InteractOn(_context.EmbeddableStream.PictureBox); } }
/// <summary> /// Create default constructed instance of addin /// </summary> /// <param name="ai"></param> /// <returns></returns> public static object CreateInstance(AddinInfo ai) { return(Activator.CreateInstance(ai.Type)); }