No Opinions...just code

Determine type of action on clipboard

private enum CurrentClipOp
{
cut = 0,
copy = 1,
none = 3
}
    1  private CurrentClipOp GetCutOrCopy()
    2         {
    3             string fmt = "Preferred DropEffect";
    4 
    5 
    6             Object obj = Clipboard.GetData(fmt);
    7 
    8             if (obj != null)
    9             {
   10                 // read in that clipboard item //
   11                 MemoryStream ms = (MemoryStream)obj;
   12                 BinaryReader br = new BinaryReader(ms);
   13 
   14                 // the dropeffect shows up right away //
   15                 DragDropEffects dde = (DragDropEffects)br.ReadInt32();
   16 
   17                 // check to see what the effect is //
   18                 if (dde == (DragDropEffects.Copy | DragDropEffects.Link))
   19                 {
   20                     return CurrentClipOp.copy;
   21                 }
   22                 else if (dde == DragDropEffects.Move)
   23                 {
   24                     return CurrentClipOp.cut;
   25                 }
   26                 else
   27                 {
   28                     return CurrentClipOp.none;
   29                 }
   30             }
   31             else
   32             {
   33                 return CurrentClipOp.none;
   34             }
   35         }

0 comments: