Пример #1
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (this.dragBeginPos != Point.Empty)
     {
         if (Math.Abs(this.dragBeginPos.X - e.X) > 5 || Math.Abs(this.dragBeginPos.Y - e.Y) > 5)
         {
             DataObject dragDropData = new DataObject();
             dragDropData.SetBatchInfos(this.GetValue().OfType<BatchInfo>().ToArray());
             this.ParentGrid.DoDragDrop(dragDropData, DragDropEffects.All);
         }
     }
 }
Пример #2
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && e.Control)
            {
                DataObject data = new DataObject();
                data.SetBatchInfos(new[] { this.DisplayedValue as BatchInfo });
                Clipboard.SetDataObject(data);
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.V && e.Control)
            {
                DataObject data = Clipboard.GetDataObject() as DataObject;
                ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
                IEnumerable<BatchInfo> refQuery = null;
                if (convert.CanPerform<BatchInfo>() && (refQuery = convert.Perform<BatchInfo>()) != null)
                {
                    this.SetValue(refQuery.FirstOrDefault());
                    this.PerformGetValue();
                    this.OnEditingFinished(FinishReason.LeapValue);
                }
                else
                    System.Media.SystemSounds.Beep.Play();

                e.Handled = true;
            }
            base.OnKeyDown(e);
        }