private static void StartUpload(Task task)
 {
     Tasks.Add(task);
     task.Info.ID = Tasks.Count - 1;
     task.UploadPreparing += new Task.TaskEventHandler(task_UploadPreparing);
     task.UploadStarted += new Task.TaskEventHandler(task_UploadStarted);
     task.UploadProgressChanged += new Task.TaskEventHandler(task_UploadProgressChanged);
     task.UploadCompleted += new Task.TaskEventHandler(task_UploadCompleted);
     CreateListViewItem(task.Info);
     StartTasks();
 }
예제 #2
0
 public static Task CreateURLShortenerTask(string url)
 {
     Task task = new Task(EDataType.URL, TaskJob.ShortenURL);
     task.Info.FileName = "URL shorten";
     task.Info.Result.URL = url;
     return task;
 }
예제 #3
0
 // string text -> MemoryStream data (in thread)
 public static Task CreateTextUploaderTask(string text, EDataType destination = EDataType.Default)
 {
     Task task = new Task(EDataType.Text, TaskJob.TextUpload);
     if (destination != EDataType.Default) task.Info.UploadDestination = destination;
     task.Info.FileName = new NameParser().Convert(Program.Settings.NameFormatPattern) + ".txt";
     task.tempText = text;
     return task;
 }
예제 #4
0
 // Image image -> MemoryStream data (in thread)
 public static Task CreateImageUploaderTask(Image image, EDataType destination = EDataType.Default)
 {
     Task task = new Task(EDataType.Image, TaskJob.ImageUpload);
     if (destination != EDataType.Default) task.Info.UploadDestination = destination;
     task.Info.FileName = "Require image encoding...";
     task.tempImage = image;
     return task;
 }
예제 #5
0
 // string filePath -> FileStream data
 public static Task CreateFileUploaderTask(EDataType dataType, string filePath, EDataType destination = EDataType.Default)
 {
     Task task = new Task(dataType, TaskJob.FileUpload);
     if (destination != EDataType.Default) task.Info.UploadDestination = destination;
     task.Info.FilePath = filePath;
     task.data = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
     return task;
 }
예제 #6
0
 public static Task CreateDataUploaderTask(EDataType dataType, Stream stream, string fileName, EDataType destination = EDataType.Default)
 {
     Task task = new Task(dataType, TaskJob.DataUpload);
     if (destination != EDataType.Default) task.Info.UploadDestination = destination;
     task.Info.FileName = fileName;
     task.data = stream;
     return task;
 }