public bool LoadAppend() { iTagCollection iTC = new iTagCollection(); iTC.Load(); iTag[] iT = iTC.Get(); for (int a = 0; a < iT.Length; a++) { SetCat(iT[a], -1); } return(false); }
private void doCat(iTagCollection tc, bool ragequit) { frmTagtype fTags = new frmTagtype(tc, ragequit); fTags.ShowDialog(); prob.Text = "Ready to organize images"; proa.Value = 0; gugMask.Enabled = false; gugOrganize.Enabled = true; itc = tc; }
public bool Add(string[] tags, int type) { //lol in-place mergesort imitation iTagCollection tc = new iTagCollection(); for (int a = 0; a < tags.Length; a++) { tc.Add(new iTag(tags[a], type, 1)); } Add(tc); //...doubles the speed \o/ return(true); }
private void guResume_Click(object sender, EventArgs e) { gugRoot.Enabled = false; prob.Text = "Validating data..."; proa.Value = 33; Application.DoEvents(); //Load stored tag counts iTagCollection tc = new iTagCollection(); tc.Load(); prob.Text = "Preparing GUI..."; proa.Value = 66; Application.DoEvents(); doCat(tc, true); }
public frmReorder(iTagCollection itc, imInfo[] inf) { InitializeComponent(); this.itc = itc; this.inf = inf; }
iTagCollection getTags(string fn, string mask, string rpl1, string rpl2, string splitBy) { string tagsUnk = ""; string tagsGen = ""; string tagsSrc = ""; string tagsChr = ""; string tagsArt = ""; //remove extension fn = fn.Substring(0, fn.LastIndexOf(".")); while (true) { string metaType = ""; Point nextMeta = GetNextMeta(mask); if (nextMeta.Y == 0) { //no more meta break; } if (nextMeta.X > 0) { //Non-meta information at start if (mask.Substring(0, nextMeta.X) != fn.Substring(0, nextMeta.X)) { throw new Exception("Mask syntax error"); } } metaType = mask.Substring(nextMeta.X, nextMeta.Y); mask = mask.Substring(nextMeta.X + nextMeta.Y); fn = fn.Substring(nextMeta.X); //We're at some meta, find end offset nextMeta = GetNextMeta(mask); string meta = fn; //assume rest of filename if (mask.Length > 0) { //naw dude, bad assumption string delim = mask; if (nextMeta.X > 0) { //more meta tags in mask delim = mask.Substring(0, nextMeta.X); } int iMetaDelim = fn.IndexOf(delim); if (iMetaDelim == -1) { throw new Exception("Mask syntax error"); } meta = fn.Substring(0, iMetaDelim); } //Now we remove meta from fn fn = fn.Substring(meta.Length); metaType = metaType.Trim('{', '}'); if (metaType == "tags") { tagsUnk += meta + "\n"; } if (metaType == "tagsGen") { tagsGen += meta + "\n"; } if (metaType == "tagsSrc") { tagsSrc += meta + "\n"; } if (metaType == "tagsChr") { tagsChr += meta + "\n"; } if (metaType == "tagsArt") { tagsArt += meta + "\n"; } } iTagCollection ret = new iTagCollection(); //This isn't pretty, you might want to close your eyes. ret.Add(SplitTags(tagsUnk, rpl1, rpl2, splitBy), iTag.tUnk); ret.Add(SplitTags(tagsGen, rpl1, rpl2, splitBy), iTag.tGen); ret.Add(SplitTags(tagsSrc, rpl1, rpl2, splitBy), iTag.tSrc); ret.Add(SplitTags(tagsChr, rpl1, rpl2, splitBy), iTag.tChr); ret.Add(SplitTags(tagsArt, rpl1, rpl2, splitBy), iTag.tArt); return(ret); }
private void guMaskOK_Click(object sender, EventArgs e) { MessageBox.Show("If you have categorized tags earlier, remember\r\n" + "to click \"Load tag cat.\" once the cat window\r\n" + "has finished loading.", "Tip"); iTagCollection tc = new iTagCollection(); gugMask.Enabled = false; string mask = guMask.Text; string rpl1 = guReplace.Text; string rpl2 = guReplace2.Text; string splitBy = guSplit.Text; string[] files; if (guRoot.Text != "list.txt") { files = cb.getFiles(guRoot.Text); } else { files = System.IO.File.ReadAllText("list.txt", Encoding.UTF8).Replace("\r", ""). Trim('\n').Split('\n'); } string[] tagFn = files; for (int a = 0; a < tagFn.Length; a++) { int ofs = tagFn[a].LastIndexOf("\\"); tagFn[a] = tagFn[a].Substring(ofs + 1); } proa.Maximum = tagFn.Length; inf = new imInfo[files.Length]; for (int a = 0; a < tagFn.Length; a++) { if (a % 250 == 0) { proa.Value = a; prob.Text = "Parsing file " + (a + 1) + " of " + tagFn.Length; Application.DoEvents(); } iTag[] it = getTags(tagFn[a], mask, rpl1, rpl2, splitBy).Get(); tc.Add(it); inf[a] = new imInfo(); inf[a].path = files[a]; inf[a].tags = new iTag[it.Length]; for (int b = 0; b < it.Length; b++) { inf[a].tags[b] = new iTag( it[b].tag, iTag.tUnk, 0); } } int proas = proa.Maximum / 3; prob.Text = "Reading categories"; proa.Value = proas * 1; Application.DoEvents(); tc.LoadAppend(); //Read db prob.Text = "Saving new tags.db"; proa.Value = proas * 2; Application.DoEvents(); tc.Save(); //Store tags.db prob.Text = "Preparing GUI"; proa.Value = proa.Maximum; Application.DoEvents(); doCat(tc, false); }
public frmTagtype(iTagCollection tc, bool ragequit) { InitializeComponent(); this.ragequit = ragequit; this.tc = tc; }
public bool Add(iTagCollection tags) { return(Add(tags.Get())); }