public void AddRevision(WikiRevision rev) { tl curr = null; if (root.children.Count == 0) { List <tl> l = new List <tl>(); tl t = new tl(); t.type = 0; t.count = 1; t.rand = Tools.FullRandom(); t.revision = rev; l.Add(t); RevisionGroup(l); } else { curr = root.children[root.children.Count - 1]; if (!curr.user.Equals(rev.user)) { curr = new tl(); curr.type = 0; } tl t = new tl(); t.type = 1; t.revision = rev; t.rand = Tools.FullRandom(); curr.children.Add(t); curr.count++; } }
public tl Get(long revid, tl z = null) { if (z == null) { z = root; } tl r; foreach (tl tmp in z.children) { if (tmp.type == 0) { r = Get(revid, tmp); if (r != null) { return(r); } } else { if (tmp.revision.revid == revid) { return(tmp); } } } return(null); }
public String GetHash(tl el) { String ret = "A"; if (sela == null) { ret += "N"; } else { ret += sela.rand; } if (selb == null) { ret += "N"; } else { ret += selb.rand; } if (el.type == 1 && el.revision != null) { ret += el.revision.revid + "" + (el.revision.flagged ? "y" : "n"); } else { foreach (tl _el in el.children) { ret += (_el.hidden ? "y" : "n") + (_el.count) + (_el.diff ? "y" : "n") + (_el.diffto) + GetHash(_el); } } return(Tools.GetMD5(curr.rand + (curr.page.is_flagged ? "y" : "n") + ret)); }
public void ScrollTo(tl aa) { try { foreach (RevListElement e in control.items2_list) { //e.selected = false; if (e.main.rand == aa.rand) { int pos = -1; for (int a = 0; a < control.Items.Count; a++) { if (control.Items[a].Equals(e.rand + "") && pos == -1) { pos = a; //break; } } if (pos == -1) { return; } //e.selected = true; control.SetSelected(pos, true); MakeCenter(pos); //e.selected = true; control.Update(); break; } } } catch (Exception e) { MessageBox.Show("Исключение в движке списка2: " + e.Message); } }
private tl psela = null, pselb = null; // previous public void UpdateSelVars(tl a, tl b) { psela = sela; pselb = selb; sela = a; selb = b; }
private void RevisionGroup(List <tl> list) { root.children.Clear(); root.type = 1; root.rootflag = true; String tmp = ""; tl curr = new tl(); curr.type = 0; curr.count = 0; tl prev_a = null; // group tl prev_b = null; // other tl prev_prev_a = null; foreach (tl t in list) { if (!t.user.Equals(tmp) || (curr.last != null && t.revision.flagged != curr.last.revision.flagged)) { if (curr.count > 0) { curr.parent = root; root.children.Add(curr); root.count++; } curr = new tl(); curr.type = 0; curr.rand = Tools.FullRandom(); curr.count = 0; curr.prev = prev_a; if (prev_a != null) { prev_a.next = curr; } prev_b = null; prev_prev_a = prev_a; prev_a = curr; } if (prev_b != null) { prev_b.next = t; } t.prev = prev_b == null ? prev_prev_a : prev_b; prev_b = t; t.parent = curr; curr.children.Add(t); tmp = t.user; curr.user = tmp; curr.count++; curr.revision = t.revision; //последняя ревизия = группа curr.last = t; } if (curr.count > 0) { curr.parent = root; root.children.Add(curr); root.count++; } }
public void UpdateItems(Element el, bool check_hash = true) { if (el.revisions == null) { return; } try { String hash = ""; lock (el.revisions) { curr = el; TRevisionSet rs = el.revisions; tl root = rs.root; if (control.items2_list.Count > 0 && check_hash) { hash = GetHash(root); if (tmp_hash.Equals(hash)) { return; } } int top_index = control.TopIndex; String top_rand_s = ""; double top_rand = -1; try { top_rand_s = control.Items[top_index].ToString(); foreach (RevListElement i in control.items2_list) { if (i.rand_s.Equals(top_rand_s)) { top_rand = i.rand; break; } } } catch { } int new_index = top_index; control.BeginUpdate(); control.Clear(); CreateItems(root); control.TopIndex = new_index; control.EndUpdate(); control.PerformLayout(); tmp_hash = hash; } } catch (Exception) { return; } }
public tl GetByIndex(int index) { tl tmp = null; if (index == -1) { return(tmp); } RevListElement t = (RevListElement)(control.ht[control.Items[index]]); if (t != null) { tmp = t.main; } return(tmp); }
public TRevisionSet(SweepNetPage pg) { List <tl> l = new List <tl>(); foreach (WikiRevision rev in pg.list) { tl curr = new tl(); curr.count = 1; curr.type = 1; curr.hidden = false; curr.revision = rev; curr.rand = Tools.FullRandom(); curr.user = rev.user; l.Add(curr); } RevisionGroup(l); }
public void AddRev_last(tl a, tl b, int type, Element el, bool restart = true) { ClearList(); if (a == null) { a = b; b = null; } RevDiffData dd = new RevDiffData(); dd.a = a.revision; dd.b = b.revision; dd.type = type; dd.page = el.page; dd.el = el; dd.rand = a.rand + (b != null?b.rand:0); list.Add(dd); if (restart) { RunThread(); } }
public void CreateItems(tl el, bool sub = false) { tl tmp; double selrand = -100, lrand = -100, rrand = -100; if (sela != null && selb != null && sela.rand == selb.rand) { selrand = sela.rand; } if (sela != null) { lrand = sela.rand; } if (selb != null) { rrand = selb.rand; } RevListElement last = null; for (int a = el.count - 1; a >= 0; a--) { RevListElement rve = new RevListElement(); last = rve; tmp = el.children[a]; rve.rand = tmp.rand; rve.rand_s = rve.rand + ""; rve.main = tmp; rve.sub = sub; if (!curr.page.is_flagged) { rve.color = 1; } else if (tmp.revision.flagged) { rve.color = 3; } else { rve.color = 2; } if (selrand == rve.rand) { rve.selected = true; } if (lrand == rve.rand) { rve.offset = 1; } if (rrand == rve.rand) { rve.offset = 2; } //if(tmp.revision.flagged if (tmp.type == 0 && tmp.count == 1) { CreateItems(tmp); continue; } else if (tmp.type == 0) { rve.state = 0; control.AddAssigned(rve.rand_s, rve); if (!tmp.hidden) { rve.state = 1; CreateItems(tmp, true); } } else if (tmp.type == 1) { rve.state = 2; control.AddAssigned(rve.rand_s, rve); } } if (last != null) { last.last = true; } }
private void EventUpdate(int action = 0) { psela = sela; pselb = selb; UpdateEvent(new object(), new RevListUpdateArgs(sela, selb, action)); }
// type: ^ private void SelUpdate(int type, tl item, bool timer = true) { if (type == 0) { sela = item; selb = item; if (item.type == 0) { item.hidden = true; } if (timer) { EventUpdate(); } } else if (type == 2) // left { bool changed = false; if (sela != null && selb != null && sela.rand == selb.rand && sela.rand == item.rand) { selb = null; changed = true; } else if (sela != null && selb != null && sela.rand == selb.rand) { sela = item; selb = null; changed = true; } else { if (sela != null && sela.rand == item.rand) { return; } if (selb != null && selb.rand == item.rand) { selb = null; changed = true; } if (!changed) { sela = item; changed = true; if (item.type == 0) { item.hidden = true; } } } if (changed && timer) { _TimerStart(); } } else if (type == 3) // right { bool changed = false; if (sela != null && selb != null && sela.rand == selb.rand && sela.rand == item.rand) { sela = null; changed = true; } else if (sela != null && selb != null && sela.rand == selb.rand) { selb = item; sela = null; changed = true; } else { if (selb != null && selb.rand == item.rand) { return; } if (sela != null && sela.rand == item.rand) { sela = null; changed = true; } if (!changed) { selb = item; changed = true; if (item.type == 0) { item.hidden = true; } } } if (changed && timer) { _TimerStart(); } } if (selb != null) { ScrollTo(selb); } }
// index: item id // button: 0 - left, 1 - rigth // type: 0 - normal, 1 - long, 2 - left dragging, 3 - right dragging private void MouseProcessor(int index, int button, int type, int x = 0) { if (index == -1) { return; } // MessageBox.Show("I: "+index+", B: " + button+ ", T: " + type); tl item = GetByIndex(index); switch (type) { case 0: if (button == 0) { if (x < 25) { goto lng; } SelUpdate(0, item); } else { SelUpdate(0, item, false); EventUpdate(1); } // context break; case 1: lng: if (button == 0) { item.hidden = !item.hidden; if (sela != null && selb != null && sela.rand == selb.rand) { break; } if (item.hidden == false) { if (sela != null && sela.rand == item.rand) { sela = item.children[item.children.Count - 1]; EventUpdate(2); } else if (selb != null && selb.rand == item.rand) { selb = item.children[item.children.Count - 1]; EventUpdate(2); } } else if (item.parent.rootflag) { double randa = -100, randb = -100; if (sela != null) { randa = sela.rand; } if (selb != null) { randb = selb.rand; } int le = item.children.Count - 1; for (int a = 0; a <= le; a++) { if (item.children[a].rand == randa) { if (a == le) { sela = item; EventUpdate(2); } else { item.hidden = !item.hidden; } break; } if (item.children[a].rand == randb) { if (a == le) { selb = item; EventUpdate(2); } else { item.hidden = !item.hidden; } break; } } } } break; case 2: if (button == 0) { SelUpdate(2, item); } break; case 3: if (button == 0) { SelUpdate(3, item); } break; } }
public readonly int action;// 0 - update, 1 - show context public RevListUpdateArgs(tl _a, tl _b, int act = 0) { a = _a; b = _b; action = act; }