private void buttonApply_Click(object sender, EventArgs e) { FilesToDelete.Clear(); FilesToDownload.Clear(); foreach (object obj in listBox1.Items) { if (obj is SMVItem) { SMVItem item = obj as SMVItem; if (item.Selected) { RemoteFileRef rf = item.File; if (rf.NewVersionAvailable) { FilesToDownload.Add(rf.FileName); FilesToDownload.Add(Path.GetFileNameWithoutExtension(rf.FileName) + ".smd"); FilesToDownload.Add(Path.GetFileNameWithoutExtension(rf.FileName) + ".sme"); } foreach (RemoteFileRef rfa in rf.Subs) { if (rf.NewVersionAvailable) { FilesToDownload.Add(rf.FileName); } } } } else if (obj is RemoteFileRef) { RemoteFileRef rf = obj as RemoteFileRef; if (rf.Selected == false && rf.Local == true) { FilesToDelete.Add(rf.FileName); } else if (rf.Local == false && rf.Selected == true) { FilesToDownload.Add(rf.FileName); FilesToDownload.Add(Path.GetFileNameWithoutExtension(rf.FileName) + ".smd"); FilesToDownload.Add(Path.GetFileNameWithoutExtension(rf.FileName) + ".sme"); foreach (RemoteFileRef subFile in rf.Subs) { if (subFile.Selected && !subFile.Local) { FilesToDownload.Add(subFile.FileName); } else if (subFile.Local && !subFile.Selected) { FilesToDelete.Add(subFile.FileName); } } } } } if (OnApplyChanges != null) { OnApplyChanges(this, e); } }
public static SMVItem MakeHeader(string t) { SMVItem sm = new SMVItem(); sm.Text = t; sm.IsHeader = true; return(sm); }
public static SMVItem MakeEntry(string t, RemoteFileRef b) { SMVItem sm = new SMVItem(); sm.Text = t; sm.IsHeader = false; sm.File = b; return(sm); }
public List <object> GetUpdatedFiles() { List <object> list = new List <object>(); foreach (RemoteFileRef rf in DatabaseStatus) { if (rf.HasUpdate()) { SMVItem item = SMVItem.MakeEntry(rf.Text, rf); item.Selected = true; list.Add(item); } } return(list); }
public void UpdateLists() { List <SMVItem> items = new List <SMVItem>(); List <RemoteFileRef> news = Library.GetNewFiles(); List <object> upds = Library.GetUpdatedFiles(); // copy files into listbox listBox1.Items.Clear(); // new items if (news.Count > 0) { listBox1.Items.Add(SMVItem.MakeHeader("New Books")); foreach (RemoteFileRef rf in news) { listBox1.Items.Add(rf); } } if (upds.Count > 0) { listBox1.Items.Add(SMVItem.MakeHeader("Updates")); foreach (RemoteFileRef rf in upds) { listBox1.Items.Add(rf); } } // all items listBox1.Items.Add(SMVItem.MakeHeader("Installed Books")); foreach (RemoteFileRef rf in Library.DatabaseStatus) { if (rf.Local) { listBox1.Items.Add(rf); } } }
public void AddItem(SMVItem item) { listBox1.Items.Add(item); }