public string Parse(TaskInfo info, string pattern)
        {
            if (info != null && !string.IsNullOrEmpty(pattern))
            {
                pattern = Parse(pattern);

                if (info.Result != null)
                {
                    pattern = pattern.Replace("$result", info.Result.ToString());
                    pattern = pattern.Replace("$url", info.Result.URL ?? "");
                    pattern = pattern.Replace("$shorturl", info.Result.ShortenedURL ?? "");
                    pattern = pattern.Replace("$thumbnailurl", info.Result.ThumbnailURL ?? "");
                    pattern = pattern.Replace("$deletionurl", info.Result.DeletionURL ?? "");
                }

                pattern = pattern.Replace("$filenamenoext", !string.IsNullOrEmpty(info.FileName) ? Path.GetFileNameWithoutExtension(info.FileName) : "");
                pattern = pattern.Replace("$filename", info.FileName ?? "");

                pattern = pattern.Replace("$filepath", info.FilePath ?? "");
                pattern = pattern.Replace("$folderpath", !string.IsNullOrEmpty(info.FilePath) ? Path.GetDirectoryName(info.FilePath) : "");
                pattern = pattern.Replace("$foldername", !string.IsNullOrEmpty(info.FilePath) ? Path.GetFileName(Path.GetDirectoryName(info.FilePath)) : "");

                pattern = pattern.Replace("$uploadtime", ((int)info.UploadDuration.TotalMilliseconds).ToString());
            }

            return pattern;
        }
Beispiel #2
0
        public BeforeUploadForm(TaskInfo info)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;
            DialogResult = DialogResult.OK;

            ucBeforeUpload.InitCompleted += (currentDestination) =>
            {
                lblTitle.Text = string.Format("{0} is about to be uploaded to {1}. You may choose a different destination.", info.FileName, currentDestination);
            };
            ucBeforeUpload.Init(info);
        }
Beispiel #3
0
        public AfterUploadForm(TaskInfo info)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            Info = info;
            if (Info.TaskSettings.AdvancedSettings.AutoCloseAfterUploadForm) tmrClose.Start();

            bool isFileExist = !string.IsNullOrEmpty(info.FilePath) && File.Exists(info.FilePath);

            if (info.DataType == EDataType.Image)
            {
                if (isFileExist)
                {
                    pbPreview.LoadImageFromFileAsync(info.FilePath);
                }
                else
                {
                    pbPreview.LoadImageFromURLAsync(info.Result.URL);
                }
            }

            Text = "ShareX - " + (isFileExist ? info.FilePath : info.FileName);

            lvClipboardFormats.Groups.Add(lvgForums);
            lvClipboardFormats.Groups.Add(lvgHtml);
            lvClipboardFormats.Groups.Add(lvgWiki);
            lvClipboardFormats.Groups.Add(lvgLocal);
            lvClipboardFormats.Groups.Add(lvgCustom);

            foreach (LinkFormatEnum type in Helpers.GetEnums<LinkFormatEnum>())
            {
                if (!Helpers.IsImageFile(Info.Result.URL) &&
                    (type == LinkFormatEnum.HTMLImage || type == LinkFormatEnum.HTMLLinkedImage ||
                    type == LinkFormatEnum.ForumImage || type == LinkFormatEnum.ForumLinkedImage ||
                    type == LinkFormatEnum.WikiImage || type == LinkFormatEnum.WikiLinkedImage))
                    continue;

                AddFormat(type.GetLocalizedDescription(), GetUrlByType(type));
            }

            if (Helpers.IsImageFile(Info.Result.URL))
            {
                foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
                {
                    AddFormat(cf.Description, parser.Parse(Info, cf.Format), lvgCustom);
                }
            }
        }
