IDragHandler IDragDropService.GetDragHandler(System.Windows.Forms.IDataObject data) { TreeListNode node = GetNode(data); if (node != null && !data.GetDataPresent(typeof(DragDataObject))) { XRControl[] controls = GetTemplateControlsFromData(node); DragDataObject obj = CreateDragData(controls, ZoomService.GetInstance(DesignerHost)); data.SetData(typeof(DragDataObject), obj); return(new MyControlDragHandler(DesignerHost)); } return(base.GetDragHandler(data)); }
//Note: GetdataPresent is not reliable for IDataObject that did not originate //from .Net. This rtn is called if it did, but we still don't use GetdataPresent. private void ProcessNetDataObject(System.Windows.Forms.IDataObject NetObject) { if (!(NetObject.GetData(typeof(ArrayList)) == null)) { Type AllowedType = typeof(CShItem); object oCSI; foreach (object tempLoopVar_oCSI in NetObject.GetData(typeof(ArrayList)) as IEnumerable) { oCSI = tempLoopVar_oCSI; if (!AllowedType.Equals(oCSI.GetType())) { m_Draglist = new ArrayList(); goto endOfForLoop; } else { m_Draglist.Add(oCSI); } } endOfForLoop: 1.GetHashCode(); //nop } //Shell IDList Array is preferred to HDROP, see if we have one if (!(NetObject.GetData("Shell IDList Array") == null)) { //Get it and also mark that we had one m_StreamCIDA = NetObject.GetData("Shell IDList Array") as MemoryStream; //has one, ASSUME that it matchs what we may have gotten from // ArrayList, if we had one of those if (m_Draglist.Count < 1) //if we didn't have an ArrayList, have to build m_DragList { if (!MakeDragListFromCIDA()) //Could not make it { return; //leaving m_IsValid as false } } } //FileDrop is only used to build m_DragList if not already done if (m_Draglist.Count < 1) { if (!(NetObject.GetData("FileDrop") == null)) { string S; foreach (string tempLoopVar_S in NetObject.GetData("FileDrop", true) as IEnumerable) { S = tempLoopVar_S; try //if GetCShitem returns Nothing(it's failure marker) then catch it { m_Draglist.Add(ExpTreeLib.CShItem.GetCShItem(S)); } catch (Exception ex) //Some problem, throw the whole thing away { Debug.WriteLine("CMyDataObject -- Error in creating CShItem for " + S + "\r\n" + "Error is: " + ex.ToString()); m_Draglist = new ArrayList(); } } } } //At this point we must have a valid m_DragList if (m_Draglist.Count < 1) { return; //no list, not valid } //ensure that DataObject has a Shell IDList Array if (m_StreamCIDA == null) //wouldn't be Nothing if it had one { m_StreamCIDA = MakeShellIDArray(m_Draglist); NetObject.SetData("Shell IDList Array", true, m_StreamCIDA); } //At this point, we have a valid DragList and have ensured that the DataObject // has a CIDA. m_IsValid = true; return; }
/// <summary> /// Stores the specified data in this instance, using the class of the data for the format. /// </summary> /// <param name="data">The data to store.</param> public void SetData(object data) { _underlyingDataObject.SetData(data); }