Пример #1
0
 private void FormMain_DragEnter(object sender, DragEventArgs e)
 {
     try
     {
         if (!CanFocus)
         {
             e.Effect = DragDropEffects.None;
             return;
         }
         DragDataWrapper ddw = new DragDataWrapper(e.Data);
         bool allowOpen = false;
         if (ddw.IsFileDrop)
         {
             string fileName = ddw.GetFilePath();
             if (fileName != string.Empty &&
                 m_vm.Spectrum.Loader.CheckCanOpenFileName(fileName))
             {
                 allowOpen = true;
             }
         }
         else if (ddw.IsLinkDrop)
         {
             allowOpen = true;
         }
         e.Effect = allowOpen ? DragDropEffects.Link : DragDropEffects.None;
     }
     catch (Exception ex)
     {
         LogAgent.Error(ex);
     }
 }
Пример #2
0
 private void FormMain_DragDrop(object sender, DragEventArgs e)
 {
     try
     {
         if (!CanFocus)
             return;
         DragDataWrapper ddw = new DragDataWrapper(e.Data);
         if (ddw.IsFileDrop)
         {
             string fileName = ddw.GetFilePath();
             if (fileName != string.Empty)
             {
                 this.Activate();
                 this.BeginInvoke(new OpenFileHandler(OpenFile), fileName, true);
             }
         }
         else if (ddw.IsLinkDrop)
         {
             string linkUrl = ddw.GetLinkUri();
             if (linkUrl != string.Empty)
             {
                 Uri fileUri = new Uri(linkUrl);
                 this.Activate();
                 this.BeginInvoke(new OpenUriHandler(OpenUri), fileUri);
             }
         }
     }
     catch (Exception ex)
     {
         LogAgent.Error(ex);
     }
 }