Beispiel #4
0
        public BeforeUploadForm(TaskInfo info)
        {
            InitializeComponent();
            DialogResult = DialogResult.OK;

            ucBeforeUpload.InitCompleted += currentDestination =>
            {
                string title = string.IsNullOrEmpty(currentDestination) ? Resources.BeforeUploadForm_BeforeUploadForm_Please_choose_a_destination_ :
                    Resources.BeforeUploadForm_BeforeUploadForm__0__is_about_to_be_uploaded_to__1___You_may_choose_a_different_destination_;
                lblTitle.Text = string.Format(title, info.FileName, currentDestination);
                pbPreview.LoadImageFromFileAsync(info.FilePath);
            };

            ucBeforeUpload.Init(info);
        }
Beispiel #5
0
 private UploadTask(TaskSettings taskSettings)
 {
     Status = TaskStatus.InQueue;
     Info = new TaskInfo(taskSettings);
 }
Beispiel #6
0
 public UploadInfoStatus(TaskInfo info)
 {
     Info = info;
     Update();
 }
Beispiel #7
0
 private WorkerTask(TaskSettings taskSettings)
 {
     Status = TaskStatus.InQueue;
     Info = new TaskInfo(taskSettings);
 }
Beispiel #8
0
        private static void task_UploadCompleted(WorkerTask task)
        {
            try
            {
                if (ListViewControl != null && task != null)
                {
                    if (task.RequestSettingUpdate)
                    {
                        Program.MainForm.UpdateCheckStates();
                    }

                    TaskInfo info = task.Info;

                    if (info != null && info.Result != null)
                    {
                        ListViewItem lvi = FindListViewItem(task);

                        if (info.Result.IsError)
                        {
                            string errors = string.Join("\r\n\r\n", info.Result.Errors.ToArray());

                            DebugHelper.WriteLine("Task failed. Filename: {0}, Errors:\r\n{1}", info.FileName, errors);

                            if (lvi != null)
                            {
                                lvi.SubItems[1].Text = Resources.TaskManager_task_UploadCompleted_Error;
                                lvi.SubItems[6].Text = string.Empty;
                                lvi.ImageIndex       = 1;
                            }

                            if (!info.TaskSettings.AdvancedSettings.DisableNotifications)
                            {
                                if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                {
                                    TaskHelpers.PlayErrorSound(info.TaskSettings);
                                }

                                if (info.TaskSettings.GeneralSettings.PopUpNotification != PopUpNotificationType.None && Program.MainForm.niTray.Visible && !string.IsNullOrEmpty(errors))
                                {
                                    Program.MainForm.niTray.Tag = null;
                                    Program.MainForm.niTray.ShowBalloonTip(5000, "ShareX - " + Resources.TaskManager_task_UploadCompleted_Error, errors, ToolTipIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            DebugHelper.WriteLine("Task completed. Filename: {0}, URL: {1}, Duration: {2} ms", info.FileName, info.Result.ToString(), (int)info.UploadDuration.TotalMilliseconds);

                            string result = info.Result.ToString();

                            if (string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(info.FilePath))
                            {
                                result = info.FilePath;
                            }

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;

                                if (!string.IsNullOrEmpty(result))
                                {
                                    lvi.SubItems[6].Text = result;
                                }
                            }

                            if (!task.StopRequested && !string.IsNullOrEmpty(result))
                            {
                                if (Program.Settings.HistorySaveTasks && (!Program.Settings.HistoryCheckURL ||
                                                                          (!string.IsNullOrEmpty(info.Result.URL) || !string.IsNullOrEmpty(info.Result.ShortenedURL))))
                                {
                                    HistoryManager.AddHistoryItemAsync(Program.HistoryFilePath, info.GetHistoryItem());
                                }

                                RecentManager.Add(task);

                                if (!info.TaskSettings.AdvancedSettings.DisableNotifications && info.Job != TaskJob.ShareURL)
                                {
                                    if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                    {
                                        TaskHelpers.PlayTaskCompleteSound(info.TaskSettings);
                                    }

                                    if (!string.IsNullOrEmpty(info.TaskSettings.AdvancedSettings.BalloonTipContentFormat))
                                    {
                                        result = new UploadInfoParser().Parse(info, info.TaskSettings.AdvancedSettings.BalloonTipContentFormat);
                                    }

                                    if (!string.IsNullOrEmpty(result))
                                    {
                                        switch (info.TaskSettings.GeneralSettings.PopUpNotification)
                                        {
                                        case PopUpNotificationType.BalloonTip:
                                            if (Program.MainForm.niTray.Visible)
                                            {
                                                Program.MainForm.niTray.Tag = result;
                                                Program.MainForm.niTray.ShowBalloonTip(5000, "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed,
                                                                                       result, ToolTipIcon.Info);
                                            }
                                            break;

                                        case PopUpNotificationType.ToastNotification:
                                            NotificationFormConfig toastConfig = new NotificationFormConfig()
                                            {
                                                Action   = info.TaskSettings.AdvancedSettings.ToastWindowClickAction,
                                                FilePath = info.FilePath,
                                                Text     = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result,
                                                URL      = result
                                            };
                                            NotificationForm.Show((int)(info.TaskSettings.AdvancedSettings.ToastWindowDuration * 1000),
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowPlacement,
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowSize, toastConfig);
                                            break;
                                        }
                                    }

                                    if (info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.ShowAfterUploadWindow))
                                    {
                                        AfterUploadForm dlg = new AfterUploadForm(info);
                                        NativeMethods.ShowWindow(dlg.Handle, (int)WindowShowStyle.ShowNoActivate);
                                    }
                                }
                            }
                        }

                        if (lvi != null)
                        {
                            lvi.EnsureVisible();
                        }
                    }
                }
            }
            finally
            {
                if (!IsBusy && Program.CLI.IsCommandExist("AutoClose"))
                {
                    Application.Exit();
                }
                else
                {
                    StartTasks();
                    UpdateProgressUI();
                }
            }
        }
Beispiel #9
0
 public UploadInfoStatus(TaskInfo info)
 {
     Info = info;
     Update();
 }
Beispiel #10
0
 private WorkerTask(TaskSettings taskSettings)
 {
     Status = TaskStatus.InQueue;
     Info   = new TaskInfo(taskSettings);
 }
Beispiel #11
0
        private static void Task_TaskCompleted(WorkerTask task)
        {
            try
            {
                if (task != null)
                {
                    task.KeepImage = false;

                    if (task.RequestSettingUpdate)
                    {
                        Program.MainForm.UpdateCheckStates();
                    }

                    TaskInfo info = task.Info;

                    if (info != null && info.Result != null)
                    {
                        TaskThumbnailPanel panel = TaskThumbnailView.FindPanel(task);

                        if (panel != null)
                        {
                            panel.UpdateStatus();
                            panel.ProgressVisible = false;
                        }

                        ListViewItem lvi = TaskListView.FindItem(task);

                        if (task.Status == TaskStatus.Stopped)
                        {
                            DebugHelper.WriteLine($"Task stopped. Filename: {info.FileName}");

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;
                            }
                        }
                        else if (task.Status == TaskStatus.Failed)
                        {
                            string errors = string.Join("\r\n\r\n", info.Result.Errors.ToArray());

                            DebugHelper.WriteLine($"Task failed. Filename: {info.FileName}, Errors:\r\n{errors}");

                            if (lvi != null)
                            {
                                lvi.SubItems[1].Text = info.Status;
                                lvi.SubItems[6].Text = "";
                                lvi.ImageIndex       = 1;
                            }

                            if (!info.TaskSettings.AdvancedSettings.DisableNotifications)
                            {
                                if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                {
                                    TaskHelpers.PlayErrorSound(info.TaskSettings);
                                }

                                if (info.Result.Errors.Count > 0)
                                {
                                    string errorMessage = info.Result.Errors[0];

                                    if (info.TaskSettings.GeneralSettings.PopUpNotification != PopUpNotificationType.None && !string.IsNullOrEmpty(errorMessage) &&
                                        (!info.TaskSettings.AdvancedSettings.DisableNotificationsOnFullscreen || !CaptureHelpers.IsActiveWindowFullscreen()))
                                    {
                                        TaskHelpers.ShowBalloonTip(errorMessage, ToolTipIcon.Error, 5000, "ShareX - " + Resources.TaskManager_task_UploadCompleted_Error);
                                    }
                                }
                            }
                        }
                        else
                        {
                            DebugHelper.WriteLine($"Task completed. Filename: {info.FileName}, Duration: {(long)info.TaskDuration.TotalMilliseconds} ms");

                            string result = info.ToString();

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;

                                if (!string.IsNullOrEmpty(result))
                                {
                                    lvi.SubItems[6].Text = result;
                                }
                            }

                            if (!task.StopRequested && !string.IsNullOrEmpty(result))
                            {
                                if (Program.Settings.HistorySaveTasks && (!Program.Settings.HistoryCheckURL ||
                                                                          (!string.IsNullOrEmpty(info.Result.URL) || !string.IsNullOrEmpty(info.Result.ShortenedURL))))
                                {
                                    HistoryItem historyItem = info.GetHistoryItem();
                                    AppendHistoryItemAsync(historyItem);
                                }

                                RecentManager.Add(task);

                                if (!info.TaskSettings.AdvancedSettings.DisableNotifications && info.Job != TaskJob.ShareURL)
                                {
                                    if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                    {
                                        TaskHelpers.PlayTaskCompleteSound(info.TaskSettings);
                                    }

                                    if (!string.IsNullOrEmpty(info.TaskSettings.AdvancedSettings.BalloonTipContentFormat))
                                    {
                                        result = new UploadInfoParser().Parse(info, info.TaskSettings.AdvancedSettings.BalloonTipContentFormat);
                                    }

                                    if (!string.IsNullOrEmpty(result) &&
                                        (!info.TaskSettings.AdvancedSettings.DisableNotificationsOnFullscreen || !CaptureHelpers.IsActiveWindowFullscreen()))
                                    {
                                        switch (info.TaskSettings.GeneralSettings.PopUpNotification)
                                        {
                                        case PopUpNotificationType.BalloonTip:
                                            BalloonTipAction action = new BalloonTipAction()
                                            {
                                                ClickAction = BalloonTipClickAction.OpenURL,
                                                Text        = result
                                            };

                                            TaskHelpers.ShowBalloonTip(result, ToolTipIcon.Info, 5000,
                                                                       "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed, action);
                                            break;

                                        case PopUpNotificationType.ToastNotification:
                                            task.KeepImage = true;

                                            NotificationFormConfig toastConfig = new NotificationFormConfig()
                                            {
                                                LeftClickAction   = info.TaskSettings.AdvancedSettings.ToastWindowClickAction,
                                                RightClickAction  = info.TaskSettings.AdvancedSettings.ToastWindowRightClickAction,
                                                MiddleClickAction = info.TaskSettings.AdvancedSettings.ToastWindowMiddleClickAction,
                                                FilePath          = info.FilePath,
                                                Image             = task.Image,
                                                Text = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result,
                                                URL  = result
                                            };
                                            NotificationForm.Show((int)(info.TaskSettings.AdvancedSettings.ToastWindowDuration * 1000),
                                                                  (int)(info.TaskSettings.AdvancedSettings.ToastWindowFadeDuration * 1000),
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowPlacement,
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowSize, toastConfig);
                                            break;
                                        }

                                        if (info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.ShowAfterUploadWindow) && info.IsUploadJob)
                                        {
                                            AfterUploadForm dlg = new AfterUploadForm(info);
                                            NativeMethods.ShowWindow(dlg.Handle, (int)WindowShowStyle.ShowNoActivate);
                                        }
                                    }
                                }
                            }
                        }

                        if (lvi != null)
                        {
                            lvi.EnsureVisible();

                            if (Program.Settings.AutoSelectLastCompletedTask)
                            {
                                TaskListView.ListViewControl.SelectSingle(lvi);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (!IsBusy && Program.CLI.IsCommandExist("AutoClose"))
                {
                    Application.Exit();
                }
                else
                {
                    StartTasks();
                    UpdateProgressUI();

                    if (Program.Settings.SaveSettingsAfterTaskCompleted && !IsBusy)
                    {
                        SettingManager.SaveAllSettingsAsync();
                    }
                }
            }
        }
Beispiel #12
0
        public void Init(TaskInfo info)
        {
            switch (info.DataType)
            {
            case EDataType.Image:
                InitCapture(info.TaskSettings);
                break;

            case EDataType.Text:
                Helpers.GetEnums <TextDestination>().ForEach(x =>
                {
                    if (x != TextDestination.FileUploader)
                    {
                        string overrideText = null;

                        if (x == TextDestination.CustomTextUploader)
                        {
                            overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomTextUploaderSelected, info.TaskSettings);
                        }

                        AddDestination <TextDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText);
                    }
                });

                Helpers.GetEnums <FileDestination>().ForEach(x =>
                {
                    string overrideText = null;

                    if (x == FileDestination.CustomFileUploader)
                    {
                        overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomFileUploaderSelected, info.TaskSettings);
                    }

                    AddDestination <FileDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    if (info.TaskSettings.TextDestination != TextDestination.FileUploader)
                    {
                        x.Checked = x.Tag is TextDestination && (TextDestination)x.Tag == info.TaskSettings.TextDestination;
                    }
                    else
                    {
                        x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == info.TaskSettings.TextFileDestination;
                    }
                });
                break;

            case EDataType.File:
                Helpers.GetEnums <FileDestination>().ForEach(x =>
                {
                    string overrideText = null;

                    if (x == FileDestination.CustomFileUploader)
                    {
                        overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomFileUploaderSelected, info.TaskSettings);
                    }

                    AddDestination <FileDestination>((int)x, EDataType.File, info.TaskSettings, overrideText);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == info.TaskSettings.FileDestination;
                });
                break;

            case EDataType.URL:
                Helpers.GetEnums <UrlShortenerType>().ForEach(x =>
                {
                    string overrideText = null;

                    if (x == UrlShortenerType.CustomURLShortener)
                    {
                        overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomURLShortenerSelected, info.TaskSettings);
                    }

                    AddDestination <UrlShortenerType>((int)x, EDataType.URL, info.TaskSettings, overrideText);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    x.Checked = x.Tag is UrlShortenerType && (UrlShortenerType)x.Tag == info.TaskSettings.URLShortenerDestination;
                });

                break;
            }

            OnInitCompleted();
        }
