Ejemplo n.º 1
0
        public void HandleDragEnter(DragEventArgs e)
        {
            //wrap standard IDataObject in OutlookDataObject
            OleDataObject dataObject = new OleDataObject(e.Data);

            string[] filenames = null;
            if (dataObject.GetDataPresent("FileDrop"))
            {
                filenames = (string[])dataObject.GetData("FileDrop");
            }
            else if (dataObject.GetDataPresent("FileGroupDescriptor"))
            {
                filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
            }
            if (filenames != null)
            {
                e.Effect = DragDropEffects.Copy;
                foreach (string filename in filenames)
                {
                    string ext = Path.GetExtension(filename).ToLower();
                    if (!this.AllowedExt.Contains(ext))
                    {
                        e.Effect = DragDropEffects.None;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether the Toolbox user supports the referenced data object.
        /// </summary>
        /// <param name="pDO">Data object to be supported.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        int IVsToolboxUser.IsSupported(IOleDataObject pDO)
        {
            // Create a OleDataObject from the input interface.
            OleDataObject oleData = new OleDataObject(pDO);

            // Check if the data object is of type MyToolboxData.
            if (oleData.GetDataPresent(typeof(Toolbox_TestItem1)))
            {
                return(VSConstants.S_OK);
            }
            if (oleData.GetDataPresent(typeof(Toolbox_TestItem2)))
            {
                return(VSConstants.S_OK);
            }

            // In all the other cases return S_FALSE
            return(VSConstants.S_FALSE);
        }
Ejemplo n.º 3
0
        /// <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(Toolbox_TestItem1)))
            {
                Debug.WriteLine("MyToolboxItemData selected from the toolbox");
                Toolbox_TestItem1 myData = (Toolbox_TestItem1)oleData.GetData(typeof(Toolbox_TestItem1));
                //editorControl.Text += myData.Content;
            }
            return(VSConstants.S_OK);
        }
        public int ItemPicked(IDataObject 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(ToolboxData)))
            {
                System.Diagnostics.Trace.WriteLine("MyToolboxItemData selected from the toolbox");
                ToolboxData myData = (ToolboxData)oleData.GetData(typeof(ToolboxData));
                editorControl.tbDropData.Text = myData.Content;
            }
            return(VSConstants.S_OK);
        }