/// <summary> /// Saves the list from the passed ListBox2 to the specified text file. /// </summary> public static void SaveList(ListBox2 articlesListBox) { try { StringBuilder strList = new StringBuilder(); if (ListFile.Length > 0) { SaveListDialog.FileName = ListFile; } if (SaveListDialog.ShowDialog() == DialogResult.OK) { switch (SaveListDialog.FilterIndex) { case 1: //wikitext foreach (Article a in articlesListBox) { strList.AppendLine("# [[:" + a.Name + "]]"); } break; case 2: //plaintext foreach (Article a in articlesListBox) { strList.AppendLine(a.Name); } break; case 3: //CSV foreach (Article a in articlesListBox) { strList.Append(a.Name + ", "); } strList = strList.Remove(strList.Length - 2, 2); break; case 4: //CSV with wikitext foreach (Article a in articlesListBox) { strList.Append("[[:" + a.Name + "]], "); } strList = strList.Remove(strList.Length - 2, 2); break; } ListFile = SaveListDialog.FileName; Tools.WriteTextFileAbsolutePath(strList, ListFile, false); } } catch (Exception ex) { ErrorHandler.Handle(ex); } }
public ListFilterForm(ListBox2 lb) { InitializeComponent(); if (lb == null) throw new ArgumentNullException("lb"); destListBox = lb; if (prefs != null) Settings = prefs; }
private static void SaveList(ListBox2<string> lb) { if (lb.Items.Count == 0) { MessageBox.Show("Nothing to save", "No items in List Boxes"); return; } lb.SaveList(); }