/// <summary> /// DN /// </summary> void dn(object selectedItem) { if (loc.lokDN || data.canal.name == "") { return; } ParamCanal nxt = new ParamCanal(); ParamCanal curr = new ParamCanal(); nxt.name = ""; bool find_ok = false; //находим следующий в фильтрованном списке foreach (var obj in myLISTbase) { if (find_ok) { nxt = obj; // nxt = (ParamCanal)obj.Clone(); break; } if (obj.Compare() == data.canal.Compare()) { curr = obj;// (ParamCanal)obj.Clone(); find_ok = true; } } if (nxt.name != "") { int i1 = myLISTfull.IndexOf(nxt); int i2 = myLISTfull.IndexOf(curr); if (i1 >= 0 && i1 <= myLISTfull.Count()) { if (i2 >= 0 && i2 <= myLISTfull.Count()) { myLISTfull[i1] = curr; //(ParamCanal)curr.Clone(); myLISTfull[i2] = nxt; //(ParamCanal)nxt.Clone(); } } } data.canal.name = ""; if (Event_UpdateCollection != null) { Event_UpdateCollection(curr); } if (Event_SELECT != null) { Event_SELECT(1, curr); } }
//============================================================================= /// <summary> /// UP /// </summary> void up(object selectedItem) { if (loc.lokUP || data.canal.name == "") { return; } ParamCanal pred = new ParamCanal(); ParamCanal curr = new ParamCanal(); pred.name = ""; //находим предыдущий в фильтрованном списке foreach (var obj in myLISTbase) { if (obj.Compare() == data.canal.Compare()) { curr = obj; // curr=(ParamCanal)obj.Clone(); break; } else { pred = obj; //pred = (ParamCanal)obj.Clone(); } } if (pred.name != "") { int i1 = myLISTfull.IndexOf(pred); int i2 = myLISTfull.IndexOf(curr); if (i1 >= 0 && i1 <= myLISTfull.Count()) { if (i2 >= 0 && i2 <= myLISTfull.Count()) { myLISTfull[i1] = curr; //(ParamCanal)curr.Clone(); myLISTfull[i2] = pred; //(ParamCanal)pred.Clone(); } } } data.canal.name = ""; if (Event_UpdateCollection != null) { Event_UpdateCollection(curr); } if (Event_SELECT != null) { Event_SELECT(1, curr); } loc.lokUP = false; loc.lokDN = false; }
void set(ParamCanal k) { int index = 0; foreach (var j in ViewModelMain.myLISTfull) { if (k.Compare() == j.Compare()) { if (chek1) { ViewModelMain.myLISTfull[index].name = ViewModelMain.myLISTfull[index].name.Replace(sel1, sel2).Trim(); } if (chek2) { ViewModelMain.myLISTfull[index].ping = ViewModelMain.myLISTfull[index].ping.Replace(sel1, sel2).Trim(); } if (chek3) { ViewModelMain.myLISTfull[index].ExtFilter = ViewModelMain.myLISTfull[index].ExtFilter.Replace(sel1, sel2).Trim(); } if (chek4) { ViewModelMain.myLISTfull[index].group_title = ViewModelMain.myLISTfull[index].group_title.Replace(sel1, sel2).Trim(); } if (chek5) { ViewModelMain.myLISTfull[index].http = ViewModelMain.myLISTfull[index].http.Replace(sel1, sel2).Trim(); } if (chek6) { ViewModelMain.myLISTfull[index].logo = ViewModelMain.myLISTfull[index].logo.Replace(sel1, sel2).Trim(); } if (chek7) { ViewModelMain.myLISTfull[index].tvg_name = ViewModelMain.myLISTfull[index].tvg_name.Replace(sel1, sel2).Trim(); } find = true; return; } index++; } }
void setregular(ParamCanal k) { int index = 0; foreach (var j in ViewModelMain.myLISTfull) { if (k.Compare() == j.Compare()) { if (chek1) { ViewModelMain.myLISTfull[index].name = sel2.Trim(); } if (chek2) { ViewModelMain.myLISTfull[index].ping = sel2.Trim(); } if (chek3) { ViewModelMain.myLISTfull[index].ExtFilter = sel2.Trim(); } if (chek4) { ViewModelMain.myLISTfull[index].group_title = sel2.Trim(); } if (chek5) { ViewModelMain.myLISTfull[index].http = sel2.Trim(); } if (chek6) { ViewModelMain.myLISTfull[index].logo = sel2.Trim(); } if (chek7) { ViewModelMain.myLISTfull[index].tvg_name = sel2.Trim(); } find = true; return; } index++; } }
void updateEDIT(ParamCanal item) { int i = 0; if (loc.edit) { return; } loc.edit = true; foreach (var obj in myLISTfull) { if (obj.Compare() == data.canal.Compare()) { myLISTfull[i] = (ParamCanal)item.Clone(); break; } i++; } Update_collection(typefilter.last); }
bool prov(string s, ParamCanal kan) { if (s == null) { return(false); } if (sel1 == "*") { setregular(kan); return(true); } Regex regex = new Regex(sel1); Match match = null; match = regex.Match(s); if (match.Success) { set(kan); return(true); } return(false); }
public List <ParamCanal> find_dublicate(List <ParamCanal> glob) { const string _NAME = "$delete$_COPY"; List <ParamCanal> myLISTdublicate1a; //временный 1 List <ParamCanal> myLISTdublicate1b; //временный 2 List <ParamCanal> myLISTdublicate2; //временный итоговый myLISTdublicate1a = new List <ParamCanal>(); myLISTdublicate1b = new List <ParamCanal>(); myLISTdublicate2 = new List <ParamCanal>(); int ct = 0; foreach (var c in glob) { myLISTdublicate1a.Add((ParamCanal)c.Clone()); myLISTdublicate1b.Add((ParamCanal)c.Clone()); } bool first = false; int index = 0; int ind = 0; ParamCanal nextitem = null; ParamCanal firsttItem = null; myLISTdublicate2.Clear(); //1111111111111111 foreach (var main in myLISTdublicate1a) { first = false; if (ind != 0) { myLISTdublicate1a[ind - 1].name = _NAME + ind.ToString(); } index = 0; if (main.http == null) { continue; } string mn = main.http.Trim(); //22222222222222222 foreach (var j in myLISTdublicate1b) { if (j.http == null) { continue; } if (mn == j.http.Trim()) { if (first) { nextitem = (ParamCanal)j.Clone(); if (firsttItem != null) { myLISTdublicate2.Add(firsttItem); } firsttItem = null; myLISTdublicate2.Add(nextitem); ct++; myLISTdublicate1b[index].name = _NAME + ind.ToString() + index.ToString(); myLISTdublicate1b[index].http = _NAME + ind.ToString() + index.ToString(); } else { //нахождение самого себя first = true; firsttItem = (ParamCanal)main.Clone(); } } index++; } ind++; Wait.progressbar++; } //чистка List <ParamCanal> resul = new List <ParamCanal>(); foreach (var c in myLISTdublicate2) { if (c.name.Contains("$delete$")) { } else { resul.Add((ParamCanal)c.Clone()); } } myLISTdublicate1a = null; myLISTdublicate1b = null; myLISTdublicate2 = null; return(resul); }
void updateLIST(ParamCanal item) { Update_collection(typefilter.last); }
/// <summary> /// from clipboard /// </summary> /// <param name="lst"></param> /// <param name="str"></param> public void OPEN_FROM_CLIPBOARD(List <IPTVman.Model.ParamCanal> lst, string[] str) { Regex regex1 = new Regex("#EXTINF"); Regex regex2 = new Regex("#EXTM3U"); Match match = null; if (str == null) { dialog.Show("Буфер пустой"); return; } if (str.Length == 1) { Regex regex3 = new Regex("http:"); Regex regex4 = new Regex(".m3u"); match = regex3.Match(str[0]); if (match.Success) { match = regex4.Match(str[0]); if (match.Success) { try { WebClient webClient = new WebClient(); Wait.Create("Загружается\n" + (str[0].ToString()), false); wblst = lst; webClient.DownloadFileCompleted += WebClient_DownloadFileCompletedClipb; webClient.DownloadFileAsync(new Uri(str[0].ToString()), temppath); return; } catch (Exception ex) { dialog.Show("Ошибка parsclb " + ex.Message.ToString()); Wait.Close(); } } } } if (chek_update) { dialog.Show("ОБНОВЛЕНИЕ ТОЛЬКО ЧЕРЕЗ ФАЙЛ"); return; } //ПОИСК заголовка foreach (var s in str) { match = regex2.Match(s); if (match.Success) { text_title = s; break; } } bool need_link = false; // dialog.Show(str.Length.ToString()); int ct_dublicat = 0; int index = 0; bool flag_adding = false; string newname = ""; string str_ex = "", str_name = "", str_http = "", str_gt = "", str_logo = "", str_tvg = ""; //ПОИСК каналов foreach (var line in str) { index++; //поиск ссылки if (need_link) { try { str_http = line.Trim();// str[index].Substring(0, str[index].Length - 1);//remove перевода строки if (str_http == "") { continue; } } catch { } } else { str_name = ""; newname = ""; } if (!need_link) { if (line == null || line == "" || line == "\r" || line == "\n") { continue; } string lineNEW = line.Replace("\r", ""); lineNEW = lineNEW.Replace("\n", ""); match = regex1.Match(lineNEW); ///========== разбор EXINF if (match.Success) { Regex regex3 = new Regex("ExtFilter=", RegexOptions.IgnoreCase); Regex regex4 = new Regex("group-title=", RegexOptions.IgnoreCase); Regex regex5 = new Regex("logo=", RegexOptions.IgnoreCase); Regex regex6 = new Regex("tvg-name=", RegexOptions.IgnoreCase); string[] split = lineNEW.Split(new Char[] { '"' }); str_name = ""; str_ex = ""; str_name = ""; str_http = ""; str_gt = ""; str_logo = ""; str_tvg = ""; if (split.Length == 0) { newname = lineNEW; } else { split = lineNEW.Split(new Char[] { ',' }); if (split.Length < 1) { dialog.Show("Буфер пустой"); return; } if (split.Length <= 2) { str_name = split[split.Length - 1]; } if (str_name != "") { newname = str_name; } need_link = true; continue; } } else { continue; } } need_link = false; ParamCanal item = null; if (newname == "") { continue; } item = lst.Find(x => (x.http == str_http && x.ExtFilter == str_ex && x.group_title == str_gt)); if (newname.Trim() != "" && str_http.Trim() != "") { if (item == null) { flag_adding = true; lst.Add(new ParamCanal { name = newname.Trim(), ExtFilter = str_ex.Trim(), http = str_http.Trim(), group_title = str_gt.Trim(), logo = str_logo.Trim(), tvg_name = str_tvg.Trim() }); } else { ct_dublicat++; } } } if (flag_adding) { if (ct_dublicat != 0) { dialog.Show("ПРОПУЩЕНО ДУБЛИРОВАННЫХ ССЫЛОК " + ct_dublicat.ToString()); } else { dialog.Show("Каналы добавлены успешно!"); } } else { dialog.Show("Ссылки не распознаны"); } if (Event_UpdateLIST != null) { Event_UpdateLIST(typefilter.last); } Wait.Close(); loc.openfile = false; }