Esempio n. 1
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            DataObject dragDropData = e.Data as DataObject;

            if (this.HoverEditor == null && dragDropData != null && !this.ReadOnly)
            {
                var batchInfoQuery = new ConvertOperation(dragDropData, ConvertOperation.Operation.All).Perform <BatchInfo>();
                if (batchInfoQuery != null)
                {
                    BatchInfo[] newBatchInfoArray = batchInfoQuery.ToArray();
                    // Accept drop
                    e.Effect = e.AllowedEffect;

                    IEnumerable <object> values    = this.GetValue();
                    BatchInfo[]          newValues = new BatchInfo[Math.Max(1, values.Count())];
                    for (int i = 0; i < newValues.Length; i++)
                    {
                        newValues[i] = new BatchInfo(newBatchInfoArray[0]);
                    }
                    this.SetValues(newValues);
                    this.PerformGetValue();
                    return;
                }
            }

            // Move on to children if failed otherwise
            base.OnDragDrop(e);
        }
Esempio n. 2
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            DataObject dragDropData = e.Data as DataObject;

            if (this.HoverEditor == null && dragDropData != null && !this.ReadOnly)
            {
                var batchInfoQuery = new ConvertOperation(dragDropData, ConvertOperation.Operation.All).Perform <BatchInfo>();
                if (batchInfoQuery != null)
                {
                    BatchInfo[] newBatchInfoArray = batchInfoQuery.ToArray();
                    // Accept drop
                    e.Effect = e.AllowedEffect;

                    IEnumerable <object>    values          = this.GetValue();
                    IEnumerable <BatchInfo> batchInfoValues = values.Cast <BatchInfo>().NotNull();
                    if (batchInfoValues.Any())
                    {
                        foreach (BatchInfo info in batchInfoValues)
                        {
                            newBatchInfoArray[0].CopyTo(info);
                        }
                        // BatchInfos aren't usually referenced, they're nested. Make sure the change notification is passed on.
                        this.SetValues(batchInfoValues);
                    }
                    else
                    {
                        this.SetValue(newBatchInfoArray[0]);
                    }
                    this.PerformGetValue();
                    return;
                }
            }

            // Move on to children if failed otherwise
            base.OnDragDrop(e);
        }
        protected override void OnDragDrop(DragEventArgs e)
        {
            DataObject dragDropData = e.Data as DataObject;
            if (this.HoverEditor == null && dragDropData != null && !this.ReadOnly)
            {
                var batchInfoQuery = new ConvertOperation(dragDropData, ConvertOperation.Operation.All).Perform<BatchInfo>();
                if (batchInfoQuery != null)
                {
                    BatchInfo[] newBatchInfoArray = batchInfoQuery.ToArray();
                    // Accept drop
                    e.Effect = e.AllowedEffect;

                    IEnumerable<object> values = this.GetValue();
                    IEnumerable<BatchInfo> batchInfoValues = values.Cast<BatchInfo>().NotNull();
                    if (batchInfoValues.Any())
                    {
                        foreach (BatchInfo info in batchInfoValues) newBatchInfoArray[0].CopyTo(info);
                        // BatchInfos aren't usually referenced, they're nested. Make sure the change notification is passed on.
                        this.SetValues(batchInfoValues);
                    }
                    else
                    {
                        this.SetValue(newBatchInfoArray[0]);
                    }
                    this.PerformGetValue();
                    return;
                }
            }

            // Move on to children if failed otherwise
            base.OnDragDrop(e);
        }