コード例 #1
0
 public void ClearAll()
 {
     UrlInput = "";
     DownloadTaskCollection.Clear();
     ImageDownloadCount     = 0;
     ImageDownloadFailCount = 0;
     ImageDownloadSize      = 0;
 }
コード例 #2
0
        private void Button_RemoveFromList_Click(object sender, RoutedEventArgs e)
        {
            Button   button   = sender as Button;
            TaskItem taskItem = button.DataContext as TaskItem;

            DownloadTaskCollection.Remove(taskItem);
            DataGrid_Tasks.Items.Refresh();
        }
コード例 #3
0
 private void Button_Add_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(UrlInput))
     {
         TextBox_UrlInput.Focus();
         return;
     }
     if (DownloadTaskCollection.Any(x => x.Url == UrlInput))
     {
         TextBox_UrlInput.Focus();
         return;
     }
     addUserInputToTaskList(UrlInput);
     UrlInput = string.Empty;
     TextBox_UrlInput.Focus();
 }
コード例 #4
0
        private void ComboBox_InputMethod_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            int      index    = comboBox.SelectedIndex;

            if (index == 0)
            {
                addUserInputToTaskList = (s) =>
                {
                    DownloadTaskCollection.Add(new TaskItem(s.Trim()));
                };
            }
            else if (index == 1)
            {
                addUserInputToTaskList = (s) =>
                {
                    string          pattern = @"(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
                    MatchCollection matches = Regex.Matches(s, pattern);
                    foreach (Match match in matches)
                    {
                        DownloadTaskCollection.Add(new TaskItem(match.Value));
                    }
                };
            }
            else if (index == 2)
            {
                addUserInputToTaskList = async(s) =>
                {
                    List <string> urls = await new ShzxParser_ParentParser().Parse(s);
                    foreach (string url in urls)
                    {
                        DownloadTaskCollection.Add(new TaskItem(url));
                    }
                };
            }
            else
            {
                return;
            }
        }