Beispiel #13
0
        private static void task_UploadCompleted(UploadTask task)
        {
            try
            {
                if (ListViewControl != null && task != null)
                {
                    if (task.RequestSettingUpdate)
                    {
                        Program.MainForm.UpdateMainFormSettings();
                    }

                    TaskInfo info = task.Info;

                    if (info != null && info.Result != null)
                    {
                        ListViewItem lvi = FindListViewItem(task);

                        if (info.Result.IsError)
                        {
                            string errors = string.Join("\r\n\r\n", info.Result.Errors.ToArray());

                            DebugHelper.WriteLine("Task failed. Filename: {0}, Errors:\r\n{1}", info.FileName, errors);

                            if (lvi != null)
                            {
                                lvi.SubItems[1].Text = "Error";
                                lvi.SubItems[8].Text = string.Empty;
                                lvi.ImageIndex       = 1;
                            }

                            if (task.Info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                            {
                                SystemSounds.Asterisk.Play();
                            }
                        }
                        else
                        {
                            DebugHelper.WriteLine("Task completed. Filename: {0}, URL: {1}, Duration: {2} ms",
                                                  info.FileName, info.Result.ToString(), (int)info.UploadDuration.TotalMilliseconds);

                            string result = info.Result.ToString();

                            if (string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(info.FilePath))
                            {
                                result = info.FilePath;
                            }

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;

                                if (!string.IsNullOrEmpty(result))
                                {
                                    lvi.SubItems[8].Text = result;
                                }
                            }

                            if (!task.IsStopped && !string.IsNullOrEmpty(result))
                            {
                                if (task.Info.TaskSettings.GeneralSettings.SaveHistory)
                                {
                                    HistoryManager.AddHistoryItemAsync(Program.HistoryFilePath, info.GetHistoryItem());
                                }

                                if (!info.TaskSettings.AdvancedSettings.DisableNotifications)
                                {
                                    string balloonTipText = result;

                                    if (info.TaskSettings.GeneralSettings.ShowAfterUploadForm)
                                    {
                                        AfterUploadForm dlg = new AfterUploadForm(info);
                                        NativeMethods.ShowWindow(dlg.Handle, (int)WindowShowStyle.ShowNoActivate);
                                    }

                                    if (!string.IsNullOrEmpty(info.TaskSettings.AdvancedSettings.BalloonTipContentFormat))
                                    {
                                        balloonTipText = new UploadInfoParser().Parse(info, info.TaskSettings.AdvancedSettings.BalloonTipContentFormat);
                                    }

                                    if (task.Info.TaskSettings.GeneralSettings.TrayBalloonTipAfterUpload && Program.MainForm.niTray.Visible)
                                    {
                                        Program.MainForm.niTray.Tag = result;
                                        Program.MainForm.niTray.ShowBalloonTip(5000, "ShareX - Task completed", balloonTipText, ToolTipIcon.Info);
                                    }

                                    if (task.Info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                    {
                                        SystemSounds.Exclamation.Play();
                                    }
                                }
                            }
                        }

                        if (lvi != null)
                        {
                            lvi.EnsureVisible();
                        }
                    }
                }
            }
            finally
            {
                StartTasks();
                UpdateProgressUI();
            }
        }
 private UploadTask(TaskSettings taskSettings)
 {
     Status = TaskStatus.InQueue;
     Info   = new TaskInfo(taskSettings);
 }
Beispiel #15
0
        public void Init(TaskInfo info)
        {
            switch (info.DataType)
            {
            case EDataType.Image:
                InitCapture(info.TaskSettings);
                break;

            case EDataType.Text:
                Helpers.GetEnums <TextDestination>().ForEach(x =>
                {
                    if (x != TextDestination.FileUploader)
                    {
                        AddDestination <TextDestination>((int)x, EDataType.Text, info.TaskSettings);
                    }
                });

                Helpers.GetEnums <FileDestination>().ForEach(x =>
                {
                    AddDestination <FileDestination>((int)x, EDataType.Text, info.TaskSettings);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    if (info.TaskSettings.TextDestination != TextDestination.FileUploader)
                    {
                        x.Checked = x.Tag is TextDestination && (TextDestination)x.Tag == info.TaskSettings.TextDestination;
                    }
                    else
                    {
                        x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == info.TaskSettings.TextFileDestination;
                    }
                });
                break;

            case EDataType.File:
                Helpers.GetEnums <FileDestination>().ForEach(x =>
                {
                    AddDestination <FileDestination>((int)x, EDataType.File, info.TaskSettings);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == info.TaskSettings.FileDestination;
                });
                break;

            case EDataType.URL:
                Helpers.GetEnums <UrlShortenerType>().ForEach(x =>
                {
                    AddDestination <UrlShortenerType>((int)x, EDataType.URL, info.TaskSettings);
                });

                flp.Controls.OfType <RadioButton>().ForEach(x =>
                {
                    x.Checked = x.Tag is UrlShortenerType && (UrlShortenerType)x.Tag == info.TaskSettings.URLShortenerDestination;
                });

                break;
            }

            OnInitCompleted();
        }
Beispiel #16
0
 protected WorkerTask(TaskSettings taskSettings)
 {
     Status = TaskStatus.InQueue;
     Info = new TaskInfo(taskSettings);
 }