public void ImportFromTextFile() { using (FileChooserDialog fc = new FileChooserDialog( "Import from text", (Window)Toplevel, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept)) { fc.ShowAll(); if (fc.Run() == (int)ResponseType.Accept) { string[] lines = File.ReadAllLines(fc.Filename); using (var batchDlg = new AddMultipleDownloadDialog()) { var list = lines.Where(s => ResourceLocation.IsURL(s)).ToArray(); foreach (var item in list) { batchDlg.Store.AddNode(new BatchDownloadNode { Checked = true, Url = item }); } batchDlg.Run(); batchDlg.Destroy(); } } fc.Destroy(); } }
public void ImportFromEF2File() { Regex r = new Regex(@"^<\n(.*)$\n[^<]*\n^>", RegexOptions.Multiline); using (FileChooserDialog fc = new FileChooserDialog("Import from EF2", (Window)Toplevel, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept)) { fc.ShowAll(); if (fc.Run() == (int)ResponseType.Accept) { string lines = File.ReadAllText(fc.Filename); var m = r.Matches(lines); var list = new List <Match>(); for (int i = 0; i < m.Count; i++) { list.Add(m[i]); } using (var batchDlg = new AddMultipleDownloadDialog()) { foreach (var item in list) { batchDlg.Store.AddNode(new BatchDownloadNode { Checked = true, Url = item.Groups[0].Value }); } batchDlg.Run(); batchDlg.Destroy(); } } fc.Destroy(); } }
private void OnResponse(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { List <string> list = new List <string>(); int min, max; if (numMin.ValueAsInt > numMax.ValueAsInt) { min = numMax.ValueAsInt; max = numMin.ValueAsInt; } else { min = numMin.ValueAsInt; max = numMax.ValueAsInt; } string wildcardSize = new string('0', numWildcardSize.ValueAsInt); for (int i = min; i < max; i++) { string url = maskedUrl.Text.Replace("*", i.ToString(wildcardSize)); if (!list.Contains(url)) { list.Add(url); } } using (var batchDlg = new AddMultipleDownloadDialog()) { foreach (var item in list) { batchDlg.Store.AddNode(new BatchDownloadNode { Checked = true, Url = item }); } batchDlg.Run(); batchDlg.Destroy(); } } }