/// <summary> /// Handles the DragDrop event of contained RichTextBox object. /// Process text changes on drop event. /// </summary> /// <param name="sender">The reference to contained RichTextBox object.</param> /// <param name="e">The event arguments.</param> void OnDragDrop(object sender, DragEventArgs e) { // Check if the picked item is the one we added to the toolbox. if (e.Data.GetDataPresent(typeof(ToolboxItemData))) { ToolboxItemData myData = (ToolboxItemData)e.Data.GetData(typeof(ToolboxItemData)); editorControl.Text += myData.Content; // Specify DragDrop result e.Effect = DragDropEffects.Copy; } }
/// <summary> /// Sends notification that an item in the Toolbox is selected through a click, or by pressing ENTER. /// </summary> /// <param name="pDO">Data object that is selected.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> int IVsToolboxUser.ItemPicked(IOleDataObject pDO) { // Create a OleDataObject from the input interface. OleDataObject oleData = new OleDataObject(pDO); // Check if the picked item is the one we added to the toolbox. if (oleData.GetDataPresent(typeof(ToolboxItemData))) { System.Diagnostics.Trace.WriteLine("MyToolboxItemData selected from the toolbox"); ToolboxItemData myData = (ToolboxItemData)oleData.GetData(typeof(ToolboxItemData)); editorControl.Text += myData.Content; } return(VSConstants.S_OK); }