Skip to content
Robert B Colton edited this page Aug 12, 2016 · 1 revision

Screenshot

Reproduces the toolbox tool window from Visual Studio. Use the [ToolboxItem] attribute to provide available items for listing in the toolbox. You specify the document type for each toolbox item. When the user switches to a different document, Gemini manages showing only the toolbox items that are supported for the active document type. Items are listed in categories. The toolbox supports drag and drop.

Provides

  • IToolbox tool window
  • ToolboxItemAttribute attribute
  • ToolboxDragDrop utility class

NuGet package

Dependencies

  • None

Usage

[ToolboxItem(typeof(GraphViewModel), "Image Source", "Generators")]
public class ImageSource : ElementViewModel
{
	// ...
}

Handling dropping onto a document (this code is from GraphView.xaml.cs):

private void OnGraphControlDragEnter(object sender, DragEventArgs e)
{
    if (!e.Data.GetDataPresent(ToolboxDragDrop.DataFormat))
        e.Effects = DragDropEffects.None;
}

private void OnGraphControlDrop(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(ToolboxDragDrop.DataFormat))
    {
        var mousePosition = e.GetPosition(GraphControl);

        var toolboxItem = (ToolboxItem) e.Data.GetData(ToolboxDragDrop.DataFormat);
        var element = (ElementViewModel) Activator.CreateInstance(toolboxItem.ItemType);
        element.X = mousePosition.X;
        element.Y = mousePosition.Y;

        ViewModel.Elements.Add(element);
    }
}
Clone this wiki locally