private void listView1_SelectedIndexChanged(object sender, EventArgs e) { panel1.Controls.Clear(); if (listView1.SelectedItems.Count == 0) { return; } if (currentControl != null) { currentControl.OnDataChanged -= CurrentControl_OnDataChanged; } currentAttachment = (Attachment)listView1.SelectedItems[0]; AttachmentType attachmentType = attachmentTypes[currentAttachment._TypeId]; Type controlType = _context.SidecarDisplayControls[attachmentType.displayControlUuid]; ConstructorInfo constructor = controlType.GetConstructor(new Type[0]); currentControl = (ISidecarDisplayControl)constructor.Invoke(new object[0]); currentControl.Data = currentAttachment._Buffer; currentControl.MediumId = _currentMedia.Id; currentControl.ForceEnabled(); currentControl.OnDataChanged += CurrentControl_OnDataChanged; System.Windows.Forms.Control control = currentControl.ToControl(); control.Dock = DockStyle.Fill; control.AllowDrop = true; control.Enabled = true; panel1.Controls.Add(control); }
private void ScanPluginAssembly(AzusaContext context, Assembly assembly) { Type[] exportedTypes = assembly.GetExportedTypes(); Array.Sort(exportedTypes, new TypeComparer()); Type pluginType = typeof(AzusaPlugin); Type imageAcquisitionPluginType = typeof(IImageAcquisitionPlugin); Type sidecarViewerPluginType = typeof(ISidecarDisplayControl); foreach (Type exportedType in exportedTypes) { if (exportedType.IsAbstract) { continue; } if (exportedType.IsInterface) { continue; } if (pluginType.IsAssignableFrom(exportedType)) { try { AzusaPlugin instance = (AzusaPlugin)Activator.CreateInstance(exportedType); LoadPlugin(instance); } catch (Exception e) { context.Splash.SetLabel(String.Format("Konnte Plug-In {0} nicht starten: {1}", exportedType.Name, e)); } } else if (imageAcquisitionPluginType.IsAssignableFrom(exportedType)) { IImageAcquisitionPlugin instance = (IImageAcquisitionPlugin)Activator.CreateInstance(exportedType); context.ImageAcquisitionPlugins.Add(instance); } else if (sidecarViewerPluginType.IsAssignableFrom(exportedType)) { ISidecarDisplayControl instance = (ISidecarDisplayControl)Activator.CreateInstance(exportedType); Guid guid = instance.DisplayControlUuid; context.SidecarDisplayControls.Add(guid, exportedType); } } }