Beispiel #1
0
 public virtual void OnToolboxDataItemPicked(ToolboxDataItem dataItem)
 {
     IDesignerHost service = (IDesignerHost) this.ServiceProvider.GetService(typeof(IDesignerHost));
     IDataObject dataObject = dataItem.GetDataObject(service);
     string html = string.Empty;
     if (dataObject != null)
     {
         if (dataObject.GetDataPresent(DataFormats.Html))
         {
             html = dataObject.GetData(DataFormats.Html).ToString();
         }
         else if (dataObject.GetDataPresent(DataFormats.Text))
         {
             html = dataObject.GetData(DataFormats.Text).ToString();
         }
         else if (this.DataObjectConverter.CanConvertToHtml(dataObject) == DataObjectConverterInfo.CanConvert)
         {
             DataObject newDataObject = new DataObject();
             if (this.DataObjectConverter.ConvertToHtml(dataObject, newDataObject))
             {
                 html = (string) newDataObject.GetData(DataFormats.Html);
             }
         }
         BatchedUndoUnit unit = this._editor.OpenBatchUndo("Toolbox");
         try
         {
             this._editor.Document.InsertHtml(html);
         }
         finally
         {
             unit.Close();
         }
     }
 }
Beispiel #2
0
 public virtual void OnToolboxDataItemPicked(ToolboxDataItem dataItem)
 {
     IDesignerHost service = (IDesignerHost) this.ServiceProvider.GetService(typeof(IDesignerHost));
     IDataObject dataObject = dataItem.GetDataObject(service);
     if (dataObject != null)
     {
         base.Paste(dataObject);
     }
 }