コード例 #1
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;
            }
        }