Пример #1
0
		void IDragDropHandler.AcceptDragDrop(object dataObject, bool controlKeyHeld)
		{
			var info = dataObject as NSDraggingInfo;
			if (info == null)
				return;
			var pboard = info.DraggingPasteboard;
			var types = pboard.Types;
			if (types.Contains(NSPasteboard.NSFilenamesType.ToString()))
			{
				if (controlKeyHeld)
					DeleteExistingLogs();
				var fnames = GetItemsForType(pboard, NSPasteboard.NSFilenamesType);
				foreach (var file in fnames)
					preprocessingManager.Preprocess(
						Enumerable.Repeat(preprocessingStepsFactory.CreateFormatDetectionStep(new PreprocessingStepParams(file)), 1),
						file
					);
			}
			else if (types.Contains(NSPasteboard.NSUrlType.ToString()))
			{
				if (controlKeyHeld)
					DeleteExistingLogs();
				var urls = GetItemsForType(pboard, NSPasteboard.NSUrlType);
				preprocessingManager.Preprocess(
					urls.Select(url => preprocessingStepsFactory.CreateURLTypeDetectionStep(new PreprocessingStepParams(url))),
					urls.Length == 1 ? urls[0] : "Urls drag&drop"
				);
			}
		}
Пример #2
0
 Task IPreprocessingStep.Execute(IPreprocessingStepCallback callback)
 {
     if (Uri.IsWellFormedUriString(sourceFile.Uri, UriKind.Absolute))
     {
         callback.YieldNextStep(preprocessingStepsFactory.CreateURLTypeDetectionStep(sourceFile));
     }
     else
     {
         callback.YieldNextStep(preprocessingStepsFactory.CreateFormatDetectionStep(sourceFile));
     }
     return(Task.FromResult(0));
 }
Пример #3
0
 async void AcceptDragDrop(IDataObject dataObject, bool controlKeyHeld)
 {
     if (UrlDragDropUtils.IsUriDataPresent(dataObject))
     {
         if (controlKeyHeld)
         {
             await logSourcesController.DeleteAllLogsAndPreprocessings();
         }
         var urls = UrlDragDropUtils.GetURLs(dataObject).ToArray();
         await preprocessingManager.Preprocess(
             urls.Select(url => preprocessingStepsFactory.CreateURLTypeDetectionStep(new PreprocessingStepParams(url))),
             urls.Length == 1?urls[0] : "Urls drag&drop"
             );
     }
     else if (dataObject.GetDataPresent(DataFormats.FileDrop, false))
     {
         if (controlKeyHeld)
         {
             await logSourcesController.DeleteAllLogsAndPreprocessings();
         }
         ((dataObject.GetData(DataFormats.FileDrop) as string[]) ?? new string[0]).Select(file =>
                                                                                          preprocessingManager.Preprocess(
                                                                                              Enumerable.Repeat(preprocessingStepsFactory.CreateFormatDetectionStep(new PreprocessingStepParams(file)), 1),
                                                                                              file
                                                                                              )
                                                                                          ).ToArray();
     }
 }