// Copy Entry private void menuItem8_Click(object sender, System.EventArgs e) { System.Text.StringBuilder txt = new System.Text.StringBuilder(); if (cheatbox.SelectedItems != null && cheatbox.SelectedItems.Count > 0) { bool first = true; foreach (ListViewItem lvi in cheatbox.SelectedItems) { Cheat cc = lvi.Tag as Cheat; if (cc != null) { if (first) { first = false; } else { txt.Append("\r\n"); } txt.AppendFormat("{0}{1}{2}", cc.Code, pos.SeperationString, cc.Description); } } } Clipboard.SetDataObject(txt.ToString()); }
public void AddCode(Cheat cheat) { try { codes.Add(cheat.Code, cheat.Description); } catch { } }
public int Compare(object x, object y) { Cheat c1 = x as Cheat; Cheat c2 = y as Cheat; if (x == null || y == null) { return(0); } return(c1.Code.CompareTo(c2.Code)); }
// private void PasteSpecial(object sender, System.EventArgs e) { // PasteOptionsForm pof = new PasteOptionsForm(pos); // if (pof.ShowDialog(this) == DialogResult.OK) { // this.pos = pos; // usemine = true; // } else { // usemine = false; // } // Paste(sender, e); // } private void Paste() { string fullinput = Clipboard.GetDataObject().GetData(typeof(string)).ToString(); if (!usemine) { PasteOptions sep = GuessSeperator(fullinput); if (sep.SeperationString.Length > 0) { pos = sep; } } string input = fullinput.Replace("\r", ""); string[] lines = input.Split('\n'); foreach (string line in lines) { if (line.Trim().Length == 0) { continue; } int ndx = line.IndexOf(pos.SeperationString); Cheat cc = new Cheat(); if (ndx > -1) { if (pos.CodeFirst) { cc.Code = line.Substring(0, ndx).Trim(); if (ndx < line.Length) { cc.Description = line.Substring(ndx).Replace(pos.SeperationString, "").Trim(); } } else { cc.Description = line.Substring(0, ndx).Trim(); cc.Code = line.Substring(ndx).Replace(pos.SeperationString, "").Trim(); } } else { cc.Code = line; } if (cc.Code != null && cc.Code.Trim().Length > 0) { // AddCode(cc); ListViewItem lvi = new ListViewItem(new string[] { cc.Code, cc.Description }); lvi.Tag = cc; cheatbox.Items.Add(lvi); } } }
private void okButton_Click(object sender, System.EventArgs e) { if (cheats == null) { cheats = new Cheats(); } cheats.SetupInformation = setupBox.Text; cheats.ClearCodes(); foreach (ListViewItem lvi in cheatbox.Items) { Cheat ct = lvi.Tag as Cheat; if (ct == null) { continue; } cheats.AddCode(ct); } this.DialogResult = DialogResult.OK; this.Hide(); }